From 0d4b50908f1b8a5334b436d243f2cb97b014d687 Mon Sep 17 00:00:00 2001 From: Richard Freimer Date: Sat, 11 May 2019 14:13:24 -0400 Subject: [PATCH] Formatting and code readability cleanup (#5467) * First pass reformatting code to be more readable (common still not done) * Replace google common collect calls with Java calls where possible * Remove a bunch of unnecessary parenthesis leaving clarifying ones * Add some missing @Nonnull annotations * Fix checking wrong type * Remove unnecessary continue/return statements and simplify comparision check * Pass exception instead of directly printing stack trace * Work on cleaning up common, through config so far * Work on cleaning up common, through integration so far * Work on cleaning up common, through network so far * Work on cleaning up common, through tier so far * Remove empty constructors that get created by default anyways * Work on cleaning up common, through transmitters so far * Work on cleaning up common, through utils so far * Finish cleaning up spacing for common --- src/api/java/cofh/api/item/IToolHammer.java | 23 +- .../api/entity/IEntityBreathable.java | 2 +- .../galacticraft/api/world/ISolarLevel.java | 5 +- src/main/java/mekanism/api/Chunk3D.java | 25 +- src/main/java/mekanism/api/Coord4D.java | 63 +-- src/main/java/mekanism/api/EnumColor.java | 8 +- .../java/mekanism/api/IAlloyInteraction.java | 8 +- src/main/java/mekanism/api/IClientTicker.java | 2 +- .../java/mekanism/api/IConfigCardAccess.java | 8 +- src/main/java/mekanism/api/IConfigurable.java | 8 +- .../java/mekanism/api/IEvaporationSolar.java | 2 +- src/main/java/mekanism/api/IHeatTransfer.java | 2 +- src/main/java/mekanism/api/IMekWrench.java | 2 +- src/main/java/mekanism/api/MekanismAPI.java | 6 +- .../mekanism/api/MekanismRecipeHelper.java | 54 +-- src/main/java/mekanism/api/Pos3D.java | 71 ++- src/main/java/mekanism/api/Range4D.java | 34 +- .../java/mekanism/api/TileNetworkList.java | 2 +- .../api/energy/EnergizedItemManager.java | 47 +- .../java/mekanism/api/energy/EnergyStack.java | 2 +- .../mekanism/api/energy/IEnergizedItem.java | 9 +- .../api/energy/IStrictEnergyAcceptor.java | 6 +- .../api/energy/IStrictEnergyOutputter.java | 6 +- .../api/energy/IStrictEnergyStorage.java | 2 +- .../mekanism/api/energy/package-info.java | 3 +- src/main/java/mekanism/api/gas/Gas.java | 12 +- .../java/mekanism/api/gas/GasRegistry.java | 15 +- src/main/java/mekanism/api/gas/GasStack.java | 9 +- src/main/java/mekanism/api/gas/GasTank.java | 27 +- .../java/mekanism/api/gas/GasTankInfo.java | 2 +- .../java/mekanism/api/gas/IGasHandler.java | 6 +- src/main/java/mekanism/api/gas/IGasItem.java | 18 +- .../mekanism/api/gas/ITubeConnection.java | 6 +- .../java/mekanism/api/gas/package-info.java | 3 +- .../mekanism/api/infuse/InfuseObject.java | 2 +- .../mekanism/api/infuse/InfuseRegistry.java | 18 +- .../java/mekanism/api/infuse/InfuseType.java | 3 +- .../mekanism/api/infuse/package-info.java | 3 +- .../mekanism/api/lasers/ILaserReceptor.java | 2 +- src/main/java/mekanism/api/package-info.java | 3 +- .../api/transmitters/DynamicNetwork.java | 54 +-- .../transmitters/IBlockableConnection.java | 2 +- .../api/transmitters/IGridTransmitter.java | 16 +- .../api/transmitters/INetworkDataHandler.java | 2 +- .../api/transmitters/ITransmitter.java | 2 +- .../api/transmitters/TransmissionType.java | 8 +- .../TransmitterNetworkRegistry.java | 56 +-- .../api/transmitters/package-info.java | 3 +- .../java/mekanism/api/util/BlockInfo.java | 4 +- src/main/java/mekanism/api/util/ItemInfo.java | 6 +- .../java/mekanism/api/util/package-info.java | 3 +- .../client/ApiJarPresentException.java | 9 +- .../client/ClientConnectionHandler.java | 3 +- .../mekanism/client/ClientPlayerTracker.java | 2 +- .../java/mekanism/client/ClientProxy.java | 335 ++++---------- .../mekanism/client/ClientTickHandler.java | 67 +-- .../java/mekanism/client/HolidayManager.java | 50 +-- .../java/mekanism/client/MekKeyHandler.java | 5 +- .../java/mekanism/client/MekanismClient.java | 3 +- .../mekanism/client/MekanismKeyHandler.java | 51 +-- .../mekanism/client/SparkleAnimation.java | 23 +- .../mekanism/client/entity/ParticleLaser.java | 31 +- .../mekanism/client/gui/ConfigGuiFactory.java | 5 +- .../gui/GuiAdvancedElectricMachine.java | 15 +- .../mekanism/client/gui/GuiBoilerStats.java | 28 +- .../mekanism/client/gui/GuiChanceMachine.java | 3 +- .../mekanism/client/gui/GuiDictionary.java | 11 +- .../mekanism/client/gui/GuiDigitalMiner.java | 50 +-- .../client/gui/GuiDigitalMinerConfig.java | 113 +---- .../client/gui/GuiDoubleElectricMachine.java | 7 +- .../mekanism/client/gui/GuiDynamicTank.java | 24 +- .../client/gui/GuiElectricMachine.java | 7 +- .../mekanism/client/gui/GuiElectricPump.java | 17 +- .../client/gui/GuiElectrolyticSeparator.java | 20 +- .../client/gui/GuiEmbeddedGaugeTile.java | 3 +- .../mekanism/client/gui/GuiEnergyCube.java | 10 +- .../java/mekanism/client/gui/GuiFactory.java | 37 +- .../mekanism/client/gui/GuiFluidTank.java | 4 +- .../client/gui/GuiFluidicPlenisher.java | 22 +- .../client/gui/GuiFormulaicAssemblicator.java | 51 +-- .../client/gui/GuiFuelwoodHeater.java | 13 +- .../java/mekanism/client/gui/GuiGasTank.java | 25 +- .../client/gui/GuiInductionMatrix.java | 35 +- .../client/gui/GuiLaserAmplifier.java | 33 +- .../client/gui/GuiLaserTractorBeam.java | 4 +- .../client/gui/GuiLogisticalSorter.java | 104 +---- .../mekanism/client/gui/GuiMatrixStats.java | 29 +- .../java/mekanism/client/gui/GuiMekanism.java | 25 +- .../client/gui/GuiMekanismConfig.java | 54 +-- .../mekanism/client/gui/GuiMekanismTile.java | 8 +- .../client/gui/GuiMetallurgicInfuser.java | 21 +- .../client/gui/GuiOredictionificator.java | 20 +- src/main/java/mekanism/client/gui/GuiPRC.java | 19 +- .../client/gui/GuiQuantumEntangloporter.java | 41 +- .../client/gui/GuiResistiveHeater.java | 25 +- .../client/gui/GuiRotaryCondensentrator.java | 26 +- .../mekanism/client/gui/GuiSecurityDesk.java | 39 +- .../mekanism/client/gui/GuiSeismicReader.java | 17 +- .../client/gui/GuiSeismicVibrator.java | 13 +- .../client/gui/GuiSideConfiguration.java | 26 +- .../mekanism/client/gui/GuiTeleporter.java | 59 +-- .../gui/GuiThermalEvaporationController.java | 37 +- .../client/gui/GuiThermoelectricBoiler.java | 38 +- .../client/gui/GuiTransporterConfig.java | 35 +- .../client/gui/GuiUpgradeManagement.java | 31 +- .../java/mekanism/client/gui/IGuiWrapper.java | 2 +- .../client/gui/chemical/GuiChemical.java | 7 +- .../gui/chemical/GuiChemicalCrystallizer.java | 7 +- .../GuiChemicalDissolutionChamber.java | 3 +- .../gui/chemical/GuiChemicalInfuser.java | 3 +- .../gui/chemical/GuiChemicalOxidizer.java | 3 +- .../gui/chemical/GuiChemicalWasher.java | 3 +- .../client/gui/element/GuiAmplifierTab.java | 8 +- .../client/gui/element/GuiBucketIO.java | 3 +- .../client/gui/element/GuiConfigTypeTab.java | 3 +- .../gui/element/GuiContainerEditMode.java | 3 +- .../client/gui/element/GuiEnergyGauge.java | 4 +- .../client/gui/element/GuiEnergyInfo.java | 4 +- .../client/gui/element/GuiFluidGauge.java | 18 +- .../client/gui/element/GuiGasGauge.java | 24 +- .../mekanism/client/gui/element/GuiGauge.java | 16 +- .../mekanism/client/gui/element/GuiGraph.java | 19 +- .../client/gui/element/GuiHeatInfo.java | 4 +- .../client/gui/element/GuiPowerBar.java | 7 +- .../client/gui/element/GuiProgress.java | 9 +- .../client/gui/element/GuiRateBar.java | 6 +- .../gui/element/GuiRedstoneControl.java | 3 +- .../client/gui/element/GuiScrollList.java | 40 +- .../client/gui/element/GuiSecurityTab.java | 20 +- .../mekanism/client/gui/element/GuiSlot.java | 3 +- .../client/gui/element/GuiSortingTab.java | 2 +- .../client/gui/element/GuiVisualsTab.java | 10 +- .../client/gui/filter/GuiFilterSelect.java | 8 +- .../client/gui/filter/GuiMFilterSelect.java | 3 +- .../gui/filter/GuiMItemStackFilter.java | 37 +- .../client/gui/filter/GuiMMaterialFilter.java | 26 +- .../client/gui/filter/GuiMModIDFilter.java | 26 +- .../client/gui/filter/GuiMOreDictFilter.java | 20 +- .../client/gui/filter/GuiMaterialFilter.java | 3 +- .../client/gui/filter/GuiModIDFilter.java | 6 +- .../client/gui/filter/GuiOreDictFilter.java | 2 +- .../filter/GuiOredictionificatorFilter.java | 18 +- .../client/gui/filter/GuiTFilterSelect.java | 3 +- .../gui/filter/GuiTItemStackFilter.java | 33 +- .../client/gui/filter/GuiTMaterialFilter.java | 21 +- .../client/gui/filter/GuiTModIDFilter.java | 24 +- .../client/gui/filter/GuiTOreDictFilter.java | 25 +- .../mekanism/client/gui/robit/GuiRobit.java | 11 +- .../client/gui/robit/GuiRobitMain.java | 62 +-- .../client/gui/robit/GuiRobitRepair.java | 21 +- .../client/gui/robit/GuiRobitSmelting.java | 3 +- .../client/jei/BaseRecipeCategory.java | 11 +- .../client/jei/GuiElementHandler.java | 4 +- .../java/mekanism/client/jei/MekanismJEI.java | 64 +-- .../client/jei/RecipeRegistryHelper.java | 103 ++--- .../client/jei/gas/GasStackRenderer.java | 16 +- .../mekanism/client/jei/gas/package-info.java | 2 +- .../AdvancedMachineRecipeCategory.java | 5 +- .../machine/AdvancedMachineRecipeWrapper.java | 3 +- ...micalDissolutionChamberRecipeCategory.java | 6 +- ...emicalDissolutionChamberRecipeWrapper.java | 4 +- .../ChemicalInfuserRecipeWrapper.java | 3 +- .../chemical/ChemicalWasherRecipeWrapper.java | 3 +- .../jei/machine/chemical/package-info.java | 2 +- .../ElectrolyticSeparatorRecipeWrapper.java | 3 +- .../MetallurgicInfuserRecipeCategory.java | 3 +- .../jei/machine/other/PRCRecipeCategory.java | 3 +- .../RotaryCondensentratorRecipeCategory.java | 12 +- .../RotaryCondensentratorRecipeWrapper.java | 4 +- .../ThermalEvaporationRecipeCategory.java | 3 +- .../jei/machine/other/package-info.java | 2 +- .../client/jei/machine/package-info.java | 2 +- .../mekanism/client/jei/package-info.java | 2 +- .../client/model/ModelArmoredJetpack.java | 2 +- .../client/model/ModelAtomicDisassembler.java | 2 +- .../model/ModelChemicalCrystallizer.java | 2 +- .../ModelChemicalDissolutionChamber.java | 2 +- .../client/model/ModelDigitalMiner.java | 2 +- .../model/ModelElectrolyticSeparator.java | 2 +- .../client/model/ModelEnergyCube.java | 8 +- .../client/model/ModelFlamethrower.java | 2 +- .../mekanism/client/model/ModelFluidTank.java | 2 +- .../client/model/ModelFreeRunners.java | 2 +- .../model/ModelQuantumEntangloporter.java | 2 +- .../client/model/ModelResistiveHeater.java | 8 +- .../mekanism/client/model/ModelRobit.java | 2 +- .../model/ModelRotaryCondensentrator.java | 2 +- .../client/model/ModelSecurityDesk.java | 2 +- .../client/model/ModelSeismicVibrator.java | 2 +- .../model/ModelSolarNeutronActivator.java | 2 +- .../client/model/ModelTransporterBox.java | 2 +- .../client/render/ColourTemperature.java | 13 +- .../client/render/FluidRenderMap.java | 8 +- .../mekanism/client/render/FluidRenderer.java | 15 +- .../client/render/MekanismRenderer.java | 33 +- .../client/render/MinerVisualRenderer.java | 10 +- .../client/render/ModelCustomArmor.java | 27 +- .../client/render/RenderResizableCuboid.java | 138 ++---- .../client/render/RenderTickHandler.java | 78 +--- .../client/render/entity/RenderBalloon.java | 14 +- .../client/render/entity/RenderFlame.java | 8 +- .../entity/RenderObsidianTNTPrimed.java | 5 +- .../client/render/entity/RenderRobit.java | 3 +- .../client/render/item/ItemLayerWrapper.java | 9 +- .../render/item/RenderEnergyCubeItem.java | 8 +- .../item/basicblock/RenderBasicBlockItem.java | 2 - .../basicblock/RenderSecurityDeskItem.java | 1 + .../item/gear/RenderAtomicDisassembler.java | 4 +- .../render/item/gear/RenderFlameThrower.java | 10 +- .../RenderChemicalDissolutionChamberItem.java | 3 +- .../item/machine/RenderDigitalMinerItem.java | 3 +- .../item/machine/RenderFluidTankItem.java | 6 +- .../RenderQuantumEntangloporterItem.java | 4 +- .../machine/RenderResistiveHeaterItem.java | 3 +- .../RenderSolarNeutronActivatorItem.java | 3 +- .../client/render/obj/GlowPanelModel.java | 49 +- .../client/render/obj/MekanismOBJLoader.java | 28 +- .../client/render/obj/MekanismOBJModel.java | 13 +- .../client/render/obj/OBJBakedModelBase.java | 49 +- .../client/render/obj/TransmitterModel.java | 100 ++--- .../render/particle/EntityJetpackFlameFX.java | 13 +- .../render/particle/EntityJetpackSmokeFX.java | 13 +- .../render/particle/EntityScubaBubbleFX.java | 13 +- .../particle/MekanismParticleHelper.java | 19 +- .../particle/TieredParticleDigging.java | 3 +- .../client/render/tileentity/RenderBin.java | 29 +- .../RenderChemicalCrystallizer.java | 5 +- .../RenderChemicalDissolutionChamber.java | 5 +- .../tileentity/RenderConfigurableMachine.java | 13 +- .../render/tileentity/RenderDigitalMiner.java | 5 +- .../render/tileentity/RenderDynamicTank.java | 14 +- .../render/tileentity/RenderEnergyCube.java | 22 +- .../render/tileentity/RenderFluidTank.java | 11 +- .../render/tileentity/RenderGasTank.java | 5 +- .../tileentity/RenderPersonalChest.java | 5 +- .../RenderQuantumEntangloporter.java | 5 +- .../tileentity/RenderResistiveHeater.java | 5 +- .../RenderRotaryCondensentrator.java | 5 +- .../render/tileentity/RenderSecurityDesk.java | 5 +- .../tileentity/RenderSeismicVibrator.java | 5 +- .../RenderSolarNeutronActivator.java | 5 +- .../render/tileentity/RenderTeleporter.java | 8 +- .../RenderThermalEvaporationController.java | 19 +- .../RenderThermoelectricBoiler.java | 22 +- .../RenderLogisticalTransporter.java | 18 +- .../transmitter/RenderMechanicalPipe.java | 9 +- .../transmitter/RenderPressurizedTube.java | 12 +- .../RenderThermodynamicConductor.java | 12 +- .../transmitter/RenderTransmitterBase.java | 10 +- .../transmitter/RenderUniversalCable.java | 12 +- .../client/sound/FlamethrowerSound.java | 11 +- .../mekanism/client/sound/GasMaskSound.java | 5 +- .../mekanism/client/sound/JetpackSound.java | 2 +- .../mekanism/client/sound/PlayerSound.java | 10 +- .../mekanism/client/sound/SoundHandler.java | 21 +- .../java/mekanism/client/sound/TileSound.java | 3 +- .../mekanism/client/voice/VoiceInput.java | 2 +- .../mekanism/client/voice/VoiceOutput.java | 2 +- .../mekanism/common/BoxBlacklistParser.java | 15 +- src/main/java/mekanism/common/ColourRGBA.java | 2 +- .../common/CommonPlayerTickHandler.java | 47 +- .../mekanism/common/CommonPlayerTracker.java | 29 +- .../java/mekanism/common/CommonProxy.java | 70 +-- .../common/CommonWorldTickHandler.java | 17 +- .../java/mekanism/common/CoreGuiHandler.java | 5 +- .../mekanism/common/CreativeTabMekanism.java | 2 +- src/main/java/mekanism/common/FluidSlot.java | 4 +- .../java/mekanism/common/FuelHandler.java | 14 +- src/main/java/mekanism/common/HashList.java | 7 +- src/main/java/mekanism/common/KeySync.java | 5 +- .../java/mekanism/common/LaserManager.java | 19 +- .../java/mekanism/common/MekFakePlayer.java | 2 +- src/main/java/mekanism/common/Mekanism.java | 425 ++++++------------ .../java/mekanism/common/MekanismBlocks.java | 2 +- .../java/mekanism/common/MekanismFluids.java | 5 +- .../java/mekanism/common/MekanismItems.java | 2 +- .../java/mekanism/common/MekanismSounds.java | 2 +- .../java/mekanism/common/OreDictCache.java | 19 +- .../java/mekanism/common/PacketHandler.java | 36 +- .../java/mekanism/common/PlayerState.java | 19 +- src/main/java/mekanism/common/Resource.java | 6 +- src/main/java/mekanism/common/SideData.java | 8 +- src/main/java/mekanism/common/Upgrade.java | 22 +- src/main/java/mekanism/common/Version.java | 19 +- .../common/base/EnergyAcceptorWrapper.java | 16 +- .../common/base/FluidHandlerWrapper.java | 11 +- .../common/base/FluidItemWrapper.java | 10 +- .../mekanism/common/base/IActiveState.java | 12 +- .../common/base/IAdvancedBoundingBlock.java | 7 +- .../java/mekanism/common/base/IBlockType.java | 12 +- .../mekanism/common/base/IBoundingBlock.java | 5 +- .../common/base/IElectricMachine.java | 5 +- .../mekanism/common/base/IEnergyWrapper.java | 6 +- .../java/mekanism/common/base/IFactory.java | 48 +- .../common/base/IFluidContainerManager.java | 2 +- .../common/base/IFluidHandlerWrapper.java | 2 +- .../common/base/IFluidItemWrapper.java | 2 +- .../mekanism/common/base/IGuiProvider.java | 16 +- .../mekanism/common/base/IItemNetwork.java | 2 +- .../common/base/ILogisticalTransporter.java | 5 +- .../java/mekanism/common/base/IMetaItem.java | 2 +- .../java/mekanism/common/base/IModule.java | 11 +- .../common/base/IRedstoneControl.java | 2 +- .../common/base/ISideConfiguration.java | 2 +- .../mekanism/common/base/ISpecialBounds.java | 5 +- .../mekanism/common/base/ISustainedData.java | 2 +- .../common/base/ISustainedInventory.java | 5 +- .../mekanism/common/base/ISustainedTank.java | 6 +- .../mekanism/common/base/ITankManager.java | 35 +- .../java/mekanism/common/base/ITierItem.java | 2 +- .../common/base/ITierUpgradeable.java | 2 +- .../mekanism/common/base/ITileComponent.java | 2 +- .../mekanism/common/base/ITileNetwork.java | 3 +- .../mekanism/common/base/IUpgradeItem.java | 2 +- .../mekanism/common/base/IUpgradeTile.java | 2 +- .../java/mekanism/common/base/SplitInfo.java | 6 +- .../mekanism/common/base/target/Target.java | 35 +- .../mekanism/common/block/BlockBasic.java | 173 ++----- .../mekanism/common/block/BlockBounding.java | 38 +- .../common/block/BlockCardboardBox.java | 38 +- .../common/block/BlockEnergyCube.java | 46 +- .../mekanism/common/block/BlockGasTank.java | 54 +-- .../mekanism/common/block/BlockGlowPanel.java | 20 +- .../mekanism/common/block/BlockMachine.java | 224 ++------- .../common/block/BlockMekanismContainer.java | 34 +- .../common/block/BlockObsidianTNT.java | 22 +- .../java/mekanism/common/block/BlockOre.java | 2 +- .../mekanism/common/block/BlockPlastic.java | 4 +- .../common/block/BlockPlasticFence.java | 2 +- .../java/mekanism/common/block/BlockSalt.java | 2 +- .../mekanism/common/block/BlockTileDrops.java | 29 +- .../common/block/BlockTransmitter.java | 71 +-- .../common/block/property/PropertyColor.java | 2 +- .../block/property/PropertyConnection.java | 5 +- .../common/block/states/BlockStateBasic.java | 104 ++--- .../block/states/BlockStateBounding.java | 2 +- .../block/states/BlockStateCardboardBox.java | 3 +- .../block/states/BlockStateEnergyCube.java | 5 +- .../common/block/states/BlockStateFacing.java | 7 +- .../block/states/BlockStateGasTank.java | 5 +- .../block/states/BlockStateGlowPanel.java | 2 +- .../block/states/BlockStateMachine.java | 153 +++---- .../common/block/states/BlockStateOre.java | 2 +- .../block/states/BlockStatePlastic.java | 3 +- .../block/states/BlockStateTransmitter.java | 15 +- .../CapabilityWrapperManager.java | 2 +- .../capabilities/DefaultAlloyInteraction.java | 2 +- .../DefaultBlockableConnection.java | 5 +- .../capabilities/DefaultCableOutputter.java | 5 +- .../capabilities/DefaultConfigCardAccess.java | 2 +- .../capabilities/DefaultConfigurable.java | 2 +- .../capabilities/DefaultEvaporationSolar.java | 2 +- .../capabilities/DefaultGasHandler.java | 2 +- .../capabilities/DefaultGridTransmitter.java | 6 +- .../capabilities/DefaultHeatTransfer.java | 3 +- .../capabilities/DefaultLaserReceptor.java | 3 +- .../DefaultLogisticalTransporter.java | 14 +- .../DefaultSpecialConfigData.java | 6 +- .../capabilities/DefaultStorageHelper.java | 3 +- .../DefaultStrictEnergyAcceptor.java | 5 +- .../DefaultStrictEnergyStorage.java | 5 +- .../capabilities/DefaultTileNetwork.java | 4 +- .../capabilities/DefaultTubeConnection.java | 2 +- .../capabilities/IOffsetCapability.java | 47 +- .../capabilities/IToggleableCapability.java | 13 +- .../capabilities/ItemCapabilityWrapper.java | 5 +- .../common/chunkloading/ChunkManager.java | 10 +- .../common/chunkloading/IChunkLoader.java | 2 +- .../mekanism/common/command/CommandChunk.java | 26 +- .../mekanism/common/command/CommandMek.java | 31 +- .../mekanism/common/config/ClientConfig.java | 12 +- .../mekanism/common/config/GeneralConfig.java | 64 ++- .../common/config/GeneratorsConfig.java | 13 +- .../mekanism/common/config/StorageConfig.java | 103 +++-- .../mekanism/common/config/TierConfig.java | 63 +-- .../mekanism/common/config/ToolsConfig.java | 60 +-- .../common/config/TypeConfigManager.java | 6 +- .../mekanism/common/config/UsageConfig.java | 35 +- .../common/config/options/BooleanOption.java | 6 +- .../common/config/options/DoubleOption.java | 6 +- .../common/config/options/EnumOption.java | 2 - .../common/config/options/FloatOption.java | 6 +- .../common/config/options/IntListOption.java | 6 +- .../common/config/options/IntOption.java | 6 +- .../common/config/options/IntSetOption.java | 6 +- .../common/config/options/Option.java | 3 +- .../content/assemblicator/RecipeFormula.java | 13 +- .../common/content/boiler/BoilerCache.java | 7 +- .../content/boiler/BoilerSteamTank.java | 5 +- .../common/content/boiler/BoilerTank.java | 61 +-- .../content/boiler/BoilerUpdateProtocol.java | 56 +-- .../content/boiler/BoilerWaterTank.java | 5 +- .../boiler/SynchronizedBoilerData.java | 20 +- .../entangloporter/InventoryFrequency.java | 30 +- .../common/content/filter/IFilter.java | 1 - .../content/filter/IItemStackFilter.java | 1 - .../content/filter/IMaterialFilter.java | 1 + .../common/content/filter/IModIDFilter.java | 1 + .../common/content/filter/IOreDictFilter.java | 1 + .../common/content/matrix/MatrixCache.java | 6 +- .../content/matrix/MatrixUpdateProtocol.java | 14 +- .../content/miner/MItemStackFilter.java | 17 +- .../common/content/miner/MMaterialFilter.java | 19 +- .../common/content/miner/MModIDFilter.java | 12 +- .../common/content/miner/MOreDictFilter.java | 13 +- .../common/content/miner/MinerFilter.java | 15 +- .../content/miner/ThreadMinerSearch.java | 14 +- .../common/content/tank/DynamicFluidTank.java | 43 +- .../content/tank/SynchronizedTankData.java | 10 +- .../common/content/tank/TankCache.java | 9 +- .../content/tank/TankUpdateProtocol.java | 25 +- .../common/content/transporter/Finder.java | 14 +- .../content/transporter/HashedItem.java | 15 +- .../common/content/transporter/InvStack.java | 40 +- .../content/transporter/PathfinderCache.java | 12 +- .../content/transporter/StackSearcher.java | 14 +- .../content/transporter/TItemStackFilter.java | 21 +- .../content/transporter/TMaterialFilter.java | 17 +- .../content/transporter/TModIDFilter.java | 13 +- .../content/transporter/TOreDictFilter.java | 16 +- .../content/transporter/TransitRequest.java | 33 +- .../transporter/TransporterFilter.java | 15 +- .../transporter/TransporterManager.java | 18 +- .../transporter/TransporterPathfinder.java | 123 +---- .../content/transporter/TransporterStack.java | 65 +-- .../common/entity/EntityBabySkeleton.java | 13 +- .../mekanism/common/entity/EntityBalloon.java | 64 +-- .../mekanism/common/entity/EntityFlame.java | 56 +-- .../common/entity/EntityObsidianTNT.java | 11 +- .../mekanism/common/entity/EntityRobit.java | 138 ++---- .../common/entity/ai/RobitAIFollow.java | 25 +- .../common/entity/ai/RobitAIPickup.java | 30 +- .../common/fixers/BaseMekanismFixer.java | 3 +- .../common/fixers/KeybindingFixer.java | 2 +- .../common/fixers/MekanismDataFixers.java | 4 +- .../java/mekanism/common/fixers/TEFixer.java | 3 - .../mekanism/common/frequency/Frequency.java | 20 +- .../common/frequency/FrequencyManager.java | 45 +- .../common/frequency/IFrequencyHandler.java | 2 +- .../common/integration/IMCHandler.java | 32 +- .../common/integration/MekanismHooks.java | 48 +- .../common/integration/OreDictManager.java | 127 ++---- .../common/integration/TOPProvider.java | 5 +- .../common/integration/WailaDataProvider.java | 16 +- .../integration/computer/CCPeripheral.java | 7 +- .../computer/IComputerIntegration.java | 2 +- .../common/integration/computer/OCDriver.java | 5 +- .../crafttweaker/CrafttweakerIntegration.java | 6 +- .../crafttweaker/commands/GasesCommand.java | 11 +- .../commands/InfuseTypesCommand.java | 8 +- .../commands/MekRecipesCommand.java | 25 +- .../gas/CraftTweakerGasStack.java | 3 +- .../crafttweaker/gas/GasBracketHandler.java | 1 - .../handlers/ChemicalCrystallizer.java | 10 +- .../handlers/ChemicalDissolution.java | 11 +- .../handlers/ChemicalInfuser.java | 11 +- .../handlers/ChemicalInjection.java | 11 +- .../handlers/ChemicalOxidizer.java | 8 +- .../crafttweaker/handlers/ChemicalWasher.java | 9 +- .../crafttweaker/handlers/Combiner.java | 8 +- .../crafttweaker/handlers/Compressor.java | 11 +- .../crafttweaker/handlers/Crusher.java | 5 +- .../handlers/EnergizedSmelter.java | 8 +- .../crafttweaker/handlers/Enrichment.java | 8 +- .../crafttweaker/handlers/Infuser.java | 8 +- .../crafttweaker/handlers/Purification.java | 11 +- .../crafttweaker/handlers/Reaction.java | 18 +- .../crafttweaker/handlers/Sawmill.java | 13 +- .../crafttweaker/handlers/Separator.java | 11 +- .../handlers/SolarNeutronActivator.java | 10 +- .../handlers/ThermalEvaporation.java | 14 +- .../helpers/IngredientHelper.java | 12 +- .../helpers/RecipeInfoHelper.java | 6 +- .../crafttweaker/util/IngredientWrapper.java | 3 +- .../util/RecipeMapModification.java | 9 +- .../util/RemoveMekanismRecipe.java | 9 +- .../ForgeEnergyCableIntegration.java | 7 +- .../forgeenergy/ForgeEnergyIntegration.java | 2 +- .../forgeenergy/ForgeEnergyItemWrapper.java | 20 +- .../integration/ic2/IC2Integration.java | 13 +- .../integration/ic2/IC2ItemManager.java | 17 +- .../multipart/MultipartGlowPanel.java | 11 +- .../multipart/MultipartMekanism.java | 51 +-- .../integration/multipart/MultipartTile.java | 2 +- .../multipart/MultipartTileNetworkJoiner.java | 26 +- .../multipart/MultipartTransmitter.java | 15 +- .../tesla/TeslaCableIntegration.java | 6 +- .../integration/tesla/TeslaIntegration.java | 8 +- .../integration/tesla/TeslaItemWrapper.java | 19 +- .../integration/wrenches/BuildCraftProxy.java | 5 +- .../integration/wrenches/CofhProxy.java | 8 +- .../common/integration/wrenches/IC2Proxy.java | 4 +- .../integration/wrenches/MekPassthrough.java | 2 +- .../integration/wrenches/MekWrenchProxy.java | 3 +- .../common/integration/wrenches/Wrenches.java | 10 +- .../common/inventory/InventoryBin.java | 23 +- .../common/inventory/InventoryList.java | 24 +- .../inventory/InventoryPersonalChest.java | 12 +- .../ContainerAdvancedElectricMachine.java | 53 +-- .../container/ContainerChanceMachine.java | 40 +- .../ContainerChemicalCrystallizer.java | 42 +- .../ContainerChemicalDissolutionChamber.java | 51 +-- .../container/ContainerChemicalInfuser.java | 38 +- .../container/ContainerChemicalOxidizer.java | 48 +- .../container/ContainerChemicalWasher.java | 50 +-- .../container/ContainerDictionary.java | 15 +- .../container/ContainerDigitalMiner.java | 27 +- .../ContainerDoubleElectricMachine.java | 56 +-- .../container/ContainerElectricMachine.java | 42 +- .../container/ContainerElectricPump.java | 11 +- .../ContainerElectrolyticSeparator.java | 29 +- .../container/ContainerEnergyStorage.java | 44 +- .../inventory/container/ContainerFactory.java | 37 +- .../inventory/container/ContainerFilter.java | 15 +- .../container/ContainerFluidStorage.java | 6 - .../container/ContainerFluidicPlenisher.java | 45 +- .../ContainerFormulaicAssemblicator.java | 50 +-- .../container/ContainerFuelwoodHeater.java | 36 +- .../inventory/container/ContainerGasTank.java | 36 +- .../container/ContainerLaserAmplifier.java | 14 +- .../container/ContainerLaserTractorBeam.java | 8 +- .../container/ContainerMekanism.java | 1 - .../ContainerMetallurgicInfuser.java | 31 +- .../inventory/container/ContainerNull.java | 2 +- .../ContainerOredictionificator.java | 36 +- .../inventory/container/ContainerPRC.java | 42 +- .../container/ContainerPersonalChest.java | 17 +- .../ContainerQuantumEntangloporter.java | 15 +- .../container/ContainerResistiveHeater.java | 36 +- .../ContainerRotaryCondensentrator.java | 54 +-- .../container/ContainerSecurityDesk.java | 36 +- .../container/ContainerSeismicVibrator.java | 36 +- .../ContainerSolarNeutronActivator.java | 42 +- .../container/ContainerTeleporter.java | 36 +- ...ContainerThermalEvaporationController.java | 42 +- .../container/ContainerUpgradeManagement.java | 44 +- .../container/robit/ContainerRobit.java | 1 - .../robit/ContainerRobitCrafting.java | 2 +- .../robit/ContainerRobitInventory.java | 8 +- .../container/robit/ContainerRobitMain.java | 2 +- .../container/robit/ContainerRobitRepair.java | 3 +- .../robit/ContainerRobitSmelting.java | 22 +- .../common/inventory/slot/SlotEnergy.java | 2 +- .../inventory/slot/SlotMachineUpgrade.java | 2 +- .../common/inventory/slot/SlotOutput.java | 2 +- .../inventory/slot/SlotPersonalChest.java | 4 +- .../common/inventory/slot/SlotSpecific.java | 3 +- .../inventory/slot/SlotStorageTank.java | 8 +- .../java/mekanism/common/item/ItemAlloy.java | 21 +- .../common/item/ItemAtomicDisassembler.java | 141 ++---- .../mekanism/common/item/ItemBalloon.java | 60 +-- .../mekanism/common/item/ItemBlockBasic.java | 100 ++--- .../common/item/ItemBlockCardboardBox.java | 40 +- .../common/item/ItemBlockEnergyCube.java | 74 +-- .../common/item/ItemBlockGasTank.java | 63 +-- .../common/item/ItemBlockGlowPanel.java | 30 +- .../common/item/ItemBlockMachine.java | 271 +++-------- .../common/item/ItemBlockMultipartAble.java | 51 +-- .../mekanism/common/item/ItemBlockOre.java | 13 +- .../common/item/ItemBlockPlastic.java | 5 +- .../common/item/ItemBlockTransmitter.java | 87 ++-- .../java/mekanism/common/item/ItemClump.java | 12 +- .../common/item/ItemConfigurationCard.java | 66 +-- .../common/item/ItemConfigurator.java | 68 +-- .../common/item/ItemControlCircuit.java | 15 +- .../common/item/ItemCraftingFormula.java | 35 +- .../mekanism/common/item/ItemCrystal.java | 12 +- .../mekanism/common/item/ItemDictionary.java | 18 +- .../mekanism/common/item/ItemDirtyDust.java | 12 +- .../java/mekanism/common/item/ItemDust.java | 12 +- .../mekanism/common/item/ItemElectricBow.java | 58 +-- .../mekanism/common/item/ItemEnergized.java | 13 +- .../common/item/ItemFlamethrower.java | 15 +- .../mekanism/common/item/ItemFreeRunners.java | 23 +- .../mekanism/common/item/ItemGasMask.java | 14 +- .../common/item/ItemGaugeDropper.java | 32 +- .../java/mekanism/common/item/ItemHDPE.java | 11 +- .../java/mekanism/common/item/ItemIngot.java | 15 +- .../mekanism/common/item/ItemJetpack.java | 28 +- .../mekanism/common/item/ItemMekanism.java | 2 +- .../common/item/ItemNetworkReader.java | 120 ++--- .../java/mekanism/common/item/ItemNugget.java | 11 +- .../mekanism/common/item/ItemOtherDust.java | 17 +- .../common/item/ItemPortableTeleporter.java | 41 +- .../java/mekanism/common/item/ItemProxy.java | 7 +- .../java/mekanism/common/item/ItemRobit.java | 18 +- .../mekanism/common/item/ItemScubaTank.java | 23 +- .../common/item/ItemSeismicReader.java | 29 +- .../java/mekanism/common/item/ItemShard.java | 12 +- .../common/item/ItemTierInstaller.java | 27 +- .../mekanism/common/item/ItemUpgrade.java | 13 +- .../common/item/ItemWalkieTalkie.java | 18 +- .../common/multiblock/IMultiblock.java | 2 +- .../multiblock/IStructuralMultiblock.java | 2 +- .../common/multiblock/MultiblockCache.java | 2 +- .../common/multiblock/MultiblockManager.java | 24 +- .../common/multiblock/SynchronizedData.java | 6 +- .../TileEntityInternalMultiblock.java | 11 +- .../common/multiblock/UpdateProtocol.java | 26 +- .../common/network/PacketBoxBlacklist.java | 16 +- .../common/network/PacketConfigSync.java | 4 +- .../network/PacketConfigurationUpdate.java | 34 +- .../network/PacketContainerEditMode.java | 9 +- .../common/network/PacketDataRequest.java | 25 +- .../common/network/PacketDigitalMinerGui.java | 79 ++-- .../common/network/PacketDropperUse.java | 10 +- .../common/network/PacketEditFilter.java | 58 +-- .../common/network/PacketEntityMove.java | 13 +- .../network/PacketFlamethrowerData.java | 35 +- .../common/network/PacketFreeRunnerData.java | 14 +- .../common/network/PacketItemStack.java | 15 +- .../common/network/PacketJetpackData.java | 52 +-- .../mekanism/common/network/PacketKey.java | 3 +- .../network/PacketLogisticalSorterGui.java | 110 ++--- .../common/network/PacketNewFilter.java | 42 +- .../network/PacketOredictionificatorGui.java | 116 ++--- .../common/network/PacketPersonalChest.java | 32 +- .../network/PacketPortableTeleporter.java | 99 +--- .../common/network/PacketPortalFX.java | 17 +- .../common/network/PacketRedstoneControl.java | 9 +- .../common/network/PacketRemoveUpgrade.java | 11 +- .../mekanism/common/network/PacketRobit.java | 14 +- .../common/network/PacketScubaTankData.java | 44 +- .../common/network/PacketSecurityMode.java | 16 +- .../common/network/PacketSecurityUpdate.java | 14 +- .../common/network/PacketSimpleGui.java | 24 +- .../common/network/PacketTileEntity.java | 22 +- .../network/PacketTransmitterUpdate.java | 36 +- .../mekanism/common/recipe/APIHandler.java | 16 +- .../mekanism/common/recipe/BinRecipe.java | 22 +- .../common/recipe/MekanismIngredient.java | 4 +- .../MekanismRecipeEnabledCondition.java | 9 +- .../common/recipe/MultiOredictIngredient.java | 2 +- .../mekanism/common/recipe/RecipeHandler.java | 227 ++++------ .../common/recipe/ShapedMekanismRecipe.java | 35 +- .../recipe/ShapelessMekanismRecipe.java | 14 +- .../recipe/inputs/AdvancedMachineInput.java | 12 +- .../recipe/inputs/ChemicalPairInput.java | 21 +- .../recipe/inputs/DoubleMachineInput.java | 17 +- .../common/recipe/inputs/FluidInput.java | 4 +- .../common/recipe/inputs/GasInput.java | 5 +- .../common/recipe/inputs/InfusionInput.java | 11 +- .../common/recipe/inputs/IntegerInput.java | 2 +- .../common/recipe/inputs/ItemStackInput.java | 7 +- .../common/recipe/inputs/MachineInput.java | 15 +- .../recipe/inputs/PressurizedInput.java | 34 +- .../machines/AdvancedMachineRecipe.java | 14 +- .../recipe/machines/AmbientGasRecipe.java | 2 +- .../recipe/machines/BasicMachineRecipe.java | 5 +- .../recipe/machines/ChanceMachineRecipe.java | 8 +- .../machines/ChemicalInfuserRecipe.java | 2 +- .../recipe/machines/CombinerRecipe.java | 5 +- .../common/recipe/machines/CrusherRecipe.java | 2 +- .../recipe/machines/CrystallizerRecipe.java | 2 +- .../recipe/machines/DissolutionRecipe.java | 5 +- .../recipe/machines/DoubleMachineRecipe.java | 8 +- .../recipe/machines/EnrichmentRecipe.java | 2 +- .../recipe/machines/GasCentrifugeRecipe.java | 2 +- .../recipe/machines/InjectionRecipe.java | 2 +- .../common/recipe/machines/MachineRecipe.java | 2 +- .../machines/MetallurgicInfuserRecipe.java | 2 +- .../machines/OsmiumCompressorRecipe.java | 2 +- .../recipe/machines/OxidationRecipe.java | 5 +- .../recipe/machines/PressurizedRecipe.java | 25 +- .../recipe/machines/PurificationRecipe.java | 2 +- .../common/recipe/machines/SawmillRecipe.java | 2 +- .../recipe/machines/SeparatorRecipe.java | 2 +- .../recipe/machines/SmeltingRecipe.java | 2 +- .../recipe/machines/SolarNeutronRecipe.java | 2 +- .../machines/ThermalEvaporationRecipe.java | 2 +- .../common/recipe/machines/WasherRecipe.java | 8 +- .../common/recipe/outputs/ChanceOutput.java | 28 +- .../recipe/outputs/ChemicalPairOutput.java | 18 +- .../common/recipe/outputs/FluidOutput.java | 4 +- .../common/recipe/outputs/GasOutput.java | 4 +- .../recipe/outputs/ItemStackOutput.java | 13 +- .../common/recipe/outputs/MachineOutput.java | 2 +- .../recipe/outputs/PressurizedOutput.java | 8 +- .../mekanism/common/security/IOwnerItem.java | 2 +- .../common/security/ISecurityItem.java | 2 +- .../common/security/ISecurityTile.java | 2 +- .../common/security/SecurityData.java | 4 +- .../common/security/SecurityFrequency.java | 10 +- .../java/mekanism/common/tier/CableTier.java | 1 - .../mekanism/common/tier/ConductorTier.java | 1 - src/main/java/mekanism/common/tier/ITier.java | 2 +- .../java/mekanism/common/tier/PipeTier.java | 1 - .../mekanism/common/tier/TransporterTier.java | 1 - .../java/mekanism/common/tier/TubeTier.java | 1 - .../tile/TileEntityAdvancedBoundingBlock.java | 44 +- .../tile/TileEntityAdvancedFactory.java | 11 +- .../tile/TileEntityAmbientAccumulator.java | 8 +- .../mekanism/common/tile/TileEntityBin.java | 149 +----- .../common/tile/TileEntityBoilerCasing.java | 56 +-- .../common/tile/TileEntityBoilerValve.java | 47 +- .../common/tile/TileEntityBoundingBlock.java | 23 +- .../common/tile/TileEntityCardboardBox.java | 5 +- .../common/tile/TileEntityChanceMachine.java | 37 +- .../common/tile/TileEntityChargepad.java | 30 +- .../tile/TileEntityChemicalCrystallizer.java | 54 +-- .../TileEntityChemicalDissolutionChamber.java | 53 +-- .../tile/TileEntityChemicalInfuser.java | 45 +- .../TileEntityChemicalInjectionChamber.java | 15 +- .../tile/TileEntityChemicalOxidizer.java | 37 +- .../common/tile/TileEntityChemicalWasher.java | 56 +-- .../common/tile/TileEntityCombiner.java | 6 +- .../common/tile/TileEntityCrusher.java | 6 +- .../common/tile/TileEntityDigitalMiner.java | 240 ++-------- .../common/tile/TileEntityDynamicTank.java | 58 +-- .../common/tile/TileEntityDynamicValve.java | 16 +- .../common/tile/TileEntityElectricPump.java | 86 +--- .../tile/TileEntityElectrolyticSeparator.java | 90 +--- .../common/tile/TileEntityEliteFactory.java | 12 +- .../tile/TileEntityEnergizedSmelter.java | 8 +- .../common/tile/TileEntityEnergyCube.java | 43 +- .../tile/TileEntityEnrichmentChamber.java | 6 +- .../common/tile/TileEntityFactory.java | 191 ++------ .../common/tile/TileEntityFluidTank.java | 108 +---- .../tile/TileEntityFluidicPlenisher.java | 72 +-- .../TileEntityFormulaicAssemblicator.java | 146 ++---- .../common/tile/TileEntityFuelwoodHeater.java | 38 +- .../common/tile/TileEntityGasTank.java | 80 +--- .../common/tile/TileEntityGlowPanel.java | 12 +- .../tile/TileEntityInductionCasing.java | 18 +- .../common/tile/TileEntityInductionCell.java | 21 +- .../common/tile/TileEntityInductionPort.java | 59 ++- .../tile/TileEntityInductionProvider.java | 14 +- .../mekanism/common/tile/TileEntityLaser.java | 30 +- .../common/tile/TileEntityLaserAmplifier.java | 55 +-- .../tile/TileEntityLaserTractorBeam.java | 101 ++--- .../tile/TileEntityLogisticalSorter.java | 143 +----- .../tile/TileEntityMetallurgicInfuser.java | 59 +-- .../common/tile/TileEntityMultiblock.java | 35 +- .../common/tile/TileEntityObsidianTNT.java | 8 - .../tile/TileEntityOredictionificator.java | 84 +--- .../tile/TileEntityOsmiumCompressor.java | 7 +- .../mekanism/common/tile/TileEntityPRC.java | 79 +--- .../common/tile/TileEntityPersonalChest.java | 26 +- .../tile/TileEntityPrecisionSawmill.java | 8 +- .../tile/TileEntityPressureDisperser.java | 2 +- .../tile/TileEntityPurificationChamber.java | 8 +- .../tile/TileEntityQuantumEntangloporter.java | 107 +---- .../tile/TileEntityResistiveHeater.java | 45 +- .../tile/TileEntityRotaryCondensentrator.java | 78 +--- .../common/tile/TileEntitySecurityDesk.java | 38 +- .../tile/TileEntitySeismicVibrator.java | 32 +- .../tile/TileEntitySolarNeutronActivator.java | 36 +- .../tile/TileEntityStructuralGlass.java | 13 +- .../tile/TileEntitySuperheatingElement.java | 12 +- .../common/tile/TileEntityTeleporter.java | 137 ++---- .../TileEntityThermalEvaporationBlock.java | 24 +- ...ileEntityThermalEvaporationController.java | 143 ++---- .../TileEntityThermalEvaporationValve.java | 27 +- .../common/tile/component/SideConfig.java | 2 +- .../component/TileComponentChunkLoader.java | 19 +- .../tile/component/TileComponentConfig.java | 14 +- .../tile/component/TileComponentEjector.java | 36 +- .../tile/component/TileComponentSecurity.java | 18 +- .../tile/component/TileComponentUpgrade.java | 27 +- .../TileEntityAdvancedElectricMachine.java | 69 +-- .../tile/prefab/TileEntityBasicBlock.java | 40 +- .../tile/prefab/TileEntityBasicMachine.java | 22 +- .../tile/prefab/TileEntityContainerBlock.java | 28 +- .../TileEntityDoubleElectricMachine.java | 48 +- .../tile/prefab/TileEntityEffectsBlock.java | 28 +- .../tile/prefab/TileEntityElectricBlock.java | 79 +--- .../prefab/TileEntityElectricMachine.java | 51 +-- .../common/tile/prefab/TileEntityMachine.java | 15 +- .../prefab/TileEntityOperationalMachine.java | 20 +- .../prefab/TileEntityUpgradeableMachine.java | 16 +- .../TileEntityDiversionTransporter.java | 33 +- .../TileEntityLogisticalTransporter.java | 79 +--- .../transmitter/TileEntityMechanicalPipe.java | 42 +- .../TileEntityPressurizedTube.java | 52 +-- .../TileEntityRestrictiveTransporter.java | 2 +- .../tile/transmitter/TileEntitySidedPipe.java | 141 ++---- .../TileEntityThermodynamicConductor.java | 34 +- .../transmitter/TileEntityTransmitter.java | 24 +- .../transmitter/TileEntityUniversalCable.java | 146 ++---- .../common/transmitters/Transmitter.java | 6 +- .../common/transmitters/TransmitterImpl.java | 28 +- .../common/transmitters/TransporterImpl.java | 85 +--- .../transmitters/grid/EnergyNetwork.java | 21 +- .../transmitters/grid/FluidNetwork.java | 49 +- .../common/transmitters/grid/GasNetwork.java | 48 +- .../common/transmitters/grid/HeatNetwork.java | 17 +- .../transmitters/grid/InventoryNetwork.java | 16 +- .../java/mekanism/common/util/CableUtils.java | 53 +-- .../mekanism/common/util/CapabilityUtils.java | 4 +- .../mekanism/common/util/ChargeUtils.java | 90 ++-- .../java/mekanism/common/util/EmitUtils.java | 52 +-- .../util/FieldsAreNonnullByDefault.java | 3 +- .../common/util/FluidContainerUtils.java | 69 +-- .../java/mekanism/common/util/GasUtils.java | 38 +- .../java/mekanism/common/util/HeatUtils.java | 18 +- .../mekanism/common/util/InventoryUtils.java | 65 +-- .../mekanism/common/util/ItemDataUtils.java | 18 +- .../common/util/ItemRegistryUtils.java | 3 +- .../java/mekanism/common/util/LangUtils.java | 7 +- .../mekanism/common/util/MekanismUtils.java | 288 +++++------- .../java/mekanism/common/util/MinerUtils.java | 23 +- .../mekanism/common/util/MultipartUtils.java | 19 +- .../java/mekanism/common/util/PipeUtils.java | 32 +- .../mekanism/common/util/RecipeUtils.java | 53 +-- .../mekanism/common/util/SecurityUtils.java | 53 +-- .../java/mekanism/common/util/StackUtils.java | 44 +- .../java/mekanism/common/util/StatUtils.java | 6 +- .../common/util/TextComponentGroup.java | 4 +- .../java/mekanism/common/util/TileUtils.java | 2 +- .../common/util/TransporterUtils.java | 26 +- .../common/util/UnitDisplayUtils.java | 80 ++-- .../common/voice/VoiceConnection.java | 19 +- .../common/voice/VoiceServerManager.java | 9 - .../mekanism/common/world/GenHandler.java | 29 +- .../mekanism/common/world/WorldGenSalt.java | 33 +- .../coremod/KeybindingMigrationHelper.java | 17 +- .../mekanism/coremod/MekanismCoremod.java | 3 +- .../client/GeneratorsClientProxy.java | 11 +- .../client/gui/GeneratorsGuiFactory.java | 3 +- .../client/gui/GuiBioGenerator.java | 15 +- .../client/gui/GuiGasGenerator.java | 10 +- .../client/gui/GuiGeneratorsConfig.java | 30 +- .../client/gui/GuiHeatGenerator.java | 9 +- .../client/gui/GuiIndustrialTurbine.java | 68 +-- .../client/gui/GuiReactorController.java | 10 +- .../generators/client/gui/GuiReactorFuel.java | 22 +- .../generators/client/gui/GuiReactorHeat.java | 19 +- .../client/gui/GuiReactorLogicAdapter.java | 39 +- .../client/gui/GuiReactorStats.java | 67 ++- .../client/gui/GuiSolarGenerator.java | 10 +- .../client/gui/GuiTurbineStats.java | 62 +-- .../client/gui/GuiWindGenerator.java | 24 +- .../generators/client/jei/GeneratorsJEI.java | 5 +- .../model/ModelAdvancedSolarGenerator.java | 2 +- .../client/model/ModelBioGenerator.java | 2 +- .../client/model/ModelGasGenerator.java | 2 +- .../client/model/ModelHeatGenerator.java | 6 +- .../client/model/ModelSolarGenerator.java | 2 +- .../generators/client/model/ModelTurbine.java | 2 +- .../client/model/ModelWindGenerator.java | 2 +- .../render/RenderAdvancedSolarGenerator.java | 5 +- .../client/render/RenderBioGenerator.java | 5 +- .../client/render/RenderGasGenerator.java | 5 +- .../client/render/RenderHeatGenerator.java | 5 +- .../render/RenderIndustrialTurbine.java | 23 +- .../client/render/RenderReactor.java | 11 +- .../client/render/RenderSolarGenerator.java | 5 +- .../client/render/RenderTurbineRotor.java | 14 +- .../client/render/RenderWindGenerator.java | 8 +- .../render/item/RenderBioGeneratorItem.java | 1 + .../render/item/RenderGeneratorItem.java | 1 - .../render/item/RenderHeatGeneratorItem.java | 3 +- .../render/item/RenderWindGeneratorItem.java | 3 +- .../generators/common/FusionReactor.java | 127 ++---- .../generators/common/GeneratorsBlocks.java | 2 +- .../common/GeneratorsCommonProxy.java | 5 +- .../common/GeneratorsGuiHandler.java | 5 +- .../generators/common/GeneratorsItems.java | 2 +- .../generators/common/MekanismGenerators.java | 18 +- .../common/block/BlockGenerator.java | 129 ++---- .../generators/common/block/BlockReactor.java | 40 +- .../block/states/BlockStateGenerator.java | 67 +-- .../block/states/BlockStateReactor.java | 29 +- .../turbine/SynchronizedTurbineData.java | 4 +- .../common/content/turbine/TurbineCache.java | 4 +- .../content/turbine/TurbineFluidTank.java | 24 +- .../turbine/TurbineUpdateProtocol.java | 29 +- .../container/ContainerBioGenerator.java | 5 +- .../container/ContainerFuelGenerator.java | 6 - .../container/ContainerPassiveGenerator.java | 6 - .../container/ContainerReactorController.java | 7 - .../common/item/ItemBlockGenerator.java | 88 +--- .../common/item/ItemBlockReactor.java | 8 +- .../generators/common/item/ItemHohlraum.java | 13 +- .../TileEntityAdvancedSolarGenerator.java | 9 +- .../common/tile/TileEntityBioGenerator.java | 48 +- .../common/tile/TileEntityGasGenerator.java | 64 +-- .../common/tile/TileEntityGenerator.java | 25 +- .../common/tile/TileEntityHeatGenerator.java | 57 +-- .../common/tile/TileEntitySolarGenerator.java | 15 +- .../common/tile/TileEntityWindGenerator.java | 35 +- .../tile/reactor/TileEntityReactorBlock.java | 15 +- .../reactor/TileEntityReactorController.java | 54 +-- .../tile/reactor/TileEntityReactorFrame.java | 2 +- .../tile/reactor/TileEntityReactorGlass.java | 2 +- .../TileEntityReactorLaserFocusMatrix.java | 3 +- .../TileEntityReactorLogicAdapter.java | 32 +- .../tile/reactor/TileEntityReactorPort.java | 81 +--- .../TileEntityElectromagneticCoil.java | 2 +- .../turbine/TileEntityRotationalComplex.java | 3 +- .../TileEntitySaturatingCondenser.java | 2 +- .../tile/turbine/TileEntityTurbineCasing.java | 49 +- .../tile/turbine/TileEntityTurbineRotor.java | 31 +- .../tile/turbine/TileEntityTurbineValve.java | 67 +-- .../tile/turbine/TileEntityTurbineVent.java | 17 +- .../tools/client/ToolsClientProxy.java | 2 +- .../tools/client/gui/GuiToolsConfig.java | 41 +- .../tools/client/gui/ToolsGuiFactory.java | 4 +- .../mekanism/tools/common/MekanismTools.java | 46 +- .../java/mekanism/tools/common/ToolUtils.java | 9 - .../tools/common/ToolsCommonProxy.java | 2 +- .../mekanism/tools/common/ToolsItems.java | 68 +-- .../tools/item/ItemMekanismArmor.java | 7 +- .../mekanism/tools/item/ItemMekanismAxe.java | 5 +- .../mekanism/tools/item/ItemMekanismHoe.java | 26 +- .../tools/item/ItemMekanismPickaxe.java | 17 +- .../tools/item/ItemMekanismShovel.java | 41 +- .../tools/item/ItemMekanismSword.java | 5 +- .../mekanism/tools/item/ItemMekanismTool.java | 3 +- 909 files changed, 6234 insertions(+), 15623 deletions(-) delete mode 100644 src/main/java/mekanism/common/tile/TileEntityObsidianTNT.java diff --git a/src/api/java/cofh/api/item/IToolHammer.java b/src/api/java/cofh/api/item/IToolHammer.java index 66cdc9f3c..b17f22e06 100644 --- a/src/api/java/cofh/api/item/IToolHammer.java +++ b/src/api/java/cofh/api/item/IToolHammer.java @@ -13,10 +13,10 @@ public interface IToolHammer { /** * Called to ensure that the tool can be used on a block. * - * @param item The ItemStack for the tool. Not required to match equipped item (e.g., multi-tools that contain other - * tools). + * @param item The ItemStack for the tool. Not required to match equipped item (e.g., multi-tools that contain other tools). * @param user The entity using the tool. - * @param pos Coordinates of the block. + * @param pos Coordinates of the block. + * * @return True if this tool can be used. */ boolean isUsable(ItemStack item, EntityLivingBase user, BlockPos pos); @@ -24,10 +24,10 @@ public interface IToolHammer { /** * Called to ensure that the tool can be used on an entity. * - * @param item The ItemStack for the tool. Not required to match equipped item (e.g., multi-tools that contain other - * tools). - * @param user The entity using the tool. + * @param item The ItemStack for the tool. Not required to match equipped item (e.g., multi-tools that contain other tools). + * @param user The entity using the tool. * @param entity The entity the tool is being used on. + * * @return True if this tool can be used. */ boolean isUsable(ItemStack item, EntityLivingBase user, Entity entity); @@ -35,21 +35,18 @@ public interface IToolHammer { /** * Callback for when the tool has been used reactively. * - * @param item The ItemStack for the tool. Not required to match equipped item (e.g., multi-tools that contain other - * tools). + * @param item The ItemStack for the tool. Not required to match equipped item (e.g., multi-tools that contain other tools). * @param user The entity using the tool. - * @param pos Coordinates of the block. + * @param pos Coordinates of the block. */ void toolUsed(ItemStack item, EntityLivingBase user, BlockPos pos); /** * Callback for when the tool has been used reactively. * - * @param item The ItemStack for the tool. Not required to match equipped item (e.g., multi-tools that contain other - * tools). - * @param user The entity using the tool. + * @param item The ItemStack for the tool. Not required to match equipped item (e.g., multi-tools that contain other tools). + * @param user The entity using the tool. * @param entity The entity the tool is being used on. */ void toolUsed(ItemStack item, EntityLivingBase user, Entity entity); - } \ No newline at end of file diff --git a/src/api/java/micdoodle8/mods/galacticraft/api/entity/IEntityBreathable.java b/src/api/java/micdoodle8/mods/galacticraft/api/entity/IEntityBreathable.java index 13b1bd8a4..1a8eaebbe 100644 --- a/src/api/java/micdoodle8/mods/galacticraft/api/entity/IEntityBreathable.java +++ b/src/api/java/micdoodle8/mods/galacticraft/api/entity/IEntityBreathable.java @@ -9,4 +9,4 @@ public interface IEntityBreathable { * Whether or not this entity can currently breathe without oxygen in it's vicinity */ boolean canBreath(); -} +} \ No newline at end of file diff --git a/src/api/java/micdoodle8/mods/galacticraft/api/world/ISolarLevel.java b/src/api/java/micdoodle8/mods/galacticraft/api/world/ISolarLevel.java index 6dafcdc14..d52195e78 100644 --- a/src/api/java/micdoodle8/mods/galacticraft/api/world/ISolarLevel.java +++ b/src/api/java/micdoodle8/mods/galacticraft/api/world/ISolarLevel.java @@ -3,8 +3,7 @@ package micdoodle8.mods.galacticraft.api.world; /** * Used to change the solar multiplier of certain world providers *

- * If you have a solar feature in your mod, check whether the world's provider inherits this class and multiply the - * solar generation by the solar multiplier double + * If you have a solar feature in your mod, check whether the world's provider inherits this class and multiply the solar generation by the solar multiplier double *

* for example: *

@@ -13,4 +12,4 @@ package micdoodle8.mods.galacticraft.api.world; public interface ISolarLevel { double getSolarEnergyMultiplier(); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/Chunk3D.java b/src/main/java/mekanism/api/Chunk3D.java index 44cbcb34b..26389cc4a 100644 --- a/src/main/java/mekanism/api/Chunk3D.java +++ b/src/main/java/mekanism/api/Chunk3D.java @@ -6,29 +6,27 @@ import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; /** - * Chunk3D - an integer-based way to keep track of and perform operations on chunks in a Minecraft-based environment. - * This also takes in account the dimension the chunk is in. + * Chunk3D - an integer-based way to keep track of and perform operations on chunks in a Minecraft-based environment. This also takes in account the dimension the chunk + * is in. * * @author aidancbrady */ public class Chunk3D { public int dimensionId; - public int x; public int z; /** * Creates a Chunk3D object from the given x and z coordinates, as well as a dimension. * - * @param x - chunk x location - * @param z - chunk z location + * @param x - chunk x location + * @param z - chunk z location * @param dimension - the dimension this Chunk3D is in */ public Chunk3D(int x, int z, int dimension) { this.x = x; this.z = z; - dimensionId = dimension; } @@ -38,9 +36,8 @@ public class Chunk3D { * @param entity - the entity to get the Chunk3D object from */ public Chunk3D(Entity entity) { - x = ((int) entity.posX) >> 4; - z = ((int) entity.posZ) >> 4; - + x = (int) entity.posX >> 4; + z = (int) entity.posZ >> 4; dimensionId = entity.dimension; } @@ -52,7 +49,6 @@ public class Chunk3D { public Chunk3D(Coord4D coord) { x = coord.x >> 4; z = coord.z >> 4; - dimensionId = coord.dimensionId; } @@ -60,6 +56,7 @@ public class Chunk3D { * Whether or not this chunk exists in the given world. * * @param world - the world to check in + * * @return if the chunk exists */ public boolean exists(World world) { @@ -70,6 +67,7 @@ public class Chunk3D { * Gets a Chunk object corresponding to this Chunk3D's coordinates. * * @param world - the world to get the Chunk object from + * * @return the corresponding Chunk object */ public Chunk getChunk(World world) { @@ -97,10 +95,7 @@ public class Chunk3D { @Override public boolean equals(Object obj) { - return obj instanceof Chunk3D && - ((Chunk3D) obj).x == x && - ((Chunk3D) obj).z == z && - ((Chunk3D) obj).dimensionId == dimensionId; + return obj instanceof Chunk3D && ((Chunk3D) obj).x == x && ((Chunk3D) obj).z == z && ((Chunk3D) obj).dimensionId == dimensionId; } @Override @@ -111,4 +106,4 @@ public class Chunk3D { code = 31 * code + dimensionId; return code; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/Coord4D.java b/src/main/java/mekanism/api/Coord4D.java index 83027fec0..48abe1125 100644 --- a/src/main/java/mekanism/api/Coord4D.java +++ b/src/main/java/mekanism/api/Coord4D.java @@ -19,8 +19,8 @@ import net.minecraft.world.chunk.Chunk; import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint; /** - * Coord4D - an integer-based way to keep track of and perform operations on blocks in a Minecraft-based environment. - * This also takes in account the dimension the coordinate is in. + * Coord4D - an integer-based way to keep track of and perform operations on blocks in a Minecraft-based environment. This also takes in account the dimension the + * coordinate is in. * * @author aidancbrady */ @@ -29,7 +29,6 @@ public class Coord4D { public int x; public int y; public int z; - public int dimensionId; /** @@ -41,23 +40,21 @@ public class Coord4D { this.x = (int) entity.posX; this.y = (int) entity.posY; this.z = (int) entity.posZ; - this.dimensionId = entity.world.provider.getDimension(); } /** * Creates a Coord4D from the defined x, y, z, and dimension values. * - * @param x - x coordinate - * @param y - y coordinate - * @param z - z coordinate + * @param x - x coordinate + * @param y - y coordinate + * @param z - z coordinate * @param dimension - dimension ID */ public Coord4D(double x, double y, double z, int dimension) { this.x = MathHelper.floor(x); this.y = MathHelper.floor(y); this.z = MathHelper.floor(z); - this.dimensionId = dimension; } @@ -73,6 +70,7 @@ public class Coord4D { * Returns a new Coord4D from a defined TileEntity's x, y and z values. * * @param tileEntity - TileEntity at the location that will represent this Coord4D + * * @return the Coord4D object from the TileEntity */ public static Coord4D get(TileEntity tileEntity) { @@ -83,6 +81,7 @@ public class Coord4D { * Returns a new Coord4D from a tag compound. * * @param tag - tag compound to read from + * * @return the Coord4D from the tag compound */ public static Coord4D read(NBTTagCompound tag) { @@ -93,6 +92,7 @@ public class Coord4D { * Returns a new Coord4D from a ByteBuf. * * @param dataStream - data input to read from + * * @return the Coord4D from the data input */ public static Coord4D read(ByteBuf dataStream) { @@ -103,6 +103,7 @@ public class Coord4D { * Gets the state of the block representing this Coord4D. * * @param world - world this Coord4D is in + * * @return the state of this Coord4D's block */ public IBlockState getBlockState(IBlockAccess world) { @@ -122,13 +123,13 @@ public class Coord4D { * Gets the TileEntity of the block representing this Coord4D. * * @param world - world this Coord4D is in + * * @return the TileEntity of this Coord4D's block */ public TileEntity getTileEntity(IBlockAccess world) { if (world instanceof World && !exists((World) world)) { return null; } - return world.getTileEntity(getPos()); } @@ -136,13 +137,13 @@ public class Coord4D { * Gets the Block value of the block representing this Coord4D. * * @param world - world this Coord4D is in + * * @return the Block value of this Coord4D's block */ public Block getBlock(IBlockAccess world) { if (world instanceof World && !exists((World) world)) { return null; } - return getBlockState(world).getBlock(); } @@ -150,6 +151,7 @@ public class Coord4D { * Writes this Coord4D's data to an NBTTagCompound. * * @param nbtTags - tag compound to write to + * * @return the tag compound with this Coord4D's data */ public NBTTagCompound write(NBTTagCompound nbtTags) { @@ -157,7 +159,6 @@ public class Coord4D { nbtTags.setInteger("y", y); nbtTags.setInteger("z", z); nbtTags.setInteger("dimensionId", dimensionId); - return nbtTags; } @@ -199,6 +200,7 @@ public class Coord4D { * @param x - x value to translate * @param y - y value to translate * @param z - z value to translate + * * @return translated Coord4D */ public Coord4D translate(int x, int y, int z) { @@ -209,6 +211,7 @@ public class Coord4D { * Translates this Coord4D by the defined Coord4D's coordinates, regardless of dimension. * * @param coord - coordinates to translate by + * * @return translated Coord4D */ public Coord4D translate(Coord4D coord) { @@ -219,6 +222,7 @@ public class Coord4D { * Creates and returns a new Coord4D translated to the defined offsets of the side. * * @param side - side to translate this Coord4D to + * * @return translated Coord4D */ public Coord4D offset(EnumFacing side) { @@ -228,26 +232,23 @@ public class Coord4D { /** * Creates and returns a new Coord4D translated to the defined offsets of the side by the defined amount. * - * @param side - side to translate this Coord4D to + * @param side - side to translate this Coord4D to * @param amount - how far to translate this Coord4D + * * @return translated Coord4D */ public Coord4D offset(EnumFacing side, int amount) { if (side == null || amount == 0) { return this; } - - return new Coord4D(x + (side.getXOffset() * amount), y + (side.getYOffset() * amount), - z + (side.getZOffset() * amount), dimensionId); + return new Coord4D(x + (side.getXOffset() * amount), y + (side.getYOffset() * amount), z + (side.getZOffset() * amount), dimensionId); } public ItemStack getStack(IBlockAccess world) { IBlockState state = getBlockState(world); - if (state == null || state.getBlock().isAir(state, world, null)) { return ItemStack.EMPTY; } - return new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)); } @@ -255,6 +256,7 @@ public class Coord4D { * Creates and returns a new Coord4D with values representing the difference between the defined Coord4D * * @param other - the Coord4D to subtract from this + * * @return a Coord4D representing the distance between the defined Coord4D */ public Coord4D difference(Coord4D other) { @@ -262,21 +264,19 @@ public class Coord4D { } /** - * A method used to find the EnumFacing represented by the distance of the defined Coord4D. Most likely won't have - * many applicable uses. + * A method used to find the EnumFacing represented by the distance of the defined Coord4D. Most likely won't have many applicable uses. * * @param other - Coord4D to find the side difference of + * * @return EnumFacing representing the side the defined relative Coord4D is on to this */ public EnumFacing sideDifference(Coord4D other) { Coord4D diff = difference(other); - for (EnumFacing side : EnumFacing.VALUES) { if (side.getXOffset() == diff.x && side.getYOffset() == diff.y && side.getZOffset() == diff.z) { return side; } } - return null; } @@ -284,6 +284,7 @@ public class Coord4D { * Gets the distance to a defined Coord4D. * * @param obj - the Coord4D to find the distance to + * * @return the distance to the defined Coord4D */ public int distanceTo(Coord4D obj) { @@ -294,8 +295,9 @@ public class Coord4D { } /** - * @param side - side to check + * @param side - side to check * @param world - world this Coord4D is in + * * @return Whether or not the defined side of this Coord4D is visible. */ public boolean sideVisible(EnumFacing side, IBlockAccess world) { @@ -306,6 +308,7 @@ public class Coord4D { * Gets a TargetPoint with the defined range from this Coord4D with the appropriate coordinates and dimension ID. * * @param range - the range the packet can be sent in of this Coord4D + * * @return TargetPoint relative to this Coord4D */ public TargetPoint getTargetPoint(double range) { @@ -316,6 +319,7 @@ public class Coord4D { * Steps this Coord4D in the defined side's offset without creating a new value. * * @param side - side to step towards + * * @return this Coord4D */ public Coord4D step(EnumFacing side) { @@ -326,17 +330,18 @@ public class Coord4D { * Whether or not the chunk this Coord4D is in exists and is loaded. * * @param world - world this Coord4D is in + * * @return the chunk of this Coord4D */ public boolean exists(World world) { - return world.isBlockLoaded(new BlockPos(x, y, - z));//world.getChunkProvider() == null || world.getChunkProvider().getLoadedChunk(x >> 4, z >> 4) != null; + return world.isBlockLoaded(new BlockPos(x, y, z));//world.getChunkProvider() == null || world.getChunkProvider().getLoadedChunk(x >> 4, z >> 4) != null; } /** * Gets the chunk this Coord4D is in. * * @param world - world this Coord4D is in + * * @return the chunk of this Coord4D */ public Chunk getChunk(World world) { @@ -356,6 +361,7 @@ public class Coord4D { * Whether or not the block this Coord4D represents is an air block. * * @param world - world this Coord4D is in + * * @return if this Coord4D is an air block */ public boolean isAirBlock(IBlockAccess world) { @@ -366,6 +372,7 @@ public class Coord4D { * Whether or not this block this Coord4D represents is replaceable. * * @param world - world this Coord4D is in + * * @return if this Coord4D is replaceable */ public boolean isReplaceable(World world) { @@ -393,11 +400,7 @@ public class Coord4D { @Override public boolean equals(Object obj) { - return obj instanceof Coord4D && - ((Coord4D) obj).x == x && - ((Coord4D) obj).y == y && - ((Coord4D) obj).z == z && - ((Coord4D) obj).dimensionId == dimensionId; + return obj instanceof Coord4D && ((Coord4D) obj).x == x && ((Coord4D) obj).y == y && ((Coord4D) obj).z == z && ((Coord4D) obj).dimensionId == dimensionId; } @Override @@ -409,4 +412,4 @@ public class Coord4D { code = 31 * code + dimensionId; return code; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/EnumColor.java b/src/main/java/mekanism/api/EnumColor.java index 06fe34fcb..b596c095e 100644 --- a/src/main/java/mekanism/api/EnumColor.java +++ b/src/main/java/mekanism/api/EnumColor.java @@ -33,8 +33,8 @@ public enum EnumColor implements IStringSerializable { BROWN("\u00a76", "brown", "Brown", new int[]{150, 75, 0}, 3, TextFormatting.GOLD), BRIGHT_PINK("\u00a7d", "brightPink", "Pink", new int[]{255, 192, 203}, 9, TextFormatting.LIGHT_PURPLE); - public static EnumColor[] DYES = new EnumColor[]{BLACK, RED, DARK_GREEN, BROWN, DARK_BLUE, PURPLE, DARK_AQUA, GREY, - DARK_GREY, BRIGHT_PINK, BRIGHT_GREEN, YELLOW, INDIGO, PINK, ORANGE, WHITE}; + public static EnumColor[] DYES = new EnumColor[]{BLACK, RED, DARK_GREEN, BROWN, DARK_BLUE, PURPLE, DARK_AQUA, GREY, DARK_GREY, BRIGHT_PINK, BRIGHT_GREEN, YELLOW, + INDIGO, PINK, ORANGE, WHITE}; /** * The color code that will be displayed @@ -66,7 +66,6 @@ public enum EnumColor implements IStringSerializable { return c; } } - return null; } @@ -124,6 +123,7 @@ public enum EnumColor implements IStringSerializable { * 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 + * * @return the color value */ public float getColor(int index) { @@ -143,4 +143,4 @@ public enum EnumColor implements IStringSerializable { public String toString() { return code; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/IAlloyInteraction.java b/src/main/java/mekanism/api/IAlloyInteraction.java index c6e9b9eaf..7813a47dc 100644 --- a/src/main/java/mekanism/api/IAlloyInteraction.java +++ b/src/main/java/mekanism/api/IAlloyInteraction.java @@ -14,10 +14,10 @@ public interface IAlloyInteraction { /** * Called when a player right-clicks this block with an alloy. * - * @param player - the player right-clicking the block - * @param hand - the hand this alloy was right-clicked with - * @param stack - the stack of alloy being right-clicked + * @param player - the player right-clicking the block + * @param hand - the hand this alloy was right-clicked with + * @param stack - the stack of alloy being right-clicked * @param tierOrdinal - the ordinal tier of the alloy (1 = advanced, 2 = elite, 3 = ultimate) */ void onAlloyInteraction(EntityPlayer player, EnumHand hand, ItemStack stack, int tierOrdinal); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/IClientTicker.java b/src/main/java/mekanism/api/IClientTicker.java index d53934e40..70b6d3aa3 100644 --- a/src/main/java/mekanism/api/IClientTicker.java +++ b/src/main/java/mekanism/api/IClientTicker.java @@ -5,4 +5,4 @@ public interface IClientTicker { void clientTick(); boolean needsTicks(); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/IConfigCardAccess.java b/src/main/java/mekanism/api/IConfigCardAccess.java index 2d2c9a372..e5c7ec307 100644 --- a/src/main/java/mekanism/api/IConfigCardAccess.java +++ b/src/main/java/mekanism/api/IConfigCardAccess.java @@ -3,8 +3,7 @@ package mekanism.api; import net.minecraft.nbt.NBTTagCompound; /** - * Implement this in your TileEntity class if you wish for Mekanism filters to be able to store any of their - * information. + * Implement this in your TileEntity class if you wish for Mekanism filters to be able to store any of their information. * * @author aidancbrady */ @@ -16,12 +15,13 @@ public interface IConfigCardAccess { * Collects the TileEntity's filter card data into the parameterized NBTTagCompound. * * @param nbtTags - the NBTTagCompound of the filter card ItemStack + * * @return the NBTTagCompound that now contains the TileEntity's filter card data */ NBTTagCompound getConfigurationData(NBTTagCompound nbtTags); /** - * Retrieves the TileEntity's data contained in the filter card based on the given NBTTagCompopund. + * Retrieves the TileEntity's data contained in the filter card based on the given NBTTagCompound. * * @param nbtTags - the NBTTagCompound of the filter card ItemStack */ @@ -34,4 +34,4 @@ public interface IConfigCardAccess { */ String getDataType(); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/IConfigurable.java b/src/main/java/mekanism/api/IConfigurable.java index 57fbe5242..70f21d005 100644 --- a/src/main/java/mekanism/api/IConfigurable.java +++ b/src/main/java/mekanism/api/IConfigurable.java @@ -15,7 +15,8 @@ public interface IConfigurable { * Called when a player shift-right clicks this block with a Configurator. * * @param player - the player who clicked the block - * @param side - the side the block was clicked on + * @param side - the side the block was clicked on + * * @return action that was performed */ EnumActionResult onSneakRightClick(EntityPlayer player, EnumFacing side); @@ -24,8 +25,9 @@ public interface IConfigurable { * Called when a player right clicks this block with a Configurator. * * @param player - the player who clicked the block - * @param side - the side the block was clicked on + * @param side - the side the block was clicked on + * * @return action that was performed */ EnumActionResult onRightClick(EntityPlayer player, EnumFacing side); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/IEvaporationSolar.java b/src/main/java/mekanism/api/IEvaporationSolar.java index 305ff7262..5f72a3d35 100644 --- a/src/main/java/mekanism/api/IEvaporationSolar.java +++ b/src/main/java/mekanism/api/IEvaporationSolar.java @@ -8,4 +8,4 @@ package mekanism.api; public interface IEvaporationSolar { boolean canSeeSun(); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/IHeatTransfer.java b/src/main/java/mekanism/api/IHeatTransfer.java index 71938648a..1f7518385 100644 --- a/src/main/java/mekanism/api/IHeatTransfer.java +++ b/src/main/java/mekanism/api/IHeatTransfer.java @@ -29,4 +29,4 @@ public interface IHeatTransfer { boolean canConnectHeat(EnumFacing side); IHeatTransfer getAdjacent(EnumFacing side); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/IMekWrench.java b/src/main/java/mekanism/api/IMekWrench.java index 167f361c4..e36f10c2b 100644 --- a/src/main/java/mekanism/api/IMekWrench.java +++ b/src/main/java/mekanism/api/IMekWrench.java @@ -17,4 +17,4 @@ public interface IMekWrench { default void wrenchUsed(EntityPlayer player, EnumHand hand, ItemStack wrench, RayTraceResult rayTrace) { } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/MekanismAPI.java b/src/main/java/mekanism/api/MekanismAPI.java index 0660fd296..f5cff537d 100644 --- a/src/main/java/mekanism/api/MekanismAPI.java +++ b/src/main/java/mekanism/api/MekanismAPI.java @@ -34,9 +34,7 @@ public class MekanismAPI { if (cardboardBoxModIgnore.contains(Objects.requireNonNull(block.getRegistryName()).getNamespace())) { return false; } - - return cardboardBoxIgnore.stream() - .noneMatch(i -> i.block == block && (i.meta == OreDictionary.WILDCARD_VALUE || i.meta == meta)); + return cardboardBoxIgnore.stream().noneMatch(i -> i.block == block && (i.meta == OreDictionary.WILDCARD_VALUE || i.meta == meta)); } public static void addBoxBlacklist(@Nullable Block block, int meta) { @@ -118,4 +116,4 @@ public class MekanismAPI { removeBoxBlacklistMod(modid); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/MekanismRecipeHelper.java b/src/main/java/mekanism/api/MekanismRecipeHelper.java index 3882494fa..715136699 100644 --- a/src/main/java/mekanism/api/MekanismRecipeHelper.java +++ b/src/main/java/mekanism/api/MekanismRecipeHelper.java @@ -11,7 +11,7 @@ public interface MekanismRecipeHelper { /** * Add an Enrichment Chamber recipe. * - * @param input - input ItemStack + * @param input - input ItemStack * @param output - output ItemStack */ void addEnrichmentChamberRecipe(ItemStack input, ItemStack output); @@ -19,7 +19,7 @@ public interface MekanismRecipeHelper { /** * Add an Osmium Compressor recipe. * - * @param input - input ItemStack + * @param input - input ItemStack * @param output - output ItemStack */ void addOsmiumCompressorRecipe(ItemStack input, ItemStack output); @@ -27,7 +27,7 @@ public interface MekanismRecipeHelper { /** * Add a Combiner recipe. * - * @param input - input ItemStack + * @param input - input ItemStack * @param output - output ItemStack */ @Deprecated @@ -36,8 +36,8 @@ public interface MekanismRecipeHelper { /** * Add a Combiner recipe. * - * @param input - input ItemStack - * @param extra - extra ItemStack + * @param input - input ItemStack + * @param extra - extra ItemStack * @param output - output ItemStack */ void addCombinerRecipe(ItemStack input, ItemStack extra, ItemStack output); @@ -45,7 +45,7 @@ public interface MekanismRecipeHelper { /** * Add a Crusher recipe. * - * @param input - input ItemStack + * @param input - input ItemStack * @param output - output ItemStack */ void addCrusherRecipe(ItemStack input, ItemStack output); @@ -53,7 +53,7 @@ public interface MekanismRecipeHelper { /** * Add a Purification Chamber recipe. * - * @param input - input ItemStack + * @param input - input ItemStack * @param output - output ItemStack */ void addPurificationChamberRecipe(ItemStack input, ItemStack output); @@ -63,7 +63,7 @@ public interface MekanismRecipeHelper { * * @param infuse - which Infuse to use * @param amount - how much of the Infuse to use - * @param input - input ItemStack + * @param input - input ItemStack * @param output - output ItemStack */ void addMetallurgicInfuserRecipe(InfuseType infuse, int amount, ItemStack input, ItemStack output); @@ -71,16 +71,16 @@ public interface MekanismRecipeHelper { /** * Add a Chemical Infuser recipe. * - * @param leftInput - left GasStack to input + * @param leftInput - left GasStack to input * @param rightInput - right GasStack to input - * @param output - output GasStack + * @param output - output GasStack */ void addChemicalInfuserRecipe(GasStack leftInput, GasStack rightInput, GasStack output); /** * Add a Chemical Oxidizer recipe. * - * @param input - input ItemStack + * @param input - input ItemStack * @param output - output GasStack */ void addChemicalOxidizerRecipe(ItemStack input, GasStack output); @@ -88,7 +88,7 @@ public interface MekanismRecipeHelper { /** * Add a Chemical Injection Chamber recipe. * - * @param input - input ItemStack + * @param input - input ItemStack * @param output - output ItemStack */ void addChemicalInjectionChamberRecipe(ItemStack input, Gas gas, ItemStack output); @@ -96,8 +96,8 @@ public interface MekanismRecipeHelper { /** * Add an Electrolytic Separator recipe. * - * @param fluid - FluidStack to electrolyze - * @param leftOutput - left gas to produce when the fluid is electrolyzed + * @param fluid - FluidStack to electrolyze + * @param leftOutput - left gas to produce when the fluid is electrolyzed * @param rightOutput - right gas to produce when the fluid is electrolyzed */ void addElectrolyticSeparatorRecipe(FluidStack fluid, double energy, GasStack leftOutput, GasStack rightOutput); @@ -105,17 +105,17 @@ public interface MekanismRecipeHelper { /** * Add a Precision Sawmill recipe. * - * @param input - input ItemStack - * @param primaryOutput - guaranteed output + * @param input - input ItemStack + * @param primaryOutput - guaranteed output * @param secondaryOutput - possible extra output - * @param chance - probability of obtaining extra output + * @param chance - probability of obtaining extra output */ void addPrecisionSawmillRecipe(ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, double chance); /** * Add a Precision Sawmill recipe with no chance output * - * @param input - input ItemStack + * @param input - input ItemStack * @param primaryOutput - guaranteed output */ void addPrecisionSawmillRecipe(ItemStack input, ItemStack primaryOutput); @@ -123,7 +123,7 @@ public interface MekanismRecipeHelper { /** * Add a Chemical Dissolution Chamber recipe. * - * @param input - input ItemStack + * @param input - input ItemStack * @param output - output GasStack */ void addChemicalDissolutionChamberRecipe(ItemStack input, GasStack output); @@ -131,7 +131,7 @@ public interface MekanismRecipeHelper { /** * Add a Chemical Washer recipe. * - * @param input - input GasStack + * @param input - input GasStack * @param output - output GasStack */ void addChemicalWasherRecipe(GasStack input, GasStack output); @@ -139,7 +139,7 @@ public interface MekanismRecipeHelper { /** * Add a Chemical Crystallizer recipe. * - * @param input - input GasStack + * @param input - input GasStack * @param output - output ItemStack */ void addChemicalCrystallizerRecipe(GasStack input, ItemStack output); @@ -147,13 +147,13 @@ public interface MekanismRecipeHelper { /** * Add a Pressurized Reaction Chamber recipe. * - * @param inputSolid - input ItemStack - * @param inputFluid - input FluidStack - * @param inputGas - input GasStack + * @param inputSolid - input ItemStack + * @param inputFluid - input FluidStack + * @param inputGas - input GasStack * @param outputSolid - output ItemStack - * @param outputGas - output GasStack + * @param outputGas - output GasStack * @param extraEnergy - extra energy needed by the recipe - * @param ticks - amount of ticks it takes for this recipe to complete + * @param ticks - amount of ticks it takes for this recipe to complete */ void addPRCRecipe(ItemStack inputSolid, FluidStack inputFluid, GasStack inputGas, ItemStack outputSolid, GasStack outputGas, double extraEnergy, int ticks); @@ -161,4 +161,4 @@ public interface MekanismRecipeHelper { void addThermalEvaporationRecipe(FluidStack inputFluid, FluidStack outputFluid); void addSolarNeutronRecipe(GasStack inputGas, GasStack outputGas); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/Pos3D.java b/src/main/java/mekanism/api/Pos3D.java index 86817ff57..58ff51afc 100644 --- a/src/main/java/mekanism/api/Pos3D.java +++ b/src/main/java/mekanism/api/Pos3D.java @@ -65,6 +65,7 @@ public class Pos3D extends Vec3d { * Returns a new Pos3D from a tag compound. * * @param tag - tag compound to read from + * * @return the Pos3D from the tag compound */ public static Pos3D read(NBTTagCompound tag) { @@ -75,6 +76,7 @@ public class Pos3D extends Vec3d { * Creates a new Pos3D from the motion of an entity. * * @param entity Entitiy to get the motion from + * * @return Pos3D representing the motion of the given entity */ public static Pos3D fromMotion(Entity entity) { @@ -85,7 +87,6 @@ public class Pos3D extends Vec3d { double x = translation.x * matrix[0] + translation.y * matrix[1] + translation.z * matrix[2] + matrix[3]; double y = translation.x * matrix[4] + translation.y * matrix[5] + translation.z * matrix[6] + matrix[7]; double z = translation.x * matrix[8] + translation.y * matrix[9] + translation.z * matrix[10] + matrix[11]; - return new Pos3D(x, y, z); } @@ -112,21 +113,21 @@ public class Pos3D extends Vec3d { * Writes this Pos3D's data to an NBTTagCompound. * * @param nbtTags - tag compound to write to + * * @return the tag compound with this Pos3D's data */ public NBTTagCompound write(NBTTagCompound nbtTags) { nbtTags.setDouble("x", x); nbtTags.setDouble("y", y); nbtTags.setDouble("z", z); - return nbtTags; } /** - * Creates and returns a Pos3D with values representing the difference between this and the Pos3D in the - * parameters. + * Creates and returns a Pos3D with values representing the difference between this and the Pos3D in the parameters. * * @param vec - Vec3 to subtract + * * @return difference of the two Pos3Ds */ public Pos3D diff(Vec3d vec) { @@ -137,6 +138,7 @@ public class Pos3D extends Vec3d { * Creates a new Coord4D representing this Pos3D in the provided dimension. * * @param dimensionId - the dimension this Pos3D is in + * * @return Coord4D representing this Pos3D */ public Coord4D getCoord(int dimensionId) { @@ -156,6 +158,7 @@ public class Pos3D extends Vec3d { * @param x - amount to translate on the x axis * @param y - amount to translate on the y axis * @param z - amount to translate on the z axis + * * @return the translated Pos3D */ public Pos3D translate(double x, double y, double z) { @@ -166,6 +169,7 @@ public class Pos3D extends Vec3d { * Performs the same operation as translate(x, y, z), but with a Pos3D value instead. * * @param pos - Pos3D value to translate by + * * @return translated Pos3D */ public Pos3D translate(Vec3d pos) { @@ -176,8 +180,7 @@ public class Pos3D extends Vec3d { * Performs the same operation as translate(x, y, z), but by a set amount in a EnumFacing */ public Pos3D translate(EnumFacing direction, double amount) { - return translate(direction.getDirectionVec().getX() * amount, direction.getDirectionVec().getY() * amount, - direction.getDirectionVec().getZ() * amount); + return translate(direction.getDirectionVec().getX() * amount, direction.getDirectionVec().getY() * amount, direction.getDirectionVec().getZ() * amount); } /** @@ -194,7 +197,6 @@ public class Pos3D extends Vec3d { if (direction.getAxis() != Axis.Z) { zPos += amount; } - return new Pos3D(xPos, yPos, zPos); } @@ -202,6 +204,7 @@ public class Pos3D extends Vec3d { * Returns the distance between this and the defined Pos3D. * * @param pos - the Pos3D to find the distance to + * * @return the distance between this and the defined Pos3D */ public double distance(Vec3d pos) { @@ -215,21 +218,19 @@ public class Pos3D extends Vec3d { * Rotates this Pos3D by the defined yaw value. * * @param yaw - yaw to rotate by + * * @return rotated Pos3D */ @Nonnull @Override public Pos3D rotateYaw(float yaw) { double yawRadians = Math.toRadians(yaw); - double xPos = x; double zPos = z; - if (yaw != 0) { xPos = x * Math.cos(yawRadians) - z * Math.sin(yawRadians); zPos = z * Math.cos(yawRadians) + x * Math.sin(yawRadians); } - return new Pos3D(xPos, y, zPos); } @@ -237,15 +238,12 @@ public class Pos3D extends Vec3d { @Override public Pos3D rotatePitch(float pitch) { double pitchRadians = Math.toRadians(pitch); - double yPos = y; double zPos = z; - if (pitch != 0) { yPos = y * Math.cos(pitchRadians) - z * Math.sin(pitchRadians); zPos = z * Math.cos(pitchRadians) + y * Math.sin(pitchRadians); } - return new Pos3D(x, yPos, zPos); } @@ -259,16 +257,12 @@ public class Pos3D extends Vec3d { double rollRadians = Math.toRadians(roll); double xPos = x * Math.cos(yawRadians) * Math.cos(pitchRadians) + z * ( - Math.cos(yawRadians) * Math.sin(pitchRadians) * Math.sin(rollRadians) - Math.sin(yawRadians) * Math - .cos(rollRadians)) + y * (Math.cos(yawRadians) * Math.sin(pitchRadians) * Math.cos(rollRadians) - + Math.sin(yawRadians) * Math.sin(rollRadians)); + Math.cos(yawRadians) * Math.sin(pitchRadians) * Math.sin(rollRadians) - Math.sin(yawRadians) * Math.cos(rollRadians)) + + y * (Math.cos(yawRadians) * Math.sin(pitchRadians) * Math.cos(rollRadians) + Math.sin(yawRadians) * Math.sin(rollRadians)); double zPos = x * Math.sin(yawRadians) * Math.cos(pitchRadians) + z * ( - Math.sin(yawRadians) * Math.sin(pitchRadians) * Math.sin(rollRadians) + Math.cos(yawRadians) * Math - .cos(rollRadians)) + y * (Math.sin(yawRadians) * Math.sin(pitchRadians) * Math.cos(rollRadians) - - Math.cos(yawRadians) * Math.sin(rollRadians)); - double yPos = -x * Math.sin(pitchRadians) + z * Math.cos(pitchRadians) * Math.sin(rollRadians) + y * Math - .cos(pitchRadians) * Math.cos(rollRadians); - + Math.sin(yawRadians) * Math.sin(pitchRadians) * Math.sin(rollRadians) + Math.cos(yawRadians) * Math.cos(rollRadians)) + + y * (Math.sin(yawRadians) * Math.sin(pitchRadians) * Math.cos(rollRadians) - Math.cos(yawRadians) * Math.sin(rollRadians)); + double yPos = -x * Math.sin(pitchRadians) + z * Math.cos(pitchRadians) * Math.sin(rollRadians) + y * Math.cos(pitchRadians) * Math.cos(rollRadians); return new Pos3D(xPos, yPos, zPos); } @@ -282,6 +276,7 @@ public class Pos3D extends Vec3d { * @param x - x value to scale by * @param y - y value to scale by * @param z - z value to scale by + * * @return scaled Pos3D */ public Pos3D scale(double x, double y, double z) { @@ -312,17 +307,16 @@ public class Pos3D extends Vec3d { float ocos = 1.0F - cos; float sin = (float) Math.sin(angle); - matrix[0] = (x * x * ocos + cos); - matrix[1] = (y * x * ocos + z * sin); - matrix[2] = (x * z * ocos - y * sin); - matrix[4] = (x * y * ocos - z * sin); - matrix[5] = (y * y * ocos + cos); - matrix[6] = (y * z * ocos + x * sin); - matrix[8] = (x * z * ocos + y * sin); - matrix[9] = (y * z * ocos - x * sin); - matrix[10] = (z * z * ocos + cos); + matrix[0] = x * x * ocos + cos; + matrix[1] = y * x * ocos + z * sin; + matrix[2] = x * z * ocos - y * sin; + matrix[4] = x * y * ocos - z * sin; + matrix[5] = y * y * ocos + cos; + matrix[6] = y * z * ocos + x * sin; + matrix[8] = x * z * ocos + y * sin; + matrix[9] = y * z * ocos - x * sin; + matrix[10] = z * z * ocos + cos; matrix[15] = 1.0F; - return matrix; } @@ -345,11 +339,7 @@ public class Pos3D extends Vec3d { } public Pos3D getPerpendicular() { - if (z == 0) { - return zCrossProduct(); - } - - return xCrossProduct(); + return z == 0 ? zCrossProduct() : xCrossProduct(); } public Pos3D floor() { @@ -369,10 +359,7 @@ public class Pos3D extends Vec3d { @Override public boolean equals(Object obj) { - return obj instanceof Vec3d && - ((Vec3d) obj).x == x && - ((Vec3d) obj).y == y && - ((Vec3d) obj).z == z; + return obj instanceof Vec3d && ((Vec3d) obj).x == x && ((Vec3d) obj).y == y && ((Vec3d) obj).z == z; } @Override @@ -383,4 +370,4 @@ public class Pos3D extends Vec3d { code = 31 * code + new Double(z).hashCode(); return code; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/Range4D.java b/src/main/java/mekanism/api/Range4D.java index f27c10cf1..350bfe457 100644 --- a/src/main/java/mekanism/api/Range4D.java +++ b/src/main/java/mekanism/api/Range4D.java @@ -8,7 +8,6 @@ import net.minecraftforge.fml.common.FMLCommonHandler; public class Range4D { public int dimensionId; - public int xMin; public int yMin; public int zMin; @@ -23,7 +22,6 @@ public class Range4D { xMax = maxX; yMax = maxY; zMax = maxZ; - dimensionId = dimension; } @@ -34,7 +32,6 @@ public class Range4D { xMax = xMin + 16; yMax = 255; zMax = zMin + 16; - dimensionId = chunk.dimensionId; } @@ -42,17 +39,14 @@ public class Range4D { xMin = coord.x; yMin = coord.y; zMin = coord.z; - xMax = coord.x + 1; yMax = coord.y + 1; zMax = coord.z + 1; - dimensionId = coord.dimensionId; } public static Range4D getChunkRange(EntityPlayer player) { int radius = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getViewDistance(); - return new Range4D(new Chunk3D(player)).expandChunks(radius); } @@ -61,7 +55,6 @@ public class Range4D { xMax += chunks * 16; zMin -= chunks * 16; zMax += chunks * 16; - return this; } @@ -70,26 +63,22 @@ public class Range4D { xMax += radius; zMin -= radius; zMax += radius; - return this; } public Set getIntersectingChunks() { Set set = new HashSet<>(); - for (int chunkX = xMin >> 4; chunkX <= xMax - 1 >> 4; chunkX++) { for (int chunkZ = zMin >> 4; chunkZ <= zMax - 1 >> 4; chunkZ++) { set.add(new Chunk3D(chunkX, chunkZ, dimensionId)); } } - return set; } public boolean intersects(Range4D range) { - return (xMax + 1 - 1.E-05D > range.xMin) && (range.xMax + 1 - 1.E-05D > xMin) && (yMax + 1 - 1.E-05D - > range.yMin) && (range.yMax + 1 - 1.E-05D > yMin) && (zMax + 1 - 1.E-05D > range.zMin) && ( - range.zMax + 1 - 1.E-05D > zMin); + return (xMax + 1 - 1.E-05D > range.xMin) && (range.xMax + 1 - 1.E-05D > xMin) && (yMax + 1 - 1.E-05D > range.yMin) && + (range.yMax + 1 - 1.E-05D > yMin) && (zMax + 1 - 1.E-05D > range.zMin) && (range.zMax + 1 - 1.E-05D > zMin); } @Override @@ -99,20 +88,19 @@ public class Range4D { @Override public String toString() { - return "[Range4D: " + xMin + ", " + yMin + ", " + zMin + ", " + xMax + ", " + yMax + ", " + zMax + ", dim=" - + dimensionId + "]"; + return "[Range4D: " + xMin + ", " + yMin + ", " + zMin + ", " + xMax + ", " + yMax + ", " + zMax + ", dim=" + dimensionId + "]"; } @Override public boolean equals(Object obj) { return obj instanceof Range4D && - ((Range4D) obj).xMin == xMin && - ((Range4D) obj).yMin == yMin && - ((Range4D) obj).zMin == zMin && - ((Range4D) obj).xMax == xMax && - ((Range4D) obj).yMax == yMax && - ((Range4D) obj).zMax == zMax && - ((Range4D) obj).dimensionId == dimensionId; + ((Range4D) obj).xMin == xMin && + ((Range4D) obj).yMin == yMin && + ((Range4D) obj).zMin == zMin && + ((Range4D) obj).xMax == xMax && + ((Range4D) obj).yMax == yMax && + ((Range4D) obj).zMax == zMax && + ((Range4D) obj).dimensionId == dimensionId; } @Override @@ -127,4 +115,4 @@ public class Range4D { code = 31 * code + dimensionId; return code; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/TileNetworkList.java b/src/main/java/mekanism/api/TileNetworkList.java index 7c1229c83..96f9a9205 100644 --- a/src/main/java/mekanism/api/TileNetworkList.java +++ b/src/main/java/mekanism/api/TileNetworkList.java @@ -21,4 +21,4 @@ public class TileNetworkList extends NonNullList { public static TileNetworkList withContents(@Nonnull Object... contents) { return new TileNetworkList(Arrays.asList(contents)); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/energy/EnergizedItemManager.java b/src/main/java/mekanism/api/energy/EnergizedItemManager.java index cd3c08b5e..799a5ea9b 100644 --- a/src/main/java/mekanism/api/energy/EnergizedItemManager.java +++ b/src/main/java/mekanism/api/energy/EnergizedItemManager.java @@ -8,25 +8,19 @@ public class EnergizedItemManager { * Discharges an IEnergizedItem with the defined amount of energy. * * @param itemStack - ItemStack to discharge - * @param amount - amount of energy to discharge from the item, usually the total amount of energy needed in a - * TileEntity + * @param amount - amount of energy to discharge from the item, usually the total amount of energy needed in a TileEntity + * * @return amount of energy discharged */ public static double discharge(ItemStack itemStack, double amount) { - if (!itemStack.isEmpty()) { - 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; - } + if (!itemStack.isEmpty() && 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; } @@ -34,25 +28,20 @@ public class EnergizedItemManager { * Charges an IEnergizedItem with the defined amount of energy. * * @param itemStack - ItemStack to charge - * @param amount - amount of energy to charge the item with, usually the total amount of energy stored in a - * TileEntity + * @param amount - amount of energy to charge the item with, usually the total amount of energy stored in a TileEntity + * * @return amount of energy charged */ public static double charge(ItemStack itemStack, double amount) { - if (!itemStack.isEmpty()) { - 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; - } + if (!itemStack.isEmpty() && 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; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/energy/EnergyStack.java b/src/main/java/mekanism/api/energy/EnergyStack.java index a7293c885..8167a29f4 100644 --- a/src/main/java/mekanism/api/energy/EnergyStack.java +++ b/src/main/java/mekanism/api/energy/EnergyStack.java @@ -10,4 +10,4 @@ public class EnergyStack { public EnergyStack(double newAmount) { amount = newAmount; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/energy/IEnergizedItem.java b/src/main/java/mekanism/api/energy/IEnergizedItem.java index 45fc1f60f..aa8a3ed8b 100644 --- a/src/main/java/mekanism/api/energy/IEnergizedItem.java +++ b/src/main/java/mekanism/api/energy/IEnergizedItem.java @@ -13,6 +13,7 @@ public interface IEnergizedItem { * Gets and returns the amount of energy stored in this item. * * @param itemStack - the ItemStack to check + * * @return energy stored */ double getEnergy(ItemStack itemStack); @@ -21,7 +22,7 @@ public interface IEnergizedItem { * 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 + * @param amount - new amount of energy */ void setEnergy(ItemStack itemStack, double amount); @@ -29,6 +30,7 @@ public interface IEnergizedItem { * Gets and returns this item's maximum amount of energy that can be stored. * * @param itemStack - the ItemStack to check + * * @return maximum energy */ double getMaxEnergy(ItemStack itemStack); @@ -37,6 +39,7 @@ public interface IEnergizedItem { * Gets and returns how much energy this item can transfer to and from charging slots. * * @param itemStack - the ItemStack to check + * * @return transfer amount */ double getMaxTransfer(ItemStack itemStack); @@ -45,6 +48,7 @@ public interface IEnergizedItem { * 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 */ boolean canReceive(ItemStack itemStack); @@ -53,7 +57,8 @@ public interface IEnergizedItem { * 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 */ boolean canSend(ItemStack itemStack); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/energy/IStrictEnergyAcceptor.java b/src/main/java/mekanism/api/energy/IStrictEnergyAcceptor.java index 585259eca..6cdbb2996 100644 --- a/src/main/java/mekanism/api/energy/IStrictEnergyAcceptor.java +++ b/src/main/java/mekanism/api/energy/IStrictEnergyAcceptor.java @@ -12,8 +12,9 @@ public interface IStrictEnergyAcceptor { /** * Transfer a certain amount of energy to this acceptor. * - * @param amount - amount to transfer + * @param amount - amount to transfer * @param simulate - if the operation should be simulated + * * @return energy used */ double acceptEnergy(EnumFacing side, double amount, boolean simulate); @@ -22,7 +23,8 @@ public interface IStrictEnergyAcceptor { * Whether or not this tile entity can accept energy from a certain side. * * @param side - side to check + * * @return if tile entity accepts energy */ boolean canReceiveEnergy(EnumFacing side); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/energy/IStrictEnergyOutputter.java b/src/main/java/mekanism/api/energy/IStrictEnergyOutputter.java index 1b823fc64..8b8d8ce79 100644 --- a/src/main/java/mekanism/api/energy/IStrictEnergyOutputter.java +++ b/src/main/java/mekanism/api/energy/IStrictEnergyOutputter.java @@ -12,8 +12,9 @@ public interface IStrictEnergyOutputter { /** * Pulls a certain amount of energy from this outputter. * - * @param amount - amount to pull + * @param amount - amount to pull * @param simulate - if the operation should be simulated + * * @return energy sent */ double pullEnergy(EnumFacing side, double amount, boolean simulate); @@ -22,7 +23,8 @@ public interface IStrictEnergyOutputter { * Whether or not this tile entity can output energy on a specific side. * * @param side - side to check + * * @return if the tile entity outputs energy */ boolean canOutputEnergy(EnumFacing side); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/energy/IStrictEnergyStorage.java b/src/main/java/mekanism/api/energy/IStrictEnergyStorage.java index 1d65576a1..e0dd756df 100644 --- a/src/main/java/mekanism/api/energy/IStrictEnergyStorage.java +++ b/src/main/java/mekanism/api/energy/IStrictEnergyStorage.java @@ -27,4 +27,4 @@ public interface IStrictEnergyStorage { * @return maximum energy */ double getMaxEnergy(); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/energy/package-info.java b/src/main/java/mekanism/api/energy/package-info.java index acd53e5b5..46ab4cb81 100644 --- a/src/main/java/mekanism/api/energy/package-info.java +++ b/src/main/java/mekanism/api/energy/package-info.java @@ -2,5 +2,4 @@ package mekanism.api.energy; import mekanism.api.MekanismAPI; -import net.minecraftforge.fml.common.API; - +import net.minecraftforge.fml.common.API; \ No newline at end of file diff --git a/src/main/java/mekanism/api/gas/Gas.java b/src/main/java/mekanism/api/gas/Gas.java index 549da3106..5be538c1e 100644 --- a/src/main/java/mekanism/api/gas/Gas.java +++ b/src/main/java/mekanism/api/gas/Gas.java @@ -72,6 +72,7 @@ public class Gas { * Returns the Gas stored in the defined tag compound. * * @param nbtTags - tag compound to get the Gas from + * * @return Gas stored in the tag compound */ public static Gas readFromNBT(NBTTagCompound nbtTags) { @@ -101,10 +102,11 @@ public class Gas { } /** - * 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. + * 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 + * * @return this Gas object */ public Gas setVisible(boolean v) { @@ -127,6 +129,7 @@ public class Gas { * DEPRECATED: Sets the unlocalized name of this Gas. Use setTranslationKey instead. * * @param s - unlocalized name to set + * * @return this Gas object */ @Deprecated @@ -147,6 +150,7 @@ public class Gas { * Sets the unlocalized name of this Gas. * * @param s - unlocalized name to set + * * @return this Gas object */ public Gas setTranslationKey(String s) { @@ -202,6 +206,7 @@ public class Gas { * Sets this gas's icon. * * @param map - IIcon to associate with this Gas + * * @return this Gas object */ public Gas registerIcon(TextureMap map) { @@ -234,6 +239,7 @@ public class Gas { * Writes this Gas to a defined tag compound. * * @param nbtTags - tag compound to write this Gas to + * * @return the tag compound this gas was written to */ public NBTTagCompound write(NBTTagCompound nbtTags) { @@ -315,4 +321,4 @@ public class Gas { public void setTint(int tint) { this.tint = tint; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/gas/GasRegistry.java b/src/main/java/mekanism/api/gas/GasRegistry.java index 64ee4e387..b61ce46c0 100644 --- a/src/main/java/mekanism/api/gas/GasRegistry.java +++ b/src/main/java/mekanism/api/gas/GasRegistry.java @@ -22,6 +22,7 @@ public class GasRegistry { * Register a new gas into GasRegistry. Call this BEFORE post-init. * * @param gas - Gas to register + * * @return the gas that has been registered, pulled right out of GasRegistry */ public static Gas register(Gas gas) { @@ -37,9 +38,7 @@ public class GasRegistry { } } } - registeredGasses.add(gas); - return getGas(gas.getName()); } @@ -47,6 +46,7 @@ public class GasRegistry { * Gets the gas associated with the defined ID. * * @param id - ID to check + * * @return gas associated with defined ID */ public static Gas getGas(int id) { @@ -61,6 +61,7 @@ public class GasRegistry { * Gets the gas associated with the defined fluid. * * @param f - fluid to check + * * @return the gas associated with the fluid */ public static Gas getGas(Fluid f) { @@ -77,6 +78,7 @@ public class GasRegistry { * Whether or not GasRegistry contains a gas with the specified name * * @param name - name to check + * * @return if GasRegistry contains a gas with the defined name */ public static boolean containsGas(String name) { @@ -96,15 +98,16 @@ public class GasRegistry { * Gets the gas associated with the specified name. * * @param name - name of the gas to get + * * @return gas associated with the name */ public static Gas getGas(String name) { + name = name.toLowerCase(Locale.ROOT); for (Gas gas : registeredGasses) { - if (gas.getName().toLowerCase(Locale.ROOT).equals(name.toLowerCase(Locale.ROOT))) { + if (gas.getName().toLowerCase(Locale.ROOT).equals(name)) { return gas; } } - return null; } @@ -112,17 +115,17 @@ public class GasRegistry { * Gets the gas ID of a specified gas. * * @param gas - gas to get the ID from + * * @return gas ID */ public static int getGasID(Gas gas) { if (gas == null || !containsGas(gas.getName())) { return -1; } - return registeredGasses.indexOf(gas); } private static boolean hasAlreadyStitched() { return Loader.instance().getLoaderState().ordinal() > LoaderState.PREINITIALIZATION.ordinal(); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/gas/GasStack.java b/src/main/java/mekanism/api/gas/GasStack.java index f5b73a03f..993ff6967 100644 --- a/src/main/java/mekanism/api/gas/GasStack.java +++ b/src/main/java/mekanism/api/gas/GasStack.java @@ -15,7 +15,7 @@ public class GasStack { /** * 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 + * @param id - gas ID to associate this GasStack to, will perform a GasRegistry lookup in the constructor * @param quantity - amount of gas to be referenced in this GasStack */ public GasStack(int id, int quantity) { @@ -26,7 +26,7 @@ public class GasStack { /** * Creates a new GasStack with a defined Gas type and quantity. * - * @param gas - gas type of the stack + * @param gas - gas type of the stack * @param quantity - amount of gas to be referenced in this GasStack */ public GasStack(Gas gas, int quantity) { @@ -41,6 +41,7 @@ public class GasStack { * Returns the GasStack stored in the defined tag compound, or null if it doesn't exist. * * @param nbtTags - tag compound to read from + * * @return GasStack stored in the tag compound */ public static GasStack readFromNBT(NBTTagCompound nbtTags) { @@ -77,6 +78,7 @@ public class GasStack { * Writes this GasStack to a defined tag compound. * * @param nbtTags - tag compound to write to + * * @return tag compound with this GasStack's data */ public NBTTagCompound write(NBTTagCompound nbtTags) { @@ -109,6 +111,7 @@ public class GasStack { * Whether or not this GasStack's gas type is equal to the other defined GasStack. * * @param stack - GasStack to check + * * @return if the GasStacks contain the same gas type */ public boolean isGasEqual(GasStack stack) { @@ -124,4 +127,4 @@ public class GasStack { public int hashCode() { return type == null ? 0 : type.getID(); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/gas/GasTank.java b/src/main/java/mekanism/api/gas/GasTank.java index 9b8ce297e..3e39defda 100644 --- a/src/main/java/mekanism/api/gas/GasTank.java +++ b/src/main/java/mekanism/api/gas/GasTank.java @@ -29,6 +29,7 @@ public class GasTank implements GasTankInfo { * Returns the tank stored in the defined tag compound, or null if it doesn't exist. * * @param nbtTags - tag compound to read from + * * @return tank stored in the tag compound */ public static GasTank readFromNBT(NBTTagCompound nbtTags) { @@ -38,7 +39,6 @@ public class GasTank implements GasTankInfo { GasTank tank = new GasTank(); tank.read(nbtTags); - return tank; } @@ -47,6 +47,7 @@ public class GasTank implements GasTankInfo { * * @param amount - amount to draw * @param doDraw - if the gas should actually be removed from this tank + * * @return gas taken from this GasTank as a GasStack value */ public GasStack draw(int amount, boolean doDraw) { @@ -55,27 +56,24 @@ public class GasTank implements GasTankInfo { } GasStack ret = new GasStack(stored.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 + * @param amount - the GasStack for this tank to receive * @param doReceive - if the gas should actually be added to this tank + * * @return the amount of gas accepted by this tank */ public int receive(GasStack amount, boolean doReceive) { @@ -100,27 +98,29 @@ public class GasTank implements GasTankInfo { * 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 + * * @return if this GasTank can accept the defined gas */ public boolean canReceive(Gas gas) { - return getNeeded() != 0 && (stored == null || (gas == null || gas == stored.getGas())); + return getNeeded() != 0 && (stored == null || gas == null || gas == stored.getGas()); } /** * 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 + * * @return if this GasTank can accept the defined gas */ public boolean canReceiveType(Gas gas) { - return stored == null || (gas == null || gas == stored.getGas()); + return stored == null || gas == null || gas == stored.getGas(); } /** - * If this GasTank can be drawn of the specified type of gas. Will return false if this tank does not contain any - * gas. + * 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 + * * @return if this GasTank can be drawn of the defined gas */ public boolean canDraw(Gas gas) { @@ -168,7 +168,6 @@ public class GasTank implements GasTankInfo { */ public void setGas(GasStack stack) { stored = stack; - if (stored != null) { stored.amount = Math.min(getMaxGas(), stored.amount); if (stored.amount <= 0) { @@ -199,15 +198,14 @@ public class GasTank implements GasTankInfo { * Writes this tank to a defined tag compound. * * @param nbtTags - tag compound to write to + * * @return tag compound with this tank's data */ public NBTTagCompound write(NBTTagCompound nbtTags) { if (stored != null && stored.getGas() != null && stored.amount > 0) { nbtTags.setTag("stored", stored.write(new NBTTagCompound())); } - nbtTags.setInteger("maxGas", maxGas); - return nbtTags; } @@ -224,9 +222,8 @@ public class GasTank implements GasTankInfo { stored = null; } } - if (nbtTags.hasKey("maxGas") && nbtTags.getInteger("maxGas") != 0) { maxGas = nbtTags.getInteger("maxGas"); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/gas/GasTankInfo.java b/src/main/java/mekanism/api/gas/GasTankInfo.java index cd38eb1a2..d7774f00b 100644 --- a/src/main/java/mekanism/api/gas/GasTankInfo.java +++ b/src/main/java/mekanism/api/gas/GasTankInfo.java @@ -28,4 +28,4 @@ public interface GasTankInfo { * @return - max gas */ int getMaxGas(); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/gas/IGasHandler.java b/src/main/java/mekanism/api/gas/IGasHandler.java index d557b344f..21d400c96 100644 --- a/src/main/java/mekanism/api/gas/IGasHandler.java +++ b/src/main/java/mekanism/api/gas/IGasHandler.java @@ -16,6 +16,7 @@ public interface IGasHandler { * Transfer a certain amount of gas to this block. * * @param stack - gas to add + * * @return gas added */ int receiveGas(EnumFacing side, GasStack stack, boolean doTransfer); @@ -24,6 +25,7 @@ public interface IGasHandler { * Draws a certain amount of gas from this block. * * @param amount - amount to draw + * * @return gas drawn */ GasStack drawGas(EnumFacing side, int amount, boolean doTransfer); @@ -33,6 +35,7 @@ public interface IGasHandler { * * @param side - side to check * @param type - type of gas to check + * * @return if block accepts gas */ boolean canReceiveGas(EnumFacing side, Gas type); @@ -42,6 +45,7 @@ public interface IGasHandler { * * @param side - side to check * @param type - type of gas to check + * * @return if block can be drawn of gas */ boolean canDrawGas(EnumFacing side, Gas type); @@ -55,4 +59,4 @@ public interface IGasHandler { default GasTankInfo[] getTankInfo() { return NONE; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/gas/IGasItem.java b/src/main/java/mekanism/api/gas/IGasItem.java index 090bfaa04..4798eab58 100644 --- a/src/main/java/mekanism/api/gas/IGasItem.java +++ b/src/main/java/mekanism/api/gas/IGasItem.java @@ -20,7 +20,8 @@ public interface IGasItem { * Adds a defined amount of a certain gas to an item. * * @param itemstack - the itemstack to add gas to - * @param stack - the type and amount of gas to add + * @param stack - the type and amount of gas to add + * * @return the gas that was accepted by the item */ int addGas(ItemStack itemstack, GasStack stack); @@ -29,7 +30,8 @@ public interface IGasItem { * Removes the defined amount of a certain gas from the item. * * @param itemstack - the itemstack to remove gas from - * @param amount - the amount of gas to remove + * @param amount - the amount of gas to remove + * * @return the gas that was removed by the item */ GasStack removeGas(ItemStack itemstack, int amount); @@ -38,7 +40,8 @@ public interface IGasItem { * Whether or not this storage tank be given a specific gas. * * @param itemstack - the itemstack to check - * @param type - the type of gas the tank can possibly receive + * @param type - the type of gas the tank can possibly receive + * * @return if the item be charged */ boolean canReceiveGas(ItemStack itemstack, Gas type); @@ -47,7 +50,8 @@ public interface IGasItem { * Whether or not this item can give a gas receiver a certain type of gas. * * @param itemstack - the itemstack to check - * @param type - the type of gas the tank can provide + * @param type - the type of gas the tank can provide + * * @return if the item can provide gas */ boolean canProvideGas(ItemStack itemstack, Gas type); @@ -56,6 +60,7 @@ public interface IGasItem { * Get the gas of a declared type. * * @param itemstack - ItemStack parameter + * * @return gas stored */ GasStack getGas(ItemStack itemstack); @@ -64,7 +69,7 @@ public interface IGasItem { * Set the gas of a declared type to a new amount; * * @param itemstack - ItemStack parameter - * @param stack - the type and amount of gas to add + * @param stack - the type and amount of gas to add */ void setGas(ItemStack itemstack, GasStack stack); @@ -72,7 +77,8 @@ public interface IGasItem { * Gets the maximum amount of gas this tile entity can store. * * @param itemstack - ItemStack parameter + * * @return maximum gas */ int getMaxGas(ItemStack itemstack); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/gas/ITubeConnection.java b/src/main/java/mekanism/api/gas/ITubeConnection.java index dbd2bd70f..06d1aa1c7 100644 --- a/src/main/java/mekanism/api/gas/ITubeConnection.java +++ b/src/main/java/mekanism/api/gas/ITubeConnection.java @@ -6,8 +6,7 @@ import net.minecraft.util.EnumFacing; * Implement this if your block can connect to Pressurized Tubes. * * @author AidanBrady - * @deprecated Dropped in favor of better support for machines of what implements GAS_HANDLER_CAPABILITY use {@link - * IGasHandler} instead. + * @deprecated Dropped in favor of better support for machines of what implements GAS_HANDLER_CAPABILITY use {@link IGasHandler} instead. */ @Deprecated public interface ITubeConnection { @@ -16,7 +15,8 @@ public interface ITubeConnection { * Whether or not a tube can connect to a certain orientation. * * @param side - orientation to check + * * @return if a tube can connect */ boolean canTubeConnect(EnumFacing side); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/gas/package-info.java b/src/main/java/mekanism/api/gas/package-info.java index 2a162b794..0238adbcc 100644 --- a/src/main/java/mekanism/api/gas/package-info.java +++ b/src/main/java/mekanism/api/gas/package-info.java @@ -2,5 +2,4 @@ package mekanism.api.gas; import mekanism.api.MekanismAPI; -import net.minecraftforge.fml.common.API; - +import net.minecraftforge.fml.common.API; \ No newline at end of file diff --git a/src/main/java/mekanism/api/infuse/InfuseObject.java b/src/main/java/mekanism/api/infuse/InfuseObject.java index 6ccdc6ab8..0f79881f8 100644 --- a/src/main/java/mekanism/api/infuse/InfuseObject.java +++ b/src/main/java/mekanism/api/infuse/InfuseObject.java @@ -21,4 +21,4 @@ public class InfuseObject { type = infusion; stored = i; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/infuse/InfuseRegistry.java b/src/main/java/mekanism/api/infuse/InfuseRegistry.java index aa39ffe8c..6202abb82 100644 --- a/src/main/java/mekanism/api/infuse/InfuseRegistry.java +++ b/src/main/java/mekanism/api/infuse/InfuseRegistry.java @@ -30,7 +30,6 @@ public class InfuseRegistry { if (infuseTypes.containsKey(infuse.name)) { return; } - infuseTypes.put(infuse.name, infuse); } @@ -38,13 +37,13 @@ public class InfuseRegistry { * Gets an InfuseType from it's name, or null if it doesn't exist. * * @param name - the name of the InfuseType to get + * * @return the name's corresponding InfuseType */ public static InfuseType get(String name) { if (name.equals("null")) { return null; } - return infuseTypes.get(name); } @@ -52,6 +51,7 @@ public class InfuseRegistry { * Whether or not the registry contains a correspondent InfuseType to a name. * * @param name - the name to check + * * @return if the name has a coorespondent InfuseType */ public static boolean contains(String name) { @@ -59,19 +59,17 @@ public class InfuseRegistry { } /** - * 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 it is placed in the Metallurgic Infuser's infuse slot, and the machine can accept the - * type and amount of infuse stored in the object. + * 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 it is placed in the Metallurgic Infuser's infuse slot, and the machine can + * accept the type and amount of infuse stored in the object. * - * @param itemStack - stack the infuse object is linked to -- stack size is ignored + * @param itemStack - stack the infuse object is linked to -- stack size is ignored * @param infuseObject - the infuse object with the type and amount data */ public static void registerInfuseObject(ItemStack itemStack, InfuseObject infuseObject) { if (getObject(itemStack) != null) { return; } - infuseObjects.put(itemStack, infuseObject); } @@ -79,6 +77,7 @@ public class InfuseRegistry { * Gets the InfuseObject data from an ItemStack. * * @param itemStack - the ItemStack to check + * * @return the ItemStack's InfuseObject */ public static InfuseObject getObject(ItemStack itemStack) { @@ -87,7 +86,6 @@ public class InfuseRegistry { return obj.getValue(); } } - return null; } @@ -108,4 +106,4 @@ public class InfuseRegistry { public static Map getInfuseMap() { return infuseTypes; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/infuse/InfuseType.java b/src/main/java/mekanism/api/infuse/InfuseType.java index da8a220ae..c7e146852 100644 --- a/src/main/java/mekanism/api/infuse/InfuseType.java +++ b/src/main/java/mekanism/api/infuse/InfuseType.java @@ -47,11 +47,10 @@ public final class InfuseType { public InfuseType setTranslationKey(String name) { unlocalizedName = "infuse." + name; - return this; } public String getLocalizedName() { return I18n.translateToLocal(unlocalizedName); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/infuse/package-info.java b/src/main/java/mekanism/api/infuse/package-info.java index 04e996cec..accf74c8f 100644 --- a/src/main/java/mekanism/api/infuse/package-info.java +++ b/src/main/java/mekanism/api/infuse/package-info.java @@ -2,5 +2,4 @@ package mekanism.api.infuse; import mekanism.api.MekanismAPI; -import net.minecraftforge.fml.common.API; - +import net.minecraftforge.fml.common.API; \ No newline at end of file diff --git a/src/main/java/mekanism/api/lasers/ILaserReceptor.java b/src/main/java/mekanism/api/lasers/ILaserReceptor.java index 1f7199d6b..32717239a 100644 --- a/src/main/java/mekanism/api/lasers/ILaserReceptor.java +++ b/src/main/java/mekanism/api/lasers/ILaserReceptor.java @@ -7,4 +7,4 @@ public interface ILaserReceptor { void receiveLaserEnergy(double energy, EnumFacing side); boolean canLasersDig(); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/package-info.java b/src/main/java/mekanism/api/package-info.java index e3616d2c8..cb4538ad4 100644 --- a/src/main/java/mekanism/api/package-info.java +++ b/src/main/java/mekanism/api/package-info.java @@ -1,5 +1,4 @@ @API(apiVersion = MekanismAPI.API_VERSION, owner = "mekanism", provides = "MekanismAPI|core") package mekanism.api; -import net.minecraftforge.fml.common.API; - +import net.minecraftforge.fml.common.API; \ No newline at end of file diff --git a/src/main/java/mekanism/api/transmitters/DynamicNetwork.java b/src/main/java/mekanism/api/transmitters/DynamicNetwork.java index 9bc931d60..df2c06ce5 100644 --- a/src/main/java/mekanism/api/transmitters/DynamicNetwork.java +++ b/src/main/java/mekanism/api/transmitters/DynamicNetwork.java @@ -1,8 +1,6 @@ package mekanism.api.transmitters; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.EnumSet; @@ -26,17 +24,15 @@ import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.eventhandler.Event; import org.apache.commons.lang3.tuple.Pair; -public abstract class DynamicNetwork, BUFFER> implements - IClientTicker, INetworkDataHandler { +public abstract class DynamicNetwork, BUFFER> implements IClientTicker, INetworkDataHandler { - protected Set> transmitters = Sets.newLinkedHashSet(); - protected Set> transmittersToAdd = Sets.newLinkedHashSet(); - protected Set> transmittersAdded = Sets.newLinkedHashSet(); + protected Set> transmitters = new HashSet<>(); + protected Set> transmittersToAdd = new HashSet<>(); + protected Set> transmittersAdded = new HashSet<>(); protected Set possibleAcceptors = new HashSet<>(); protected Map> acceptorDirections = new HashMap<>(); - protected Map, EnumSet> changedAcceptors = Maps - .newHashMap(); + protected Map, EnumSet> changedAcceptors = new HashMap<>(); protected Range4D packetRange = null; protected int capacity = 0; protected double meanCapacity = 0; @@ -70,13 +66,12 @@ public abstract class DynamicNetwork(transmittersToAdd)); transmittersToAdd.clear(); } if (!changedAcceptors.isEmpty()) { - for (Entry, EnumSet> entry : changedAcceptors - .entrySet()) { + for (Entry, EnumSet> entry : changedAcceptors.entrySet()) { IGridTransmitter transmitter = entry.getKey(); if (transmitter.isValid()) { @@ -87,7 +82,6 @@ public abstract class DynamicNetwork transmitter, EnumFacing side) { EnumSet directions = changedAcceptors.get(transmitter); - if (directions != null) { directions.add(side); } else { @@ -179,26 +168,22 @@ public abstract class DynamicNetwork> entry : net.acceptorDirections.entrySet()) { Coord4D coord = entry.getKey(); - if (acceptorDirections.containsKey(coord)) { acceptorDirections.get(coord).addAll(entry.getValue()); } else { acceptorDirections.put(coord, entry.getValue()); } } - } public Range4D getPacketRange() { if (packetRange == null) { return genPacketRange(); } - return packetRange; } @@ -240,7 +225,6 @@ public abstract class DynamicNetwork 0) { @@ -316,7 +299,6 @@ public abstract class DynamicNetwork 0) { q.delay--; } else { @@ -330,10 +312,8 @@ public abstract class DynamicNetwork 0) { updateDelay--; - if (updateDelay == 0) { - MinecraftForge.EVENT_BUS - .post(new TransmittersAddedEvent(this, firstUpdate, (Collection) transmittersAdded)); + MinecraftForge.EVENT_BUS.post(new TransmittersAddedEvent(this, firstUpdate, (Collection) transmittersAdded)); firstUpdate = false; transmittersAdded.clear(); needsUpdate = true; @@ -465,4 +445,4 @@ public abstract class DynamicNetwork other){ + default boolean isCompatibleWith(IGridTransmitter other) { return true; } /** - * Gets called on an orphan if at least one attempted network fails to connect - * due to having connected to another network that is incompatible with the - * next attempted ones. + * Gets called on an orphan if at least one attempted network fails to connect due to having connected to another network that is incompatible with the next attempted + * ones. * - * This is primarily used for if extra handling needs to be done, such as - * refreshing the connections visually on a minor delay so that it has - * time to have the buffer no longer be null and properly compare the - * connection. + * This is primarily used for if extra handling needs to be done, such as refreshing the connections visually on a minor delay so that it has time to have the buffer + * no longer be null and properly compare the connection. */ default void connectionFailed() { } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/transmitters/INetworkDataHandler.java b/src/main/java/mekanism/api/transmitters/INetworkDataHandler.java index 157e7e42e..4b05eb489 100644 --- a/src/main/java/mekanism/api/transmitters/INetworkDataHandler.java +++ b/src/main/java/mekanism/api/transmitters/INetworkDataHandler.java @@ -7,4 +7,4 @@ public interface INetworkDataHandler { String getStoredInfo(); String getFlowInfo(); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/transmitters/ITransmitter.java b/src/main/java/mekanism/api/transmitters/ITransmitter.java index 3503edde0..3b6c2f31e 100644 --- a/src/main/java/mekanism/api/transmitters/ITransmitter.java +++ b/src/main/java/mekanism/api/transmitters/ITransmitter.java @@ -8,4 +8,4 @@ public interface ITransmitter { * @return TransmissionType this transmitter uses */ TransmissionType getTransmissionType(); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/transmitters/TransmissionType.java b/src/main/java/mekanism/api/transmitters/TransmissionType.java index 04ab270b5..528c876a8 100644 --- a/src/main/java/mekanism/api/transmitters/TransmissionType.java +++ b/src/main/java/mekanism/api/transmitters/TransmissionType.java @@ -51,10 +51,6 @@ public enum TransmissionType { } public boolean checkTransmissionType(TileEntity sideTile, TileEntity currentTile) { - if (sideTile instanceof ITransmitter) { - return ((ITransmitter) sideTile).getTransmissionType() == this; - } - - return false; + return sideTile instanceof ITransmitter && ((ITransmitter) sideTile).getTransmissionType() == this; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/transmitters/TransmitterNetworkRegistry.java b/src/main/java/mekanism/api/transmitters/TransmitterNetworkRegistry.java index 77e7927eb..b9a19731a 100644 --- a/src/main/java/mekanism/api/transmitters/TransmitterNetworkRegistry.java +++ b/src/main/java/mekanism/api/transmitters/TransmitterNetworkRegistry.java @@ -1,11 +1,11 @@ package mekanism.api.transmitters; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; import java.util.Deque; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; +import java.util.Map; +import java.util.Set; import mekanism.api.Coord4D; import mekanism.api.MekanismAPI; import net.minecraft.util.EnumFacing; @@ -22,16 +22,15 @@ public class TransmitterNetworkRegistry { private static TransmitterNetworkRegistry INSTANCE = new TransmitterNetworkRegistry(); private static boolean loaderRegistered = false; private static Logger logger = LogManager.getLogger("MekanismTransmitters"); - private HashSet networks = Sets.newHashSet(); - private HashSet networksToChange = Sets.newHashSet(); - private HashSet invalidTransmitters = Sets.newHashSet(); - private HashMap orphanTransmitters = Maps.newHashMap(); - private HashMap newOrphanTransmitters = Maps.newHashMap(); + private Set networks = new HashSet<>(); + private Set networksToChange = new HashSet<>(); + private Set invalidTransmitters = new HashSet<>(); + private Map orphanTransmitters = new HashMap<>(); + private Map newOrphanTransmitters = new HashMap<>(); public static void initiate() { if (!loaderRegistered) { loaderRegistered = true; - MinecraftForge.EVENT_BUS.register(INSTANCE); } } @@ -82,11 +81,8 @@ public class TransmitterNetworkRegistry { public void tickEnd() { removeInvalidTransmitters(); - assignOrphans(); - commitChanges(); - for (DynamicNetwork net : networks) { net.tick(); } @@ -100,7 +96,6 @@ public class TransmitterNetworkRegistry { for (IGridTransmitter invalid : invalidTransmitters) { if (!(invalid.isOrphan() && invalid.isValid())) { DynamicNetwork n = invalid.getTransmitterNetwork(); - if (n != null) { n.invalidate(); } @@ -118,9 +113,8 @@ public class TransmitterNetworkRegistry { logger.info("Dealing with " + orphanTransmitters.size() + " orphan Transmitters"); } - for (IGridTransmitter orphanTransmitter : (new HashMap<>(orphanTransmitters)).values()) { + for (IGridTransmitter orphanTransmitter : new HashMap<>(orphanTransmitters).values()) { DynamicNetwork network = getNetworkFromOrphan(orphanTransmitter); - if (network != null) { networksToChange.add(network); network.register(); @@ -130,8 +124,7 @@ public class TransmitterNetworkRegistry { orphanTransmitters.clear(); } - public , BUFFER> DynamicNetwork getNetworkFromOrphan( - IGridTransmitter startOrphan) { + public , BUFFER> DynamicNetwork getNetworkFromOrphan(IGridTransmitter startOrphan) { if (startOrphan.isValid() && startOrphan.isOrphan()) { OrphanPathFinder finder = new OrphanPathFinder<>(startOrphan); finder.start(); @@ -140,28 +133,20 @@ public class TransmitterNetworkRegistry { switch (finder.networksFound.size()) { case 0: if (MekanismAPI.debug) { - logger.info("No networks found. Creating new network for " + finder.connectedTransmitters.size() - + " transmitters"); + logger.info("No networks found. Creating new network for " + finder.connectedTransmitters.size() + " transmitters"); } - network = startOrphan.createEmptyNetwork(); - break; case 1: if (MekanismAPI.debug) { - logger.info("Adding " + finder.connectedTransmitters.size() - + " transmitters to single found network"); + logger.info("Adding " + finder.connectedTransmitters.size() + " transmitters to single found network"); } - network = finder.networksFound.iterator().next(); - break; default: if (MekanismAPI.debug) { - logger.info("Merging " + finder.networksFound.size() + " networks with " - + finder.connectedTransmitters.size() + " new transmitters"); + logger.info("Merging " + finder.networksFound.size() + " networks with " + finder.connectedTransmitters.size() + " new transmitters"); } - network = startOrphan.mergeNetworks(finder.networksFound); } @@ -173,10 +158,8 @@ public class TransmitterNetworkRegistry { // so that it can refresh the connections startOrphan.connectionFailed(); } - return network; } - return null; } @@ -184,7 +167,6 @@ public class TransmitterNetworkRegistry { for (DynamicNetwork network : networksToChange) { network.commit(); } - networksToChange.clear(); } @@ -200,7 +182,6 @@ public class TransmitterNetworkRegistry { for (DynamicNetwork network : networks) { strings[i++] = network.toString(); } - return strings; } @@ -208,10 +189,10 @@ public class TransmitterNetworkRegistry { public IGridTransmitter startPoint; - public HashSet iterated = Sets.newHashSet(); + public HashSet iterated = new HashSet<>(); - public HashSet> connectedTransmitters = Sets.newHashSet(); - public HashSet networksFound = Sets.newHashSet(); + public HashSet> connectedTransmitters = new HashSet<>(); + public HashSet networksFound = new HashSet<>(); private Deque queue = new LinkedList<>(); @@ -242,8 +223,8 @@ public class TransmitterNetworkRegistry { if (orphanTransmitters.containsKey(from)) { IGridTransmitter transmitter = orphanTransmitters.get(from); - if (transmitter.isValid() && transmitter.isOrphan() && (connectedTransmitters.isEmpty() - || connectedTransmitters.stream().anyMatch(existing -> existing.isCompatibleWith(transmitter)))) { + if (transmitter.isValid() && transmitter.isOrphan() && + (connectedTransmitters.isEmpty() || connectedTransmitters.stream().anyMatch(existing -> existing.isCompatibleWith(transmitter)))) { connectedTransmitters.add(transmitter); transmitter.setOrphan(false); @@ -253,7 +234,6 @@ public class TransmitterNetworkRegistry { continue; } Coord4D directionCoord = transmitter.getAdjacentConnectableTransmitterCoord(direction); - if (directionCoord != null && !iterated.contains(directionCoord)) { queue.addLast(directionCoord); } @@ -278,4 +258,4 @@ public class TransmitterNetworkRegistry { } } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/transmitters/package-info.java b/src/main/java/mekanism/api/transmitters/package-info.java index 76788ca45..18ec72601 100644 --- a/src/main/java/mekanism/api/transmitters/package-info.java +++ b/src/main/java/mekanism/api/transmitters/package-info.java @@ -2,5 +2,4 @@ package mekanism.api.transmitters; import mekanism.api.MekanismAPI; -import net.minecraftforge.fml.common.API; - +import net.minecraftforge.fml.common.API; \ No newline at end of file diff --git a/src/main/java/mekanism/api/util/BlockInfo.java b/src/main/java/mekanism/api/util/BlockInfo.java index 01e11787d..6d89ee12b 100644 --- a/src/main/java/mekanism/api/util/BlockInfo.java +++ b/src/main/java/mekanism/api/util/BlockInfo.java @@ -20,9 +20,7 @@ public class BlockInfo { @Override public boolean equals(Object obj) { - return obj instanceof BlockInfo && - ((BlockInfo) obj).block == block && - ((BlockInfo) obj).meta == meta; + return obj instanceof BlockInfo && ((BlockInfo) obj).block == block && ((BlockInfo) obj).meta == meta; } @Override diff --git a/src/main/java/mekanism/api/util/ItemInfo.java b/src/main/java/mekanism/api/util/ItemInfo.java index c30bad3d7..d05e231a7 100644 --- a/src/main/java/mekanism/api/util/ItemInfo.java +++ b/src/main/java/mekanism/api/util/ItemInfo.java @@ -19,9 +19,7 @@ public class ItemInfo { @Override public boolean equals(Object obj) { - return obj instanceof ItemInfo && - ((ItemInfo) obj).item == item && - ((ItemInfo) obj).meta == meta; + return obj instanceof ItemInfo && ((ItemInfo) obj).item == item && ((ItemInfo) obj).meta == meta; } @Override @@ -31,4 +29,4 @@ public class ItemInfo { code = 7 * code + meta; return code; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/api/util/package-info.java b/src/main/java/mekanism/api/util/package-info.java index b5f886c11..fd25d9d24 100644 --- a/src/main/java/mekanism/api/util/package-info.java +++ b/src/main/java/mekanism/api/util/package-info.java @@ -1,5 +1,4 @@ @API(apiVersion = "9.0.0", owner = "mekanism", provides = "MekanismAPI|util") package mekanism.api.util; -import net.minecraftforge.fml.common.API; - +import net.minecraftforge.fml.common.API; \ No newline at end of file diff --git a/src/main/java/mekanism/client/ApiJarPresentException.java b/src/main/java/mekanism/client/ApiJarPresentException.java index 1e1ef6afb..aac3a90f8 100644 --- a/src/main/java/mekanism/client/ApiJarPresentException.java +++ b/src/main/java/mekanism/client/ApiJarPresentException.java @@ -13,8 +13,8 @@ public class ApiJarPresentException extends CustomModLoadingErrorDisplayExceptio private static final long serialVersionUID = 1L; - private final @Nonnull - String[] msgs; + @Nonnull + private final String[] msgs; public ApiJarPresentException(@Nonnull String[] msgs) { super(msgs[0], new RuntimeException()); @@ -26,8 +26,7 @@ public class ApiJarPresentException extends CustomModLoadingErrorDisplayExceptio } @Override - public void drawScreen(@Nullable GuiErrorScreen errorScreen, @Nullable FontRenderer fontRenderer, int mouseRelX, - int mouseRelY, float tickTime) { + public void drawScreen(@Nullable GuiErrorScreen errorScreen, @Nullable FontRenderer fontRenderer, int mouseRelX, int mouseRelY, float tickTime) { if (errorScreen == null || fontRenderer == null) { return; } @@ -41,4 +40,4 @@ public class ApiJarPresentException extends CustomModLoadingErrorDisplayExceptio } } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/ClientConnectionHandler.java b/src/main/java/mekanism/client/ClientConnectionHandler.java index b3d6b2032..125ab6a24 100644 --- a/src/main/java/mekanism/client/ClientConnectionHandler.java +++ b/src/main/java/mekanism/client/ClientConnectionHandler.java @@ -27,8 +27,7 @@ public class ClientConnectionHandler { } else { // If the client is connecting to a foreign integrated or dedicated server. try { - MekanismClient.voiceClient = new VoiceClient( - ((InetSocketAddress) event.getManager().getRemoteAddress()).getHostString()); + MekanismClient.voiceClient = new VoiceClient(((InetSocketAddress) event.getManager().getRemoteAddress()).getHostString()); } catch (Throwable e) { Mekanism.logger.error("Unable to establish VoiceClient on remote connection.", e); } diff --git a/src/main/java/mekanism/client/ClientPlayerTracker.java b/src/main/java/mekanism/client/ClientPlayerTracker.java index 2a42b9b5c..3edc57edd 100644 --- a/src/main/java/mekanism/client/ClientPlayerTracker.java +++ b/src/main/java/mekanism/client/ClientPlayerTracker.java @@ -14,4 +14,4 @@ public class ClientPlayerTracker { Mekanism.playerState.clearPlayer(event.player); Mekanism.freeRunnerOn.remove(event.player.getUniqueID()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/ClientProxy.java b/src/main/java/mekanism/client/ClientProxy.java index a4990e764..ca40ec276 100644 --- a/src/main/java/mekanism/client/ClientProxy.java +++ b/src/main/java/mekanism/client/ClientProxy.java @@ -263,31 +263,24 @@ public class ClientProxy extends CommonProxy { @Override public void loadConfiguration() { super.loadConfiguration(); - MekanismConfig.current().client.load(Mekanism.configuration); - if (Mekanism.configuration.hasChanged()) { Mekanism.configuration.save(); } } @Override - public void openPersonalChest(EntityPlayer entityplayer, int id, int windowId, boolean isBlock, BlockPos pos, - EnumHand hand) { - TileEntityPersonalChest tileEntity = (TileEntityPersonalChest) entityplayer.world.getTileEntity(pos); - + public void openPersonalChest(EntityPlayer entityplayer, int id, int windowId, boolean isBlock, BlockPos pos, EnumHand hand) { if (id == 0) { if (isBlock) { - FMLClientHandler.instance() - .displayGuiScreen(entityplayer, new GuiPersonalChest(entityplayer.inventory, tileEntity)); + TileEntityPersonalChest tileEntity = (TileEntityPersonalChest) entityplayer.world.getTileEntity(pos); + FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiPersonalChest(entityplayer.inventory, tileEntity)); entityplayer.openContainer.windowId = windowId; } else { ItemStack stack = entityplayer.getHeldItem(hand); - if (MachineType.get(stack) == MachineType.PERSONAL_CHEST) { InventoryPersonalChest inventory = new InventoryPersonalChest(stack, hand); - FMLClientHandler.instance() - .displayGuiScreen(entityplayer, new GuiPersonalChest(entityplayer.inventory, inventory)); + FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiPersonalChest(entityplayer.inventory, inventory)); entityplayer.openContainer.windowId = windowId; } } @@ -296,63 +289,45 @@ public class ClientProxy extends CommonProxy { @Override public void registerTESRs() { - ClientRegistry - .bindTileEntitySpecialRenderer(TileEntityAdvancedFactory.class, new RenderConfigurableMachine<>()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityAdvancedFactory.class, new RenderConfigurableMachine<>()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBin.class, new RenderBin()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBoilerCasing.class, new RenderThermoelectricBoiler()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBoilerValve.class, new RenderThermoelectricBoiler()); - ClientRegistry - .bindTileEntitySpecialRenderer(TileEntityChemicalCrystallizer.class, new RenderChemicalCrystallizer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityChemicalDissolutionChamber.class, - new RenderChemicalDissolutionChamber()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityChemicalInjectionChamber.class, - new RenderConfigurableMachine<>()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityChemicalCrystallizer.class, new RenderChemicalCrystallizer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityChemicalDissolutionChamber.class, new RenderChemicalDissolutionChamber()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityChemicalInjectionChamber.class, new RenderConfigurableMachine<>()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCombiner.class, new RenderConfigurableMachine<>()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrusher.class, new RenderConfigurableMachine<>()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDigitalMiner.class, new RenderDigitalMiner()); - ClientRegistry - .bindTileEntitySpecialRenderer(TileEntityDiversionTransporter.class, new RenderLogisticalTransporter()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDiversionTransporter.class, new RenderLogisticalTransporter()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDynamicTank.class, new RenderDynamicTank()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDynamicValve.class, new RenderDynamicTank()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEliteFactory.class, new RenderConfigurableMachine<>()); - ClientRegistry - .bindTileEntitySpecialRenderer(TileEntityEnergizedSmelter.class, new RenderConfigurableMachine<>()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEnergizedSmelter.class, new RenderConfigurableMachine<>()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEnergyCube.class, new RenderEnergyCube()); - ClientRegistry - .bindTileEntitySpecialRenderer(TileEntityEnrichmentChamber.class, new RenderConfigurableMachine<>()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEnrichmentChamber.class, new RenderConfigurableMachine<>()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFactory.class, new RenderConfigurableMachine<>()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFluidTank.class, RenderFluidTank.INSTANCE); - ClientRegistry - .bindTileEntitySpecialRenderer(TileEntityFormulaicAssemblicator.class, new RenderConfigurableMachine<>()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFormulaicAssemblicator.class, new RenderConfigurableMachine<>()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityGasTank.class, new RenderGasTank()); - ClientRegistry - .bindTileEntitySpecialRenderer(TileEntityLogisticalTransporter.class, new RenderLogisticalTransporter()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityLogisticalTransporter.class, new RenderLogisticalTransporter()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMechanicalPipe.class, new RenderMechanicalPipe()); - ClientRegistry - .bindTileEntitySpecialRenderer(TileEntityMetallurgicInfuser.class, new RenderConfigurableMachine<>()); - ClientRegistry - .bindTileEntitySpecialRenderer(TileEntityOsmiumCompressor.class, new RenderConfigurableMachine<>()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMetallurgicInfuser.class, new RenderConfigurableMachine<>()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityOsmiumCompressor.class, new RenderConfigurableMachine<>()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPRC.class, new RenderConfigurableMachine<>()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPersonalChest.class, new RenderPersonalChest()); - ClientRegistry - .bindTileEntitySpecialRenderer(TileEntityPrecisionSawmill.class, new RenderConfigurableMachine<>()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPrecisionSawmill.class, new RenderConfigurableMachine<>()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPressurizedTube.class, new RenderPressurizedTube()); - ClientRegistry - .bindTileEntitySpecialRenderer(TileEntityPurificationChamber.class, new RenderConfigurableMachine<>()); - ClientRegistry - .bindTileEntitySpecialRenderer(TileEntityQuantumEntangloporter.class, new RenderQuantumEntangloporter()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPurificationChamber.class, new RenderConfigurableMachine<>()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityQuantumEntangloporter.class, new RenderQuantumEntangloporter()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityResistiveHeater.class, new RenderResistiveHeater()); - ClientRegistry - .bindTileEntitySpecialRenderer(TileEntityRestrictiveTransporter.class, new RenderLogisticalTransporter()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRestrictiveTransporter.class, new RenderLogisticalTransporter()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySecurityDesk.class, new RenderSecurityDesk()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySeismicVibrator.class, new RenderSeismicVibrator()); - ClientRegistry - .bindTileEntitySpecialRenderer(TileEntitySolarNeutronActivator.class, new RenderSolarNeutronActivator()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySolarNeutronActivator.class, new RenderSolarNeutronActivator()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTeleporter.class, new RenderTeleporter()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityThermalEvaporationController.class, - new RenderThermalEvaporationController()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityThermodynamicConductor.class, - new RenderThermodynamicConductor()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityThermalEvaporationController.class, new RenderThermalEvaporationController()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityThermodynamicConductor.class, new RenderThermodynamicConductor()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityUniversalCable.class, new RenderUniversalCable()); } @@ -415,8 +390,7 @@ public class ClientProxy extends CommonProxy { ModelBakery.registerItemVariants(MekanismItems.WalkieTalkie, ItemWalkieTalkie.getModel(i)); } - ModelBakery.registerItemVariants(MekanismItems.CraftingFormula, ItemCraftingFormula.MODEL, - ItemCraftingFormula.INVALID_MODEL, ItemCraftingFormula.ENCODED_MODEL); + ModelBakery.registerItemVariants(MekanismItems.CraftingFormula, ItemCraftingFormula.MODEL, ItemCraftingFormula.INVALID_MODEL, ItemCraftingFormula.ENCODED_MODEL); MekanismItems.Jetpack.setTileEntityItemStackRenderer(new RenderJetpack()); MekanismItems.ArmoredJetpack.setTileEntityItemStackRenderer(new RenderArmoredJetpack()); @@ -430,7 +404,6 @@ public class ClientProxy extends CommonProxy { Item.getItemFromBlock(MekanismBlocks.MachineBlock2).setTileEntityItemStackRenderer(new RenderMachineItem()); Item.getItemFromBlock(MekanismBlocks.MachineBlock3).setTileEntityItemStackRenderer(new RenderMachineItem()); Item.getItemFromBlock(MekanismBlocks.BasicBlock2).setTileEntityItemStackRenderer(new RenderBasicBlockItem()); - } private ModelResourceLocation getInventoryMRL(String type) { @@ -453,45 +426,28 @@ public class ClientProxy extends CommonProxy { ModelLoader.setCustomStateMapper(MekanismBlocks.CardboardBox, boxMapper); ModelLoader.setCustomStateMapper(MekanismBlocks.Transmitter, transmitterMapper); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.ObsidianTNT), 0, - getInventoryMRL("ObsidianTNT")); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.SaltBlock), 0, - getInventoryMRL("SaltBlock")); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.CardboardBox), 0, - new ModelResourceLocation("mekanism:CardboardBox", "storage=false")); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.CardboardBox), 1, - new ModelResourceLocation("mekanism:CardboardBox", "storage=true")); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.EnergyCube), 0, - getInventoryMRL("EnergyCube")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.ObsidianTNT), 0, getInventoryMRL("ObsidianTNT")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.SaltBlock), 0, getInventoryMRL("SaltBlock")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.CardboardBox), 0, new ModelResourceLocation("mekanism:CardboardBox", "storage=false")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.CardboardBox), 1, new ModelResourceLocation("mekanism:CardboardBox", "storage=true")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.EnergyCube), 0, getInventoryMRL("EnergyCube")); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.MachineBlock), 4, - getInventoryMRL("digital_miner")); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.MachineBlock), 13, - getInventoryMRL("personal_chest")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.MachineBlock), 4, getInventoryMRL("digital_miner")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.MachineBlock), 13, getInventoryMRL("personal_chest")); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.MachineBlock2), 6, - getInventoryMRL("chemical_dissolution_chamber")); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.MachineBlock2), 8, - getInventoryMRL("chemical_crystallizer")); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.MachineBlock2), 9, - getInventoryMRL("seismic_vibrator")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.MachineBlock2), 6, getInventoryMRL("chemical_dissolution_chamber")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.MachineBlock2), 8, getInventoryMRL("chemical_crystallizer")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.MachineBlock2), 9, getInventoryMRL("seismic_vibrator")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.MachineBlock2), 11, getInventoryMRL("fluid_tank")); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.MachineBlock2), 11, - getInventoryMRL("fluid_tank")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.MachineBlock3), 0, getInventoryMRL("quantum_entangloporter")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.MachineBlock3), 1, getInventoryMRL("solar_neutron_activator")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.MachineBlock3), 4, getInventoryMRL("resistive_heater")); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.MachineBlock3), 0, - getInventoryMRL("quantum_entangloporter")); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.MachineBlock3), 1, - getInventoryMRL("solar_neutron_activator")); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.MachineBlock3), 4, - getInventoryMRL("resistive_heater")); - - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.BasicBlock2), 9, - getInventoryMRL("security_desk")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.BasicBlock2), 9, getInventoryMRL("security_desk")); for (int i = 0; i < EnumColor.DYES.length; i++) { - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.GlowPanel), i, - getInventoryMRL("glowpanel")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.GlowPanel), i, getInventoryMRL("glowpanel")); } for (MachineType type : MachineType.values()) { @@ -503,8 +459,7 @@ public class ClientProxy extends CommonProxy { String resource = "mekanism:" + type.getName(); RecipeType recipePointer = null; - if (type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY - || type == MachineType.ELITE_FACTORY) { + if (type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY || type == MachineType.ELITE_FACTORY) { recipePointer = RecipeType.values()[0]; resource = "mekanism:" + type.getName() + "_" + recipePointer.getName(); } @@ -512,38 +467,30 @@ public class ClientProxy extends CommonProxy { while (true) { if (machineResources.get(resource) == null) { List entries = new ArrayList<>(); - if (type.hasActiveTexture()) { entries.add("active=false"); } - if (type.hasRotations()) { entries.add("facing=north"); } String properties = getProperties(entries); - ModelResourceLocation model = new ModelResourceLocation(resource, properties); - machineResources.put(resource, model); modelsToAdd.add(model); - if (type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY - || type == MachineType.ELITE_FACTORY) { + if (type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY || type == MachineType.ELITE_FACTORY) { if (recipePointer.ordinal() < RecipeType.values().length - 1) { recipePointer = RecipeType.values()[recipePointer.ordinal() + 1]; resource = "mekanism:" + type.getName() + "_" + recipePointer.getName(); - continue; } } } - break; } - ModelLoader.registerItemVariants(Item.getItemFromBlock(type.typeBlock.getBlock()), - modelsToAdd.toArray(new ModelResourceLocation[]{})); + ModelLoader.registerItemVariants(Item.getItemFromBlock(type.typeBlock.getBlock()), modelsToAdd.toArray(new ModelResourceLocation[]{})); } for (BasicBlockType type : BasicBlockType.values()) { @@ -559,41 +506,32 @@ public class ClientProxy extends CommonProxy { while (true) { if (basicResources.get(resource) == null) { List entries = new ArrayList<>(); - if (type.hasActiveTexture()) { entries.add("active=false"); } - if (type.hasRotations() || type == BasicBlockType.THERMAL_EVAPORATION_CONTROLLER) { entries.add("facing=north"); } //TODO: Is this check against bin's needed String properties = type == BasicBlockType.BIN ? "inventory" : getProperties(entries); - ModelResourceLocation model = new ModelResourceLocation(resource, properties); - basicResources.put(resource, model); modelsToAdd.add(model); if (type.tiers) { if (tierPointer.ordinal() < BaseTier.values().length - 1) { tierPointer = BaseTier.values()[tierPointer.ordinal() + 1]; - if (type == BasicBlockType.BIN || tierPointer.isObtainable()) { resource = "mekanism:" + type.getName() + "_" + tierPointer.getName(); - continue; } } } } - break; } - - ModelLoader.registerItemVariants(Item.getItemFromBlock(type.blockType.getBlock()), - modelsToAdd.toArray(new ModelResourceLocation[]{})); + ModelLoader.registerItemVariants(Item.getItemFromBlock(type.blockType.getBlock()), modelsToAdd.toArray(new ModelResourceLocation[]{})); } for (TransmitterType type : TransmitterType.values()) { @@ -610,76 +548,55 @@ public class ClientProxy extends CommonProxy { if (transmitterResources.get(resource) == null) { String properties = "inventory"; ModelResourceLocation model = new ModelResourceLocation(resource, properties); - transmitterResources.put(resource, model); modelsToAdd.add(model); - if (type.hasTiers()) { if (tierPointer.ordinal() < BaseTier.values().length - 1) { tierPointer = BaseTier.values()[tierPointer.ordinal() + 1]; - if (tierPointer.isObtainable()) { resource = "mekanism:" + type.getName() + "_" + tierPointer.getName(); - continue; } } } } - break; } - ModelLoader.registerItemVariants(Item.getItemFromBlock(MekanismBlocks.Transmitter), - modelsToAdd.toArray(new ModelResourceLocation[]{})); + ModelLoader.registerItemVariants(Item.getItemFromBlock(MekanismBlocks.Transmitter), modelsToAdd.toArray(new ModelResourceLocation[]{})); } for (EnumColor color : EnumColor.DYES) { - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.PlasticBlock), - color.getMetaValue(), new ModelResourceLocation("mekanism:plastic_block", "type=plastic")); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.SlickPlasticBlock), - color.getMetaValue(), new ModelResourceLocation("mekanism:plastic_block", "type=slick")); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.GlowPlasticBlock), - color.getMetaValue(), new ModelResourceLocation("mekanism:plastic_block", "type=glow")); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.ReinforcedPlasticBlock), - color.getMetaValue(), new ModelResourceLocation("mekanism:plastic_block", "type=reinforced")); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.RoadPlasticBlock), - color.getMetaValue(), new ModelResourceLocation("mekanism:plastic_block", "type=road")); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.PlasticFence), - color.getMetaValue(), getInventoryMRL("PlasticFence")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.PlasticBlock), color.getMetaValue(), new ModelResourceLocation("mekanism:plastic_block", "type=plastic")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.SlickPlasticBlock), color.getMetaValue(), new ModelResourceLocation("mekanism:plastic_block", "type=slick")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.GlowPlasticBlock), color.getMetaValue(), new ModelResourceLocation("mekanism:plastic_block", "type=glow")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.ReinforcedPlasticBlock), color.getMetaValue(), new ModelResourceLocation("mekanism:plastic_block", "type=reinforced")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.RoadPlasticBlock), color.getMetaValue(), new ModelResourceLocation("mekanism:plastic_block", "type=road")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.PlasticFence), color.getMetaValue(), getInventoryMRL("PlasticFence")); } for (EnumOreType ore : EnumOreType.values()) { - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.OreBlock), ore.ordinal(), - new ModelResourceLocation("mekanism:OreBlock", "type=" + ore.getName())); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.OreBlock), ore.ordinal(), new ModelResourceLocation("mekanism:OreBlock", "type=" + ore.getName())); } - ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(MekanismBlocks.GasTank), stack -> - { + ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(MekanismBlocks.GasTank), stack -> { GasTankTier tier = GasTankTier.values()[((ItemBlockGasTank) stack.getItem()).getBaseTier(stack).ordinal()]; ResourceLocation baseLocation = new ResourceLocation("mekanism", "GasTank"); - return new ModelResourceLocation(baseLocation, "facing=north,tier=" + tier); }); - ItemMeshDefinition machineMesher = stack -> - { + ItemMeshDefinition machineMesher = stack -> { MachineType type = MachineType.get(stack); - if (type != null) { String resource = "mekanism:" + type.getName(); - - if (type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY - || type == MachineType.ELITE_FACTORY) { + if (type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY || type == MachineType.ELITE_FACTORY) { RecipeType recipe = ((ItemBlockMachine) stack.getItem()).getRecipeTypeOrNull(stack); if (recipe != null) { resource = "mekanism:" + type.getName() + "_" + recipe.getName(); } } - return machineResources.get(resource); } - return null; }; @@ -687,75 +604,58 @@ public class ClientProxy extends CommonProxy { ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(MekanismBlocks.MachineBlock2), machineMesher); ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(MekanismBlocks.MachineBlock3), machineMesher); - ItemMeshDefinition basicMesher = stack -> - { + ItemMeshDefinition basicMesher = stack -> { BasicBlockType type = BasicBlockType.get(stack); - if (type != null) { String resource = "mekanism:" + type.getName(); - if (type.tiers) { BaseTier tier = ((ItemBlockBasic) stack.getItem()).getBaseTier(stack); resource = "mekanism:" + type.getName() + "_" + tier.getName(); } - return basicResources.get(resource); } - return null; }; ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(MekanismBlocks.BasicBlock), basicMesher); ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(MekanismBlocks.BasicBlock2), basicMesher); - ItemMeshDefinition transmitterMesher = stack -> - { + ItemMeshDefinition transmitterMesher = stack -> { TransmitterType type = TransmitterType.get(stack.getItemDamage()); if (type != null) { String resource = "mekanism:" + type.getName(); - if (type.hasTiers()) { BaseTier tier = ((ItemBlockTransmitter) stack.getItem()).getBaseTier(stack); resource = "mekanism:" + type.getName() + "_" + tier.getName(); } - return transmitterResources.get(resource); } - return null; }; ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(MekanismBlocks.Transmitter), transmitterMesher); //Walkie Talkie dynamic texture - ModelLoader.setCustomMeshDefinition(MekanismItems.WalkieTalkie, stack -> - { + ModelLoader.setCustomMeshDefinition(MekanismItems.WalkieTalkie, stack -> { if (!stack.isEmpty() && stack.getItem() instanceof ItemWalkieTalkie) { ItemWalkieTalkie item = (ItemWalkieTalkie) stack.getItem(); - if (item.getOn(stack)) { return ItemWalkieTalkie.CHANNEL_MODELS.get(item.getChannel(stack)); } } - return ItemWalkieTalkie.OFF_MODEL; }); //Crafting Formula dynamic texture - ModelLoader.setCustomMeshDefinition(MekanismItems.CraftingFormula, stack -> - { + ModelLoader.setCustomMeshDefinition(MekanismItems.CraftingFormula, stack -> { if (!stack.isEmpty() && stack.getItem() instanceof ItemCraftingFormula) { ItemCraftingFormula item = (ItemCraftingFormula) stack.getItem(); - if (item.getInventory(stack) == null) { return ItemCraftingFormula.MODEL; - } else { - return item.isInvalid(stack) ? ItemCraftingFormula.INVALID_MODEL - : ItemCraftingFormula.ENCODED_MODEL; } + return item.isInvalid(stack) ? ItemCraftingFormula.INVALID_MODEL : ItemCraftingFormula.ENCODED_MODEL; } - return ItemCraftingFormula.MODEL; }); @@ -812,11 +712,9 @@ public class ClientProxy extends CommonProxy { return new GuiTeleporter(player.inventory, (TileEntityTeleporter) tileEntity); case 14: ItemStack itemStack = player.getHeldItem(EnumHand.values()[pos.getX()]); - if (!itemStack.isEmpty() && itemStack.getItem() instanceof ItemPortableTeleporter) { return new GuiTeleporter(player, EnumHand.values()[pos.getX()], itemStack); } - return null; case 15: return new GuiPurificationChamber(player.inventory, (TileEntityAdvancedElectricMachine) tileEntity); @@ -829,72 +727,57 @@ public class ClientProxy extends CommonProxy { //EMPTY 19, 20 case 21: EntityRobit robit = (EntityRobit) world.getEntityByID(pos.getX()); - if (robit != null) { return new GuiRobitMain(player.inventory, robit); } - return null; case 22: robit = (EntityRobit) world.getEntityByID(pos.getX()); - if (robit != null) { return new GuiRobitCrafting(player.inventory, robit); } - return null; case 23: robit = (EntityRobit) world.getEntityByID(pos.getX()); - if (robit != null) { return new GuiRobitInventory(player.inventory, robit); } - return null; case 24: robit = (EntityRobit) world.getEntityByID(pos.getX()); - if (robit != null) { return new GuiRobitSmelting(player.inventory, robit); } - return null; case 25: robit = (EntityRobit) world.getEntityByID(pos.getX()); - if (robit != null) { return new GuiRobitRepair(player.inventory, robit); } - return null; case 29: return new GuiChemicalOxidizer(player.inventory, (TileEntityChemicalOxidizer) tileEntity); case 30: return new GuiChemicalInfuser(player.inventory, (TileEntityChemicalInfuser) tileEntity); case 31: - return new GuiChemicalInjectionChamber(player.inventory, - (TileEntityAdvancedElectricMachine) tileEntity); + return new GuiChemicalInjectionChamber(player.inventory, (TileEntityAdvancedElectricMachine) tileEntity); case 32: return new GuiElectrolyticSeparator(player.inventory, (TileEntityElectrolyticSeparator) tileEntity); case 33: - return new GuiThermalEvaporationController(player.inventory, - (TileEntityThermalEvaporationController) tileEntity); + return new GuiThermalEvaporationController(player.inventory, (TileEntityThermalEvaporationController) tileEntity); case 34: return new GuiPrecisionSawmill(player.inventory, (TileEntityPrecisionSawmill) tileEntity); case 35: - return new GuiChemicalDissolutionChamber(player.inventory, - (TileEntityChemicalDissolutionChamber) tileEntity); + return new GuiChemicalDissolutionChamber(player.inventory, (TileEntityChemicalDissolutionChamber) tileEntity); case 36: return new GuiChemicalWasher(player.inventory, (TileEntityChemicalWasher) tileEntity); case 37: return new GuiChemicalCrystallizer(player.inventory, (TileEntityChemicalCrystallizer) tileEntity); case 38: ItemStack itemStack1 = player.getHeldItem(EnumHand.values()[pos.getX()]); - if (!itemStack1.isEmpty() && itemStack1.getItem() instanceof ItemSeismicReader) { return new GuiSeismicReader(world, new Coord4D(player), itemStack1.copy()); } - return null; case 39: return new GuiSeismicVibrator(player.inventory, (TileEntitySeismicVibrator) tileEntity); @@ -939,7 +822,6 @@ public class ClientProxy extends CommonProxy { case 59: return new GuiLogisticalSorter(player, (TileEntityLogisticalSorter) tileEntity); } - return null; } @@ -949,12 +831,10 @@ public class ClientProxy extends CommonProxy { if (screen instanceof GuiTeleporter && !((GuiTeleporter) screen).isStackEmpty()) { GuiTeleporter teleporter = (GuiTeleporter) screen; - teleporter.setStatus(message.status); teleporter.setFrequency(message.frequency); teleporter.setPublicCache(message.publicCache); teleporter.setPrivateCache(message.privateCache); - teleporter.updateButtons(); } } @@ -973,15 +853,13 @@ public class ClientProxy extends CommonProxy { if (MekanismConfig.current().client.enableMultiblockFormationParticles.val()) { anim.run(); } else { - player.sendStatusMessage( - new TextComponentGroup(TextFormatting.BLUE).translation("chat.mek.multiblockformed"), true); + player.sendStatusMessage(new TextComponentGroup(TextFormatting.BLUE).translation("chat.mek.multiblockformed"), true); } } } @Override - public void doMultiblockSparkle(TileEntity tileEntity, BlockPos renderLoc, int length, int width, int height, - INodeChecker checker) { + public void doMultiblockSparkle(TileEntity tileEntity, BlockPos renderLoc, int length, int width, int height, INodeChecker checker) { doSparkle(tileEntity, new SparkleAnimation(tileEntity, renderLoc, length, width, height, checker)); } @@ -990,61 +868,40 @@ public class ClientProxy extends CommonProxy { doSparkle(tileEntity, new SparkleAnimation(tileEntity, corner1, corner2, checker)); } - @Override public void init() { super.init(); - Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler((state, worldIn, pos, tintIndex) -> - { + Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler((state, worldIn, pos, tintIndex) -> { BlockMachine machine = (BlockMachine) state.getBlock(); - if (state.getValue(machine.getMachineBlock().getProperty()) == MachineType.FLUID_TANK) { EnumColor color = state.getValue(BlockStateMachine.tierProperty).getColor(); - - return (int) (color.getColor(0) * 255) << 16 | (int) (color.getColor(1) * 255) << 8 | (int) ( - color.getColor(2) * 255); + return (int) (color.getColor(0) * 255) << 16 | (int) (color.getColor(1) * 255) << 8 | (int) (color.getColor(2) * 255); } - return -1; }, MekanismBlocks.MachineBlock, MekanismBlocks.MachineBlock2, MekanismBlocks.MachineBlock3); - Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler((state, worldIn, pos, tintIndex) -> - { + Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler((state, worldIn, pos, tintIndex) -> { EnumDyeColor color = state.getValue(colorProperty); EnumColor dye = EnumColor.DYES[color.getDyeDamage()]; - - return (int) (dye.getColor(0) * 255) << 16 | (int) (dye.getColor(1) * 255) << 8 | (int) (dye.getColor(2) - * 255); - }, MekanismBlocks.PlasticBlock, MekanismBlocks.GlowPlasticBlock, MekanismBlocks.RoadPlasticBlock, - MekanismBlocks.ReinforcedPlasticBlock, + return (int) (dye.getColor(0) * 255) << 16 | (int) (dye.getColor(1) * 255) << 8 | (int) (dye.getColor(2) * 255); + }, MekanismBlocks.PlasticBlock, MekanismBlocks.GlowPlasticBlock, MekanismBlocks.RoadPlasticBlock, MekanismBlocks.ReinforcedPlasticBlock, MekanismBlocks.SlickPlasticBlock, MekanismBlocks.PlasticFence); - Minecraft.getMinecraft().getItemColors().registerItemColorHandler((stack, tintIndex) -> - { + Minecraft.getMinecraft().getItemColors().registerItemColorHandler((stack, tintIndex) -> { if (MachineType.get(stack) == MachineType.FLUID_TANK) { EnumColor color = ((ItemBlockMachine) stack.getItem()).getBaseTier(stack).getColor(); - - return (int) (color.getColor(0) * 255) << 16 | (int) (color.getColor(1) * 255) << 8 | (int) ( - color.getColor(2) * 255); + return (int) (color.getColor(0) * 255) << 16 | (int) (color.getColor(1) * 255) << 8 | (int) (color.getColor(2) * 255); } - return -1; }, MekanismBlocks.MachineBlock, MekanismBlocks.MachineBlock2, MekanismBlocks.MachineBlock3); - Minecraft.getMinecraft().getItemColors().registerItemColorHandler((stack, tintIndex) -> - { + Minecraft.getMinecraft().getItemColors().registerItemColorHandler((stack, tintIndex) -> { EnumDyeColor dyeColor = EnumDyeColor.byDyeDamage(stack.getItemDamage() & 15); EnumColor dye = EnumColor.DYES[dyeColor.getDyeDamage()]; - - return (int) (dye.getColor(0) * 255) << 16 | (int) (dye.getColor(1) * 255) << 8 | (int) (dye.getColor(2) - * 255); - }, MekanismBlocks.PlasticBlock, MekanismBlocks.GlowPlasticBlock, MekanismBlocks.RoadPlasticBlock, - MekanismBlocks.ReinforcedPlasticBlock, + return (int) (dye.getColor(0) * 255) << 16 | (int) (dye.getColor(1) * 255) << 8 | (int) (dye.getColor(2) * 255); + }, MekanismBlocks.PlasticBlock, MekanismBlocks.GlowPlasticBlock, MekanismBlocks.RoadPlasticBlock, MekanismBlocks.ReinforcedPlasticBlock, MekanismBlocks.SlickPlasticBlock, MekanismBlocks.PlasticFence); - Minecraft.getMinecraft().getItemColors().registerItemColorHandler((stack, tintIndex) -> - { + Minecraft.getMinecraft().getItemColors().registerItemColorHandler((stack, tintIndex) -> { EnumColor dye = EnumColor.DYES[stack.getItemDamage()]; - - return (int) (dye.getColor(0) * 255) << 16 | (int) (dye.getColor(1) * 255) << 8 | (int) (dye.getColor(2) - * 255); + return (int) (dye.getColor(0) * 255) << 16 | (int) (dye.getColor(1) * 255) << 8 | (int) (dye.getColor(2) * 255); }, MekanismItems.Balloon); MinecraftForge.EVENT_BUS.register(new ClientConnectionHandler()); @@ -1073,32 +930,25 @@ public class ClientProxy extends CommonProxy { modelRegistry.putObject(ERL, RenderEnergyCubeItem.model = new ItemLayerWrapper(modelRegistry.getObject(ERL))); ModelResourceLocation JetpackRL = getInventoryMRL("Jetpack"); - modelRegistry - .putObject(JetpackRL, RenderJetpack.model = new ItemLayerWrapper(modelRegistry.getObject(JetpackRL))); + modelRegistry.putObject(JetpackRL, RenderJetpack.model = new ItemLayerWrapper(modelRegistry.getObject(JetpackRL))); ModelResourceLocation ArmorJetpackRL = getInventoryMRL("ArmoredJetpack"); - modelRegistry.putObject(ArmorJetpackRL, - RenderArmoredJetpack.model = new ItemLayerWrapper(modelRegistry.getObject(ArmorJetpackRL))); + modelRegistry.putObject(ArmorJetpackRL, RenderArmoredJetpack.model = new ItemLayerWrapper(modelRegistry.getObject(ArmorJetpackRL))); ModelResourceLocation GasMaskRL = getInventoryMRL("GasMask"); - modelRegistry - .putObject(GasMaskRL, RenderGasMask.model = new ItemLayerWrapper(modelRegistry.getObject(GasMaskRL))); + modelRegistry.putObject(GasMaskRL, RenderGasMask.model = new ItemLayerWrapper(modelRegistry.getObject(GasMaskRL))); ModelResourceLocation ScubaTankRL = getInventoryMRL("ScubaTank"); - modelRegistry.putObject(ScubaTankRL, - RenderScubaTank.model = new ItemLayerWrapper(modelRegistry.getObject(ScubaTankRL))); + modelRegistry.putObject(ScubaTankRL, RenderScubaTank.model = new ItemLayerWrapper(modelRegistry.getObject(ScubaTankRL))); ModelResourceLocation FreeRunnerRL = getInventoryMRL("FreeRunners"); - modelRegistry.putObject(FreeRunnerRL, - RenderFreeRunners.model = new ItemLayerWrapper(modelRegistry.getObject(FreeRunnerRL))); + modelRegistry.putObject(FreeRunnerRL, RenderFreeRunners.model = new ItemLayerWrapper(modelRegistry.getObject(FreeRunnerRL))); ModelResourceLocation AtomicDisassemblerRL = getInventoryMRL("AtomicDisassembler"); - modelRegistry.putObject(AtomicDisassemblerRL, - RenderAtomicDisassembler.model = new ItemLayerWrapper(modelRegistry.getObject(AtomicDisassemblerRL))); + modelRegistry.putObject(AtomicDisassemblerRL, RenderAtomicDisassembler.model = new ItemLayerWrapper(modelRegistry.getObject(AtomicDisassemblerRL))); ModelResourceLocation FlamethrowerRL = getInventoryMRL("Flamethrower"); - modelRegistry.putObject(FlamethrowerRL, - RenderFlameThrower.model = new ItemLayerWrapper(modelRegistry.getObject(FlamethrowerRL))); + modelRegistry.putObject(FlamethrowerRL, RenderFlameThrower.model = new ItemLayerWrapper(modelRegistry.getObject(FlamethrowerRL))); machineModelBake(modelRegistry, "digital_miner", MachineType.DIGITAL_MINER); machineModelBake(modelRegistry, "solar_neutron_activator", MachineType.SOLAR_NEUTRON_ACTIVATOR); @@ -1115,16 +965,14 @@ public class ClientProxy extends CommonProxy { basicBlockModelBake(modelRegistry, "security_desk", BasicBlockType.SECURITY_DESK); } - private void machineModelBake(IRegistry modelRegistry, String type, - MachineType machineType) { + private void machineModelBake(IRegistry modelRegistry, String type, MachineType machineType) { ModelResourceLocation modelResourceLocation = getInventoryMRL(type); ItemLayerWrapper itemLayerWrapper = new ItemLayerWrapper(modelRegistry.getObject(modelResourceLocation)); RenderMachineItem.modelMap.put(machineType, itemLayerWrapper); modelRegistry.putObject(modelResourceLocation, itemLayerWrapper); } - private void basicBlockModelBake(IRegistry modelRegistry, String type, - BasicBlockType basicType) { + private void basicBlockModelBake(IRegistry modelRegistry, String type, BasicBlockType basicType) { ModelResourceLocation modelResourceLocation = getInventoryMRL(type); ItemLayerWrapper itemLayerWrapper = new ItemLayerWrapper(modelRegistry.getObject(modelResourceLocation)); RenderBasicBlockItem.modelMap.put(basicType, itemLayerWrapper); @@ -1155,13 +1003,10 @@ public class ClientProxy extends CommonProxy { @Override public boolean isPaused() { - if (FMLClientHandler.instance().getClient().isSingleplayer() && !FMLClientHandler.instance().getClient() - .getIntegratedServer().getPublic()) { + if (FMLClientHandler.instance().getClient().isSingleplayer() && !FMLClientHandler.instance().getClient().getIntegratedServer().getPublic()) { GuiScreen screen = FMLClientHandler.instance().getClient().currentScreen; - return screen != null && screen.doesGuiPauseGame(); } - return false; } @@ -1174,9 +1019,8 @@ public class ClientProxy extends CommonProxy { public EntityPlayer getPlayer(MessageContext context) { if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { return context.getServerHandler().player; - } else { - return Minecraft.getMinecraft().player; } + return Minecraft.getMinecraft().player; } @Override @@ -1192,8 +1036,7 @@ public class ClientProxy extends CommonProxy { if (server != null) { server.addScheduledTask(runnable); } else { - Mekanism.logger.error( - "Packet handler wanted to set a scheduled task, but we couldn't find a way to set one."); + Mekanism.logger.error("Packet handler wanted to set a scheduled task, but we couldn't find a way to set one."); Mekanism.logger.error("Player = {}, World = {}", player, player.world); } } @@ -1214,4 +1057,4 @@ public class ClientProxy extends CommonProxy { public void throwApiPresentException() { throw new ApiJarPresentException(API_PRESENT_MESSAGE); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/ClientTickHandler.java b/src/main/java/mekanism/client/ClientTickHandler.java index acbbcbd6b..655a03719 100644 --- a/src/main/java/mekanism/client/ClientTickHandler.java +++ b/src/main/java/mekanism/client/ClientTickHandler.java @@ -1,6 +1,6 @@ package mekanism.client; -import com.google.common.collect.Lists; +import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -75,24 +75,20 @@ public class ClientTickHandler { ItemJetpack jetpack = (ItemJetpack) stack.getItem(); if (jetpack.getGas(stack) != null) { - if ((mc.gameSettings.keyBindJump.isKeyDown() && jetpack.getMode(stack) == JetpackMode.NORMAL) - && mc.currentScreen == null) { + if (mc.gameSettings.keyBindJump.isKeyDown() && jetpack.getMode(stack) == JetpackMode.NORMAL && mc.currentScreen == null) { return true; } else if (jetpack.getMode(stack) == JetpackMode.HOVER) { - if ((!mc.gameSettings.keyBindJump.isKeyDown() && !mc.gameSettings.keyBindSneak.isKeyDown()) || ( - mc.gameSettings.keyBindJump.isKeyDown() && mc.gameSettings.keyBindSneak.isKeyDown()) - || mc.currentScreen != null) { + if ((!mc.gameSettings.keyBindJump.isKeyDown() && !mc.gameSettings.keyBindSneak.isKeyDown()) || + (mc.gameSettings.keyBindJump.isKeyDown() && mc.gameSettings.keyBindSneak.isKeyDown()) || mc.currentScreen != null) { return !CommonPlayerTickHandler.isOnGround(player); } else if (mc.gameSettings.keyBindSneak.isKeyDown() && mc.currentScreen == null) { return !CommonPlayerTickHandler.isOnGround(player); } - return true; } } } } - return false; } @@ -100,20 +96,16 @@ public class ClientTickHandler { if (player != mc.player) { return Mekanism.playerState.isGasmaskOn(player); } - ItemStack tank = player.inventory.armorInventory.get(2); ItemStack mask = player.inventory.armorInventory.get(3); - if (!tank.isEmpty() && !mask.isEmpty()) { if (tank.getItem() instanceof ItemScubaTank && mask.getItem() instanceof ItemGasMask) { ItemScubaTank scubaTank = (ItemScubaTank) tank.getItem(); - if (scubaTank.getGas(tank) != null) { return scubaTank.getFlowing(tank); } } } - return false; } @@ -123,14 +115,11 @@ public class ClientTickHandler { } ItemStack stack = player.getItemStackFromSlot(EntityEquipmentSlot.FEET); - if (!stack.isEmpty() && stack.getItem() instanceof ItemFreeRunners) { ItemFreeRunners freeRunners = (ItemFreeRunners) stack.getItem(); - /*freeRunners.getEnergy(stack) > 0 && */ return freeRunners.getMode(stack) == ItemFreeRunners.FreeRunnerMode.NORMAL; } - return false; } @@ -138,32 +127,25 @@ public class ClientTickHandler { if (player != mc.player) { return Mekanism.playerState.isFlamethrowerOn(player); } - if (hasFlamethrower(player)) { return mc.gameSettings.keyBindUseItem.isKeyDown(); } - return false; } public static boolean hasFlamethrower(EntityPlayer player) { - if (!player.inventory.getCurrentItem().isEmpty() && player.inventory.getCurrentItem() - .getItem() instanceof ItemFlamethrower) { + if (!player.inventory.getCurrentItem().isEmpty() && player.inventory.getCurrentItem().getItem() instanceof ItemFlamethrower) { ItemFlamethrower flamethrower = (ItemFlamethrower) player.inventory.getCurrentItem().getItem(); - return flamethrower.getGas(player.inventory.getCurrentItem()) != null; } - return false; } public static void portableTeleport(EntityPlayer player, EnumHand hand, Frequency freq) { if (MekanismConfig.current().general.portableTeleporterDelay.val() == 0) { - Mekanism.packetHandler - .sendToServer(new PortableTeleporterMessage(PortableTeleporterPacketType.TELEPORT, hand, freq)); + Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage(PortableTeleporterPacketType.TELEPORT, hand, freq)); } else { - portableTeleports.put(player, new TeleportData(hand, freq, - mc.world.getWorldTime() + MekanismConfig.current().general.portableTeleporterDelay.val())); + portableTeleports.put(player, new TeleportData(hand, freq, mc.world.getWorldTime() + MekanismConfig.current().general.portableTeleporterDelay.val())); } } @@ -209,15 +191,13 @@ public class ClientTickHandler { Mekanism.freeRunnerOn.remove(mc.player.getUniqueID()); } - Mekanism.packetHandler.sendToServer( - new PacketFreeRunnerData.FreeRunnerDataMessage(PacketFreeRunnerData.FreeRunnerPacket.UPDATE, - mc.player.getUniqueID(), isFreeRunnerOn(mc.player))); + Mekanism.packetHandler.sendToServer(new PacketFreeRunnerData.FreeRunnerDataMessage(PacketFreeRunnerData.FreeRunnerPacket.UPDATE, + mc.player.getUniqueID(), isFreeRunnerOn(mc.player))); } ItemStack bootStack = mc.player.getItemStackFromSlot(EntityEquipmentSlot.FEET); - if (!bootStack.isEmpty() && bootStack.getItem() instanceof ItemFreeRunners && isFreeRunnerOn(mc.player) - && !mc.player.isSneaking()) { + if (!bootStack.isEmpty() && bootStack.getItem() instanceof ItemFreeRunners && isFreeRunnerOn(mc.player) && !mc.player.isSneaking()) { mc.player.stepHeight = 1.002F; } else if (mc.player.stepHeight == 1.002F) { mc.player.stepHeight = 0.6F; @@ -229,8 +209,7 @@ public class ClientTickHandler { Mekanism.playerState.setGasmaskState(mc.player.getUniqueID(), isGasMaskOn(mc.player), true); Mekanism.playerState.setFlamethrowerState(mc.player.getUniqueID(), isFlamethrowerOn(mc.player), true); - for (Iterator> iter = portableTeleports.entrySet().iterator(); - iter.hasNext(); ) { + for (Iterator> iter = portableTeleports.entrySet().iterator(); iter.hasNext(); ) { Entry entry = iter.next(); for (int i = 0; i < 100; i++) { @@ -242,9 +221,7 @@ public class ClientTickHandler { } if (mc.world.getWorldTime() == entry.getValue().teleportTime) { - Mekanism.packetHandler.sendToServer( - new PortableTeleporterMessage(PortableTeleporterPacketType.TELEPORT, entry.getValue().hand, - entry.getValue().freq)); + Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage(PortableTeleporterPacketType.TELEPORT, entry.getValue().hand, entry.getValue().freq)); iter.remove(); } } @@ -258,7 +235,6 @@ public class ClientTickHandler { if (isFlamethrowerOn(mc.player)) { ItemFlamethrower flamethrower = (ItemFlamethrower) mc.player.inventory.getCurrentItem().getItem(); - if (!(mc.player.isCreative() || mc.player.isSpectator())) { flamethrower.useGas(mc.player.inventory.getCurrentItem()); } @@ -271,9 +247,8 @@ public class ClientTickHandler { mc.player.motionY = Math.min(mc.player.motionY + 0.15D, 0.5D); mc.player.fallDistance = 0.0F; } else if (jetpack.getMode(chestStack) == JetpackMode.HOVER) { - if ((!mc.gameSettings.keyBindJump.isKeyDown() && !mc.gameSettings.keyBindSneak.isKeyDown()) || ( - mc.gameSettings.keyBindJump.isKeyDown() && mc.gameSettings.keyBindSneak.isKeyDown()) - || mc.currentScreen != null) { + if ((!mc.gameSettings.keyBindJump.isKeyDown() && !mc.gameSettings.keyBindSneak.isKeyDown()) || + (mc.gameSettings.keyBindJump.isKeyDown() && mc.gameSettings.keyBindSneak.isKeyDown()) || mc.currentScreen != null) { if (mc.player.motionY > 0) { mc.player.motionY = Math.max(mc.player.motionY - 0.15D, 0); } else if (mc.player.motionY < 0) { @@ -290,25 +265,20 @@ public class ClientTickHandler { } } } - mc.player.fallDistance = 0.0F; } - jetpack.useGas(chestStack); } if (isGasMaskOn(mc.player)) { ItemScubaTank tank = (ItemScubaTank) chestStack.getItem(); - final int max = 300; - tank.useGas(chestStack); GasStack received = tank.useGas(chestStack, max - mc.player.getAir()); if (received != null) { mc.player.setAir(mc.player.getAir() + received.amount); } - if (mc.player.getAir() == max) { for (Object obj : mc.player.getActivePotionEffects()) { if (obj instanceof PotionEffect) { @@ -324,8 +294,7 @@ public class ClientTickHandler { @SubscribeEvent public void onMouseEvent(MouseEvent event) { - if (MekanismConfig.current().client.allowConfiguratorModeScroll.val() && mc.player != null && mc.player - .isSneaking()) { + if (MekanismConfig.current().client.allowConfiguratorModeScroll.val() && mc.player != null && mc.player.isSneaking()) { ItemStack stack = mc.player.getHeldItemMainhand(); int delta = event.getDwheel(); @@ -343,10 +312,8 @@ public class ClientTickHandler { } else if (newVal < 0) { newVal = ConfiguratorMode.values().length + newVal; } - configurator.setState(stack, ConfiguratorMode.values()[newVal]); - Mekanism.packetHandler - .sendToServer(new ItemStackMessage(EnumHand.MAIN_HAND, Lists.newArrayList(newVal))); + Mekanism.packetHandler.sendToServer(new ItemStackMessage(EnumHand.MAIN_HAND, new ArrayList<>(newVal))); event.setCanceled(true); } } @@ -364,4 +331,4 @@ public class ClientTickHandler { teleportTime = t; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/HolidayManager.java b/src/main/java/mekanism/client/HolidayManager.java index 9a22cef7c..6787fb732 100644 --- a/src/main/java/mekanism/client/HolidayManager.java +++ b/src/main/java/mekanism/client/HolidayManager.java @@ -24,7 +24,6 @@ public final class HolidayManager { holidays.add(new Christmas()); holidays.add(new NewYear()); } - Mekanism.logger.info("Initialized HolidayManager."); } @@ -48,10 +47,8 @@ public final class HolidayManager { if (!MekanismConfig.current().client.holidays.val()) { return sound; } - try { YearlyDate date = getDate(); - for (Holiday holiday : holidays) { if (holiday.getDate().equals(date)) { return holiday.filterSound(sound); @@ -59,7 +56,6 @@ public final class HolidayManager { } } catch (Exception ignored) { } - return sound; } @@ -69,11 +65,9 @@ public final class HolidayManager { 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]).append("-"); } - return builder.toString(); } @@ -119,8 +113,7 @@ public final class HolidayManager { private static class Christmas extends Holiday { - private String[] nutcracker = new String[]{"christmas.1", "christmas.2", "christmas.3", "christmas.4", - "christmas.5"}; + private String[] nutcracker = new String[]{"christmas.1", "christmas.2", "christmas.3", "christmas.4", "christmas.5"}; @Override public YearlyDate getDate() { @@ -130,10 +123,8 @@ public final class HolidayManager { @Override public void onEvent(EntityPlayer player) { String themedLines = getThemedLines(new EnumColor[]{EnumColor.DARK_GREEN, EnumColor.DARK_RED}, 13); - player.sendMessage( - new TextComponentString(themedLines + EnumColor.DARK_BLUE + Mekanism.LOG_TAG + themedLines)); - player.sendMessage(new TextComponentString( - EnumColor.RED + "Merry Christmas, " + EnumColor.DARK_BLUE + player.getName() + EnumColor.RED + "!")); + player.sendMessage(new TextComponentString(themedLines + EnumColor.DARK_BLUE + Mekanism.LOG_TAG + themedLines)); + player.sendMessage(new TextComponentString(EnumColor.RED + "Merry Christmas, " + EnumColor.DARK_BLUE + player.getName() + EnumColor.RED + "!")); player.sendMessage(new TextComponentString(EnumColor.RED + "May you have plenty of Christmas cheer")); player.sendMessage(new TextComponentString(EnumColor.RED + "and have a relaxing holiday with your")); player.sendMessage(new TextComponentString(EnumColor.RED + "family :)")); @@ -143,20 +134,18 @@ public final class HolidayManager { @Override public ResourceLocation filterSound(ResourceLocation sound) { - String soundResourceLocationString = sound.toString(); - - if (soundResourceLocationString.contains("machine.enrichment")) { - return new ResourceLocation(sound.toString().replace("machine.enrichment", nutcracker[0])); - } else if (soundResourceLocationString.contains("machine.metalinfuser")) { - return new ResourceLocation(sound.toString().replace("machine.metalinfuser", nutcracker[1])); - } else if (soundResourceLocationString.contains("machine.purification")) { - return new ResourceLocation(sound.toString().replace("machine.purification", nutcracker[2])); - } else if (soundResourceLocationString.contains("machine.smelter")) { - return new ResourceLocation(sound.toString().replace("machine.smelter", nutcracker[3])); - } else if (soundResourceLocationString.contains("machine.dissolution")) { - return new ResourceLocation(sound.toString().replace("machine.dissolution", nutcracker[4])); + String soundLocation = sound.toString(); + if (soundLocation.contains("machine.enrichment")) { + return new ResourceLocation(soundLocation.replace("machine.enrichment", nutcracker[0])); + } else if (soundLocation.contains("machine.metalinfuser")) { + return new ResourceLocation(soundLocation.replace("machine.metalinfuser", nutcracker[1])); + } else if (soundLocation.contains("machine.purification")) { + return new ResourceLocation(soundLocation.replace("machine.purification", nutcracker[2])); + } else if (soundLocation.contains("machine.smelter")) { + return new ResourceLocation(soundLocation.replace("machine.smelter", nutcracker[3])); + } else if (soundLocation.contains("machine.dissolution")) { + return new ResourceLocation(soundLocation.replace("machine.dissolution", nutcracker[4])); } - return sound; } } @@ -171,13 +160,10 @@ public final class HolidayManager { @Override public void onEvent(EntityPlayer player) { String themedLines = getThemedLines(new EnumColor[]{EnumColor.WHITE, EnumColor.YELLOW}, 13); - player.sendMessage( - new TextComponentString(themedLines + EnumColor.DARK_BLUE + Mekanism.LOG_TAG + themedLines)); - player.sendMessage(new TextComponentString( - EnumColor.AQUA + "Happy New Year, " + EnumColor.DARK_BLUE + player.getName() + EnumColor.RED + "!")); + player.sendMessage(new TextComponentString(themedLines + EnumColor.DARK_BLUE + Mekanism.LOG_TAG + themedLines)); + player.sendMessage(new TextComponentString(EnumColor.AQUA + "Happy New Year, " + EnumColor.DARK_BLUE + player.getName() + EnumColor.RED + "!")); player.sendMessage(new TextComponentString(EnumColor.AQUA + "Best wishes to you as we enter this")); - player.sendMessage(new TextComponentString( - EnumColor.AQUA + "new and exciting year of " + calendar.get(Calendar.YEAR) + "! :)")); + player.sendMessage(new TextComponentString(EnumColor.AQUA + "new and exciting year of " + calendar.get(Calendar.YEAR) + "! :)")); player.sendMessage(new TextComponentString(EnumColor.DARK_GREY + "-aidancbrady")); player.sendMessage(new TextComponentString(themedLines + EnumColor.DARK_BLUE + "[=======]" + themedLines)); } @@ -211,4 +197,4 @@ public final class HolidayManager { return code; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/MekKeyHandler.java b/src/main/java/mekanism/client/MekKeyHandler.java index dbd1370fe..e0090c433 100644 --- a/src/main/java/mekanism/client/MekKeyHandler.java +++ b/src/main/java/mekanism/client/MekKeyHandler.java @@ -71,13 +71,14 @@ public abstract class MekKeyHandler { public abstract void keyUp(KeyBinding kb); protected static class Builder { + private List bindings = new ArrayList<>(4); private BitSet repeatFlags = new BitSet(); /** * Add a keybinding to the list * - * @param k the KeyBinding to add + * @param k the KeyBinding to add * @param repeatFlag true if keyDown pseudo-events continue to be sent while key is held */ protected Builder addBinding(KeyBinding k, boolean repeatFlag) { @@ -94,4 +95,4 @@ public abstract class MekKeyHandler { return bindings.toArray(new KeyBinding[0]); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/MekanismClient.java b/src/main/java/mekanism/client/MekanismClient.java index 3748d9dca..fccbed60d 100644 --- a/src/main/java/mekanism/client/MekanismClient.java +++ b/src/main/java/mekanism/client/MekanismClient.java @@ -27,7 +27,6 @@ public class MekanismClient extends Mekanism { public static void updateKey(KeyBinding key, int type) { boolean down = Minecraft.getMinecraft().currentScreen == null && key.isKeyDown(); - if (down != keyMap.has(Minecraft.getMinecraft().player, type)) { Mekanism.packetHandler.sendToServer(new KeyMessage(type, down)); keyMap.update(Minecraft.getMinecraft().player, type, down); @@ -67,4 +66,4 @@ public class MekanismClient extends Mekanism { module.resetClient(); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/MekanismKeyHandler.java b/src/main/java/mekanism/client/MekanismKeyHandler.java index c6f51db40..82f8f7c3b 100644 --- a/src/main/java/mekanism/client/MekanismKeyHandler.java +++ b/src/main/java/mekanism/client/MekanismKeyHandler.java @@ -54,11 +54,10 @@ public class MekanismKeyHandler extends MekKeyHandler { public static KeyBinding jumpKey = Minecraft.getMinecraft().gameSettings.keyBindJump; private static Builder BINDINGS = new Builder() - .addBinding(modeSwitchKey, false) - .addBinding(armorModeSwitchKey, false) - .addBinding(freeRunnerModeSwitchKey, false) - .addBinding(voiceKey, true) - ; + .addBinding(modeSwitchKey, false) + .addBinding(armorModeSwitchKey, false) + .addBinding(freeRunnerModeSwitchKey, false) + .addBinding(voiceKey, true); public MekanismKeyHandler() { super(BINDINGS); @@ -81,51 +80,35 @@ public class MekanismKeyHandler extends MekKeyHandler { if (kb == modeSwitchKey) { EntityPlayer player = FMLClientHandler.instance().getClient().player; ItemStack toolStack = player.inventory.getCurrentItem(); - Item item = toolStack.getItem(); if (player.isSneaking() && item instanceof ItemConfigurator) { ItemConfigurator configurator = (ItemConfigurator) item; - ConfiguratorMode configuratorMode = configurator.getState(toolStack); int toSet = (configuratorMode.ordinal() + 1) % ConfiguratorMode.values().length; configuratorMode = ConfiguratorMode.values()[toSet]; configurator.setState(toolStack, configuratorMode); - Mekanism.packetHandler.sendToServer(new ItemStackMessage(EnumHand.MAIN_HAND, Collections.singletonList(toSet))); - - player.sendMessage( - new TextComponentGroup(TextFormatting.GRAY) - .string(Mekanism.LOG_TAG, TextFormatting.DARK_BLUE).string(" ") - .translation("mekanism.tooltip.configureState", LangUtils.withColor(configuratorMode.getNameComponent(), configuratorMode.getColor().textFormatting)) - ); + player.sendMessage(new TextComponentGroup(TextFormatting.GRAY).string(Mekanism.LOG_TAG, TextFormatting.DARK_BLUE).string(" ") + .translation("mekanism.tooltip.configureState", LangUtils.withColor(configuratorMode.getNameComponent(), configuratorMode.getColor().textFormatting))); } else if (player.isSneaking() && item instanceof ItemElectricBow) { ItemElectricBow bow = (ItemElectricBow) item; - boolean newBowState = !bow.getFireState(toolStack); bow.setFireState(toolStack, newBowState); Mekanism.packetHandler.sendToServer(new ItemStackMessage(EnumHand.MAIN_HAND, Collections.singletonList(newBowState))); - player.sendMessage( - new TextComponentGroup(TextFormatting.GRAY) - .string(Mekanism.LOG_TAG, TextFormatting.DARK_BLUE).string(" ") - .translation("mekanism.tooltip.fireMode", LangUtils.onOffColoured(newBowState)) - ); + player.sendMessage(new TextComponentGroup(TextFormatting.GRAY).string(Mekanism.LOG_TAG, TextFormatting.DARK_BLUE).string(" ") + .translation("mekanism.tooltip.fireMode", LangUtils.onOffColoured(newBowState))); } else if (player.isSneaking() && item instanceof ItemBlockMachine) { ItemBlockMachine machine = (ItemBlockMachine) item; - if (MachineType.get(toolStack) == MachineType.FLUID_TANK) { boolean newBucketMode = !machine.getBucketMode(toolStack); machine.setBucketMode(toolStack, newBucketMode); Mekanism.packetHandler.sendToServer(new ItemStackMessage(EnumHand.MAIN_HAND, Collections.singletonList(machine.getBucketMode(toolStack)))); - player.sendMessage( - new TextComponentGroup(TextFormatting.GRAY) - .string(Mekanism.LOG_TAG, TextFormatting.DARK_BLUE).string(" ") - .translation("mekanism.tooltip.portableTank.bucketMode", LangUtils.onOffColoured(newBucketMode)) - ); + player.sendMessage(new TextComponentGroup(TextFormatting.GRAY).string(Mekanism.LOG_TAG, TextFormatting.DARK_BLUE).string(" ") + .translation("mekanism.tooltip.portableTank.bucketMode", LangUtils.onOffColoured(newBucketMode))); } } else if (player.isSneaking() && item instanceof ItemWalkieTalkie) { ItemWalkieTalkie wt = (ItemWalkieTalkie) item; - if (wt.getOn(toolStack)) { int newChan = wt.getChannel(toolStack) + 1; if (newChan == 9) { @@ -136,14 +119,10 @@ public class MekanismKeyHandler extends MekKeyHandler { } } else if (player.isSneaking() && item instanceof ItemFlamethrower) { ItemFlamethrower flamethrower = (ItemFlamethrower) item; - flamethrower.incrementMode(toolStack); Mekanism.packetHandler.sendToServer(new FlamethrowerDataMessage(FlamethrowerPacket.MODE, EnumHand.MAIN_HAND, null, false)); - player.sendMessage( - new TextComponentGroup(TextFormatting.GRAY) - .string(Mekanism.LOG_TAG, TextFormatting.DARK_BLUE).string(" ") - .translation("mekanism.tooltip.flamethrower.modeBump", flamethrower.getMode(toolStack).getTextComponent()) - ); + player.sendMessage(new TextComponentGroup(TextFormatting.GRAY).string(Mekanism.LOG_TAG, TextFormatting.DARK_BLUE).string(" ") + .translation("mekanism.tooltip.flamethrower.modeBump", flamethrower.getMode(toolStack).getTextComponent())); } } else if (kb == armorModeSwitchKey) { EntityPlayer player = FMLClientHandler.instance().getClient().player; @@ -152,7 +131,6 @@ public class MekanismKeyHandler extends MekKeyHandler { if (chestItem instanceof ItemJetpack) { ItemJetpack jetpack = (ItemJetpack) chestItem; - if (player.isSneaking()) { jetpack.setMode(chestStack, JetpackMode.DISABLED); } else { @@ -163,7 +141,6 @@ public class MekanismKeyHandler extends MekKeyHandler { SoundHandler.playSound(MekanismSounds.HYDRAULIC); } else if (chestItem instanceof ItemScubaTank) { ItemScubaTank scubaTank = (ItemScubaTank) chestItem; - scubaTank.toggleFlowing(chestStack); Mekanism.packetHandler.sendToServer(ScubaTankDataMessage.MODE_CHANGE(false)); SoundHandler.playSound(MekanismSounds.HYDRAULIC); @@ -175,13 +152,11 @@ public class MekanismKeyHandler extends MekKeyHandler { if (feetItem instanceof ItemFreeRunners) { ItemFreeRunners freeRunners = (ItemFreeRunners) feetItem; - if (player.isSneaking()) { freeRunners.setMode(feetStack, ItemFreeRunners.FreeRunnerMode.DISABLED); } else { freeRunners.incrementMode(feetStack); } - Mekanism.packetHandler.sendToServer(new FreeRunnerDataMessage(PacketFreeRunnerData.FreeRunnerPacket.MODE, null, player.isSneaking())); SoundHandler.playSound(MekanismSounds.HYDRAULIC); } @@ -191,4 +166,4 @@ public class MekanismKeyHandler extends MekKeyHandler { @Override public void keyUp(KeyBinding kb) { } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/SparkleAnimation.java b/src/main/java/mekanism/client/SparkleAnimation.java index 5cc8976e1..1c6234927 100644 --- a/src/main/java/mekanism/client/SparkleAnimation.java +++ b/src/main/java/mekanism/client/SparkleAnimation.java @@ -38,9 +38,7 @@ public class SparkleAnimation { public void run() { if (MekanismConfig.current().general.dynamicTankEasterEgg.val()) { - tile.getWorld() - .playSound(null, tile.getPos().getX(), tile.getPos().getY(), tile.getPos().getZ(), - MekanismSounds.CJ_EASTER_EGG, SoundCategory.BLOCKS, 1F, 1F); + tile.getWorld().playSound(null, tile.getPos().getX(), tile.getPos().getY(), tile.getPos().getZ(), MekanismSounds.CJ_EASTER_EGG, SoundCategory.BLOCKS, 1F, 1F); } // Using the provided radius, get an iterable over all the positions within the radius @@ -61,19 +59,20 @@ public class SparkleAnimation { } for (int i = 0; i < 2; i++) { - world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + random.nextDouble(), - pos.getY() + random.nextDouble(), pos.getZ() + -.01, 0, 0, 0); - world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + random.nextDouble(), - pos.getY() + random.nextDouble(), pos.getZ() + 1.01, 0, 0, 0); - world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + -.01, - pos.getY() + random.nextDouble(), pos.getZ() + random.nextDouble(), 0, 0, 0); - world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 1.01, - pos.getY() + random.nextDouble(), pos.getZ() + random.nextDouble(), 0, 0, 0); + world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + random.nextDouble(), pos.getY() + random.nextDouble(), + pos.getZ() + -.01, 0, 0, 0); + world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + random.nextDouble(), pos.getY() + random.nextDouble(), + pos.getZ() + 1.01, 0, 0, 0); + world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + -.01, pos.getY() + random.nextDouble(), + pos.getZ() + random.nextDouble(), 0, 0, 0); + world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 1.01, pos.getY() + random.nextDouble(), + pos.getZ() + random.nextDouble(), 0, 0, 0); } } } public interface INodeChecker { + boolean isNode(TileEntity tile); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/entity/ParticleLaser.java b/src/main/java/mekanism/client/entity/ParticleLaser.java index 1c0a6fcfc..37ecb8584 100644 --- a/src/main/java/mekanism/client/entity/ParticleLaser.java +++ b/src/main/java/mekanism/client/entity/ParticleLaser.java @@ -17,8 +17,8 @@ import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class ParticleLaser extends Particle { - double length; - EnumFacing direction; + private double length; + private EnumFacing direction; public ParticleLaser(World world, Pos3D start, Pos3D end, EnumFacing dir, double energy) { super(world, (start.x + end.x) / 2D, (start.y + end.y) / 2D, (start.z + end.z) / 2D); @@ -34,8 +34,7 @@ public class ParticleLaser extends Particle { } @Override - public void renderParticle(BufferBuilder worldRendererIn, Entity entityIn, float partialTicks, float p_180434_4_, - float p_180434_5_, float p_180434_6_, float p_180434_7_, float p_180434_8_) { + public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) { Tessellator tessellator = Tessellator.getInstance(); tessellator.draw(); @@ -72,26 +71,26 @@ public class ParticleLaser extends Particle { float vMax = particleTexture.getInterpolatedV(16); GlStateManager.rotate(45, 0, 1, 0); - worldRendererIn.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP); - worldRendererIn.pos(-particleScale, -length / 2, 0).tex(uMin, vMin) + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP); + buffer.pos(-particleScale, -length / 2, 0).tex(uMin, vMin) .color(particleRed, particleGreen, particleBlue, particleAlpha).lightmap(240, 240).endVertex(); - worldRendererIn.pos(-particleScale, length / 2, 0).tex(uMin, vMax) + buffer.pos(-particleScale, length / 2, 0).tex(uMin, vMax) .color(particleRed, particleGreen, particleBlue, particleAlpha).lightmap(240, 240).endVertex(); - worldRendererIn.pos(particleScale, length / 2, 0).tex(uMax, vMax) + buffer.pos(particleScale, length / 2, 0).tex(uMax, vMax) .color(particleRed, particleGreen, particleBlue, particleAlpha).lightmap(240, 240).endVertex(); - worldRendererIn.pos(particleScale, -length / 2, 0).tex(uMax, vMin) + buffer.pos(particleScale, -length / 2, 0).tex(uMax, vMin) .color(particleRed, particleGreen, particleBlue, particleAlpha).lightmap(240, 240).endVertex(); tessellator.draw(); GlStateManager.rotate(90, 0, 1, 0); - worldRendererIn.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP); - worldRendererIn.pos(-particleScale, -length / 2, 0).tex(uMin, vMin) + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP); + buffer.pos(-particleScale, -length / 2, 0).tex(uMin, vMin) .color(particleRed, particleGreen, particleBlue, particleAlpha).lightmap(240, 240).endVertex(); - worldRendererIn.pos(-particleScale, length / 2, 0).tex(uMin, vMax) + buffer.pos(-particleScale, length / 2, 0).tex(uMin, vMax) .color(particleRed, particleGreen, particleBlue, particleAlpha).lightmap(240, 240).endVertex(); - worldRendererIn.pos(particleScale, length / 2, 0).tex(uMax, vMax) + buffer.pos(particleScale, length / 2, 0).tex(uMax, vMax) .color(particleRed, particleGreen, particleBlue, particleAlpha).lightmap(240, 240).endVertex(); - worldRendererIn.pos(particleScale, -length / 2, 0).tex(uMax, vMin) + buffer.pos(particleScale, -length / 2, 0).tex(uMax, vMin) .color(particleRed, particleGreen, particleBlue, particleAlpha).lightmap(240, 240).endVertex(); tessellator.draw(); @@ -99,11 +98,11 @@ public class ParticleLaser extends Particle { GL11.glPopAttrib(); GlStateManager.popMatrix(); - worldRendererIn.begin(7, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP); + buffer.begin(7, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP); } @Override public int getFXLayer() { return 1; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/ConfigGuiFactory.java b/src/main/java/mekanism/client/gui/ConfigGuiFactory.java index 4a94f98cf..1003b04a3 100644 --- a/src/main/java/mekanism/client/gui/ConfigGuiFactory.java +++ b/src/main/java/mekanism/client/gui/ConfigGuiFactory.java @@ -11,8 +11,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; public class ConfigGuiFactory implements IModGuiFactory { @Override - public void initialize(Minecraft minecraftInstance) { - + public void initialize(Minecraft instance) { } @Override @@ -29,4 +28,4 @@ public class ConfigGuiFactory implements IModGuiFactory { public GuiScreen createConfigGui(GuiScreen parentScreen) { return new GuiMekanismConfig(parentScreen); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/GuiAdvancedElectricMachine.java b/src/main/java/mekanism/client/gui/GuiAdvancedElectricMachine.java index c73277247..7c4c8d926 100644 --- a/src/main/java/mekanism/client/gui/GuiAdvancedElectricMachine.java +++ b/src/main/java/mekanism/client/gui/GuiAdvancedElectricMachine.java @@ -41,8 +41,7 @@ public class GuiAdvancedElectricMachine extends GuiMekanismTile { String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); return Arrays.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", - LangUtils.localize("gui.needed") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); + LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); }, this, resource)); addGuiElement(new GuiSlot(SlotType.INPUT, this, resource, 55, 16)); addGuiElement(new GuiSlot(SlotType.POWER, this, resource, 30, 34).with(SlotOverlay.POWER)); @@ -62,15 +61,13 @@ public class GuiAdvancedElectricMachine extends GuiMekanismTile= 61 && xAxis <= 67 && yAxis >= 37 && yAxis <= 49) { - drawHoveringText(tileEntity.gasTank.getGas() != null ? - tileEntity.gasTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.gasTank.getStored() - : LangUtils.localize("gui.none"), xAxis, yAxis); + drawHoveringText(tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.gasTank.getStored() + : LangUtils.localize("gui.none"), xAxis, yAxis); } super.drawGuiContainerForegroundLayer(mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/GuiBoilerStats.java b/src/main/java/mekanism/client/gui/GuiBoilerStats.java index 96a7efe15..f6fff8c01 100644 --- a/src/main/java/mekanism/client/gui/GuiBoilerStats.java +++ b/src/main/java/mekanism/client/gui/GuiBoilerStats.java @@ -32,38 +32,28 @@ public class GuiBoilerStats extends GuiMekanismTile { addGuiElement(new GuiBoilerTab(this, tileEntity, BoilerTab.MAIN, 6, resource)); addGuiElement(new GuiHeatInfo(() -> { TemperatureUnit unit = TemperatureUnit.values()[MekanismConfig.current().general.tempUnit.val().ordinal()]; - String environment = UnitDisplayUtils - .getDisplayShort(tileEntity.structure.lastEnvironmentLoss * unit.intervalSize, false, unit); + String environment = UnitDisplayUtils.getDisplayShort(tileEntity.structure.lastEnvironmentLoss * unit.intervalSize, false, unit); return Collections.singletonList(LangUtils.localize("gui.dissipated") + ": " + environment + "/t"); }, this, resource)); addGuiElement(boilGraph = new GuiGraph(this, resource, 8, 83, 160, 36, data -> LangUtils.localize("gui.boilRate") + ": " + data + " mB/t")); addGuiElement(maxGraph = new GuiGraph(this, resource, 8, 122, 160, 36, data -> LangUtils.localize("gui.maxBoil") + ": " + data + " mB/t")); - maxGraph.enableFixedScale((int) ( - (tileEntity.structure.superheatingElements * MekanismConfig.current().general.superheatingHeatTransfer - .val()) / SynchronizedBoilerData.getHeatEnthalpy())); + maxGraph.enableFixedScale((int) ((tileEntity.structure.superheatingElements * MekanismConfig.current().general.superheatingHeatTransfer.val()) / + SynchronizedBoilerData.getHeatEnthalpy())); } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { String stats = LangUtils.localize("gui.boilerStats"); fontRenderer.drawString(stats, (xSize / 2) - (fontRenderer.getStringWidth(stats) / 2), 6, 0x404040); - fontRenderer - .drawString(LangUtils.localize("gui.maxWater") + ": " + tileEntity.clientWaterCapacity + " mB", 8, 26, - 0x404040); - fontRenderer - .drawString(LangUtils.localize("gui.maxSteam") + ": " + tileEntity.clientSteamCapacity + " mB", 8, 35, - 0x404040); + fontRenderer.drawString(LangUtils.localize("gui.maxWater") + ": " + tileEntity.clientWaterCapacity + " mB", 8, 26, 0x404040); + fontRenderer.drawString(LangUtils.localize("gui.maxSteam") + ": " + tileEntity.clientSteamCapacity + " mB", 8, 35, 0x404040); fontRenderer.drawString(LangUtils.localize("gui.heatTransfer"), 8, 49, 0x797979); - fontRenderer - .drawString(LangUtils.localize("gui.superheaters") + ": " + tileEntity.structure.superheatingElements, 14, - 58, 0x404040); - int boilCapacity = (int) ((tileEntity.structure.superheatingElements * - MekanismConfig.current().general.superheatingHeatTransfer.val()) / SynchronizedBoilerData - .getHeatEnthalpy()); - fontRenderer - .drawString(LangUtils.localize("gui.boilCapacity") + ": " + boilCapacity + " mB/t", 8, 72, 0x404040); + fontRenderer.drawString(LangUtils.localize("gui.superheaters") + ": " + tileEntity.structure.superheatingElements, 14, 58, 0x404040); + int boilCapacity = (int) ((tileEntity.structure.superheatingElements * MekanismConfig.current().general.superheatingHeatTransfer.val()) / + SynchronizedBoilerData.getHeatEnthalpy()); + fontRenderer.drawString(LangUtils.localize("gui.boilCapacity") + ": " + boilCapacity + " mB/t", 8, 72, 0x404040); super.drawGuiContainerForegroundLayer(mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/GuiChanceMachine.java b/src/main/java/mekanism/client/gui/GuiChanceMachine.java index 238d9e1f2..d60d3a897 100644 --- a/src/main/java/mekanism/client/gui/GuiChanceMachine.java +++ b/src/main/java/mekanism/client/gui/GuiChanceMachine.java @@ -39,8 +39,7 @@ public class GuiChanceMachine extends GuiMekanismTile { addGuiElement(new GuiEnergyInfo(() -> { String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); return Arrays.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", - LangUtils.localize("gui.needed") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); + LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); }, this, resource)); addGuiElement(new GuiSlot(SlotType.INPUT, this, resource, 55, 16)); addGuiElement(new GuiSlot(SlotType.POWER, this, resource, 55, 52).with(SlotOverlay.POWER)); diff --git a/src/main/java/mekanism/client/gui/GuiDictionary.java b/src/main/java/mekanism/client/gui/GuiDictionary.java index ef827a957..2181d33a8 100644 --- a/src/main/java/mekanism/client/gui/GuiDictionary.java +++ b/src/main/java/mekanism/client/gui/GuiDictionary.java @@ -78,8 +78,8 @@ public class GuiDictionary extends GuiMekanism { @Override protected void mouseClicked(int mouseX, int mouseY, int button) throws IOException { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; if (button == 0) { if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { @@ -87,7 +87,6 @@ public class GuiDictionary extends GuiMekanism { for (int i = 0; i < inventorySlots.inventorySlots.size(); i++) { Slot slot = inventorySlots.inventorySlots.get(i); - if (isMouseOverSlot(slot, mouseX, mouseY)) { hovering = slot; break; @@ -96,14 +95,11 @@ public class GuiDictionary extends GuiMekanism { if (hovering != null) { ItemStack stack = hovering.getStack(); - if (!stack.isEmpty()) { itemType = stack.copy(); itemType.setCount(1); - scrollList.setText(OreDictCache.getOreDictName(itemType)); SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - return; } } @@ -115,18 +111,15 @@ public class GuiDictionary extends GuiMekanism { if (!stack.isEmpty() && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { itemType = stack.copy(); itemType.setCount(1); - scrollList.setText(OreDictCache.getOreDictName(itemType)); } else if (stack.isEmpty() && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { itemType = ItemStack.EMPTY; - scrollList.setText(null); } SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); } } - super.mouseClicked(mouseX, mouseY, button); } diff --git a/src/main/java/mekanism/client/gui/GuiDigitalMiner.java b/src/main/java/mekanism/client/gui/GuiDigitalMiner.java index 3c86789ad..90978a0eb 100644 --- a/src/main/java/mekanism/client/gui/GuiDigitalMiner.java +++ b/src/main/java/mekanism/client/gui/GuiDigitalMiner.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.util.ArrayList; import mekanism.api.Coord4D; import mekanism.api.EnumColor; +import mekanism.api.TileNetworkList; import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiRedstoneControl; @@ -16,7 +17,6 @@ import mekanism.client.gui.element.GuiVisualsTab; import mekanism.client.render.MekanismRenderer; import mekanism.client.sound.SoundHandler; import mekanism.common.Mekanism; -import mekanism.api.TileNetworkList; import mekanism.common.content.miner.ThreadMinerSearch.State; import mekanism.common.inventory.container.ContainerDigitalMiner; import mekanism.common.network.PacketDigitalMinerGui.DigitalMinerGuiMessage; @@ -57,14 +57,12 @@ public class GuiDigitalMiner extends GuiMekanismTile { double perTick = tileEntity.getPerTick(); String multiplier = MekanismUtils.getEnergyDisplay(perTick); ArrayList ret = new ArrayList<>(4); - ret.add(LangUtils.localize("mekanism.gui.digitalMiner.capacity") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getMaxEnergy())); + ret.add(LangUtils.localize("mekanism.gui.digitalMiner.capacity") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy())); ret.add(LangUtils.localize("gui.needed") + ": " + multiplier + "/t"); if (perTick > tileEntity.getMaxEnergy()) { ret.add(TextFormatting.RED + LangUtils.localize("mekanism.gui.insufficientbuffer")); } - ret.add(LangUtils.localize("mekanism.gui.bufferfree") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); + ret.add(LangUtils.localize("mekanism.gui.bufferfree") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); return ret; }, this, resource)); addGuiElement(new GuiSlot(SlotType.NORMAL, this, resource, 151, 5).with(SlotOverlay.POWER)); @@ -105,8 +103,7 @@ public class GuiDigitalMiner extends GuiMekanismTile { TileNetworkList data = TileNetworkList.withContents(4); Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); } else if (guibutton.id == 2) { - Mekanism.packetHandler - .sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0)); + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0)); } } @@ -133,14 +130,9 @@ public class GuiDigitalMiner extends GuiMekanismTile { fontRenderer.drawString(runningType, 9, 10, 0x00CD00); fontRenderer.drawString(tileEntity.searcher.state.desc, 9, 19, 0x00CD00); - fontRenderer.drawString( - LangUtils.localize("gui.eject") + ": " + LangUtils.localize("gui." + (tileEntity.doEject ? "on" : "off")), - 9, 30, 0x00CD00); - fontRenderer.drawString(LangUtils.localize("gui.digitalMiner.pull") + ": " + LangUtils - .localize("gui." + (tileEntity.doPull ? "on" : "off")), 9, 39, 0x00CD00); - fontRenderer.drawString(LangUtils.localize("gui.digitalMiner.silk") + ": " + LangUtils - .localize("gui." + (tileEntity.silkTouch ? "on" : "off")), 9, 48, 0x00CD00); - + fontRenderer.drawString(LangUtils.localize("gui.eject") + ": " + LangUtils.localize("gui." + (tileEntity.doEject ? "on" : "off")), 9, 30, 0x00CD00); + fontRenderer.drawString(LangUtils.localize("gui.digitalMiner.pull") + ": " + LangUtils.localize("gui." + (tileEntity.doPull ? "on" : "off")), 9, 39, 0x00CD00); + fontRenderer.drawString(LangUtils.localize("gui.digitalMiner.silk") + ": " + LangUtils.localize("gui." + (tileEntity.silkTouch ? "on" : "off")), 9, 48, 0x00CD00); fontRenderer.drawString(LangUtils.localize("gui.digitalMiner.toMine") + ":", 9, 59, 0x00CD00); fontRenderer.drawString("" + tileEntity.clientToMine, 9, 68, 0x00CD00); @@ -152,7 +144,6 @@ public class GuiDigitalMiner extends GuiMekanismTile { mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); drawTexturedRectFromIcon(144, 27, MekanismRenderer.getColorIcon(EnumColor.DARK_RED), 16, 16); itemRender.renderItemAndEffectIntoGUI(tileEntity.missingStack, 144, 27); - RenderHelper.disableStandardItemLighting(); GlStateManager.popMatrix(); } else { @@ -160,11 +151,10 @@ public class GuiDigitalMiner extends GuiMekanismTile { drawTexturedModalRect(143, 26, SlotOverlay.CHECK.textureX, SlotOverlay.CHECK.textureY, 18, 18); } - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; if (xAxis >= 164 && xAxis <= 168 && yAxis >= 25 && yAxis <= 77) { - drawHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), xAxis, - yAxis); + drawHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), xAxis, yAxis); } if (xAxis >= 147 && xAxis <= 161 && yAxis >= 47 && yAxis <= 61) { drawHoveringText(LangUtils.localize("gui.autoEject"), xAxis, yAxis); @@ -198,10 +188,7 @@ public class GuiDigitalMiner extends GuiMekanismTile { int xAxis = mouseX - guiWidth; int yAxis = mouseY - guiHeight; - - int displayInt; - - displayInt = tileEntity.getScaledEnergyLevel(52); + int 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) { @@ -227,47 +214,36 @@ public class GuiDigitalMiner extends GuiMekanismTile { } else { drawTexturedModalRect(guiWidth + 131, guiHeight + 63, 176 + 4 + 42, 14, 14, 14); } - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); } @Override protected void mouseClicked(int mouseX, int mouseY, int button) throws IOException { super.mouseClicked(mouseX, mouseY, button); - if (button == 0) { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; if (xAxis >= 147 && xAxis <= 161 && yAxis >= 47 && yAxis <= 61) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - TileNetworkList data = TileNetworkList.withContents(0); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); } if (xAxis >= 147 && xAxis <= 161 && yAxis >= 63 && yAxis <= 77) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - TileNetworkList data = TileNetworkList.withContents(1); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); } if (xAxis >= 131 && xAxis <= 145 && yAxis >= 47 && yAxis <= 61) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - TileNetworkList data = TileNetworkList.withContents(5); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); } if (xAxis >= 131 && xAxis <= 145 && yAxis >= 63 && yAxis <= 77) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - TileNetworkList data = TileNetworkList.withContents(9); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); } } diff --git a/src/main/java/mekanism/client/gui/GuiDigitalMinerConfig.java b/src/main/java/mekanism/client/gui/GuiDigitalMinerConfig.java index e0dbf32d6..7f94693d2 100644 --- a/src/main/java/mekanism/client/gui/GuiDigitalMinerConfig.java +++ b/src/main/java/mekanism/client/gui/GuiDigitalMinerConfig.java @@ -81,7 +81,6 @@ public class GuiDigitalMinerConfig extends GuiMekanismTile entry : oreDictStacks.entrySet()) { if (entry.getValue().iterStacks != null && entry.getValue().iterStacks.size() > 0) { - if (entry.getValue().stackIndex == -1 - || entry.getValue().stackIndex == entry.getValue().iterStacks.size() - 1) { + if (entry.getValue().stackIndex == -1 || entry.getValue().stackIndex == entry.getValue().iterStacks.size() - 1) { entry.getValue().stackIndex = 0; } else if (entry.getValue().stackIndex < entry.getValue().iterStacks.size() - 1) { entry.getValue().stackIndex++; } - entry.getValue().renderStack = entry.getValue().iterStacks.get(entry.getValue().stackIndex); } } for (Map.Entry entry : modIDStacks.entrySet()) { if (entry.getValue().iterStacks != null && entry.getValue().iterStacks.size() > 0) { - if (entry.getValue().stackIndex == -1 - || entry.getValue().stackIndex == entry.getValue().iterStacks.size() - 1) { + if (entry.getValue().stackIndex == -1 || entry.getValue().stackIndex == entry.getValue().iterStacks.size() - 1) { entry.getValue().stackIndex = 0; } else if (entry.getValue().stackIndex < entry.getValue().iterStacks.size() - 1) { entry.getValue().stackIndex++; } - entry.getValue().renderStack = entry.getValue().iterStacks.get(entry.getValue().stackIndex); } } @@ -131,7 +126,6 @@ public class GuiDigitalMinerConfig extends GuiMekanismTile entry : modIDStacks.entrySet()) { if (entry.getValue().iterStacks != null && entry.getValue().iterStacks.size() == 0) { entry.getValue().renderStack = ItemStack.EMPTY; @@ -168,8 +162,8 @@ public class GuiDigitalMinerConfig extends GuiMekanismTile= 154 && xAxis <= 166 && yAxis >= getScroll() + 18 && yAxis <= getScroll() + 18 + 15) { if (needsScrollBars()) { @@ -191,10 +185,8 @@ public class GuiDigitalMinerConfig extends GuiMekanismTile= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 14 && yAxis <= yStart + 20) { // Process up button click final TileNetworkList data = TileNetworkList.withContents(11, getFilterIndex() + i); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - return; } } @@ -203,10 +195,8 @@ public class GuiDigitalMinerConfig extends GuiMekanismTile= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 21 && yAxis <= yStart + 27) { // Process down button click final TileNetworkList data = TileNetworkList.withContents(12, getFilterIndex() + i); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - return; } } @@ -216,24 +206,16 @@ public class GuiDigitalMinerConfig extends GuiMekanismTile= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - Mekanism.packetHandler.sendToServer( - new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 4, 0, 0)); + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 4, 0, 0)); } if (xAxis >= 39 && xAxis <= 50 && yAxis >= 67 && yAxis <= 78) { @@ -262,7 +243,6 @@ public class GuiDigitalMinerConfig extends GuiMekanismTile= 11 && xAxis <= 25 && yAxis >= 141 && yAxis <= 155) { TileNetworkList data = TileNetworkList.withContents(10); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); } @@ -273,7 +253,7 @@ public class GuiDigitalMinerConfig extends GuiMekanismTile 0) { i = 1; - } - - if (i < 0) { + } else { i = -1; } - scroll = (float) (scroll - (double) i / (double) j); - if (scroll < 0.0F) { scroll = 0.0F; - } - - if (scroll > 1.0F) { + } else if (scroll > 1.0F) { scroll = 1.0F; } } @@ -328,7 +298,6 @@ public class GuiDigitalMinerConfig extends GuiMekanismTile= 11 && xAxis <= 25 && yAxis >= 141 && yAxis <= 155) { drawHoveringText(LangUtils.localize("gui.digitalMiner.inverse"), xAxis, yAxis); } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); } @@ -474,12 +421,10 @@ public class GuiDigitalMinerConfig extends GuiMekanismTile { String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); return Arrays.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", - LangUtils.localize("gui.needed") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); + LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); }, this, resource)); addGuiElement(new GuiSlot(SlotType.INPUT, this, resource, 55, 16)); addGuiElement(new GuiSlot(SlotType.POWER, this, resource, 30, 34).with(SlotOverlay.POWER)); @@ -60,9 +59,7 @@ public class GuiDoubleElectricMachine extends GuiMekanismTile @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - fontRenderer - .drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), - 6, 0x404040); + fontRenderer.drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), 6, 0x404040); fontRenderer.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040); - fontRenderer.drawString( - LangUtils.localize("gui.volume") + ": " + tileEntity.clientCapacity / TankUpdateProtocol.FLUID_PER_TANK, - 53, 26, 0x00CD00); - renderScaledText( - tileEntity.structure.fluidStored != null ? LangUtils.localizeFluidStack(tileEntity.structure.fluidStored) - + ":" : LangUtils.localize("gui.noFluid"), 53, 44, 0x00CD00, 74); + fontRenderer.drawString(LangUtils.localize("gui.volume") + ": " + tileEntity.clientCapacity / TankUpdateProtocol.FLUID_PER_TANK, 53, 26, 0x00CD00); + renderScaledText(tileEntity.structure.fluidStored != null ? LangUtils.localizeFluidStack(tileEntity.structure.fluidStored) + + ":" : LangUtils.localize("gui.noFluid"), 53, 44, 0x00CD00, 74); if (tileEntity.structure.fluidStored != null) { fontRenderer.drawString(tileEntity.structure.fluidStored.amount + "mB", 53, 53, 0x00CD00); } - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; if (xAxis >= 7 && xAxis <= 39 && yAxis >= 14 && yAxis <= 72) { - drawHoveringText(tileEntity.structure.fluidStored != null ? - LangUtils.localizeFluidStack(tileEntity.structure.fluidStored) + ": " - + tileEntity.structure.fluidStored.amount + "mB" : LangUtils.localize("gui.empty"), xAxis, - yAxis); + drawHoveringText(tileEntity.structure.fluidStored != null + ? LangUtils.localizeFluidStack(tileEntity.structure.fluidStored) + ": " + tileEntity.structure.fluidStored.amount + "mB" + : LangUtils.localize("gui.empty"), xAxis, yAxis); } super.drawGuiContainerForegroundLayer(mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/GuiElectricMachine.java b/src/main/java/mekanism/client/gui/GuiElectricMachine.java index ef569ce94..577b60df6 100644 --- a/src/main/java/mekanism/client/gui/GuiElectricMachine.java +++ b/src/main/java/mekanism/client/gui/GuiElectricMachine.java @@ -39,8 +39,7 @@ public class GuiElectricMachine extends GuiMekanismTile { String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); return Arrays.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", - LangUtils.localize("gui.needed") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); + LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); }, this, resource)); addGuiElement(new GuiSlot(SlotType.INPUT, this, resource, 55, 16)); addGuiElement(new GuiSlot(SlotType.POWER, this, resource, 55, 52).with(SlotOverlay.POWER)); @@ -59,9 +58,7 @@ public class GuiElectricMachine extends GuiMekanismTile { addGuiElement(new GuiEnergyInfo(() -> { String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); return Arrays.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", - LangUtils.localize("gui.needed") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); + LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); }, this, resource)); addGuiElement(new GuiSecurityTab(this, tileEntity, resource)); addGuiElement(new GuiRedstoneControl(this, tileEntity, resource)); @@ -47,16 +46,12 @@ public class GuiElectricPump extends GuiMekanismTile { @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - fontRenderer - .drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), - 6, 0x404040); + fontRenderer.drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), 6, 0x404040); fontRenderer.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040); - fontRenderer - .drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), 51, 26, - 0x00CD00); - String text = - tileEntity.fluidTank.getFluid() != null ? LangUtils.localizeFluidStack(tileEntity.fluidTank.getFluid()) - + ": " + tileEntity.fluidTank.getFluid().amount : LangUtils.localize("gui.noFluid"); + fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), 51, 26, 0x00CD00); + String text = tileEntity.fluidTank.getFluid() != null + ? LangUtils.localizeFluidStack(tileEntity.fluidTank.getFluid()) + ": " + tileEntity.fluidTank.getFluid().amount + : LangUtils.localize("gui.noFluid"); renderScaledText(text, 51, 35, 0x00CD00, 74); super.drawGuiContainerForegroundLayer(mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/GuiElectrolyticSeparator.java b/src/main/java/mekanism/client/gui/GuiElectrolyticSeparator.java index 875a4920a..09fc3680e 100755 --- a/src/main/java/mekanism/client/gui/GuiElectrolyticSeparator.java +++ b/src/main/java/mekanism/client/gui/GuiElectrolyticSeparator.java @@ -3,6 +3,7 @@ package mekanism.client.gui; import java.io.IOException; import java.util.Arrays; import mekanism.api.Coord4D; +import mekanism.api.TileNetworkList; import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiFluidGauge; import mekanism.client.gui.element.GuiGasGauge; @@ -19,7 +20,6 @@ import mekanism.client.gui.element.GuiSlot.SlotType; import mekanism.client.gui.element.GuiUpgradeTab; import mekanism.client.sound.SoundHandler; import mekanism.common.Mekanism; -import mekanism.api.TileNetworkList; import mekanism.common.inventory.container.ContainerElectrolyticSeparator; import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.tile.TileEntityElectrolyticSeparator; @@ -45,8 +45,7 @@ public class GuiElectrolyticSeparator extends GuiMekanismTile { String usage = MekanismUtils.getEnergyDisplay(tileEntity.clientEnergyUsed); return Arrays.asList(LangUtils.localize("gui.using") + ": " + usage + "/t", - LangUtils.localize("gui.needed") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); + LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); }, this, resource)); addGuiElement(new GuiFluidGauge(() -> tileEntity.fluidTank, GuiGauge.Type.STANDARD, this, resource, 5, 10)); addGuiElement(new GuiGasGauge(() -> tileEntity.leftTank, GuiGauge.Type.SMALL, this, resource, 58, 18)); @@ -68,8 +67,8 @@ public class GuiElectrolyticSeparator extends GuiMekanismTile 8 && xAxis < 17 && yAxis > 73 && yAxis < 82) { TileNetworkList data = TileNetworkList.withContents((byte) 0); Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); @@ -89,13 +88,10 @@ public class GuiElectrolyticSeparator extends GuiMekanismTile { addGuiElement(new GuiSideConfigurationTab(this, tileEntity, resource)); addGuiElement(new GuiTransporterConfigTab(this, 34, tileEntity, resource)); addGuiElement(new GuiEnergyGauge(() -> tileEntity, GuiEnergyGauge.Type.WIDE, this, resource, 55, 18)); - addGuiElement(new GuiEnergyInfo(() -> Arrays.asList(LangUtils.localize("gui.storing") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), - LangUtils.localize("gui.maxOutput") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) - + "/t"), this, resource)); + addGuiElement(new GuiEnergyInfo(() -> Arrays.asList(LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), + LangUtils.localize("gui.maxOutput") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t"), this, resource)); addGuiElement(new GuiSlot(SlotType.INPUT, this, resource, 16, 34).with(SlotOverlay.MINUS)); addGuiElement(new GuiSlot(SlotType.OUTPUT, this, resource, 142, 34).with(SlotOverlay.PLUS)); } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - fontRenderer - .drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), - 6, 0x404040); + fontRenderer.drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), 6, 0x404040); fontRenderer.drawString(LangUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040); super.drawGuiContainerForegroundLayer(mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/GuiFactory.java b/src/main/java/mekanism/client/gui/GuiFactory.java index 7ae50bad6..a19e9434d 100644 --- a/src/main/java/mekanism/client/gui/GuiFactory.java +++ b/src/main/java/mekanism/client/gui/GuiFactory.java @@ -3,7 +3,9 @@ package mekanism.client.gui; import java.io.IOException; import java.util.Arrays; import mekanism.api.Coord4D; +import mekanism.api.TileNetworkList; import mekanism.api.gas.GasStack; +import mekanism.api.infuse.InfuseType; import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiRecipeType; import mekanism.client.gui.element.GuiRedstoneControl; @@ -15,13 +17,12 @@ import mekanism.client.gui.element.GuiUpgradeTab; import mekanism.client.render.MekanismRenderer; import mekanism.client.sound.SoundHandler; import mekanism.common.Mekanism; -import mekanism.common.tier.FactoryTier; import mekanism.common.base.IFactory.MachineFuelType; import mekanism.common.base.IFactory.RecipeType; -import mekanism.api.TileNetworkList; import mekanism.common.inventory.container.ContainerFactory; import mekanism.common.item.ItemGaugeDropper; import mekanism.common.network.PacketTileEntity.TileEntityMessage; +import mekanism.common.tier.FactoryTier; import mekanism.common.tile.TileEntityFactory; import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; @@ -52,32 +53,26 @@ public class GuiFactory extends GuiMekanismTile { addGuiElement(new GuiEnergyInfo(() -> { String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.lastUsage); return Arrays.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", - LangUtils.localize("gui.needed") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); + LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); }, this, resource)); } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - fontRenderer - .drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), - 4, 0x404040); + fontRenderer.drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), 4, 0x404040); fontRenderer.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 93) + 2, 0x404040); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; if (xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) { - drawHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), xAxis, - yAxis); + drawHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), xAxis, yAxis); } if (xAxis >= 8 && xAxis <= 168 && yAxis >= 78 && yAxis <= 83) { if (tileEntity.getRecipeType().getFuelType() == MachineFuelType.ADVANCED) { - drawHoveringText( - tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas().getLocalizedName() - + ": " + tileEntity.gasTank.getStored() : LangUtils.localize("gui.none"), xAxis, yAxis); + GasStack gasStack = tileEntity.gasTank.getGas(); + drawHoveringText(gasStack != null ? gasStack.getGas().getLocalizedName() + ": " + tileEntity.gasTank.getStored() : LangUtils.localize("gui.none"), xAxis, yAxis); } else if (tileEntity.getRecipeType() == RecipeType.INFUSING) { - drawHoveringText( - tileEntity.infuseStored.getType() != null ? tileEntity.infuseStored.getType().getLocalizedName() + ": " - + tileEntity.infuseStored.getAmount() : LangUtils.localize("gui.empty"), xAxis, yAxis); + InfuseType type = tileEntity.infuseStored.getType(); + drawHoveringText(type != null ? type.getLocalizedName() + ": " + tileEntity.infuseStored.getAmount() : LangUtils.localize("gui.empty"), xAxis, yAxis); } } super.drawGuiContainerForegroundLayer(mouseX, mouseY); @@ -92,8 +87,8 @@ public class GuiFactory extends GuiMekanismTile { drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); int displayInt = tileEntity.getScaledEnergyLevel(52); drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt); - int xOffset = tileEntity.tier == FactoryTier.BASIC ? 59 : (tileEntity.tier == FactoryTier.ADVANCED ? 39 : 33); - int xDistance = tileEntity.tier == FactoryTier.BASIC ? 38 : (tileEntity.tier == FactoryTier.ADVANCED ? 26 : 19); + int xOffset = tileEntity.tier == FactoryTier.BASIC ? 59 : tileEntity.tier == FactoryTier.ADVANCED ? 39 : 33; + int xDistance = tileEntity.tier == FactoryTier.BASIC ? 38 : tileEntity.tier == FactoryTier.ADVANCED ? 26 : 19; for (int i = 0; i < tileEntity.tier.processes; i++) { int xPos = xOffset + (i * xDistance); @@ -135,8 +130,8 @@ public class GuiFactory extends GuiMekanismTile { protected void mouseClicked(int x, int y, int button) throws IOException { super.mouseClicked(x, y, button); if (button == 0 || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - int xAxis = (x - (width - xSize) / 2); - int yAxis = (y - (height - ySize) / 2); + int xAxis = x - (width - xSize) / 2; + int yAxis = y - (height - ySize) / 2; if (xAxis > 8 && xAxis < 168 && yAxis > 78 && yAxis < 83) { ItemStack stack = mc.player.inventory.getItemStack(); if (!stack.isEmpty() && stack.getItem() instanceof ItemGaugeDropper) { diff --git a/src/main/java/mekanism/client/gui/GuiFluidTank.java b/src/main/java/mekanism/client/gui/GuiFluidTank.java index eab10b9dd..13f4d1713 100644 --- a/src/main/java/mekanism/client/gui/GuiFluidTank.java +++ b/src/main/java/mekanism/client/gui/GuiFluidTank.java @@ -32,9 +32,7 @@ public class GuiFluidTank extends GuiMekanismTile { @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - fontRenderer - .drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), - 6, 0x404040); + fontRenderer.drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), 6, 0x404040); fontRenderer.drawString(LangUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040); super.drawGuiContainerForegroundLayer(mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/GuiFluidicPlenisher.java b/src/main/java/mekanism/client/gui/GuiFluidicPlenisher.java index 9fa8b3b40..57ef551d1 100644 --- a/src/main/java/mekanism/client/gui/GuiFluidicPlenisher.java +++ b/src/main/java/mekanism/client/gui/GuiFluidicPlenisher.java @@ -18,6 +18,7 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import org.lwjgl.opengl.GL11; @@ -36,8 +37,7 @@ public class GuiFluidicPlenisher extends GuiMekanismTile { String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); return Arrays.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", - LangUtils.localize("gui.needed") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); + LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); }, this, resource)); addGuiElement(new GuiSecurityTab(this, tileEntity, resource)); addGuiElement(new GuiRedstoneControl(this, tileEntity, resource)); @@ -46,20 +46,12 @@ public class GuiFluidicPlenisher extends GuiMekanismTile { String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); return Arrays.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", - LangUtils.localize("gui.needed") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); + LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); }, this, resource)); addGuiElement(new GuiSlot(SlotType.POWER, this, resource, 151, 75).with(SlotOverlay.POWER)); ySize += 64; @@ -59,12 +58,10 @@ public class GuiFormulaicAssemblicator extends GuiMekanismTile= 44 && xAxis <= 60 && yAxis >= 75 && yAxis <= 91) { drawHoveringText(LangUtils.localize("gui.fillEmpty"), xAxis, yAxis); } @@ -78,12 +75,10 @@ public class GuiFormulaicAssemblicator extends GuiMekanismTile= 107 && xAxis <= 123 && yAxis >= 75 && yAxis <= 91) { - drawHoveringText(LangUtils.localize("gui.autoModeToggle") + ": " + - LangUtils.transOnOff(tileEntity.autoMode), xAxis, yAxis); + drawHoveringText(LangUtils.localize("gui.autoModeToggle") + ": " + LangUtils.transOnOff(tileEntity.autoMode), xAxis, yAxis); } if (xAxis >= 26 && xAxis <= 42 && yAxis >= 75 && yAxis <= 91) { - drawHoveringText(LangUtils.localize("gui.stockControl") + ": " + - LangUtils.transOnOff(tileEntity.stockControl), xAxis, yAxis); + drawHoveringText(LangUtils.localize("gui.stockControl") + ": " + LangUtils.transOnOff(tileEntity.stockControl), xAxis, yAxis); } super.drawGuiContainerForegroundLayer(mouseX, mouseY); } @@ -167,13 +162,14 @@ public class GuiFormulaicAssemblicator extends GuiMekanismTile= 44 && xAxis <= 60 && yAxis >= 75 && yAxis <= 91) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - TileNetworkList data = TileNetworkList.withContents(4); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); } @@ -211,26 +206,20 @@ public class GuiFormulaicAssemblicator extends GuiMekanismTile= 7 && xAxis <= 21 && yAxis >= 45 && yAxis <= 59) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - TileNetworkList data = TileNetworkList.withContents(1); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); } } if (xAxis >= 71 && xAxis <= 87 && yAxis >= 75 && yAxis <= 91) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - TileNetworkList data = TileNetworkList.withContents(2); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); } if (xAxis >= 89 && xAxis <= 105 && yAxis >= 75 && yAxis <= 91) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - TileNetworkList data = TileNetworkList.withContents(3); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); } } @@ -239,17 +228,13 @@ public class GuiFormulaicAssemblicator extends GuiMekanismTile= 107 && xAxis <= 123 && yAxis >= 75 && yAxis <= 91) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - TileNetworkList data = TileNetworkList.withContents(0); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); } if (xAxis >= 26 && xAxis <= 42 && yAxis >= 75 && yAxis <= 91) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - TileNetworkList data = TileNetworkList.withContents(5); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); } } diff --git a/src/main/java/mekanism/client/gui/GuiFuelwoodHeater.java b/src/main/java/mekanism/client/gui/GuiFuelwoodHeater.java index 379e2f6c9..a6653d8f7 100644 --- a/src/main/java/mekanism/client/gui/GuiFuelwoodHeater.java +++ b/src/main/java/mekanism/client/gui/GuiFuelwoodHeater.java @@ -29,20 +29,16 @@ public class GuiFuelwoodHeater extends GuiMekanismTile addGuiElement(new GuiSecurityTab(this, tileEntity, resource)); addGuiElement(new GuiHeatInfo(() -> { TemperatureUnit unit = TemperatureUnit.values()[MekanismConfig.current().general.tempUnit.val().ordinal()]; - String environment = UnitDisplayUtils - .getDisplayShort(tileEntity.lastEnvironmentLoss * unit.intervalSize, false, unit); + String environment = UnitDisplayUtils.getDisplayShort(tileEntity.lastEnvironmentLoss * unit.intervalSize, false, unit); return Collections.singletonList(LangUtils.localize("gui.dissipated") + ": " + environment + "/t"); }, this, resource)); } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - fontRenderer - .drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), - 6, 0x404040); + fontRenderer.drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), 6, 0x404040); fontRenderer.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040); - renderScaledText(LangUtils.localize("gui.temp") + ": " + MekanismUtils - .getTemperatureDisplay(tileEntity.temperature, TemperatureUnit.AMBIENT), 50, 25, 0x00CD00, 76); + renderScaledText(LangUtils.localize("gui.temp") + ": " + MekanismUtils.getTemperatureDisplay(tileEntity.temperature, TemperatureUnit.AMBIENT), 50, 25, 0x00CD00, 76); renderScaledText(LangUtils.localize("gui.fuel") + ": " + tileEntity.burnTime, 50, 41, 0x00CD00, 76); super.drawGuiContainerForegroundLayer(mouseX, mouseY); } @@ -56,8 +52,7 @@ public class GuiFuelwoodHeater extends GuiMekanismTile drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); if (tileEntity.burnTime > 0) { int displayInt = tileEntity.burnTime * 13 / tileEntity.maxBurnTime; - drawTexturedModalRect(guiWidth + 143, guiHeight + 30 + 12 - displayInt, 176, 12 - displayInt, 14, - displayInt + 1); + drawTexturedModalRect(guiWidth + 143, guiHeight + 30 + 12 - displayInt, 176, 12 - displayInt, 14, displayInt + 1); } super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/GuiGasTank.java b/src/main/java/mekanism/client/gui/GuiGasTank.java index 261d36464..f0d321ff5 100644 --- a/src/main/java/mekanism/client/gui/GuiGasTank.java +++ b/src/main/java/mekanism/client/gui/GuiGasTank.java @@ -41,21 +41,15 @@ public class GuiGasTank extends GuiMekanismTile { @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - String stored = "" + (tileEntity.gasTank.getStored() == Integer.MAX_VALUE ? LangUtils.localize("gui.infinite") - : tileEntity.gasTank.getStored()); - String capacityInfo = - stored + " / " + (tileEntity.tier.getStorage() == Integer.MAX_VALUE ? LangUtils.localize("gui.infinite") - : tileEntity.tier.getStorage()); - fontRenderer - .drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), - 6, 0x404040); + String stored = "" + (tileEntity.gasTank.getStored() == Integer.MAX_VALUE ? LangUtils.localize("gui.infinite") : tileEntity.gasTank.getStored()); + String capacityInfo = stored + " / " + (tileEntity.tier.getStorage() == Integer.MAX_VALUE ? LangUtils.localize("gui.infinite") : tileEntity.tier.getStorage()); + fontRenderer.drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), 6, 0x404040); fontRenderer.drawString(capacityInfo, 45, 40, 0x404040); - renderScaledText( - LangUtils.localize("gui.gas") + ": " + (tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas() - .getGas().getLocalizedName() : LangUtils.localize("gui.none")), 45, 49, 0x404040, 112); + renderScaledText(LangUtils.localize("gui.gas") + ": " + (tileEntity.gasTank.getGas() != null + ? tileEntity.gasTank.getGas().getGas().getLocalizedName() + : LangUtils.localize("gui.none")), 45, 49, 0x404040, 112); fontRenderer.drawString(LangUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040); - String name = chooseByMode(tileEntity.dumping, LangUtils.localize("gui.idle"), - LangUtils.localize("gui.dumping"), LangUtils.localize("gui.dumping_excess")); + String name = chooseByMode(tileEntity.dumping, LangUtils.localize("gui.idle"), LangUtils.localize("gui.dumping"), LangUtils.localize("gui.dumping_excess")); fontRenderer.drawString(name, 156 - fontRenderer.getStringWidth(name), 73, 0x404040); super.drawGuiContainerForegroundLayer(mouseX, mouseY); } @@ -80,8 +74,8 @@ public class GuiGasTank extends GuiMekanismTile { @Override protected void mouseClicked(int x, int y, int button) throws IOException { super.mouseClicked(x, y, button); - int xAxis = (x - (width - xSize) / 2); - int yAxis = (y - (height - ySize) / 2); + int xAxis = x - (width - xSize) / 2; + int yAxis = y - (height - ySize) / 2; if (xAxis > 160 && xAxis < 169 && yAxis > 73 && yAxis < 82) { TileNetworkList data = TileNetworkList.withContents(0); Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); @@ -103,7 +97,6 @@ public class GuiGasTank extends GuiMekanismTile { } else if (dumping.equals(TileEntityGasTank.GasMode.DUMPING_EXCESS)) { return dumpingExcessOption; } - return idleOption; //should not happen; } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/GuiInductionMatrix.java b/src/main/java/mekanism/client/gui/GuiInductionMatrix.java index 1ea75949c..db4cccb34 100644 --- a/src/main/java/mekanism/client/gui/GuiInductionMatrix.java +++ b/src/main/java/mekanism/client/gui/GuiInductionMatrix.java @@ -23,32 +23,23 @@ public class GuiInductionMatrix extends GuiMekanismTile Arrays.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), - LangUtils.localize("gui.input") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput) - + "/t", - LangUtils.localize("gui.output") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) - + "/t"), this, resource)); + addGuiElement(new GuiEnergyInfo(() -> Arrays.asList(LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), + LangUtils.localize("gui.input") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput) + "/t", + LangUtils.localize("gui.output") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/t"), this, resource)); } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - fontRenderer - .drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), - 6, 0x404040); + fontRenderer.drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), 6, 0x404040); fontRenderer.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040); fontRenderer.drawString(LangUtils.localize("gui.input") + ":", 53, 26, 0x00CD00); - fontRenderer - .drawString(MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput) + "/t", 53, 35, 0x00CD00); + fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput) + "/t", 53, 35, 0x00CD00); fontRenderer.drawString(LangUtils.localize("gui.output") + ":", 53, 44, 0x00CD00); - fontRenderer - .drawString(MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/t", 53, 53, 0x00CD00); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/t", 53, 53, 0x00CD00); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; if (xAxis >= 7 && xAxis <= 39 && yAxis >= 14 && yAxis <= 72) { - drawHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), xAxis, - yAxis); + drawHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), xAxis, yAxis); } super.drawGuiContainerForegroundLayer(mouseX, mouseY); } @@ -75,12 +66,9 @@ public class GuiInductionMatrix extends GuiMekanismTile 16) { renderRemaining = 16; scale -= 16; @@ -90,15 +78,12 @@ public class GuiInductionMatrix extends GuiMekanismTile @Override public String getText(double level) { - return LangUtils.localize("gui.storing") + ": " + MekanismUtils - .getEnergyDisplay(level, tileEntity.getMaxEnergy()); + return LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(level, tileEntity.getMaxEnergy()); } }, Type.STANDARD, this, resource, 6, 10)); addGuiElement(new GuiSecurityTab(this, tileEntity, resource)); @@ -68,13 +67,9 @@ public class GuiLaserAmplifier extends GuiMekanismTile fontRenderer.drawString(tileEntity.getName(), 55, 6, 0x404040); fontRenderer.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); fontRenderer.drawString(tileEntity.time > 0 ? LangUtils.localize("gui.delay") + ": " + tileEntity.time + "t" - : LangUtils.localize("gui.noDelay"), 26, 30, 0x404040); - fontRenderer.drawString( - LangUtils.localize("gui.min") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.minThreshold), 26, 45, - 0x404040); - fontRenderer.drawString( - LangUtils.localize("gui.max") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.maxThreshold), 26, 60, - 0x404040); + : LangUtils.localize("gui.noDelay"), 26, 30, 0x404040); + fontRenderer.drawString(LangUtils.localize("gui.min") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.minThreshold), 26, 45, 0x404040); + fontRenderer.drawString(LangUtils.localize("gui.max") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.maxThreshold), 26, 60, 0x404040); super.drawGuiContainerForegroundLayer(mouseX, mouseY); } @@ -96,7 +91,6 @@ public class GuiLaserAmplifier extends GuiMekanismTile @Override public void updateScreen() { super.updateScreen(); - minField.updateCursorCounter(); maxField.updateCursorCounter(); timerField.updateCursorCounter(); @@ -105,7 +99,6 @@ public class GuiLaserAmplifier extends GuiMekanismTile @Override public void mouseClicked(int mouseX, int mouseY, int button) throws IOException { super.mouseClicked(mouseX, mouseY, button); - minField.mouseClicked(mouseX, mouseY, button); maxField.mouseClicked(mouseX, mouseY, button); timerField.mouseClicked(mouseX, mouseY, button); @@ -137,7 +130,7 @@ public class GuiLaserAmplifier extends GuiMekanismTile if (Character.isDigit(c) || c == '.' || c == 'E' || isTextboxKey(c, i)) { minField.textboxKeyTyped(c, i); maxField.textboxKeyTyped(c, i); - if(c != '.' && c != 'E') { + if (c != '.' && c != 'E') { timerField.textboxKeyTyped(c, i); } } @@ -146,18 +139,14 @@ public class GuiLaserAmplifier extends GuiMekanismTile private void setMinThreshold() { if (!minField.getText().isEmpty()) { double toUse; - try { toUse = Math.max(0, Double.parseDouble(minField.getText())); } catch (Exception e) { minField.setText(""); return; } - TileNetworkList data = TileNetworkList.withContents(0, toUse); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - minField.setText(""); } } @@ -165,18 +154,14 @@ public class GuiLaserAmplifier extends GuiMekanismTile private void setMaxThreshold() { if (!maxField.getText().isEmpty()) { double toUse; - try { toUse = Math.max(0, Double.parseDouble(maxField.getText())); } catch (Exception e) { maxField.setText(""); return; } - TileNetworkList data = TileNetworkList.withContents(1, toUse); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - maxField.setText(""); } } @@ -184,11 +169,8 @@ public class GuiLaserAmplifier extends GuiMekanismTile private void setTime() { if (!timerField.getText().isEmpty()) { int toUse = Math.max(0, Integer.parseInt(timerField.getText())); - TileNetworkList data = TileNetworkList.withContents(2, toUse); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - timerField.setText(""); } } @@ -196,12 +178,10 @@ public class GuiLaserAmplifier extends GuiMekanismTile @Override public void initGui() { super.initGui(); - int guiWidth = (width - xSize) / 2; int guiHeight = (height - ySize) / 2; String prevTime = timerField != null ? timerField.getText() : ""; - timerField = new GuiTextField(0, fontRenderer, guiWidth + 96, guiHeight + 28, 36, 11); timerField.setMaxStringLength(4); timerField.setText(prevTime); @@ -212,7 +192,6 @@ public class GuiLaserAmplifier extends GuiMekanismTile minField.setText(prevMin); String prevMax = maxField != null ? maxField.getText() : ""; - maxField = new GuiTextField(2, fontRenderer, guiWidth + 96, guiHeight + 58, 72, 11); maxField.setMaxStringLength(10); maxField.setText(prevMax); diff --git a/src/main/java/mekanism/client/gui/GuiLaserTractorBeam.java b/src/main/java/mekanism/client/gui/GuiLaserTractorBeam.java index 3bc312d3a..b7fad5b53 100644 --- a/src/main/java/mekanism/client/gui/GuiLaserTractorBeam.java +++ b/src/main/java/mekanism/client/gui/GuiLaserTractorBeam.java @@ -22,9 +22,7 @@ public class GuiLaserTractorBeam extends GuiMekanismTile entry : oreDictStacks.entrySet()) { setNextRenderStack(entry.getValue()); } - for (final Map.Entry entry : modIDStacks.entrySet()) { setNextRenderStack(entry.getValue()); } - stackSwitch = 20; } else { for (final Map.Entry entry : oreDictStacks.entrySet()) { @@ -131,7 +128,6 @@ public class GuiLogisticalSorter extends GuiMekanismTile entry : modIDStacks.entrySet()) { if (entry.getValue().iterStacks != null && entry.getValue().iterStacks.size() == 0) { entry.getValue().renderStack = ItemStack.EMPTY; @@ -162,12 +158,11 @@ public class GuiLogisticalSorter extends GuiMekanismTile 0) { if (value.stackIndex == -1 - || value.stackIndex == value.iterStacks.size() - 1) { + || value.stackIndex == value.iterStacks.size() - 1) { value.stackIndex = 0; } else if (value.stackIndex < value.iterStacks.size() - 1) { value.stackIndex++; } - value.renderStack = value.iterStacks.get(value.stackIndex); } } @@ -195,61 +190,48 @@ public class GuiLogisticalSorter extends GuiMekanismTile= 56 && xAxis <= 152 && yAxis >= yStart && yAxis <= yStart + 29) { // Check for sorting button final int arrowX = filterX + filterW - 12; if (getFilterIndex() + i > 0) { if (xAxis >= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 14 - && yAxis <= yStart + 20) { + && yAxis <= yStart + 20) { // Process up button click final TileNetworkList data = TileNetworkList.withContents(3, getFilterIndex() + i); - - Mekanism.packetHandler - .sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); + Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - return; } } - if (getFilterIndex() + i < tileEntity.filters.size() - 1) { if (xAxis >= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 21 - && yAxis <= yStart + 27) { + && yAxis <= yStart + 27) { // Process down button click final TileNetworkList data = TileNetworkList.withContents(4, getFilterIndex() + i); - - Mekanism.packetHandler - .sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); + Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - return; } } final TransporterFilter filter = tileEntity.filters.get(getFilterIndex() + i); - if (filter instanceof TItemStackFilter) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer( - new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER_INDEX, Coord4D.get(tileEntity), - 1, getFilterIndex() + i, 0)); + new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER_INDEX, Coord4D.get(tileEntity), 1, getFilterIndex() + i, 0)); } else if (filter instanceof TOreDictFilter) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer( - new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER_INDEX, Coord4D.get(tileEntity), - 2, getFilterIndex() + i, 0)); + new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER_INDEX, Coord4D.get(tileEntity), 2, getFilterIndex() + i, 0)); } else if (filter instanceof TMaterialFilter) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer( - new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER_INDEX, Coord4D.get(tileEntity), - 3, getFilterIndex() + i, 0)); + new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER_INDEX, Coord4D.get(tileEntity), 3, getFilterIndex() + i, 0)); } else if (filter instanceof TModIDFilter) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer( - new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER_INDEX, Coord4D.get(tileEntity), - 5, getFilterIndex() + i, 0)); + new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER_INDEX, Coord4D.get(tileEntity), 5, getFilterIndex() + i, 0)); } } } @@ -258,7 +240,6 @@ public class GuiLogisticalSorter extends GuiMekanismTile= 12 && xAxis <= 26 && yAxis >= 110 && yAxis <= 124) { final TileNetworkList data = TileNetworkList.withContents(1); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); } @@ -266,7 +247,6 @@ public class GuiLogisticalSorter extends GuiMekanismTile= 12 && xAxis <= 26 && yAxis >= 84 && yAxis <= 98) { final TileNetworkList data = TileNetworkList.withContents(2); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); } @@ -274,7 +254,6 @@ public class GuiLogisticalSorter extends GuiMekanismTile= 12 && xAxis <= 26 && yAxis >= 58 && yAxis <= 72) { final TileNetworkList data = TileNetworkList.withContents(5); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); } @@ -287,7 +266,6 @@ public class GuiLogisticalSorter extends GuiMekanismTile= 13 && xAxis <= 29 && yAxis >= 137 && yAxis <= 153) { final TileNetworkList data = TileNetworkList.withContents(0, mouseBtn); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); SoundHandler.playSound(MekanismSounds.DING); } @@ -306,7 +284,6 @@ public class GuiLogisticalSorter extends GuiMekanismTile 0) { i = 1; } - if (i < 0) { i = -1; } - scroll = (float) (scroll - (double) i / (double) j); - if (scroll < 0.0F) { scroll = 0.0F; } - if (scroll > 1.0F) { scroll = 1.0F; } @@ -356,17 +326,14 @@ public class GuiLogisticalSorter extends GuiMekanismTile= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 21 && yAxis <= yStart + 27) { drawHoveringText(LangUtils.localize("gui.moveDown"), xAxis, yAxis); @@ -519,24 +468,15 @@ public class GuiLogisticalSorter extends GuiMekanismTile= 12 && xAxis <= 26 && yAxis >= 110 && yAxis <= 124) { - drawHoveringText( - MekanismUtils.splitTooltip( - LangUtils.localize("mekanism.gui.logisticalSorter.autoEject.tooltip"), ItemStack.EMPTY - ), xAxis, yAxis); + drawHoveringText(MekanismUtils.splitTooltip(LangUtils.localize("mekanism.gui.logisticalSorter.autoEject.tooltip"), ItemStack.EMPTY), xAxis, yAxis); } if (xAxis >= 12 && xAxis <= 26 && yAxis >= 84 && yAxis <= 98) { - drawHoveringText( - MekanismUtils.splitTooltip( - LangUtils.localize("mekanism.gui.logisticalSorter.roundRobin.tooltip"), ItemStack.EMPTY - ), xAxis, yAxis); + drawHoveringText(MekanismUtils.splitTooltip(LangUtils.localize("mekanism.gui.logisticalSorter.roundRobin.tooltip"), ItemStack.EMPTY), xAxis, yAxis); } if (xAxis >= 12 && xAxis <= 26 && yAxis >= 58 && yAxis <= 72) { - drawHoveringText( - MekanismUtils.splitTooltip( - LangUtils.localize("mekanism.gui.logisticalSorter.singleItem.tooltip"), ItemStack.EMPTY - ), xAxis, yAxis); + drawHoveringText(MekanismUtils.splitTooltip(LangUtils.localize("mekanism.gui.logisticalSorter.singleItem.tooltip"), ItemStack.EMPTY), xAxis, yAxis); } super.drawGuiContainerForegroundLayer(mouseX, mouseY); @@ -552,8 +492,7 @@ public class GuiLogisticalSorter extends GuiMekanismTile= filterX && xAxis <= filterX + filterW && yAxis >= yStart && yAxis <= yStart + filterH; + boolean mouseOver = xAxis >= filterX && xAxis <= filterX + filterW && yAxis >= yStart && yAxis <= yStart + filterH; // Change colour based on filter type if (filter instanceof TItemStackFilter) { diff --git a/src/main/java/mekanism/client/gui/GuiMatrixStats.java b/src/main/java/mekanism/client/gui/GuiMatrixStats.java index 130b2a0b7..903e10332 100644 --- a/src/main/java/mekanism/client/gui/GuiMatrixStats.java +++ b/src/main/java/mekanism/client/gui/GuiMatrixStats.java @@ -29,8 +29,7 @@ public class GuiMatrixStats extends GuiMekanismTile { addGuiElement(new GuiRateBar(this, new IRateInfoHandler() { @Override public String getTooltip() { - return LangUtils.localize("gui.receiving") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.structure.lastInput) + "/t"; + return LangUtils.localize("gui.receiving") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput) + "/t"; } @Override @@ -41,8 +40,7 @@ public class GuiMatrixStats extends GuiMekanismTile { addGuiElement(new GuiRateBar(this, new IRateInfoHandler() { @Override public String getTooltip() { - return LangUtils.localize("gui.outputting") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.structure.lastOutput) + "/t"; + return LangUtils.localize("gui.outputting") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/t"; } @Override @@ -51,12 +49,9 @@ public class GuiMatrixStats extends GuiMekanismTile { } }, resource, 38, 13)); addGuiElement(new GuiEnergyInfo(() -> Arrays.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), - LangUtils.localize("gui.input") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput) - + "/t", - LangUtils.localize("gui.output") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) - + "/t"), this, resource)); + LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), + LangUtils.localize("gui.input") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput) + "/t", + LangUtils.localize("gui.output") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/t"), this, resource)); } @Override @@ -64,18 +59,16 @@ public class GuiMatrixStats extends GuiMekanismTile { String stats = LangUtils.localize("gui.matrixStats"); fontRenderer.drawString(stats, (xSize / 2) - (fontRenderer.getStringWidth(stats) / 2), 6, 0x404040); fontRenderer.drawString(LangUtils.localize("gui.input") + ":", 53, 26, 0x797979); - fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput) + "/" + MekanismUtils - .getEnergyDisplay(tileEntity.structure.transferCap), 59, 35, 0x404040); + fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput) + "/" + + MekanismUtils.getEnergyDisplay(tileEntity.structure.transferCap), 59, 35, 0x404040); fontRenderer.drawString(LangUtils.localize("gui.output") + ":", 53, 46, 0x797979); - fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/" + MekanismUtils - .getEnergyDisplay(tileEntity.structure.transferCap), 59, 55, 0x404040); + fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/" + + MekanismUtils.getEnergyDisplay(tileEntity.structure.transferCap), 59, 55, 0x404040); fontRenderer.drawString(LangUtils.localize("gui.dimensions") + ":", 8, 82, 0x797979); - fontRenderer.drawString(tileEntity.structure.volWidth + " x " + tileEntity.structure.volHeight + " x " - + tileEntity.structure.volLength, 14, 91, 0x404040); + fontRenderer.drawString(tileEntity.structure.volWidth + " x " + tileEntity.structure.volHeight + " x " + tileEntity.structure.volLength, 14, 91, 0x404040); fontRenderer.drawString(LangUtils.localize("gui.constituents") + ":", 8, 102, 0x797979); fontRenderer.drawString(tileEntity.clientCells + " " + LangUtils.localize("gui.cells"), 14, 111, 0x404040); - fontRenderer - .drawString(tileEntity.clientProviders + " " + LangUtils.localize("gui.providers"), 14, 120, 0x404040); + fontRenderer.drawString(tileEntity.clientProviders + " " + LangUtils.localize("gui.providers"), 14, 120, 0x404040); super.drawGuiContainerForegroundLayer(mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/GuiMekanism.java b/src/main/java/mekanism/client/gui/GuiMekanism.java index 0ebb92266..588e9614d 100644 --- a/src/main/java/mekanism/client/gui/GuiMekanism.java +++ b/src/main/java/mekanism/client/gui/GuiMekanism.java @@ -27,9 +27,8 @@ public abstract class GuiMekanism extends GuiContainer implements IGuiWrapper { } public static boolean isTextboxKey(char c, int i) { - return i == Keyboard.KEY_BACK || i == Keyboard.KEY_DELETE || i == Keyboard.KEY_LEFT || i == Keyboard.KEY_RIGHT - || i == Keyboard.KEY_END || i == Keyboard.KEY_HOME || isKeyComboCtrlA(i) || isKeyComboCtrlC(i) - || isKeyComboCtrlV(i) || isKeyComboCtrlX(i); + return i == Keyboard.KEY_BACK || i == Keyboard.KEY_DELETE || i == Keyboard.KEY_LEFT || i == Keyboard.KEY_RIGHT || i == Keyboard.KEY_END || + i == Keyboard.KEY_HOME || isKeyComboCtrlA(i) || isKeyComboCtrlC(i) || isKeyComboCtrlV(i) || isKeyComboCtrlX(i); } public Set getGuiElements() { @@ -50,14 +49,12 @@ public abstract class GuiMekanism extends GuiContainer implements IGuiWrapper { */ public void renderScaledText(String text, int x, int y, int color, int maxX) { int length = fontRenderer.getStringWidth(text); - if (length <= maxX) { fontRenderer.drawString(text, x, y, color); } else { float scale = (float) maxX / length; float reverse = 1 / scale; float yAdd = 4 - (scale * 8) / 2F; - GlStateManager.pushMatrix(); GlStateManager.scale(scale, scale, scale); fontRenderer.drawString(text, (int) (x * reverse), (int) ((y * reverse) + yAdd), color); @@ -68,8 +65,8 @@ public abstract class GuiMekanism extends GuiContainer implements IGuiWrapper { @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { super.drawGuiContainerForegroundLayer(mouseX, mouseY); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; guiElements.forEach(element -> element.renderForeground(xAxis, yAxis)); } @@ -88,8 +85,8 @@ public abstract class GuiMekanism extends GuiContainer implements IGuiWrapper { @Override protected void mouseClicked(int mouseX, int mouseY, int button) throws IOException { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; guiElements.forEach(element -> element.preMouseClicked(xAxis, yAxis, button)); super.mouseClicked(mouseX, mouseY, button); guiElements.forEach(element -> element.mouseClicked(xAxis, yAxis, button)); @@ -123,16 +120,16 @@ public abstract class GuiMekanism extends GuiContainer implements IGuiWrapper { @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); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; guiElements.forEach(element -> element.mouseClickMove(xAxis, yAxis, button, ticks)); } @Override protected void mouseReleased(int mouseX, int mouseY, int type) { super.mouseReleased(mouseX, mouseY, type); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; guiElements.forEach(element -> element.mouseReleased(xAxis, yAxis, type)); } @@ -172,7 +169,7 @@ public abstract class GuiMekanism extends GuiContainer implements IGuiWrapper { protected void renderCenteredText(int leftMargin, int areaWidth, int y, int color, String text) { int textWidth = fontRenderer.getStringWidth(text); - int centerX = leftMargin + (areaWidth/2) - (textWidth/2); + int centerX = leftMargin + (areaWidth / 2) - (textWidth / 2); fontRenderer.drawString(text, centerX, y, color); } diff --git a/src/main/java/mekanism/client/gui/GuiMekanismConfig.java b/src/main/java/mekanism/client/gui/GuiMekanismConfig.java index f288f0439..f42d8ec25 100644 --- a/src/main/java/mekanism/client/gui/GuiMekanismConfig.java +++ b/src/main/java/mekanism/client/gui/GuiMekanismConfig.java @@ -24,18 +24,12 @@ public class GuiMekanismConfig extends GuiConfig { private static List getConfigElements() { List list = new ArrayList<>(); - list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.general"), - "mekanism.configgui.ctgy.general", GeneralEntry.class)); - list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.machines"), - "mekanism.configgui.ctgy.machines", MachinesEntry.class)); - list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.tier"), - "mekanism.configgui.ctgy.tier", TierEntry.class)); - list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.usage"), - "mekanism.configgui.ctgy.usage", UsageEntry.class)); - list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.storage"), - "mekanism.configgui.ctgy.storage", StorageEntry.class)); - list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.client"), - "mekanism.configgui.ctgy.client", ClientEntry.class)); + list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.general"), "mekanism.configgui.ctgy.general", GeneralEntry.class)); + list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.machines"), "mekanism.configgui.ctgy.machines", MachinesEntry.class)); + list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.tier"), "mekanism.configgui.ctgy.tier", TierEntry.class)); + list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.usage"), "mekanism.configgui.ctgy.usage", UsageEntry.class)); + list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.storage"), "mekanism.configgui.ctgy.storage", StorageEntry.class)); + list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.client"), "mekanism.configgui.ctgy.client", ClientEntry.class)); return list; } @@ -48,10 +42,8 @@ public class GuiMekanismConfig extends GuiConfig { @Override protected GuiScreen buildChildScreen() { return new GuiConfig(owningScreen, - new ConfigElement(Mekanism.configuration.getCategory(Configuration.CATEGORY_GENERAL)) - .getChildElements(), - owningScreen.modID, Configuration.CATEGORY_GENERAL, false, false, - GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); + new ConfigElement(Mekanism.configuration.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), owningScreen.modID, + Configuration.CATEGORY_GENERAL, false, false, GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); } } @@ -63,10 +55,8 @@ public class GuiMekanismConfig extends GuiConfig { @Override protected GuiScreen buildChildScreen() { - return new GuiConfig(owningScreen, - new ConfigElement(Mekanism.configuration.getCategory("machines")).getChildElements(), - owningScreen.modID, Configuration.CATEGORY_GENERAL, false, false, - GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); + return new GuiConfig(owningScreen, new ConfigElement(Mekanism.configuration.getCategory("machines")).getChildElements(), owningScreen.modID, + Configuration.CATEGORY_GENERAL, false, false, GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); } } @@ -78,10 +68,8 @@ public class GuiMekanismConfig extends GuiConfig { @Override protected GuiScreen buildChildScreen() { - return new GuiConfig(owningScreen, - new ConfigElement(Mekanism.configuration.getCategory("tier")).getChildElements(), - owningScreen.modID, Configuration.CATEGORY_GENERAL, false, false, - GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); + return new GuiConfig(owningScreen, new ConfigElement(Mekanism.configuration.getCategory("tier")).getChildElements(), owningScreen.modID, + Configuration.CATEGORY_GENERAL, false, false, GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); } } @@ -93,10 +81,8 @@ public class GuiMekanismConfig extends GuiConfig { @Override protected GuiScreen buildChildScreen() { - return new GuiConfig(owningScreen, - new ConfigElement(Mekanism.configuration.getCategory("usage")).getChildElements(), - owningScreen.modID, Configuration.CATEGORY_GENERAL, false, false, - GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); + return new GuiConfig(owningScreen, new ConfigElement(Mekanism.configuration.getCategory("usage")).getChildElements(), owningScreen.modID, + Configuration.CATEGORY_GENERAL, false, false, GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); } } @@ -108,10 +94,8 @@ public class GuiMekanismConfig extends GuiConfig { @Override protected GuiScreen buildChildScreen() { - return new GuiConfig(owningScreen, - new ConfigElement(Mekanism.configuration.getCategory("storage")).getChildElements(), - owningScreen.modID, Configuration.CATEGORY_GENERAL, false, false, - GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); + return new GuiConfig(owningScreen, new ConfigElement(Mekanism.configuration.getCategory("storage")).getChildElements(), owningScreen.modID, + Configuration.CATEGORY_GENERAL, false, false, GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); } } @@ -123,10 +107,8 @@ public class GuiMekanismConfig extends GuiConfig { @Override protected GuiScreen buildChildScreen() { - return new GuiConfig(owningScreen, - new ConfigElement(Mekanism.configuration.getCategory("client")).getChildElements(), - owningScreen.modID, "client", false, false, - GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); + return new GuiConfig(owningScreen, new ConfigElement(Mekanism.configuration.getCategory("client")).getChildElements(), owningScreen.modID, + Configuration.CATEGORY_CLIENT, false, false, GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); } } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/GuiMekanismTile.java b/src/main/java/mekanism/client/gui/GuiMekanismTile.java index 5d3865fe7..982a41e8a 100644 --- a/src/main/java/mekanism/client/gui/GuiMekanismTile.java +++ b/src/main/java/mekanism/client/gui/GuiMekanismTile.java @@ -29,8 +29,8 @@ public abstract class GuiMekanismTile ext @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { super.drawGuiContainerForegroundLayer(mouseX, mouseY); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; if (tileEntity instanceof ISideConfiguration) { Slot hovering = null; for (int i = 0; i < inventorySlots.inventorySlots.size(); i++) { @@ -45,8 +45,7 @@ public abstract class GuiMekanismTile ext if (!stack.isEmpty() && stack.getItem() instanceof ItemConfigurator && hovering != null) { SideData data = getFromSlot(hovering); if (data != null) { - drawHoveringText(data.color + data.localize() + " (" + data.color.getColoredName() + ")", xAxis, - yAxis); + drawHoveringText(data.color + data.localize() + " (" + data.color.getColoredName() + ")", xAxis, yAxis); } } } @@ -66,7 +65,6 @@ public abstract class GuiMekanismTile ext } } } - return null; } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/GuiMetallurgicInfuser.java b/src/main/java/mekanism/client/gui/GuiMetallurgicInfuser.java index 276e0fad1..9acb19874 100644 --- a/src/main/java/mekanism/client/gui/GuiMetallurgicInfuser.java +++ b/src/main/java/mekanism/client/gui/GuiMetallurgicInfuser.java @@ -3,6 +3,7 @@ package mekanism.client.gui; import java.io.IOException; import java.util.Arrays; import mekanism.api.Coord4D; +import mekanism.api.TileNetworkList; import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiProgress; @@ -19,7 +20,6 @@ import mekanism.client.gui.element.GuiUpgradeTab; import mekanism.client.render.MekanismRenderer; import mekanism.client.sound.SoundHandler; import mekanism.common.Mekanism; -import mekanism.api.TileNetworkList; import mekanism.common.inventory.container.ContainerMetallurgicInfuser; import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.tile.TileEntityMetallurgicInfuser; @@ -48,8 +48,7 @@ public class GuiMetallurgicInfuser extends GuiMekanismTile { String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); return Arrays.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", - LangUtils.localize("gui.needed") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); + LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); }, this, resource)); addGuiElement(new GuiSlot(SlotType.EXTRA, this, resource, 16, 34)); addGuiElement(new GuiSlot(SlotType.INPUT, this, resource, 50, 42)); @@ -67,12 +66,11 @@ public class GuiMetallurgicInfuser extends GuiMekanismTile= 7 && xAxis <= 11 && yAxis >= 17 && yAxis <= 69) { - drawHoveringText( - tileEntity.infuseStored.getType() != null ? tileEntity.infuseStored.getType().getLocalizedName() + ": " - + tileEntity.infuseStored.getAmount() : LangUtils.localize("gui.empty"), xAxis, yAxis); + drawHoveringText(tileEntity.infuseStored.getType() != null ? tileEntity.infuseStored.getType().getLocalizedName() + ": " + tileEntity.infuseStored.getAmount() + : LangUtils.localize("gui.empty"), xAxis, yAxis); } super.drawGuiContainerForegroundLayer(mouseX, mouseY); } @@ -87,8 +85,7 @@ public class GuiMetallurgicInfuser extends GuiMekanismTile 148 && xAxis < 168 && yAxis > 73 && yAxis < 82) { TileNetworkList data = TileNetworkList.withContents(0); Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); diff --git a/src/main/java/mekanism/client/gui/GuiOredictionificator.java b/src/main/java/mekanism/client/gui/GuiOredictionificator.java index cc248fedc..367b7cc47 100644 --- a/src/main/java/mekanism/client/gui/GuiOredictionificator.java +++ b/src/main/java/mekanism/client/gui/GuiOredictionificator.java @@ -68,7 +68,7 @@ public class GuiOredictionificator extends GuiMekanismTile= 154 && xAxis <= 166 && yAxis >= getScroll() + 18 && yAxis <= getScroll() + 18 + 15) { if (tileEntity.filters.size() > 3) { dragOffset = yAxis - (getScroll() + 18); @@ -162,11 +158,9 @@ public class GuiOredictionificator extends GuiMekanismTile 10 && xAxis <= 152 && yAxis > yStart && yAxis <= yStart + 22) { - OredictionificatorFilter filter = tileEntity.filters.get(getFilterIndex() + i); SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer( - new OredictionificatorGuiMessage(OredictionificatorGuiPacket.SERVER_INDEX, - Coord4D.get(tileEntity), 1, getFilterIndex() + i, 0)); + new OredictionificatorGuiMessage(OredictionificatorGuiPacket.SERVER_INDEX, Coord4D.get(tileEntity), 1, getFilterIndex() + i, 0)); } } } @@ -177,7 +171,7 @@ public class GuiOredictionificator extends GuiMekanismTile { addGuiElement(new GuiUpgradeTab(this, tileEntity, resource)); addGuiElement(new GuiEnergyInfo(() -> { double extra = tileEntity.getRecipe() != null ? tileEntity.getRecipe().extraEnergy : 0; - String multiplier = MekanismUtils.getEnergyDisplay( - MekanismUtils.getEnergyPerTick(tileEntity, tileEntity.BASE_ENERGY_PER_TICK + extra)); + String multiplier = MekanismUtils.getEnergyDisplay(MekanismUtils.getEnergyPerTick(tileEntity, tileEntity.BASE_ENERGY_PER_TICK + extra)); return Arrays.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", - LangUtils.localize("gui.needed") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); + LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); }, this, resource)); - addGuiElement(new GuiFluidGauge(() -> - tileEntity.inputFluidTank, GuiGauge.Type.STANDARD_YELLOW, this, resource, 5, 10)); - addGuiElement(new GuiGasGauge(() -> - tileEntity.inputGasTank, GuiGauge.Type.STANDARD_RED, this, resource, 28, 10)); - addGuiElement(new GuiGasGauge(() -> - tileEntity.outputGasTank, GuiGauge.Type.SMALL_BLUE, this, resource, 140, 40)); + addGuiElement(new GuiFluidGauge(() -> tileEntity.inputFluidTank, GuiGauge.Type.STANDARD_YELLOW, this, resource, 5, 10)); + addGuiElement(new GuiGasGauge(() -> tileEntity.inputGasTank, GuiGauge.Type.STANDARD_RED, this, resource, 28, 10)); + addGuiElement(new GuiGasGauge(() -> tileEntity.outputGasTank, GuiGauge.Type.SMALL_BLUE, this, resource, 140, 40)); addGuiElement(new GuiPowerBar(this, tileEntity, resource, 164, 15)); addGuiElement(new GuiSlot(SlotType.INPUT, this, resource, 53, 34)); addGuiElement(new GuiSlot(SlotType.POWER, this, resource, 140, 18).with(SlotOverlay.POWER)); @@ -67,9 +62,7 @@ public class GuiPRC extends GuiMekanismTile { @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - fontRenderer - .drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), - 6, 0x404040); + fontRenderer.drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), 6, 0x404040); fontRenderer.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); super.drawGuiContainerForegroundLayer(mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/GuiQuantumEntangloporter.java b/src/main/java/mekanism/client/gui/GuiQuantumEntangloporter.java index 4c7335e32..d0d3b6084 100644 --- a/src/main/java/mekanism/client/gui/GuiQuantumEntangloporter.java +++ b/src/main/java/mekanism/client/gui/GuiQuantumEntangloporter.java @@ -85,8 +85,7 @@ public class GuiQuantumEntangloporter extends GuiMekanismTile= 137 && xAxis <= 148 && yAxis >= 103 && yAxis <= 114) { setFrequency(frequencyField.getText()); frequencyField.setText(""); @@ -161,8 +159,7 @@ public class GuiQuantumEntangloporter extends GuiMekanismTile= 137 && xAxis <= 148 && yAxis >= 103 && yAxis <= 114) { drawTexturedModalRect(guiWidth + 137, guiHeight + 103, xSize, 0, 11, 11); } else { diff --git a/src/main/java/mekanism/client/gui/GuiResistiveHeater.java b/src/main/java/mekanism/client/gui/GuiResistiveHeater.java index 624d823e7..65be08cec 100644 --- a/src/main/java/mekanism/client/gui/GuiResistiveHeater.java +++ b/src/main/java/mekanism/client/gui/GuiResistiveHeater.java @@ -48,13 +48,11 @@ public class GuiResistiveHeater extends GuiMekanismTile { String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyUsage); return Arrays.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", - LangUtils.localize("gui.needed") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); + LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); }, this, resource)); addGuiElement(new GuiHeatInfo(() -> { TemperatureUnit unit = TemperatureUnit.values()[MekanismConfig.current().general.tempUnit.val().ordinal()]; - String environment = UnitDisplayUtils - .getDisplayShort(tileEntity.lastEnvironmentLoss * unit.intervalSize, false, unit); + String environment = UnitDisplayUtils.getDisplayShort(tileEntity.lastEnvironmentLoss * unit.intervalSize, false, unit); return Collections.singletonList(LangUtils.localize("gui.dissipated") + ": " + environment + "/t"); }, this, resource)); } @@ -73,15 +71,10 @@ public class GuiResistiveHeater extends GuiMekanismTile= 116 && xAxis <= 126 && yAxis >= 51 && yAxis <= 61) { drawTexturedModalRect(guiWidth + 116, guiHeight + 51, xSize, 0, 11, 11); } else { @@ -123,8 +116,8 @@ public class GuiResistiveHeater extends GuiMekanismTile= 116 && xAxis <= 126 && yAxis >= 51 && yAxis <= 61) { setEnergyUsage(); SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); diff --git a/src/main/java/mekanism/client/gui/GuiRotaryCondensentrator.java b/src/main/java/mekanism/client/gui/GuiRotaryCondensentrator.java index 532092f78..76f51e283 100644 --- a/src/main/java/mekanism/client/gui/GuiRotaryCondensentrator.java +++ b/src/main/java/mekanism/client/gui/GuiRotaryCondensentrator.java @@ -3,6 +3,7 @@ package mekanism.client.gui; import java.io.IOException; import java.util.Arrays; import mekanism.api.Coord4D; +import mekanism.api.TileNetworkList; import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiFluidGauge; import mekanism.client.gui.element.GuiGasGauge; @@ -18,7 +19,6 @@ import mekanism.client.gui.element.GuiSlot.SlotType; import mekanism.client.gui.element.GuiUpgradeTab; import mekanism.client.sound.SoundHandler; import mekanism.common.Mekanism; -import mekanism.api.TileNetworkList; import mekanism.common.inventory.container.ContainerRotaryCondensentrator; import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.tile.TileEntityRotaryCondensentrator; @@ -49,8 +49,7 @@ public class GuiRotaryCondensentrator extends GuiMekanismTile { String usage = MekanismUtils.getEnergyDisplay(tileEntity.clientEnergyUsed); return Arrays.asList(LangUtils.localize("gui.using") + ": " + usage + "/t", - LangUtils.localize("gui.needed") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); + LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); }, this, resource)); addGuiElement(new GuiFluidGauge(() -> tileEntity.fluidTank, GuiGauge.Type.STANDARD, this, resource, 133, 13)); addGuiElement(new GuiGasGauge(() -> tileEntity.gasTank, GuiGauge.Type.STANDARD, this, resource, 25, 13)); @@ -80,16 +79,13 @@ public class GuiRotaryCondensentrator extends GuiMekanismTile= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80) { - drawHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), xAxis, - yAxis); + drawHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), xAxis, yAxis); } if (xAxis >= 4 && xAxis <= 22 && yAxis >= 4 && yAxis <= 22) { drawHoveringText(LangUtils.localize("gui.rotaryCondensentrator.toggleOperation"), xAxis, yAxis); @@ -105,8 +101,8 @@ public class GuiRotaryCondensentrator extends GuiMekanismTile= 4 && xAxis <= 22 && yAxis >= 4 && yAxis <= 22) { @@ -121,8 +117,8 @@ public class GuiRotaryCondensentrator extends GuiMekanismTile= 4 && xAxis <= 22 && yAxis >= 4 && yAxis <= 22) { TileNetworkList data = TileNetworkList.withContents(0); Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); diff --git a/src/main/java/mekanism/client/gui/GuiSecurityDesk.java b/src/main/java/mekanism/client/gui/GuiSecurityDesk.java index 3c4fee044..88441ef8d 100644 --- a/src/main/java/mekanism/client/gui/GuiSecurityDesk.java +++ b/src/main/java/mekanism/client/gui/GuiSecurityDesk.java @@ -6,10 +6,10 @@ import java.util.Arrays; import java.util.List; import mekanism.api.Coord4D; import mekanism.api.EnumColor; +import mekanism.api.TileNetworkList; import mekanism.client.gui.element.GuiScrollList; import mekanism.client.sound.SoundHandler; import mekanism.common.Mekanism; -import mekanism.api.TileNetworkList; import mekanism.common.inventory.container.ContainerSecurityDesk; import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.security.ISecurityTile.SecurityMode; @@ -91,10 +91,10 @@ public class GuiSecurityDesk extends GuiMekanismTile { updateButtons(); trustedField.mouseClicked(mouseX, mouseY, button); if (button == 0) { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - if (tileEntity.frequency != null && tileEntity.ownerUUID != null && tileEntity.clientOwner - .equals(mc.player.getName())) { + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; + //TODO: replace compare with uuid instead of clientOwner and player name + if (tileEntity.frequency != null && tileEntity.ownerUUID != null && tileEntity.clientOwner.equals(mc.player.getName())) { if (xAxis >= 123 && xAxis <= 134 && yAxis >= 68 && yAxis <= 79) { addTrusted(trustedField.getText()); trustedField.setText(""); @@ -167,14 +167,9 @@ public class GuiSecurityDesk extends GuiMekanismTile { @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - String ownerText = - tileEntity.clientOwner != null ? (LangUtils.localize("gui.owner") + ": " + tileEntity.clientOwner) - : EnumColor.RED + LangUtils.localize("gui.noOwner"); - fontRenderer - .drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), - 4, 0x404040); - fontRenderer - .drawString(ownerText, (xSize - 7) - fontRenderer.getStringWidth(ownerText), (ySize - 96) + 2, 0x404040); + String ownerText = tileEntity.clientOwner != null ? (LangUtils.localize("gui.owner") + ": " + tileEntity.clientOwner) : EnumColor.RED + LangUtils.localize("gui.noOwner"); + fontRenderer.drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), 4, 0x404040); + fontRenderer.drawString(ownerText, xSize - 7 - fontRenderer.getStringWidth(ownerText), (ySize - 96) + 2, 0x404040); fontRenderer.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); String trusted = LangUtils.localize("gui.trustedPlayers"); fontRenderer.drawString(trusted, 74 - (fontRenderer.getStringWidth(trusted) / 2), 57, 0x787878); @@ -184,11 +179,10 @@ public class GuiSecurityDesk extends GuiMekanismTile { } fontRenderer.drawString(security, 13, 103, 0x404040); renderScaledText(LangUtils.localize("gui.add") + ":", 13, 70, 0x404040, 20); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; if (tileEntity.frequency != null && xAxis >= 146 && xAxis <= 162 && yAxis >= 59 && yAxis <= 75) { - displayTooltip(LangUtils.localize("gui.securityOverride") + ": " + LangUtils - .transOnOff(tileEntity.frequency.override), xAxis, yAxis); + displayTooltip(LangUtils.localize("gui.securityOverride") + ": " + LangUtils.transOnOff(tileEntity.frequency.override), xAxis, yAxis); } if (xAxis >= 13 && xAxis <= 53 && yAxis >= 113 && yAxis <= 129) { displayTooltip(LangUtils.localize("gui.publicMode"), xAxis, yAxis); @@ -209,12 +203,11 @@ public class GuiSecurityDesk extends GuiMekanismTile { 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 (tileEntity.frequency != null && tileEntity.clientOwner != null && mc.player.getName() - .equals(tileEntity.clientOwner)) { - drawTexturedModalRect(guiWidth + 145, guiHeight + 78, xSize + (tileEntity.frequency.override ? 0 : 6), 22, - 6, 6); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; + //TODO: replace compare with uuid instead of clientOwner and player name + if (tileEntity.frequency != null && tileEntity.clientOwner != null && mc.player.getName().equals(tileEntity.clientOwner)) { + drawTexturedModalRect(guiWidth + 145, guiHeight + 78, xSize + (tileEntity.frequency.override ? 0 : 6), 22, 6, 6); if (xAxis >= 146 && xAxis <= 162 && yAxis >= 59 && yAxis <= 75) { drawTexturedModalRect(guiWidth + 146, guiHeight + 59, xSize + 12, 0, 16, 16); } else { diff --git a/src/main/java/mekanism/client/gui/GuiSeismicReader.java b/src/main/java/mekanism/client/gui/GuiSeismicReader.java index 179763058..bab3026d0 100644 --- a/src/main/java/mekanism/client/gui/GuiSeismicReader.java +++ b/src/main/java/mekanism/client/gui/GuiSeismicReader.java @@ -46,7 +46,6 @@ public class GuiSeismicReader extends GuiScreen { @Override public void initGui() { super.initGui(); - upButton = new Rectangle((width - xSize) / 2 + 70, (height - ySize) / 2 + 75, 13, 13); downButton = new Rectangle((width - xSize) / 2 + 70, (height - ySize) / 2 + 92, 13, 13); tooltip = new Rectangle((width - xSize) / 2 + 30, (height - ySize) / 2 + 82, 16, 16); @@ -75,8 +74,7 @@ public class GuiSeismicReader extends GuiScreen { GL11.glColor3f(0.5f, 0.5f, 1f); } - drawTexturedModalRect(downButton.getX(), downButton.getY(), 150, 0, downButton.getWidth(), - downButton.getHeight()); + drawTexturedModalRect(downButton.getX(), downButton.getY(), 150, 0, downButton.getWidth(), downButton.getHeight()); GL11.glColor3f(1, 1, 1); // Fix the overlapping if > 100 @@ -120,8 +118,7 @@ public class GuiSeismicReader extends GuiScreen { // Get the name from the stack and render it if (currentLayer - 1 >= 0) { - ItemStack nameStack = new ItemStack(blockList.get(currentLayer - 1).getRight(), 1, - blockList.get(currentLayer - 1).getLeft()); + ItemStack nameStack = new ItemStack(blockList.get(currentLayer - 1).getRight(), 1, blockList.get(currentLayer - 1).getLeft()); String renderString = nameStack.getDisplayName(); String capitalised = renderString.substring(0, 1).toUpperCase() + renderString.substring(1); @@ -153,8 +150,7 @@ public class GuiSeismicReader extends GuiScreen { if (blockList.get(currentLayer - 1) != null) { Block block = blockList.get(currentLayer - 1).getRight(); - if (pair.getRight() == block && Objects - .equals(pair.getLeft(), blockList.get(currentLayer - 1).getLeft())) { + if (pair.getRight() == block && Objects.equals(pair.getLeft(), blockList.get(currentLayer - 1).getLeft())) { frequency++; } } @@ -170,20 +166,17 @@ public class GuiSeismicReader extends GuiScreen { public String wrapString(String str, int index) { String string = str; - for (int i = 0; i < string.length(); i++) { if (i == index) { string = string.substring(0, i) + "\n" + string.substring(i); } } - return string; } @Override public void onGuiClosed() { super.onGuiClosed(); - blockList.clear(); } @@ -192,7 +185,6 @@ public class GuiSeismicReader extends GuiScreen { IBlockState state = worldObj.getBlockState(p); Block block = state.getBlock(); int metadata = block.getMetaFromState(state); - blockList.add(Pair.of(metadata, block)); } } @@ -200,7 +192,6 @@ public class GuiSeismicReader extends GuiScreen { @Override protected void mouseClicked(int xPos, int yPos, int buttonClicked) throws IOException { super.mouseClicked(xPos, yPos, buttonClicked); - if (upButton.intersects(new Rectangle(xPos, yPos, 1, 1))) { if (currentLayer + 1 <= blockList.size() - 1) { currentLayer++; @@ -218,4 +209,4 @@ public class GuiSeismicReader extends GuiScreen { public boolean doesGuiPauseGame() { return false; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/GuiSeismicVibrator.java b/src/main/java/mekanism/client/gui/GuiSeismicVibrator.java index 68cc721b4..fa9634783 100644 --- a/src/main/java/mekanism/client/gui/GuiSeismicVibrator.java +++ b/src/main/java/mekanism/client/gui/GuiSeismicVibrator.java @@ -30,11 +30,9 @@ public class GuiSeismicVibrator extends GuiMekanismTile { - String multiplier = MekanismUtils - .getEnergyDisplay(MekanismConfig.current().usage.seismicVibrator.val()); + String multiplier = MekanismUtils.getEnergyDisplay(MekanismConfig.current().usage.seismicVibrator.val()); return Arrays.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", - LangUtils.localize("gui.needed") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); + LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); }, this, resource)); addGuiElement(new GuiSlot(SlotType.NORMAL, this, resource, 142, 34).with(SlotOverlay.POWER)); } @@ -43,11 +41,8 @@ public class GuiSeismicVibrator extends GuiMekanismTile> 4) + ", " + ( - tileEntity.getPos().getZ() >> 4), 19, 35, 0x00CD00); + fontRenderer.drawString(tileEntity.isActive ? LangUtils.localize("gui.vibrating") : LangUtils.localize("gui.idle"), 19, 26, 0x00CD00); + fontRenderer.drawString(LangUtils.localize("gui.chunk") + ": " + (tileEntity.getPos().getX() >> 4) + ", " + (tileEntity.getPos().getZ() >> 4), 19, 35, 0x00CD00); super.drawGuiContainerForegroundLayer(mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/GuiSideConfiguration.java b/src/main/java/mekanism/client/gui/GuiSideConfiguration.java index 2b41c4470..76cdf14b2 100644 --- a/src/main/java/mekanism/client/gui/GuiSideConfiguration.java +++ b/src/main/java/mekanism/client/gui/GuiSideConfiguration.java @@ -89,8 +89,8 @@ public class GuiSideConfiguration extends GuiMekanismTile= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176 + 28, 0, 14, 14); } else { @@ -127,23 +127,20 @@ public class GuiSideConfiguration extends GuiMekanismTile= x && xAxis <= x + 14 && yAxis >= y && yAxis <= y + 14) { - drawHoveringText(data.color + data.localize() + " (" + data.color.getColoredName() + ")", xAxis, - yAxis); + drawHoveringText(data.color + data.localize() + " (" + data.color.getColoredName() + ")", xAxis, yAxis); } } } @@ -165,8 +162,8 @@ public class GuiSideConfiguration extends GuiMekanismTile= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { @@ -176,8 +173,7 @@ public class GuiSideConfiguration extends GuiMekanismTile= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - Mekanism.packetHandler.sendToServer( - new ConfigurationUpdateMessage(ConfigurationPacket.EJECT, Coord4D.get(tile), 0, 0, currentType)); + Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage(ConfigurationPacket.EJECT, Coord4D.get(tile), 0, 0, currentType)); } } if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && button == 0) { @@ -188,9 +184,7 @@ public class GuiSideConfiguration extends GuiMekanismTile= x && xAxis <= x + 14 && yAxis >= y && yAxis <= y + 14) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - Mekanism.packetHandler.sendToServer( - new ConfigurationUpdateMessage(ConfigurationPacket.SIDE_DATA, Coord4D.get(tile), button, i, - currentType)); + Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage(ConfigurationPacket.SIDE_DATA, Coord4D.get(tile), button, i, currentType)); } } } diff --git a/src/main/java/mekanism/client/gui/GuiTeleporter.java b/src/main/java/mekanism/client/gui/GuiTeleporter.java index 37a673a08..9c38e96bd 100644 --- a/src/main/java/mekanism/client/gui/GuiTeleporter.java +++ b/src/main/java/mekanism/client/gui/GuiTeleporter.java @@ -117,8 +117,7 @@ public class GuiTeleporter extends GuiMekanismTile { privateMode = !item.getFrequency(stack).publicFreq; setFrequency(item.getFrequency(stack).name); } else { - Mekanism.packetHandler.sendToServer( - new PortableTeleporterMessage(PortableTeleporterPacketType.DATA_REQUEST, currentHand, clientFreq)); + Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage(PortableTeleporterPacketType.DATA_REQUEST, currentHand, clientFreq)); } ySize = 175; } @@ -134,8 +133,7 @@ public class GuiTeleporter extends GuiMekanismTile { setButton = new GuiButton(2, guiWidth + 27, guiHeight + 116, 60, 20, LangUtils.localize("gui.set")); deleteButton = new GuiButton(3, guiWidth + 89, guiHeight + 116, 60, 20, LangUtils.localize("gui.delete")); if (!itemStack.isEmpty()) { - teleportButton = new GuiButton(4, guiWidth + 42, guiHeight + 140, 92, 20, - LangUtils.localize("gui.teleport")); + teleportButton = new GuiButton(4, guiWidth + 42, guiHeight + 140, 92, 20, LangUtils.localize("gui.teleport")); } frequencyField = new GuiTextField(5, fontRenderer, guiWidth + 50, guiHeight + 104, 86, 11); frequencyField.setMaxStringLength(FrequencyManager.MAX_FREQ_LENGTH); @@ -148,9 +146,7 @@ public class GuiTeleporter extends GuiMekanismTile { if (!itemStack.isEmpty()) { buttonList.add(teleportButton); if (!isInit) { - Mekanism.packetHandler.sendToServer( - new PortableTeleporterMessage(PortableTeleporterPacketType.DATA_REQUEST, currentHand, - clientFreq)); + Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage(PortableTeleporterPacketType.DATA_REQUEST, currentHand, clientFreq)); } else { isInit = false; } @@ -174,8 +170,7 @@ public class GuiTeleporter extends GuiMekanismTile { } public String getSecurity(Frequency freq) { - return !freq.publicFreq ? EnumColor.DARK_RED + LangUtils.localize("gui.private") - : LangUtils.localize("gui.public"); + return !freq.publicFreq ? EnumColor.DARK_RED + LangUtils.localize("gui.private") : LangUtils.localize("gui.public"); } public void updateButtons() { @@ -201,8 +196,7 @@ public class GuiTeleporter extends GuiMekanismTile { privateButton.enabled = true; } if (scrollList.hasSelection()) { - Frequency freq = privateMode ? getPrivateCache().get(scrollList.getSelection()) - : getPublicCache().get(scrollList.getSelection()); + Frequency freq = privateMode ? getPrivateCache().get(scrollList.getSelection()) : getPublicCache().get(scrollList.getSelection()); setButton.enabled = getFrequency() == null || !getFrequency().equals(freq); deleteButton.enabled = getOwner().equals(freq.ownerUUID); } else { @@ -227,8 +221,8 @@ public class GuiTeleporter extends GuiMekanismTile { updateButtons(); frequencyField.mouseClicked(mouseX, mouseY, button); if (button == 0) { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; if (xAxis >= 137 && xAxis <= 148 && yAxis >= 103 && yAxis <= 114) { setFrequency(frequencyField.getText()); frequencyField.setText(""); @@ -239,8 +233,7 @@ public class GuiTeleporter extends GuiMekanismTile { @Override protected ResourceLocation getGuiLocation() { - return MekanismUtils - .getResource(ResourceType.GUI, isPortable ? "GuiPortableTeleporter.png" : "GuiTeleporter.png"); + return MekanismUtils.getResource(ResourceType.GUI, isPortable ? "GuiPortableTeleporter.png" : "GuiTeleporter.png"); } @Override @@ -254,8 +247,7 @@ public class GuiTeleporter extends GuiMekanismTile { frequencyField.setText(""); } } - if (Character.isDigit(c) || Character.isLetter(c) || isTextboxKey(c, i) || FrequencyManager.SPECIAL_CHARS - .contains(c)) { + if (Character.isDigit(c) || Character.isLetter(c) || isTextboxKey(c, i) || FrequencyManager.SPECIAL_CHARS.contains(c)) { frequencyField.textboxKeyTyped(c, i); } updateButtons(); @@ -282,10 +274,8 @@ public class GuiTeleporter extends GuiMekanismTile { TileNetworkList data = TileNetworkList.withContents(1, freq.name, freq.publicFreq); Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); } else { - Mekanism.packetHandler.sendToServer( - new PortableTeleporterMessage(PortableTeleporterPacketType.DEL_FREQ, currentHand, freq)); - Mekanism.packetHandler.sendToServer( - new PortableTeleporterMessage(PortableTeleporterPacketType.DATA_REQUEST, currentHand, null)); + Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage(PortableTeleporterPacketType.DEL_FREQ, currentHand, freq)); + Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage(PortableTeleporterPacketType.DATA_REQUEST, currentHand, null)); } scrollList.clearSelection(); } @@ -301,22 +291,18 @@ public class GuiTeleporter extends GuiMekanismTile { @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { fontRenderer.drawString(getName(), (xSize / 2) - (fontRenderer.getStringWidth(getName()) / 2), 4, 0x404040); - fontRenderer.drawString( - LangUtils.localize("gui.owner") + ": " + (getOwnerUsername() != null ? getOwnerUsername() - : LangUtils.localize("gui.none")), 8, !itemStack.isEmpty() ? ySize - 12 : (ySize - 96) + 4, - 0x404040); + fontRenderer.drawString(LangUtils.localize("gui.owner") + ": " + (getOwnerUsername() != null ? getOwnerUsername() : LangUtils.localize("gui.none")), + 8, !itemStack.isEmpty() ? ySize - 12 : (ySize - 96) + 4, 0x404040); fontRenderer.drawString(LangUtils.localize("gui.freq") + ":", 32, 81, 0x404040); fontRenderer.drawString(LangUtils.localize("gui.security") + ":", 32, 91, 0x404040); - fontRenderer.drawString(" " + (getFrequency() != null ? getFrequency().name - : EnumColor.DARK_RED + LangUtils.localize("gui.none")), + fontRenderer.drawString(" " + (getFrequency() != null ? getFrequency().name : EnumColor.DARK_RED + LangUtils.localize("gui.none")), 32 + fontRenderer.getStringWidth(LangUtils.localize("gui.freq") + ":"), 81, 0x797979); - fontRenderer.drawString(" " + (getFrequency() != null ? getSecurity(getFrequency()) - : EnumColor.DARK_RED + LangUtils.localize("gui.none")), + fontRenderer.drawString(" " + (getFrequency() != null ? getSecurity(getFrequency()) : EnumColor.DARK_RED + LangUtils.localize("gui.none")), 32 + fontRenderer.getStringWidth(LangUtils.localize("gui.security") + ":"), 91, 0x797979); String str = LangUtils.localize("gui.set") + ":"; renderScaledText(str, 27, 104, 0x404040, 20); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; if (xAxis >= 6 && xAxis <= 24 && yAxis >= 6 && yAxis <= 24) { if (getFrequency() == null) { drawHoveringText(EnumColor.DARK_RED + LangUtils.localize("gui.teleporter.noFreq"), xAxis, yAxis); @@ -334,15 +320,14 @@ public class GuiTeleporter extends GuiMekanismTile { 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); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; if (xAxis >= 137 && xAxis <= 148 && yAxis >= 103 && yAxis <= 114) { drawTexturedModalRect(guiWidth + 137, guiHeight + 103, xSize, 0, 11, 11); } else { drawTexturedModalRect(guiWidth + 137, guiHeight + 103, xSize, 11, 11, 11); } - int y = getFrequency() == null ? 94 : (getStatus() == 2 ? 22 : (getStatus() == 3 ? 40 : - (getStatus() == 4 ? 58 : 76))); + int y = getFrequency() == null ? 94 : getStatus() == 2 ? 22 : getStatus() == 3 ? 40 : getStatus() == 4 ? 58 : 76; drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, y, 18, 18); super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); frequencyField.drawTextBox(); @@ -367,7 +352,6 @@ public class GuiTeleporter extends GuiMekanismTile { return tileEntity.getSecurity().getOwnerUUID(); } return ((IOwnerItem) itemStack.getItem()).getOwnerUUID(itemStack); - } private String getOwnerUsername() { @@ -402,8 +386,7 @@ public class GuiTeleporter extends GuiMekanismTile { Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); } else { Frequency newFreq = new Frequency(freq, null).setPublic(!privateMode); - Mekanism.packetHandler.sendToServer( - new PortableTeleporterMessage(PortableTeleporterPacketType.SET_FREQ, currentHand, newFreq)); + Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage(PortableTeleporterPacketType.SET_FREQ, currentHand, newFreq)); } } diff --git a/src/main/java/mekanism/client/gui/GuiThermalEvaporationController.java b/src/main/java/mekanism/client/gui/GuiThermalEvaporationController.java index 5ad5ae446..9e2a66653 100644 --- a/src/main/java/mekanism/client/gui/GuiThermalEvaporationController.java +++ b/src/main/java/mekanism/client/gui/GuiThermalEvaporationController.java @@ -14,6 +14,7 @@ import mekanism.common.util.UnitDisplayUtils; import mekanism.common.util.UnitDisplayUtils.TemperatureUnit; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import org.lwjgl.opengl.GL11; @@ -25,12 +26,10 @@ public class GuiThermalEvaporationController extends GuiMekanismTile tileEntity.inputTank, GuiGauge.Type.STANDARD, this, resource, 6, 13)); - addGuiElement(new GuiFluidGauge(() -> - tileEntity.outputTank, GuiGauge.Type.STANDARD, this, resource, 152, 13)); + addGuiElement(new GuiFluidGauge(() -> tileEntity.outputTank, GuiGauge.Type.STANDARD, this, resource, 152, 13)); addGuiElement(new GuiHeatInfo(() -> { TemperatureUnit unit = TemperatureUnit.values()[MekanismConfig.current().general.tempUnit.val().ordinal()]; - String environment = UnitDisplayUtils - .getDisplayShort(tileEntity.totalLoss * unit.intervalSize, false, unit); + String environment = UnitDisplayUtils.getDisplayShort(tileEntity.totalLoss * unit.intervalSize, false, unit); return Collections.singletonList(LangUtils.localize("gui.dissipated") + ": " + environment + "/t"); }, this, resource)); } @@ -38,26 +37,20 @@ public class GuiThermalEvaporationController extends GuiMekanismTile= 7 && xAxis <= 23 && yAxis >= 14 && yAxis <= 72) { - drawHoveringText(tileEntity.inputTank.getFluid() != null ? - LangUtils.localizeFluidStack(tileEntity.inputTank.getFluid()) + ": " + tileEntity.inputTank - .getFluidAmount() : LangUtils.localize("gui.empty"), xAxis, yAxis); + FluidStack fluid = tileEntity.inputTank.getFluid(); + drawHoveringText(fluid != null ? LangUtils.localizeFluidStack(fluid) + ": " + tileEntity.inputTank.getFluidAmount() : LangUtils.localize("gui.empty"), xAxis, yAxis); } if (xAxis >= 153 && xAxis <= 169 && yAxis >= 14 && yAxis <= 72) { - drawHoveringText(tileEntity.outputTank.getFluid() != null ? - LangUtils.localizeFluidStack(tileEntity.outputTank.getFluid()) + ": " + tileEntity.outputTank - .getFluidAmount() : LangUtils.localize("gui.empty"), xAxis, yAxis); + FluidStack fluid = tileEntity.outputTank.getFluid(); + drawHoveringText(fluid != null ? LangUtils.localizeFluidStack(fluid) + ": " + tileEntity.outputTank.getFluidAmount() : LangUtils.localize("gui.empty"), xAxis, yAxis); } if (xAxis >= 49 && xAxis <= 127 && yAxis >= 64 && yAxis <= 72) { drawHoveringText(getTemp(), xAxis, yAxis); @@ -68,12 +61,10 @@ public class GuiThermalEvaporationController extends GuiMekanismTile { TemperatureUnit unit = TemperatureUnit.values()[MekanismConfig.current().general.tempUnit.val().ordinal()]; - String environment = UnitDisplayUtils - .getDisplayShort(tileEntity.structure.lastEnvironmentLoss * unit.intervalSize, false, unit); + String environment = UnitDisplayUtils.getDisplayShort(tileEntity.structure.lastEnvironmentLoss * unit.intervalSize, false, unit); return Collections.singletonList(LangUtils.localize("gui.dissipated") + ": " + environment + "/t"); }, this, resource)); } @@ -63,28 +61,22 @@ public class GuiThermoelectricBoiler extends GuiEmbeddedGaugeTile= 7 && xAxis <= 23 && yAxis >= 14 && yAxis <= 72) { - drawHoveringText(tileEntity.structure.waterStored != null ? - LangUtils.localizeFluidStack(tileEntity.structure.waterStored) + ": " - + tileEntity.structure.waterStored.amount + "mB" : LangUtils.localize("gui.empty"), xAxis, - yAxis); + drawHoveringText(tileEntity.structure.waterStored != null + ? LangUtils.localizeFluidStack(tileEntity.structure.waterStored) + ": " + tileEntity.structure.waterStored.amount + "mB" + : LangUtils.localize("gui.empty"), xAxis, yAxis); } if (xAxis >= 153 && xAxis <= 169 && yAxis >= 14 && yAxis <= 72) { - drawHoveringText(tileEntity.structure.steamStored != null ? - LangUtils.localizeFluidStack(tileEntity.structure.steamStored) + ": " - + tileEntity.structure.steamStored.amount + "mB" : LangUtils.localize("gui.empty"), xAxis, - yAxis); + drawHoveringText(tileEntity.structure.steamStored != null + ? LangUtils.localizeFluidStack(tileEntity.structure.steamStored) + ": " + tileEntity.structure.steamStored.amount + "mB" + : LangUtils.localize("gui.empty"), xAxis, yAxis); } super.drawGuiContainerForegroundLayer(mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/GuiTransporterConfig.java b/src/main/java/mekanism/client/gui/GuiTransporterConfig.java index 77e37dd61..bdeaeacf2 100644 --- a/src/main/java/mekanism/client/gui/GuiTransporterConfig.java +++ b/src/main/java/mekanism/client/gui/GuiTransporterConfig.java @@ -58,8 +58,8 @@ public class GuiTransporterConfig extends GuiMekanismTile= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176 + 14, 0, 14, 14); } else { @@ -76,7 +76,7 @@ public class GuiTransporterConfig extends GuiMekanismTile= x && xAxis <= x + 14 && yAxis >= y && yAxis <= y + 14) { - drawHoveringText(color != null ? color.getColoredName() : LangUtils.localize("gui.none"), xAxis, - yAxis); + drawHoveringText(color != null ? color.getColoredName() : LangUtils.localize("gui.none"), xAxis, yAxis); } } } @@ -142,8 +139,8 @@ public class GuiTransporterConfig extends GuiMekanismTile= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { @@ -153,8 +150,7 @@ public class GuiTransporterConfig extends GuiMekanismTile= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - Mekanism.packetHandler.sendToServer( - new ConfigurationUpdateMessage(ConfigurationPacket.STRICT_INPUT, Coord4D.get(tile), 0, 0, null)); + Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage(ConfigurationPacket.STRICT_INPUT, Coord4D.get(tile), 0, 0, null)); } } if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && button == 0) { @@ -162,17 +158,14 @@ public class GuiTransporterConfig extends GuiMekanismTile= 122 && xAxis <= 138 && yAxis >= 49 && yAxis <= 65) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - Mekanism.packetHandler.sendToServer( - new ConfigurationUpdateMessage(ConfigurationPacket.EJECT_COLOR, Coord4D.get(tile), button, 0, null)); + Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage(ConfigurationPacket.EJECT_COLOR, Coord4D.get(tile), button, 0, null)); } 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) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - Mekanism.packetHandler.sendToServer( - new ConfigurationUpdateMessage(ConfigurationPacket.INPUT_COLOR, Coord4D.get(tile), button, i, - null)); + Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage(ConfigurationPacket.INPUT_COLOR, Coord4D.get(tile), button, i, null)); } } } diff --git a/src/main/java/mekanism/client/gui/GuiUpgradeManagement.java b/src/main/java/mekanism/client/gui/GuiUpgradeManagement.java index 959b53cf2..cf33721d8 100644 --- a/src/main/java/mekanism/client/gui/GuiUpgradeManagement.java +++ b/src/main/java/mekanism/client/gui/GuiUpgradeManagement.java @@ -64,8 +64,7 @@ public class GuiUpgradeManagement extends GuiMekanism { } else { int amount = tileEntity.getComponent().getUpgrades(selectedType); renderText(selectedType.getName() + " " + LangUtils.localize("gui.upgrade"), 92, 8, 0.6F, true); - renderText(LangUtils.localize("gui.upgrades.amount") + ": " + amount + "/" + selectedType.getMax(), 92, 16, - 0.6F, true); + renderText(LangUtils.localize("gui.upgrades.amount") + ": " + amount + "/" + selectedType.getMax(), 92, 16, 0.6F, true); int text = 0; for (String s : selectedType.getInfo((TileEntity) tileEntity)) { renderText(s, 92, 22 + (6 * text++), 0.6F, true); @@ -79,8 +78,8 @@ public class GuiUpgradeManagement extends GuiMekanism { } } Upgrade[] upgrades = getCurrentUpgrades().toArray(new Upgrade[0]); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; for (int i = 0; i < 4; i++) { int index = getUpgradeIndex() + i; if (index > upgrades.length - 1) { @@ -92,8 +91,7 @@ public class GuiUpgradeManagement extends GuiMekanism { fontRenderer.drawString(upgrade.getName(), xPos + 12, yPos + 2, 0x404040); renderUpgrade(upgrade, xPos + 2, yPos + 2, 0.5F, true); if (xAxis >= xPos && xAxis <= xPos + 58 && yAxis >= yPos && yAxis <= yPos + 12) { - drawHoveringText(MekanismUtils.splitTooltip(upgrade.getDescription(), upgrade.getStack()), xAxis, - yAxis); + drawHoveringText(MekanismUtils.splitTooltip(upgrade.getDescription(), upgrade.getStack()), xAxis, yAxis); } } @@ -103,8 +101,7 @@ public class GuiUpgradeManagement extends GuiMekanism { private void renderText(String text, int x, int y, float size, boolean scale) { GlStateManager.pushMatrix(); GlStateManager.scale(size, size, size); - fontRenderer - .drawString(text, scale ? (int) ((1F / size) * x) : x, scale ? (int) ((1F / size) * y) : y, 0x00CD00); + fontRenderer.drawString(text, scale ? (int) ((1F / size) * x) : x, scale ? (int) ((1F / size) * y) : y, 0x00CD00); GlStateManager.popMatrix(); } @@ -112,8 +109,7 @@ public class GuiUpgradeManagement extends GuiMekanism { GlStateManager.pushMatrix(); GlStateManager.scale(size, size, size); RenderHelper.enableGUIStandardItemLighting(); - itemRender.renderItemAndEffectIntoGUI(type.getStack(), scale ? (int) ((1F / size) * x) : x, - scale ? (int) ((1F / size) * y) : y); + itemRender.renderItemAndEffectIntoGUI(type.getStack(), scale ? (int) ((1F / size) * x) : x, scale ? (int) ((1F / size) * y) : y); RenderHelper.disableStandardItemLighting(); GlStateManager.popMatrix(); } @@ -125,8 +121,8 @@ public class GuiUpgradeManagement extends GuiMekanism { 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); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; if (xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, 0, 14, 14); } else { @@ -180,14 +176,14 @@ public class GuiUpgradeManagement extends GuiMekanism { if (getCurrentUpgrades().size() <= 4) { return 0; } - return (int) ((getCurrentUpgrades().size() * scroll) - ((4F / (float) getCurrentUpgrades().size())) * scroll); + return (int) ((getCurrentUpgrades().size() * scroll) - (4F / (float) getCurrentUpgrades().size()) * scroll); } @Override protected void mouseClickMove(int mouseX, int mouseY, int button, long ticks) { super.mouseClickMove(mouseX, mouseY, button, ticks); if (isDragging) { - int yAxis = (mouseY - (height - ySize) / 2); + int yAxis = mouseY - (height - ySize) / 2; scroll = Math.min(Math.max((float) (yAxis - 8 - dragOffset) / 42F, 0), 1); } } @@ -209,8 +205,8 @@ public class GuiUpgradeManagement extends GuiMekanism { @Override protected void mouseClicked(int mouseX, int mouseY, int button) throws IOException { super.mouseClicked(mouseX, mouseY, button); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; TileEntity tile = (TileEntity) tileEntity; if (button == 0) { if (xAxis >= 84 && xAxis <= 88 && yAxis >= getScroll() + 8 && yAxis <= getScroll() + 8 + 4) { @@ -228,8 +224,7 @@ public class GuiUpgradeManagement extends GuiMekanism { } if (selectedType != null && xAxis >= 136 && xAxis <= 148 && yAxis >= 57 && yAxis <= 69) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - Mekanism.packetHandler - .sendToServer(new RemoveUpgradeMessage(Coord4D.get(tile), selectedType.ordinal())); + Mekanism.packetHandler.sendToServer(new RemoveUpgradeMessage(Coord4D.get(tile), selectedType.ordinal())); } int counter = 0; for (Upgrade upgrade : getCurrentUpgrades()) { diff --git a/src/main/java/mekanism/client/gui/IGuiWrapper.java b/src/main/java/mekanism/client/gui/IGuiWrapper.java index 0a6b8ae56..bc6ac9308 100644 --- a/src/main/java/mekanism/client/gui/IGuiWrapper.java +++ b/src/main/java/mekanism/client/gui/IGuiWrapper.java @@ -20,4 +20,4 @@ public interface IGuiWrapper { @Nullable FontRenderer getFont(); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/chemical/GuiChemical.java b/src/main/java/mekanism/client/gui/chemical/GuiChemical.java index 12a906568..15aad8387 100644 --- a/src/main/java/mekanism/client/gui/chemical/GuiChemical.java +++ b/src/main/java/mekanism/client/gui/chemical/GuiChemical.java @@ -32,11 +32,10 @@ public abstract class GuiChemical extends @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { drawForegroundText(); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; if (xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80) { - drawHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), xAxis, - yAxis); + drawHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), xAxis, yAxis); } super.drawGuiContainerForegroundLayer(mouseX, mouseY); } diff --git a/src/main/java/mekanism/client/gui/chemical/GuiChemicalCrystallizer.java b/src/main/java/mekanism/client/gui/chemical/GuiChemicalCrystallizer.java index 6bab62b63..4686b845d 100644 --- a/src/main/java/mekanism/client/gui/chemical/GuiChemicalCrystallizer.java +++ b/src/main/java/mekanism/client/gui/chemical/GuiChemicalCrystallizer.java @@ -59,8 +59,7 @@ public class GuiChemicalCrystallizer extends GuiMekanismTile { String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); return Arrays.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", - LangUtils.localize("gui.needed") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); + LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); }, this, resource)); addGuiElement(new GuiGasGauge(() -> tileEntity.inputTank, GuiGauge.Type.STANDARD, this, resource, 5, 4)); addGuiElement(new GuiSlot(SlotType.EXTRA, this, resource, 5, 64).with(SlotOverlay.PLUS)); @@ -80,9 +79,7 @@ public class GuiChemicalCrystallizer extends GuiMekanismTile { String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); return Arrays.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", - LangUtils.localize("gui.needed") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); + LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); }, this, resource)); addGuiElement(new GuiGasGauge(() -> tileEntity.injectTank, GuiGauge.Type.STANDARD, this, resource, 5, 4)); addGuiElement(new GuiGasGauge(() -> tileEntity.outputTank, GuiGauge.Type.STANDARD, this, resource, 133, 13)); diff --git a/src/main/java/mekanism/client/gui/chemical/GuiChemicalInfuser.java b/src/main/java/mekanism/client/gui/chemical/GuiChemicalInfuser.java index 68319792b..2c622fc0a 100644 --- a/src/main/java/mekanism/client/gui/chemical/GuiChemicalInfuser.java +++ b/src/main/java/mekanism/client/gui/chemical/GuiChemicalInfuser.java @@ -35,8 +35,7 @@ public class GuiChemicalInfuser extends GuiChemical { addGuiElement(new GuiEnergyInfo(() -> { String usage = MekanismUtils.getEnergyDisplay(tileEntity.clientEnergyUsed); return Arrays.asList(LangUtils.localize("gui.using") + ": " + usage + "/t", - LangUtils.localize("gui.needed") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); + LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); }, this, resource)); addGuiElement(new GuiGasGauge(() -> tileEntity.leftTank, GuiGauge.Type.STANDARD, this, resource, 25, 13)); addGuiElement(new GuiGasGauge(() -> tileEntity.centerTank, GuiGauge.Type.STANDARD, this, resource, 79, 4)); diff --git a/src/main/java/mekanism/client/gui/chemical/GuiChemicalOxidizer.java b/src/main/java/mekanism/client/gui/chemical/GuiChemicalOxidizer.java index 1ec37052d..e6d8518b1 100644 --- a/src/main/java/mekanism/client/gui/chemical/GuiChemicalOxidizer.java +++ b/src/main/java/mekanism/client/gui/chemical/GuiChemicalOxidizer.java @@ -35,8 +35,7 @@ public class GuiChemicalOxidizer extends GuiChemical addGuiElement(new GuiEnergyInfo(() -> { String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); return Arrays.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", - LangUtils.localize("gui.needed") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); + LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); }, this, resource)); addGuiElement(new GuiGasGauge(() -> tileEntity.gasTank, GuiGauge.Type.STANDARD, this, resource, 133, 13)); addGuiElement(new GuiSlot(SlotType.NORMAL, this, resource, 154, 4).with(SlotOverlay.POWER)); diff --git a/src/main/java/mekanism/client/gui/chemical/GuiChemicalWasher.java b/src/main/java/mekanism/client/gui/chemical/GuiChemicalWasher.java index 6888f10ea..c29a9f4fa 100644 --- a/src/main/java/mekanism/client/gui/chemical/GuiChemicalWasher.java +++ b/src/main/java/mekanism/client/gui/chemical/GuiChemicalWasher.java @@ -39,8 +39,7 @@ public class GuiChemicalWasher extends GuiChemical { addGuiElement(new GuiEnergyInfo(() -> { String usage = MekanismUtils.getEnergyDisplay(tileEntity.clientEnergyUsed); return Arrays.asList(LangUtils.localize("gui.using") + ": " + usage + "/t", - LangUtils.localize("gui.needed") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); + LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy())); }, this, resource)); addGuiElement(new GuiFluidGauge(() -> tileEntity.fluidTank, Type.STANDARD, this, resource, 5, 4)); addGuiElement(new GuiGasGauge(() -> tileEntity.inputTank, GuiGauge.Type.STANDARD, this, resource, 26, 13)); diff --git a/src/main/java/mekanism/client/gui/element/GuiAmplifierTab.java b/src/main/java/mekanism/client/gui/element/GuiAmplifierTab.java index 7b9cef6a1..cc0aceb74 100644 --- a/src/main/java/mekanism/client/gui/element/GuiAmplifierTab.java +++ b/src/main/java/mekanism/client/gui/element/GuiAmplifierTab.java @@ -1,10 +1,10 @@ package mekanism.client.gui.element; import mekanism.api.Coord4D; +import mekanism.api.TileNetworkList; import mekanism.client.gui.IGuiWrapper; import mekanism.client.sound.SoundHandler; import mekanism.common.Mekanism; -import mekanism.api.TileNetworkList; import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.tile.TileEntityLaserAmplifier; import mekanism.common.util.LangUtils; @@ -37,8 +37,7 @@ public class GuiAmplifierTab extends GuiTileEntityElement= 180 && xAxis <= 196 && yAxis >= 71 && yAxis <= 87 || xAxis >= 180 && xAxis <= 196 - && yAxis >= 102 && yAxis <= 118; + return xAxis >= 180 && xAxis <= 196 && yAxis >= 71 && yAxis <= 87 || xAxis >= 180 && xAxis <= 196 && yAxis >= 102 && yAxis <= 118; } @Override diff --git a/src/main/java/mekanism/client/gui/element/GuiConfigTypeTab.java b/src/main/java/mekanism/client/gui/element/GuiConfigTypeTab.java index 626586fa0..31f8c0ba8 100644 --- a/src/main/java/mekanism/client/gui/element/GuiConfigTypeTab.java +++ b/src/main/java/mekanism/client/gui/element/GuiConfigTypeTab.java @@ -65,8 +65,7 @@ public class GuiConfigTypeTab extends GuiElement { } mc.renderEngine.bindTexture(RESOURCE); guiObj.drawTexturedRect(guiWidth + getLeftBound(false) - 4, guiHeight + yPos, 0, left ? 0 : 26, 26, 26); - guiObj.drawTexturedRect(guiWidth + getLeftBound(true), guiHeight + yPos + 4, 26, - inBounds(xAxis, yAxis) ? 0 : 18, 18, 18); + guiObj.drawTexturedRect(guiWidth + getLeftBound(true), guiHeight + yPos + 4, 26, inBounds(xAxis, yAxis) ? 0 : 18, 18, 18); mc.renderEngine.bindTexture(defaultLocation); } diff --git a/src/main/java/mekanism/client/gui/element/GuiContainerEditMode.java b/src/main/java/mekanism/client/gui/element/GuiContainerEditMode.java index 8429c4abd..58e72c780 100644 --- a/src/main/java/mekanism/client/gui/element/GuiContainerEditMode.java +++ b/src/main/java/mekanism/client/gui/element/GuiContainerEditMode.java @@ -62,8 +62,7 @@ public class GuiContainerEditMode extends GuiTileEntityElement { public static GuiFluidGauge getDummy(Type type, IGuiWrapper gui, ResourceLocation def, int x, int y) { GuiFluidGauge gauge = new GuiFluidGauge(null, type, gui, def, x, y); gauge.dummy = true; - return gauge; } @@ -44,15 +43,13 @@ public class GuiFluidGauge extends GuiGauge { if (dummy) { return dummyType.getFluid().getColor(); } - FluidStack fluid = infoHandler.getTank().getFluid(); return fluid == null ? dummyType.getFluid().getColor() : fluid.getFluid().getColor(fluid); } @Override protected boolean inBounds(int xAxis, int yAxis) { - return xAxis >= xLocation + 1 && xAxis <= xLocation + width - 1 && yAxis >= yLocation + 1 - && yAxis <= yLocation + height - 1; + return xAxis >= xLocation + 1 && xAxis <= xLocation + width - 1 && yAxis >= yLocation + 1 && yAxis <= yLocation + height - 1; } @Override @@ -64,18 +61,14 @@ public class GuiFluidGauge extends GuiGauge { public void mouseClicked(int xAxis, int yAxis, int button) { if (inBounds(xAxis, yAxis)) { ItemStack stack = mc.player.inventory.getItemStack(); - if (guiObj instanceof GuiMekanismTile && !stack.isEmpty() && stack.getItem() instanceof ItemGaugeDropper) { TileEntity tile = ((GuiMekanismTile) guiObj).getTileEntity(); - if (tile instanceof ITankManager && ((ITankManager) tile).getTanks() != null) { int index = Arrays.asList(((ITankManager) tile).getTanks()).indexOf(infoHandler.getTank()); - if (index != -1) { if (button == 0 && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { button = 2; } - Mekanism.packetHandler.sendToServer(new DropperUseMessage(Coord4D.get(tile), button, index)); } } @@ -111,12 +104,9 @@ public class GuiFluidGauge extends GuiGauge { if (dummy) { return dummyType.getLocalizedName(); } - - String amountStr = (infoHandler.getTank().getFluidAmount() == Integer.MAX_VALUE ? LangUtils - .localize("gui.infinite") : infoHandler.getTank().getFluidAmount() + " mB"); - - return infoHandler.getTank().getFluid() != null ? LangUtils.localizeFluidStack(infoHandler.getTank().getFluid()) - + ": " + amountStr : LangUtils.localize("gui.empty"); + FluidTank tank = infoHandler.getTank(); + String amountStr = tank.getFluidAmount() == Integer.MAX_VALUE ? LangUtils.localize("gui.infinite") : tank.getFluidAmount() + " mB"; + return tank.getFluid() != null ? LangUtils.localizeFluidStack(tank.getFluid()) + ": " + amountStr : LangUtils.localize("gui.empty"); } public interface IFluidInfoHandler { diff --git a/src/main/java/mekanism/client/gui/element/GuiGasGauge.java b/src/main/java/mekanism/client/gui/element/GuiGasGauge.java index 7eac473ba..372559128 100644 --- a/src/main/java/mekanism/client/gui/element/GuiGasGauge.java +++ b/src/main/java/mekanism/client/gui/element/GuiGasGauge.java @@ -33,14 +33,12 @@ public class GuiGasGauge extends GuiGauge { public static GuiGasGauge getDummy(Type type, IGuiWrapper gui, ResourceLocation def, int x, int y) { GuiGasGauge gauge = new GuiGasGauge(null, type, gui, def, x, y); gauge.dummy = true; - return gauge; } @Override protected boolean inBounds(int xAxis, int yAxis) { - return xAxis >= xLocation + 1 && xAxis <= xLocation + width - 1 && yAxis >= yLocation + 1 - && yAxis <= yLocation + height - 1; + return xAxis >= xLocation + 1 && xAxis <= xLocation + width - 1 && yAxis >= yLocation + 1 && yAxis <= yLocation + height - 1; } @Override @@ -52,18 +50,14 @@ public class GuiGasGauge extends GuiGauge { public void mouseClicked(int xAxis, int yAxis, int button) { if (inBounds(xAxis, yAxis)) { ItemStack stack = mc.player.inventory.getItemStack(); - if (guiObj instanceof GuiMekanismTile && !stack.isEmpty() && stack.getItem() instanceof ItemGaugeDropper) { TileEntity tile = ((GuiMekanismTile) guiObj).getTileEntity(); - if (tile instanceof ITankManager && ((ITankManager) tile).getTanks() != null) { int index = Arrays.asList(((ITankManager) tile).getTanks()).indexOf(infoHandler.getTank()); - if (index != -1) { if (button == 0 && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { button = 2; } - Mekanism.packetHandler.sendToServer(new DropperUseMessage(Coord4D.get(tile), button, index)); } } @@ -76,11 +70,9 @@ public class GuiGasGauge extends GuiGauge { if (dummy) { return height - 2; } - if (infoHandler.getTank().getGas() == null || infoHandler.getTank().getMaxGas() == 0) { return 0; } - return infoHandler.getTank().getStored() * (height - 2) / infoHandler.getTank().getMaxGas(); } @@ -89,10 +81,8 @@ public class GuiGasGauge extends GuiGauge { if (dummy) { return dummyType.getSprite(); } - - return (infoHandler.getTank() != null && infoHandler.getTank().getGas() != null - && infoHandler.getTank().getGas().getGas() != null) ? infoHandler.getTank().getGas().getGas().getSprite() - : null; + return (infoHandler.getTank() != null && infoHandler.getTank().getGas() != null && infoHandler.getTank().getGas().getGas() != null) ? + infoHandler.getTank().getGas().getGas().getSprite() : null; } @Override @@ -100,9 +90,8 @@ public class GuiGasGauge extends GuiGauge { if (dummy) { return dummyType.getLocalizedName(); } - - return (infoHandler.getTank().getGas() != null) ? infoHandler.getTank().getGas().getGas().getLocalizedName() - + ": " + infoHandler.getTank().getStored() : LangUtils.localize("gui.empty"); + return (infoHandler.getTank().getGas() != null) ? infoHandler.getTank().getGas().getGas().getLocalizedName() + ": " + infoHandler.getTank().getStored() + : LangUtils.localize("gui.empty"); } @Override @@ -110,9 +99,8 @@ public class GuiGasGauge extends GuiGauge { if (dummy) { return dummyType.getTint(); } - return (infoHandler.getTank().getGas() != null) ? infoHandler.getTank().getGas().getGas().getTint() - : super.getRenderColor(); + : super.getRenderColor(); } public interface IGasInfoHandler { diff --git a/src/main/java/mekanism/client/gui/element/GuiGauge.java b/src/main/java/mekanism/client/gui/element/GuiGauge.java index 33c21eb05..4de404e73 100644 --- a/src/main/java/mekanism/client/gui/element/GuiGauge.java +++ b/src/main/java/mekanism/client/gui/element/GuiGauge.java @@ -34,7 +34,6 @@ public abstract class GuiGauge extends GuiElement { public GuiGauge(Type type, IGuiWrapper gui, ResourceLocation def, int x, int y) { super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, type.textureLocation), gui, def); - xLocation = x; yLocation = y; @@ -95,8 +94,7 @@ public abstract class GuiGauge extends GuiElement { } for (int i = 0; i < number; i++) { - guiObj.drawTexturedRectFromIcon(guiWidth + xLocation + 16 * i + 1, - guiHeight + yLocation + height - renderRemaining - start - 1, getIcon(), 16, renderRemaining); + guiObj.drawTexturedRectFromIcon(guiWidth + xLocation + 16 * i + 1, guiHeight + yLocation + height - renderRemaining - start - 1, getIcon(), 16, renderRemaining); } MekanismRenderer.resetColor(); @@ -114,27 +112,21 @@ public abstract class GuiGauge extends GuiElement { @Override public void renderForeground(int xAxis, int yAxis) { - if (xAxis >= xLocation + 1 && xAxis <= xLocation + width - 1 && yAxis >= yLocation + 1 - && yAxis <= yLocation + height - 1) { + if (xAxis >= xLocation + 1 && xAxis <= xLocation + width - 1 && yAxis >= yLocation + 1 && yAxis <= yLocation + height - 1) { ItemStack stack = mc.player.inventory.getItemStack(); - if (!stack.isEmpty() && stack.getItem() instanceof ItemConfigurator && color != null) { if (guiObj instanceof GuiMekanismTile && ((GuiMekanismTile) guiObj).getTileEntity() != null) { TileEntity tile = ((GuiMekanismTile) guiObj).getTileEntity(); - if (tile instanceof ISideConfiguration && getTransmission() != null) { SideData data = null; - - for (SideData iterData : ((ISideConfiguration) tile).getConfig() - .getOutputs(getTransmission())) { + for (SideData iterData : ((ISideConfiguration) tile).getConfig().getOutputs(getTransmission())) { if (iterData.color == color) { data = iterData; break; } } String localized = data == null ? "" : data.localize(); - guiObj.displayTooltip(color + localized + " (" + color.getColoredName() + ")", xAxis, - yAxis); + guiObj.displayTooltip(color + localized + " (" + color.getColoredName() + ")", xAxis, yAxis); } } } else { diff --git a/src/main/java/mekanism/client/gui/element/GuiGraph.java b/src/main/java/mekanism/client/gui/element/GuiGraph.java index 4fbd9ce52..6fce15dff 100644 --- a/src/main/java/mekanism/client/gui/element/GuiGraph.java +++ b/src/main/java/mekanism/client/gui/element/GuiGraph.java @@ -24,8 +24,7 @@ public class GuiGraph extends GuiElement { private int currentScale = 10; private boolean fixedScale = false; - public GuiGraph(IGuiWrapper gui, ResourceLocation def, int x, int y, int sizeX, int sizeY, - GraphDataHandler handler) { + public GuiGraph(IGuiWrapper gui, ResourceLocation def, int x, int y, int sizeX, int sizeY, GraphDataHandler handler) { super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiGraph.png"), gui, def); xPosition = x; yPosition = y; @@ -45,7 +44,6 @@ public class GuiGraph extends GuiElement { } graphData.add(data); - if (!fixedScale) { for (int i : graphData) { if (i > currentScale) { @@ -96,10 +94,9 @@ public class GuiGraph extends GuiElement { for (int yIter = 0; yIter < yDisplays; yIter++) { for (int xIter = 0; xIter < xDisplays; xIter++) { - int width = (xSize % 10 > 0 && xIter == xDisplays - 1 ? xSize % 10 : 10); - int height = (ySize % 10 > 0 && yIter == yDisplays - 1 ? ySize % 10 : 10); - guiObj.drawTexturedRect(guiWidth + xPosition + (xIter * 10), guiHeight + yPosition + (yIter * 10), 0, 0, - width, height); + int width = xSize % 10 > 0 && xIter == xDisplays - 1 ? xSize % 10 : 10; + int height = ySize % 10 > 0 && yIter == yDisplays - 1 ? ySize % 10 : 10; + guiObj.drawTexturedRect(guiWidth + xPosition + (xIter * 10), guiHeight + yPosition + (yIter * 10), 0, 0, width, height); } } } @@ -108,17 +105,15 @@ public class GuiGraph extends GuiElement { for (int i = 0; i < graphData.size(); i++) { int data = Math.min(currentScale, graphData.get(i)); int relativeHeight = (int) (((double) data / (double) currentScale) * ySize); - guiObj.drawTexturedRect(guiWidth + xPosition + i, guiHeight + yPosition + (ySize - relativeHeight), 10, 0, - 1, 1); + guiObj.drawTexturedRect(guiWidth + xPosition + i, guiHeight + yPosition + (ySize - relativeHeight), 10, 0, 1, 1); int displays = (relativeHeight - 1) / 10 + ((relativeHeight - 1) % 10 > 0 ? 1 : 0); for (int iter = 0; iter < displays; iter++) { MekanismRenderer.blendOn(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.2F + (0.8F * ((float) i / (float) graphData.size()))); - int height = ((relativeHeight - 1) % 10 > 0 && iter == displays - 1 ? (relativeHeight - 1) % 10 : 10); - guiObj.drawTexturedRect(guiWidth + xPosition + i, - guiHeight + yPosition + (ySize - (iter * 10)) - 10 + (10 - height), 11, 0, 1, height); + int height = (relativeHeight - 1) % 10 > 0 && iter == displays - 1 ? (relativeHeight - 1) % 10 : 10; + guiObj.drawTexturedRect(guiWidth + xPosition + i, guiHeight + yPosition + (ySize - (iter * 10)) - 10 + (10 - height), 11, 0, 1, height); MekanismRenderer.blendOff(); } } diff --git a/src/main/java/mekanism/client/gui/element/GuiHeatInfo.java b/src/main/java/mekanism/client/gui/element/GuiHeatInfo.java index 9c2d1e9f2..4edc0f5c7 100644 --- a/src/main/java/mekanism/client/gui/element/GuiHeatInfo.java +++ b/src/main/java/mekanism/client/gui/element/GuiHeatInfo.java @@ -55,9 +55,7 @@ public class GuiHeatInfo extends GuiElement { @Override public void mouseClicked(int xAxis, int yAxis, int button) { if (button == 0 && inBounds(xAxis, yAxis)) { - MekanismConfig.current().general.tempUnit - .set(TempType.values()[(MekanismConfig.current().general.tempUnit.val().ordinal() + 1) % TempType - .values().length]); + MekanismConfig.current().general.tempUnit.set(TempType.values()[(MekanismConfig.current().general.tempUnit.val().ordinal() + 1) % TempType.values().length]); } } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/element/GuiPowerBar.java b/src/main/java/mekanism/client/gui/element/GuiPowerBar.java index 010fb0b42..219445515 100644 --- a/src/main/java/mekanism/client/gui/element/GuiPowerBar.java +++ b/src/main/java/mekanism/client/gui/element/GuiPowerBar.java @@ -20,7 +20,6 @@ public class GuiPowerBar extends GuiElement { public GuiPowerBar(IGuiWrapper gui, IStrictEnergyStorage tile, ResourceLocation def, int x, int y) { super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiPowerBar.png"), gui, def); - tileEntity = tile; handler = new IPowerInfoHandler() { @@ -61,15 +60,11 @@ public class GuiPowerBar extends GuiElement { @Override public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { mc.renderEngine.bindTexture(RESOURCE); - guiObj.drawTexturedRect(guiWidth + xLocation, guiHeight + yLocation, 0, 0, width, height); - if (handler.getLevel() > 0) { int displayInt = (int) (handler.getLevel() * 52) + 2; - guiObj.drawTexturedRect(guiWidth + xLocation, guiHeight + yLocation + height - displayInt, 6, - height - displayInt, width, displayInt); + guiObj.drawTexturedRect(guiWidth + xLocation, guiHeight + yLocation + height - displayInt, 6, height - displayInt, width, displayInt); } - mc.renderEngine.bindTexture(defaultLocation); } diff --git a/src/main/java/mekanism/client/gui/element/GuiProgress.java b/src/main/java/mekanism/client/gui/element/GuiProgress.java index 674eb1e71..d114bd65d 100644 --- a/src/main/java/mekanism/client/gui/element/GuiProgress.java +++ b/src/main/java/mekanism/client/gui/element/GuiProgress.java @@ -15,8 +15,7 @@ public class GuiProgress extends GuiElement { private final int xLocation; private final int yLocation; - public GuiProgress(IProgressInfoHandler handler, ProgressBar type, IGuiWrapper gui, ResourceLocation def, int x, - int y) { + public GuiProgress(IProgressInfoHandler handler, ProgressBar type, IGuiWrapper gui, ResourceLocation def, int x, int y) { super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiProgress.png"), gui, def); xLocation = x; yLocation = y; @@ -35,12 +34,10 @@ public class GuiProgress extends GuiElement { mc.renderEngine.bindTexture(RESOURCE); if (handler.isActive()) { - guiObj.drawTexturedRect(guiWidth + xLocation, guiHeight + yLocation, type.textureX, type.textureY, - type.width, type.height); + guiObj.drawTexturedRect(guiWidth + xLocation, guiHeight + yLocation, type.textureX, type.textureY, type.width, type.height); int innerOffsetX = 2; int displayInt = (int) (handler.getProgress() * (type.width - 2 * innerOffsetX)); - guiObj.drawTexturedRect(guiWidth + xLocation + innerOffsetX, guiHeight + yLocation, - type.textureX + type.width + innerOffsetX, type.textureY, displayInt, type.height); + guiObj.drawTexturedRect(guiWidth + xLocation + innerOffsetX, guiHeight + yLocation, type.textureX + type.width + innerOffsetX, type.textureY, displayInt, type.height); } mc.renderEngine.bindTexture(defaultLocation); diff --git a/src/main/java/mekanism/client/gui/element/GuiRateBar.java b/src/main/java/mekanism/client/gui/element/GuiRateBar.java index 77ebeb66b..956da2748 100644 --- a/src/main/java/mekanism/client/gui/element/GuiRateBar.java +++ b/src/main/java/mekanism/client/gui/element/GuiRateBar.java @@ -30,8 +30,7 @@ public class GuiRateBar extends GuiElement { @Override protected boolean inBounds(int xAxis, int yAxis) { - return xAxis >= xLocation + 1 && xAxis <= xLocation + width - 1 && yAxis >= yLocation + 1 - && yAxis <= yLocation + height - 1; + return xAxis >= xLocation + 1 && xAxis <= xLocation + width - 1 && yAxis >= yLocation + 1 && yAxis <= yLocation + height - 1; } @Override @@ -40,8 +39,7 @@ public class GuiRateBar extends GuiElement { guiObj.drawTexturedRect(guiWidth + xLocation, guiHeight + yLocation, 0, 0, width, height); if (handler.getLevel() > 0) { int displayInt = (int) (handler.getLevel() * 58); - guiObj.drawTexturedRect(guiWidth + xLocation + 1, guiHeight + yLocation + height - 1 - displayInt, 8, - height - 2 - displayInt, width - 2, displayInt); + guiObj.drawTexturedRect(guiWidth + xLocation + 1, guiHeight + yLocation + height - 1 - displayInt, 8, height - 2 - displayInt, width - 2, displayInt); } mc.renderEngine.bindTexture(defaultLocation); } diff --git a/src/main/java/mekanism/client/gui/element/GuiRedstoneControl.java b/src/main/java/mekanism/client/gui/element/GuiRedstoneControl.java index 9105f6db0..53438ab09 100644 --- a/src/main/java/mekanism/client/gui/element/GuiRedstoneControl.java +++ b/src/main/java/mekanism/client/gui/element/GuiRedstoneControl.java @@ -68,8 +68,7 @@ public class GuiRedstoneControl extends GuiTileEntityElement { } SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - Mekanism.packetHandler.sendToServer( - new RedstoneControlMessage(Coord4D.get(tileEntity), RedstoneControl.values()[ordinalToSet])); + Mekanism.packetHandler.sendToServer(new RedstoneControlMessage(Coord4D.get(tileEntity), RedstoneControl.values()[ordinalToSet])); } } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/element/GuiScrollList.java b/src/main/java/mekanism/client/gui/element/GuiScrollList.java index 8e652df15..86f507ec1 100644 --- a/src/main/java/mekanism/client/gui/element/GuiScrollList.java +++ b/src/main/java/mekanism/client/gui/element/GuiScrollList.java @@ -71,10 +71,8 @@ public class GuiScrollList extends GuiElement { @Override public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { mc.renderEngine.bindTexture(RESOURCE); - drawBlack(guiWidth, guiHeight); drawSelected(guiWidth, guiHeight, selected); - mc.renderEngine.bindTexture(defaultLocation); } @@ -83,9 +81,8 @@ public class GuiScrollList extends GuiElement { for (int yIter = 0; yIter < size; yIter++) { for (int xIter = 0; xIter < xDisplays; xIter++) { - int width = (xSize % 10 > 0 && xIter == xDisplays - 1 ? xSize % 10 : 10); - guiObj.drawTexturedRect(guiWidth + xPosition + (xIter * 10), guiHeight + yPosition + (yIter * 10), 0, 0, - width, 10); + int width = xSize % 10 > 0 && xIter == xDisplays - 1 ? xSize % 10 : 10; + guiObj.drawTexturedRect(guiWidth + xPosition + (xIter * 10), guiHeight + yPosition + (yIter * 10), 0, 0, width, 10); } } } @@ -97,9 +94,8 @@ public class GuiScrollList extends GuiElement { int xDisplays = xSize / 10 + (xSize % 10 > 0 ? 1 : 0); for (int xIter = 0; xIter < xDisplays; xIter++) { - int width = (xSize % 10 > 0 && xIter == xDisplays - 1 ? xSize % 10 : 10); - guiObj.drawTexturedRect(guiWidth + xPosition + (xIter * 10), - guiHeight + yPosition + (index - scroll) * 10, 0, 10, width, 10); + int width = xSize % 10 > 0 && xIter == xDisplays - 1 ? xSize % 10 : 10; + guiObj.drawTexturedRect(guiWidth + xPosition + (xIter * 10), guiHeight + yPosition + (index - scroll) * 10, 0, 10, width, 10); } } } @@ -125,15 +121,14 @@ public class GuiScrollList extends GuiElement { } public int getScroll() { - return Math.max(Math.min((int) (scroll * (getMaxScroll() - 4)), (getMaxScroll() - 4)), 0); + return Math.max(Math.min((int) (scroll * (getMaxScroll() - 4)), getMaxScroll() - 4), 0); } public int getScrollIndex() { if (textEntries.size() <= size) { return 0; } - - return (int) ((textEntries.size() * scroll) - (((float) size / (float) textEntries.size())) * scroll); + return (int) ((textEntries.size() * scroll) - ((float) size / (float) textEntries.size()) * scroll); } @Override @@ -141,18 +136,14 @@ public class GuiScrollList extends GuiElement { if (!textEntries.isEmpty()) { for (int i = 0; i < size; i++) { int index = getScrollIndex() + i; - if (index <= textEntries.size() - 1) { - renderScaledText(textEntries.get(index), xPosition + 1, yPosition + 1 + (10 * i), 0x00CD00, - xSize - 6); + renderScaledText(textEntries.get(index), xPosition + 1, yPosition + 1 + (10 * i), 0x00CD00, xSize - 6); } } } mc.renderEngine.bindTexture(RESOURCE); - drawScroll(); - mc.renderEngine.bindTexture(defaultLocation); } @@ -165,17 +156,14 @@ public class GuiScrollList extends GuiElement { if (button == 0) { int xStart = xPosition + xSize - 5; - if (xAxis >= xStart && xAxis <= xStart + 4 && yAxis >= getScroll() + yPosition + 1 - && yAxis <= getScroll() + 4 + yPosition + 1) { + if (xAxis >= xStart && xAxis <= xStart + 4 && yAxis >= getScroll() + yPosition + 1 && yAxis <= getScroll() + 4 + yPosition + 1) { if (textEntries.size() > size) { dragOffset = yAxis - (getScroll() + yPosition + 1); isDragging = true; } - } else if (xAxis >= xPosition && xAxis <= xPosition + xSize - 6 && yAxis >= yPosition - && yAxis <= yPosition + size * 10) { + } else if (xAxis >= xPosition && xAxis <= xPosition + xSize - 6 && yAxis >= yPosition && yAxis <= yPosition + size * 10) { int index = getScrollIndex(); clearSelection(); - for (int i = 0; i < size; i++) { if (index + i <= textEntries.size() - 1) { if (yAxis >= (yPosition + i * 10) && yAxis <= (yPosition + i * 10 + 10)) { @@ -191,17 +179,14 @@ public class GuiScrollList extends GuiElement { @Override public void mouseClickMove(int xAxis, int yAxis, int button, long ticks) { super.mouseClickMove(xAxis, yAxis, button, ticks); - if (isDragging) { - scroll = Math - .min(Math.max((float) (yAxis - (yPosition + 1) - dragOffset) / (float) (getMaxScroll() - 4), 0), 1); + scroll = Math.min(Math.max((float) (yAxis - (yPosition + 1) - dragOffset) / (float) (getMaxScroll() - 4), 0), 1); } } @Override public void mouseReleased(int xAxis, int yAxis, int type) { super.mouseReleased(xAxis, yAxis, type); - if (type == 0) { if (isDragging) { dragOffset = 0; @@ -213,10 +198,9 @@ public class GuiScrollList extends GuiElement { @Override public void mouseWheel(int x, int y, int delta) { super.mouseWheel(x, y, delta); - if (x > xPosition && x < xPosition + xSize && y > yPosition && y < yPosition + size * 10) { - scroll = Math.min(Math.max(scroll - (delta / 120F) * (1F / textEntries.size()), 0), - 1); // 120 = DirectInput factor for one notch. Linux/OSX LWGL scale accordingly + // 120 = DirectInput factor for one notch. Linux/OSX LWGL scale accordingly + scroll = Math.min(Math.max(scroll - (delta / 120F) * (1F / textEntries.size()), 0), 1); drawScroll(); } } diff --git a/src/main/java/mekanism/client/gui/element/GuiSecurityTab.java b/src/main/java/mekanism/client/gui/element/GuiSecurityTab.java index 53246ce4c..b49573d58 100644 --- a/src/main/java/mekanism/client/gui/element/GuiSecurityTab.java +++ b/src/main/java/mekanism/client/gui/element/GuiSecurityTab.java @@ -76,14 +76,12 @@ public class GuiSecurityTab extends GuiTileEntityElement { public void renderForeground(int xAxis, int yAxis) { mc.renderEngine.bindTexture(RESOURCE); if (inBounds(xAxis, yAxis)) { - String securityDisplay = isItem ? SecurityUtils.getSecurityDisplay(getItem(), Side.CLIENT) - : SecurityUtils.getSecurityDisplay(tileEntity, Side.CLIENT); + String securityDisplay = isItem ? SecurityUtils.getSecurityDisplay(getItem(), Side.CLIENT) : SecurityUtils.getSecurityDisplay(tileEntity, Side.CLIENT); String securityText = EnumColor.GREY + LangUtils.localize("gui.security") + ": " + securityDisplay; String ownerText = SecurityUtils.getOwnerDisplay(mc.player, getOwnerUsername()); String overrideText = EnumColor.RED + "(" + LangUtils.localize("gui.overridden") + ")"; - if (isItem ? SecurityUtils.isOverridden(getItem(), Side.CLIENT) - : SecurityUtils.isOverridden(tileEntity, Side.CLIENT)) { + if (isItem ? SecurityUtils.isOverridden(getItem(), Side.CLIENT) : SecurityUtils.isOverridden(tileEntity, Side.CLIENT)) { displayTooltips(Arrays.asList(securityText, ownerText, overrideText), xAxis, yAxis); } else { displayTooltips(Arrays.asList(securityText, ownerText), xAxis, yAxis); @@ -113,11 +111,9 @@ public class GuiSecurityTab extends GuiTileEntityElement { mc.player.closeScreen(); return SecurityMode.PUBLIC; } - return ((ISecurityItem) getItem().getItem()).getSecurity(getItem()); - } else { - return ((ISecurityTile) tileEntity).getSecurity().getMode(); } + return ((ISecurityTile) tileEntity).getSecurity().getMode(); } private UUID getOwner() { @@ -156,17 +152,13 @@ public class GuiSecurityTab extends GuiTileEntityElement { if (getOwner() != null && mc.player.getUniqueID().equals(getOwner())) { if (inBounds(xAxis, yAxis)) { SecurityMode current = getSecurity(); - int ordinalToSet = - current.ordinal() < (SecurityMode.values().length - 1) ? current.ordinal() + 1 : 0; + int ordinalToSet = current.ordinal() < (SecurityMode.values().length - 1) ? current.ordinal() + 1 : 0; SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - if (isItem) { - Mekanism.packetHandler - .sendToServer(new SecurityModeMessage(currentHand, SecurityMode.values()[ordinalToSet])); + Mekanism.packetHandler.sendToServer(new SecurityModeMessage(currentHand, SecurityMode.values()[ordinalToSet])); } else { - Mekanism.packetHandler.sendToServer( - new SecurityModeMessage(Coord4D.get(tileEntity), SecurityMode.values()[ordinalToSet])); + Mekanism.packetHandler.sendToServer(new SecurityModeMessage(Coord4D.get(tileEntity), SecurityMode.values()[ordinalToSet])); } } } diff --git a/src/main/java/mekanism/client/gui/element/GuiSlot.java b/src/main/java/mekanism/client/gui/element/GuiSlot.java index 8c61d5ec6..a06871b69 100644 --- a/src/main/java/mekanism/client/gui/element/GuiSlot.java +++ b/src/main/java/mekanism/client/gui/element/GuiSlot.java @@ -51,8 +51,7 @@ public class GuiSlot extends GuiElement { int h = overlay.height; int xLocationOverlay = xLocation + (width - w) / 2; int yLocationOverlay = yLocation + (height - h) / 2; - guiObj.drawTexturedRect(guiWidth + xLocationOverlay, guiHeight + yLocationOverlay, overlay.textureX, - overlay.textureY, w, h); + guiObj.drawTexturedRect(guiWidth + xLocationOverlay, guiHeight + yLocationOverlay, overlay.textureX, overlay.textureY, w, h); } mc.renderEngine.bindTexture(defaultLocation); } diff --git a/src/main/java/mekanism/client/gui/element/GuiSortingTab.java b/src/main/java/mekanism/client/gui/element/GuiSortingTab.java index 5eaf0bdac..1fca81256 100644 --- a/src/main/java/mekanism/client/gui/element/GuiSortingTab.java +++ b/src/main/java/mekanism/client/gui/element/GuiSortingTab.java @@ -1,10 +1,10 @@ package mekanism.client.gui.element; import mekanism.api.Coord4D; +import mekanism.api.TileNetworkList; import mekanism.client.gui.IGuiWrapper; import mekanism.client.sound.SoundHandler; import mekanism.common.Mekanism; -import mekanism.api.TileNetworkList; import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.tile.TileEntityFactory; import mekanism.common.util.LangUtils; diff --git a/src/main/java/mekanism/client/gui/element/GuiVisualsTab.java b/src/main/java/mekanism/client/gui/element/GuiVisualsTab.java index 7e35bba38..8cc3fc323 100644 --- a/src/main/java/mekanism/client/gui/element/GuiVisualsTab.java +++ b/src/main/java/mekanism/client/gui/element/GuiVisualsTab.java @@ -43,14 +43,10 @@ public class GuiVisualsTab extends GuiTileEntityElement mc.renderEngine.bindTexture(RESOURCE); if (inBounds(xAxis, yAxis)) { if (tileEntity.getRadius() <= 64) { - displayTooltip( - LangUtils.localize("gui.visuals") + ": " + LangUtils.transOnOff(tileEntity.clientRendering), - xAxis, yAxis); + displayTooltip(LangUtils.localize("gui.visuals") + ": " + LangUtils.transOnOff(tileEntity.clientRendering), xAxis, yAxis); } else { - displayTooltips(Arrays.asList( - LangUtils.localize("gui.visuals") + ": " + LangUtils.transOnOff(tileEntity.clientRendering), - TextFormatting.RED.toString() + LangUtils.localize("mekanism.gui.visuals.toobig") - ), xAxis, yAxis); + displayTooltips(Arrays.asList(LangUtils.localize("gui.visuals") + ": " + LangUtils.transOnOff(tileEntity.clientRendering), + TextFormatting.RED.toString() + LangUtils.localize("mekanism.gui.visuals.toobig")), xAxis, yAxis); } } mc.renderEngine.bindTexture(defaultLocation); diff --git a/src/main/java/mekanism/client/gui/filter/GuiFilterSelect.java b/src/main/java/mekanism/client/gui/filter/GuiFilterSelect.java index 936d8ea99..afda3e8e1 100644 --- a/src/main/java/mekanism/client/gui/filter/GuiFilterSelect.java +++ b/src/main/java/mekanism/client/gui/filter/GuiFilterSelect.java @@ -53,8 +53,8 @@ public abstract class GuiFilterSelect ext 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); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, inBounds(xAxis, yAxis) ? 0 : 11, 11, 11); super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); } @@ -63,8 +63,8 @@ public abstract class GuiFilterSelect ext public void mouseClicked(int mouseX, int mouseY, int button) throws IOException { super.mouseClicked(mouseX, mouseY, button); if (button == 0) { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; if (inBounds(xAxis, yAxis)) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); sendPacketToServer(0); diff --git a/src/main/java/mekanism/client/gui/filter/GuiMFilterSelect.java b/src/main/java/mekanism/client/gui/filter/GuiMFilterSelect.java index 40104f4a3..d011aaee2 100644 --- a/src/main/java/mekanism/client/gui/filter/GuiMFilterSelect.java +++ b/src/main/java/mekanism/client/gui/filter/GuiMFilterSelect.java @@ -23,8 +23,7 @@ public class GuiMFilterSelect extends GuiFilterSelect { @Override protected void sendPacketToServer(int guiID) { - Mekanism.packetHandler.sendToServer( - new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), guiID, 0, 0)); + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), guiID, 0, 0)); } @Override diff --git a/src/main/java/mekanism/client/gui/filter/GuiMItemStackFilter.java b/src/main/java/mekanism/client/gui/filter/GuiMItemStackFilter.java index 9ec1675be..65fc098d7 100644 --- a/src/main/java/mekanism/client/gui/filter/GuiMItemStackFilter.java +++ b/src/main/java/mekanism/client/gui/filter/GuiMItemStackFilter.java @@ -58,27 +58,23 @@ public class GuiMItemStackFilter extends GuiItemStackFilter= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) { - drawHoveringText(LangUtils.localize("gui.digitalMiner.requireReplace") + ": " + LangUtils - .transYesNo(filter.requireStack), xAxis, yAxis); + drawHoveringText(LangUtils.localize("gui.digitalMiner.requireReplace") + ": " + LangUtils.transYesNo(filter.requireStack), xAxis, yAxis); } if (xAxis >= 15 && xAxis <= 29 && yAxis >= 45 && yAxis <= 59) { - drawHoveringText( - LangUtils.localize("gui.digitalMiner.fuzzyMode") + ": " + LangUtils.transYesNo(filter.fuzzy), xAxis, - yAxis); + drawHoveringText(LangUtils.localize("gui.digitalMiner.fuzzyMode") + ": " + LangUtils.transYesNo(filter.fuzzy), xAxis, yAxis); } super.drawGuiContainerForegroundLayer(mouseX, mouseY); } @@ -117,8 +110,8 @@ public class GuiMItemStackFilter extends GuiItemStackFilter= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); } else { @@ -167,12 +160,11 @@ public class GuiMItemStackFilter extends GuiItemStackFilter= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - Mekanism.packetHandler.sendToServer( - new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 5 : 0, 0, 0)); + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 5 : 0, 0, 0)); } if (xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); @@ -184,7 +176,6 @@ public class GuiMItemStackFilter extends GuiItemStackFilter= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) { ItemStack stack = mc.player.inventory.getItemStack(); - if (!stack.isEmpty() && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { if (stack.getItem() instanceof ItemBlock) { if (Block.getBlockFromItem(stack.getItem()) != Blocks.BEDROCK) { diff --git a/src/main/java/mekanism/client/gui/filter/GuiMMaterialFilter.java b/src/main/java/mekanism/client/gui/filter/GuiMMaterialFilter.java index 8c6b7fb5f..6faeaac87 100644 --- a/src/main/java/mekanism/client/gui/filter/GuiMMaterialFilter.java +++ b/src/main/java/mekanism/client/gui/filter/GuiMMaterialFilter.java @@ -49,15 +49,13 @@ public class GuiMMaterialFilter extends GuiMaterialFilter= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) { - drawHoveringText(LangUtils.localize("gui.digitalMiner.requireReplace") + ": " + LangUtils - .transYesNo(filter.requireStack), xAxis, yAxis); + drawHoveringText(LangUtils.localize("gui.digitalMiner.requireReplace") + ": " + LangUtils.transYesNo(filter.requireStack), xAxis, yAxis); } super.drawGuiContainerForegroundLayer(mouseX, mouseY); } @@ -91,8 +88,8 @@ public class GuiMMaterialFilter extends GuiMaterialFilter= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); } else { @@ -136,12 +133,11 @@ public class GuiMMaterialFilter extends GuiMaterialFilter= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - Mekanism.packetHandler.sendToServer( - new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 5 : 0, 0, 0)); + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 5 : 0, 0, 0)); } if (xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); diff --git a/src/main/java/mekanism/client/gui/filter/GuiMModIDFilter.java b/src/main/java/mekanism/client/gui/filter/GuiMModIDFilter.java index bae551fcd..d9da4349a 100644 --- a/src/main/java/mekanism/client/gui/filter/GuiMModIDFilter.java +++ b/src/main/java/mekanism/client/gui/filter/GuiMModIDFilter.java @@ -45,9 +45,8 @@ public class GuiMModIDFilter extends GuiModIDFilter= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) { - drawHoveringText(LangUtils.localize("gui.digitalMiner.requireReplace") + ": " + LangUtils - .transYesNo(filter.requireStack), xAxis, yAxis); + drawHoveringText(LangUtils.localize("gui.digitalMiner.requireReplace") + ": " + LangUtils.transYesNo(filter.requireStack), xAxis, yAxis); } super.drawGuiContainerForegroundLayer(mouseX, mouseY); } @@ -83,8 +81,8 @@ public class GuiMModIDFilter extends GuiModIDFilter= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); } else { @@ -122,12 +120,11 @@ public class GuiMModIDFilter extends GuiModIDFilter= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - Mekanism.packetHandler.sendToServer( - new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 5 : 0, 0, 0)); + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 5 : 0, 0, 0)); } if (xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); @@ -179,7 +176,6 @@ public class GuiMModIDFilter extends GuiModIDFilter= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) { drawHoveringText(LangUtils.localize("gui.digitalMiner.requireReplace") + ": " + LangUtils .transYesNo(filter.requireStack), xAxis, yAxis); @@ -95,8 +93,8 @@ public class GuiMOreDictFilter extends GuiOreDictFilter= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); } else { @@ -134,8 +132,8 @@ public class GuiMOreDictFilter extends GuiOreDictFilter= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer( diff --git a/src/main/java/mekanism/client/gui/filter/GuiMaterialFilter.java b/src/main/java/mekanism/client/gui/filter/GuiMaterialFilter.java index 2c61f3069..3b0506f3e 100644 --- a/src/main/java/mekanism/client/gui/filter/GuiMaterialFilter.java +++ b/src/main/java/mekanism/client/gui/filter/GuiMaterialFilter.java @@ -48,8 +48,7 @@ public abstract class GuiMaterialFilter= 31 && xAxis <= 43 && yAxis >= 21 && yAxis <= 33) { drawHoveringText(LangUtils.localize("gui.lastItem"), xAxis, yAxis); } @@ -139,8 +138,8 @@ public class GuiOredictionificatorFilter extends GuiMekanismTile= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176 + 36, 0, 11, 11); } else { @@ -189,8 +188,7 @@ public class GuiOredictionificatorFilter extends GuiMekanismTile= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tileEntity), 0, 52)); diff --git a/src/main/java/mekanism/client/gui/filter/GuiTFilterSelect.java b/src/main/java/mekanism/client/gui/filter/GuiTFilterSelect.java index a5449a3b5..ad88a67a9 100644 --- a/src/main/java/mekanism/client/gui/filter/GuiTFilterSelect.java +++ b/src/main/java/mekanism/client/gui/filter/GuiTFilterSelect.java @@ -23,8 +23,7 @@ public class GuiTFilterSelect extends GuiFilterSelect max) { status = EnumColor.DARK_RED + "Max 64 || min > 64) - { + } else { //if(max > 64 || min > 64) status = EnumColor.DARK_RED + "Max>64"; ticker = 20; } @@ -103,8 +100,7 @@ public class GuiTItemStackFilter extends GuiItemStackFilter= 128 && xAxis <= 139 && yAxis >= 44 && yAxis <= 55) { String sizeModeTooltip = LangUtils.localize("gui.sizeMode"); if (tileEntity.singleItem && filter.sizeMode) { @@ -189,8 +184,8 @@ public class GuiTItemStackFilter extends GuiItemStackFilter= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); } else { @@ -229,14 +224,12 @@ public class GuiTItemStackFilter extends GuiItemStackFilter= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - Mekanism.packetHandler.sendToServer( - new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 4 : 0, 0, - 0)); + Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 4 : 0, 0, 0)); } if (xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) { ItemStack stack = mc.player.inventory.getItemStack(); diff --git a/src/main/java/mekanism/client/gui/filter/GuiTMaterialFilter.java b/src/main/java/mekanism/client/gui/filter/GuiTMaterialFilter.java index 986a9fc09..4da64726d 100644 --- a/src/main/java/mekanism/client/gui/filter/GuiTMaterialFilter.java +++ b/src/main/java/mekanism/client/gui/filter/GuiTMaterialFilter.java @@ -59,9 +59,8 @@ public class GuiTMaterialFilter extends GuiMaterialFilter= 11 && xAxis <= 22 && yAxis >= 64 && yAxis <= 75) { drawHoveringText(LangUtils.localize("gui.allowDefault"), xAxis, yAxis); } @@ -105,8 +104,8 @@ public class GuiTMaterialFilter extends GuiMaterialFilter= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); } else { @@ -136,14 +135,12 @@ public class GuiTMaterialFilter extends GuiMaterialFilter= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - Mekanism.packetHandler.sendToServer( - new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 4 : 0, 0, - 0)); + Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 4 : 0, 0, 0)); } if (xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) { ItemStack stack = mc.player.inventory.getItemStack(); diff --git a/src/main/java/mekanism/client/gui/filter/GuiTModIDFilter.java b/src/main/java/mekanism/client/gui/filter/GuiTModIDFilter.java index b75538742..e596d2555 100644 --- a/src/main/java/mekanism/client/gui/filter/GuiTModIDFilter.java +++ b/src/main/java/mekanism/client/gui/filter/GuiTModIDFilter.java @@ -45,9 +45,8 @@ public class GuiTModIDFilter extends GuiModIDFilter= 11 && xAxis <= 22 && yAxis >= 64 && yAxis <= 75) { drawHoveringText(LangUtils.localize("gui.allowDefault"), xAxis, yAxis); } @@ -93,8 +92,8 @@ public class GuiTModIDFilter extends GuiModIDFilter= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); } else { @@ -118,14 +117,12 @@ public class GuiTModIDFilter extends GuiModIDFilter= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - Mekanism.packetHandler.sendToServer( - new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 4 : 0, 0, - 0)); + Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 4 : 0, 0, 0)); } if (xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); @@ -171,7 +168,6 @@ public class GuiTModIDFilter extends GuiModIDFilter= 11 && xAxis <= 22 && yAxis >= 64 && yAxis <= 75) { drawHoveringText(LangUtils.localize("gui.allowDefault"), xAxis, yAxis); } @@ -106,8 +103,8 @@ public class GuiTOreDictFilter extends GuiOreDictFilter= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); } else { @@ -131,14 +128,12 @@ public class GuiTOreDictFilter extends GuiOreDictFilter= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - Mekanism.packetHandler.sendToServer( - new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 4 : 0, 0, - 0)); + Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 4 : 0, 0, 0)); } if (xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); diff --git a/src/main/java/mekanism/client/gui/robit/GuiRobit.java b/src/main/java/mekanism/client/gui/robit/GuiRobit.java index 016052add..f29e54981 100644 --- a/src/main/java/mekanism/client/gui/robit/GuiRobit.java +++ b/src/main/java/mekanism/client/gui/robit/GuiRobit.java @@ -42,8 +42,8 @@ public abstract class GuiRobit extends GuiMekanism { 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); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; boolean correctX = xAxis >= 179 && xAxis <= 197; drawRect(correctX, yAxis, guiWidth, guiHeight, 10, 0); drawRect(correctX, yAxis, guiWidth, guiHeight, 30, 36); @@ -60,8 +60,7 @@ public abstract class GuiRobit extends GuiMekanism { private void buttonClicked(int id) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); if (openGui(id)) { - Mekanism.packetHandler - .sendToServer(new RobitMessage(PacketRobit.RobitPacketType.GUI, id, robit.getEntityId(), null)); + Mekanism.packetHandler.sendToServer(new RobitMessage(PacketRobit.RobitPacketType.GUI, id, robit.getEntityId(), null)); mc.player.openGui(Mekanism.instance, 21 + id, mc.world, robit.getEntityId(), 0, 0); } } @@ -75,9 +74,9 @@ public abstract class GuiRobit extends GuiMekanism { protected void mouseClicked(int mouseX, int mouseY, int button) throws IOException { super.mouseClicked(mouseX, mouseY, button); extraClickListeners(mouseX, mouseY, button); - int xAxis = (mouseX - (width - xSize) / 2); + int xAxis = mouseX - (width - xSize) / 2; if (button == 0 && xAxis >= 179 && xAxis <= 197) { - int yAxis = (mouseY - (height - ySize) / 2); + int yAxis = mouseY - (height - ySize) / 2; if (yAxis >= 10 && yAxis <= 28) { buttonClicked(0); } else if (yAxis >= 30 && yAxis <= 48) { diff --git a/src/main/java/mekanism/client/gui/robit/GuiRobitMain.java b/src/main/java/mekanism/client/gui/robit/GuiRobitMain.java index ded81bcd0..0ac8954d0 100644 --- a/src/main/java/mekanism/client/gui/robit/GuiRobitMain.java +++ b/src/main/java/mekanism/client/gui/robit/GuiRobitMain.java @@ -44,8 +44,7 @@ public class GuiRobitMain extends GuiMekanism { private void changeName() { if (!nameChangeField.getText().isEmpty()) { - Mekanism.packetHandler.sendToServer( - new RobitMessage(RobitPacketType.NAME, robit.getEntityId(), 0, nameChangeField.getText())); + Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.NAME, robit.getEntityId(), 0, nameChangeField.getText())); toggleNameChange(); nameChangeField.setText(""); } @@ -66,8 +65,7 @@ public class GuiRobitMain extends GuiMekanism { int guiHeight = (height - ySize) / 2; buttonList.clear(); - buttonList.add(confirmName = new GuiButton(0, guiWidth + 58, guiHeight + 47, 60, 20, - LangUtils.localize("gui.confirm"))); + buttonList.add(confirmName = new GuiButton(0, guiWidth + 58, guiHeight + 47, 60, 20, LangUtils.localize("gui.confirm"))); confirmName.visible = displayNameChange; nameChangeField = new GuiTextField(1, fontRenderer, guiWidth + 48, guiHeight + 21, 80, 12); @@ -85,7 +83,6 @@ public class GuiRobitMain extends GuiMekanism { } else if (i == Keyboard.KEY_ESCAPE) { mc.player.closeScreen(); } - nameChangeField.textboxKeyTyped(c, i); } } @@ -95,23 +92,17 @@ public class GuiRobitMain extends GuiMekanism { fontRenderer.drawString(LangUtils.localize("gui.robit"), 76, 6, 0x404040); if (!displayNameChange) { - CharSequence owner = - robit.getOwnerName().length() > 14 ? robit.getOwnerName().subSequence(0, 14) : robit.getOwnerName(); - fontRenderer - .drawString(LangUtils.localize("gui.robit.greeting") + " " + robit.getName() + "!", 29, 18, 0x00CD00); - fontRenderer.drawString(LangUtils.localize("gui.energy") + ": " + MekanismUtils - .getEnergyDisplay(robit.getEnergy(), robit.MAX_ELECTRICITY), 29, 36 - 4, 0x00CD00); - fontRenderer.drawString(LangUtils.localize("gui.robit.following") + ": " + robit.getFollowing(), 29, 45 - 4, - 0x00CD00); - fontRenderer - .drawString(LangUtils.localize("gui.robit.dropPickup") + ": " + robit.getDropPickup(), 29, 54 - 4, - 0x00CD00); + CharSequence owner = robit.getOwnerName().length() > 14 ? robit.getOwnerName().subSequence(0, 14) : robit.getOwnerName(); + fontRenderer.drawString(LangUtils.localize("gui.robit.greeting") + " " + robit.getName() + "!", 29, 18, 0x00CD00); + fontRenderer.drawString(LangUtils.localize("gui.energy") + ": " + MekanismUtils.getEnergyDisplay(robit.getEnergy(), robit.MAX_ELECTRICITY), + 29, 36 - 4, 0x00CD00); + fontRenderer.drawString(LangUtils.localize("gui.robit.following") + ": " + robit.getFollowing(), 29, 45 - 4, 0x00CD00); + fontRenderer.drawString(LangUtils.localize("gui.robit.dropPickup") + ": " + robit.getDropPickup(), 29, 54 - 4, 0x00CD00); fontRenderer.drawString(LangUtils.localize("gui.robit.owner") + ": " + owner, 29, 63 - 4, 0x00CD00); } - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; if (xAxis >= 28 && xAxis <= 148 && yAxis >= 75 && yAxis <= 79) { drawHoveringText(MekanismUtils.getEnergyDisplay(robit.getEnergy(), robit.MAX_ELECTRICITY), xAxis, yAxis); } else if (xAxis >= 152 && xAxis <= 170 && yAxis >= 54 && yAxis <= 72) { @@ -123,7 +114,6 @@ public class GuiRobitMain extends GuiMekanism { } else if (xAxis >= 6 && xAxis <= 24 && yAxis >= 35 && yAxis <= 53) { drawHoveringText(LangUtils.localize("gui.robit.togglePickup"), xAxis, yAxis); } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); } @@ -137,8 +127,8 @@ public class GuiRobitMain extends GuiMekanism { int guiHeight = (height - ySize) / 2; drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + 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); @@ -212,58 +202,48 @@ public class GuiRobitMain extends GuiMekanism { @Override public void updateScreen() { super.updateScreen(); - nameChangeField.updateCursorCounter(); } @Override protected void mouseClicked(int mouseX, int mouseY, int button) throws IOException { 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); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; if (xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); } else if (xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - Mekanism.packetHandler - .sendToServer(new RobitMessage(RobitPacketType.GUI, 1, robit.getEntityId(), null)); + Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 1, robit.getEntityId(), null)); mc.player.openGui(Mekanism.instance, 22, mc.world, robit.getEntityId(), 0, 0); } else if (xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - Mekanism.packetHandler - .sendToServer(new RobitMessage(RobitPacketType.GUI, 2, robit.getEntityId(), null)); + Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 2, robit.getEntityId(), null)); mc.player.openGui(Mekanism.instance, 23, mc.world, robit.getEntityId(), 0, 0); } else if (xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - Mekanism.packetHandler - .sendToServer(new RobitMessage(RobitPacketType.GUI, 3, robit.getEntityId(), null)); + Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 3, robit.getEntityId(), null)); mc.player.openGui(Mekanism.instance, 24, mc.world, robit.getEntityId(), 0, 0); } else if (xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - Mekanism.packetHandler - .sendToServer(new RobitMessage(RobitPacketType.GUI, 4, robit.getEntityId(), null)); + Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 4, robit.getEntityId(), null)); mc.player.openGui(Mekanism.instance, 25, mc.world, robit.getEntityId(), 0, 0); } else if (xAxis >= 152 && xAxis <= 170 && yAxis >= 54 && yAxis <= 72) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - Mekanism.packetHandler - .sendToServer(new RobitMessage(RobitPacketType.FOLLOW, robit.getEntityId(), 0, null)); + Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.FOLLOW, robit.getEntityId(), 0, null)); } else if (xAxis >= 6 && xAxis <= 24 && yAxis >= 54 && yAxis <= 72) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); toggleNameChange(); } else if (xAxis >= 6 && xAxis <= 24 && yAxis >= 16 && yAxis <= 34) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - Mekanism.packetHandler - .sendToServer(new RobitMessage(RobitPacketType.GO_HOME, robit.getEntityId(), 0, null)); + Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GO_HOME, robit.getEntityId(), 0, null)); mc.displayGuiScreen(null); } else if (xAxis >= 6 && xAxis <= 24 && yAxis >= 35 && yAxis <= 53) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); - Mekanism.packetHandler - .sendToServer(new RobitMessage(RobitPacketType.DROP_PICKUP, robit.getEntityId(), 0, null)); + Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.DROP_PICKUP, robit.getEntityId(), 0, null)); } } } diff --git a/src/main/java/mekanism/client/gui/robit/GuiRobitRepair.java b/src/main/java/mekanism/client/gui/robit/GuiRobitRepair.java index 9c19220e4..4d68b577d 100644 --- a/src/main/java/mekanism/client/gui/robit/GuiRobitRepair.java +++ b/src/main/java/mekanism/client/gui/robit/GuiRobitRepair.java @@ -79,24 +79,21 @@ public class GuiRobitRepair extends GuiRobit implements IContainerListener { if (flag) { int l = -16777216 | (k & 16579836) >> 2 | k & -16777216; - int i1 = (xSize - 25) - 8 - fontRenderer.getStringWidth(s); + 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); + 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); } } - GL11.glEnable(GL11.GL_LIGHTING); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); } @@ -104,8 +101,7 @@ public class GuiRobitRepair extends GuiRobit implements IContainerListener { protected void keyTyped(char c, int i) throws IOException { if (itemNameField.textboxKeyTyped(c, i)) { repairContainer.updateItemName(itemNameField.getText()); - mc.player.connection.sendPacket(new CPacketCustomPayload("MC|ItemName", - (new PacketBuffer(Unpooled.buffer())).writeString(itemNameField.getText()))); + mc.player.connection.sendPacket(new CPacketCustomPayload("MC|ItemName", new PacketBuffer(Unpooled.buffer()).writeString(itemNameField.getText()))); } else { super.keyTyped(c, i); } @@ -138,10 +134,8 @@ public class GuiRobitRepair extends GuiRobit implements IContainerListener { super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); int guiWidth = (width - xSize) / 2; int guiHeight = (height - ySize) / 2; - 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 + 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); } } @@ -158,8 +152,7 @@ public class GuiRobitRepair extends GuiRobit implements IContainerListener { itemNameField.setEnabled(!itemstack.isEmpty()); if (!itemstack.isEmpty()) { repairContainer.updateItemName(itemNameField.getText()); - mc.player.connection.sendPacket(new CPacketCustomPayload("MC|ItemName", - new PacketBuffer(Unpooled.buffer()).writeString(itemNameField.getText()))); + mc.player.connection.sendPacket(new CPacketCustomPayload("MC|ItemName", new PacketBuffer(Unpooled.buffer()).writeString(itemNameField.getText()))); } } } diff --git a/src/main/java/mekanism/client/gui/robit/GuiRobitSmelting.java b/src/main/java/mekanism/client/gui/robit/GuiRobitSmelting.java index 2f220463b..313c04f7a 100644 --- a/src/main/java/mekanism/client/gui/robit/GuiRobitSmelting.java +++ b/src/main/java/mekanism/client/gui/robit/GuiRobitSmelting.java @@ -34,8 +34,7 @@ public class GuiRobitSmelting extends GuiRobit { 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); + 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); diff --git a/src/main/java/mekanism/client/jei/BaseRecipeCategory.java b/src/main/java/mekanism/client/jei/BaseRecipeCategory.java index a003fd4d4..6889da282 100644 --- a/src/main/java/mekanism/client/jei/BaseRecipeCategory.java +++ b/src/main/java/mekanism/client/jei/BaseRecipeCategory.java @@ -47,8 +47,7 @@ public abstract class BaseRecipeCategory implements IRecipeCategory group, int slot, boolean input, int x, int y, int width, - int height, @Nullable GasStack stack, boolean overlay) { + protected void initGas(IGuiIngredientGroup group, int slot, boolean input, int x, int y, int width, int height, @Nullable GasStack stack, boolean overlay) { if (stack == null) { return; } IDrawable fluidOverlay = height > 50 ? fluidOverlayLarge : fluidOverlaySmall; - - GasStackRenderer renderer = new GasStackRenderer(stack.amount, false, width, height, - overlay ? fluidOverlay : null); + GasStackRenderer renderer = new GasStackRenderer(stack.amount, false, width, height, overlay ? fluidOverlay : null); group.init(slot, input, renderer, x, y, width, height, 0, 0); group.set(slot, stack); } public static class GuiDummy extends Gui { - } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/jei/GuiElementHandler.java b/src/main/java/mekanism/client/jei/GuiElementHandler.java index d784d7b12..3ce1b43cf 100644 --- a/src/main/java/mekanism/client/jei/GuiElementHandler.java +++ b/src/main/java/mekanism/client/jei/GuiElementHandler.java @@ -18,9 +18,7 @@ public class GuiElementHandler implements IAdvancedGuiHandler { public List getGuiExtraAreas(GuiContainer gui) { if (gui instanceof GuiMekanism) { GuiMekanism guiMek = (GuiMekanism) gui; - return guiMek.getGuiElements().stream() - .map(element -> element.getBounds(guiMek.getXPos(), guiMek.getYPos()).toRectangle()) - .collect(Collectors.toList()); + return guiMek.getGuiElements().stream().map(element -> element.getBounds(guiMek.getXPos(), guiMek.getYPos()).toRectangle()).collect(Collectors.toList()); } return null; } diff --git a/src/main/java/mekanism/client/jei/MekanismJEI.java b/src/main/java/mekanism/client/jei/MekanismJEI.java index 162018547..b7ef2a19d 100644 --- a/src/main/java/mekanism/client/jei/MekanismJEI.java +++ b/src/main/java/mekanism/client/jei/MekanismJEI.java @@ -96,8 +96,7 @@ public class MekanismJEI implements IModPlugin { @Override public void registerIngredients(IModIngredientRegistration registry) { - List list = GasRegistry.getRegisteredGasses().stream().filter(Gas::isVisible) - .map(g -> new GasStack(g, Fluid.BUCKET_VOLUME)).collect(Collectors.toList()); + List list = GasRegistry.getRegisteredGasses().stream().filter(Gas::isVisible).map(g -> new GasStack(g, Fluid.BUCKET_VOLUME)).collect(Collectors.toList()); registry.register(MekanismJEI.TYPE_GAS, list, new GasStackHelper(), new GasStackRenderer()); } @@ -105,59 +104,45 @@ public class MekanismJEI implements IModPlugin { public void registerCategories(IRecipeCategoryRegistration registry) { IGuiHelper guiHelper = registry.getJeiHelpers().getGuiHelper(); - addRecipeCategory(registry, MachineType.CHEMICAL_CRYSTALLIZER, - new ChemicalCrystallizerRecipeCategory(guiHelper)); - addRecipeCategory(registry, MachineType.CHEMICAL_DISSOLUTION_CHAMBER, - new ChemicalDissolutionChamberRecipeCategory(guiHelper)); + addRecipeCategory(registry, MachineType.CHEMICAL_CRYSTALLIZER, new ChemicalCrystallizerRecipeCategory(guiHelper)); + addRecipeCategory(registry, MachineType.CHEMICAL_DISSOLUTION_CHAMBER, new ChemicalDissolutionChamberRecipeCategory(guiHelper)); addRecipeCategory(registry, MachineType.CHEMICAL_INFUSER, new ChemicalInfuserRecipeCategory(guiHelper)); addRecipeCategory(registry, MachineType.CHEMICAL_OXIDIZER, new ChemicalOxidizerRecipeCategory(guiHelper)); addRecipeCategory(registry, MachineType.CHEMICAL_WASHER, new ChemicalWasherRecipeCategory(guiHelper)); - addRecipeCategory(registry, MachineType.ELECTROLYTIC_SEPARATOR, - new ElectrolyticSeparatorRecipeCategory(guiHelper)); + addRecipeCategory(registry, MachineType.ELECTROLYTIC_SEPARATOR, new ElectrolyticSeparatorRecipeCategory(guiHelper)); addRecipeCategory(registry, MachineType.METALLURGIC_INFUSER, new MetallurgicInfuserRecipeCategory(guiHelper)); addRecipeCategory(registry, MachineType.PRESSURIZED_REACTION_CHAMBER, new PRCRecipeCategory(guiHelper)); - addRecipeCategory(registry, MachineType.ROTARY_CONDENSENTRATOR, - new RotaryCondensentratorRecipeCategory(guiHelper, true)); - addRecipeCategory(registry, MachineType.ROTARY_CONDENSENTRATOR, - new RotaryCondensentratorRecipeCategory(guiHelper, false)); + addRecipeCategory(registry, MachineType.ROTARY_CONDENSENTRATOR, new RotaryCondensentratorRecipeCategory(guiHelper, true)); + addRecipeCategory(registry, MachineType.ROTARY_CONDENSENTRATOR, new RotaryCondensentratorRecipeCategory(guiHelper, false)); addRecipeCategory(registry, MachineType.SOLAR_NEUTRON_ACTIVATOR, new SolarNeutronRecipeCategory(guiHelper)); - addRecipeCategory(registry, MachineType.COMBINER, - new DoubleMachineRecipeCategory(guiHelper, Recipe.COMBINER.getJEICategory(), - "tile.MachineBlock.Combiner.name", ProgressBar.STONE)); + addRecipeCategory(registry, MachineType.COMBINER, new DoubleMachineRecipeCategory(guiHelper, Recipe.COMBINER.getJEICategory(), + "tile.MachineBlock.Combiner.name", ProgressBar.STONE)); - addRecipeCategory(registry, MachineType.PURIFICATION_CHAMBER, - new AdvancedMachineRecipeCategory(guiHelper, Recipe.PURIFICATION_CHAMBER.getJEICategory(), - "tile.MachineBlock.PurificationChamber.name", ProgressBar.RED)); - addRecipeCategory(registry, MachineType.OSMIUM_COMPRESSOR, - new AdvancedMachineRecipeCategory(guiHelper, Recipe.OSMIUM_COMPRESSOR.getJEICategory(), - "tile.MachineBlock.OsmiumCompressor.name", ProgressBar.RED)); - addRecipeCategory(registry, MachineType.CHEMICAL_INJECTION_CHAMBER, - new AdvancedMachineRecipeCategory(guiHelper, Recipe.CHEMICAL_INJECTION_CHAMBER.getJEICategory(), - "tile.MachineBlock2.ChemicalInjectionChamber.name", ProgressBar.YELLOW)); + addRecipeCategory(registry, MachineType.PURIFICATION_CHAMBER, new AdvancedMachineRecipeCategory(guiHelper, Recipe.PURIFICATION_CHAMBER.getJEICategory(), + "tile.MachineBlock.PurificationChamber.name", ProgressBar.RED)); + addRecipeCategory(registry, MachineType.OSMIUM_COMPRESSOR, new AdvancedMachineRecipeCategory(guiHelper, Recipe.OSMIUM_COMPRESSOR.getJEICategory(), + "tile.MachineBlock.OsmiumCompressor.name", ProgressBar.RED)); + addRecipeCategory(registry, MachineType.CHEMICAL_INJECTION_CHAMBER, new AdvancedMachineRecipeCategory(guiHelper, Recipe.CHEMICAL_INJECTION_CHAMBER.getJEICategory(), + "tile.MachineBlock2.ChemicalInjectionChamber.name", ProgressBar.YELLOW)); - addRecipeCategory(registry, MachineType.PRECISION_SAWMILL, - new ChanceMachineRecipeCategory(guiHelper, Recipe.PRECISION_SAWMILL.getJEICategory(), - "tile.MachineBlock2.PrecisionSawmill.name", ProgressBar.PURPLE)); + addRecipeCategory(registry, MachineType.PRECISION_SAWMILL, new ChanceMachineRecipeCategory(guiHelper, Recipe.PRECISION_SAWMILL.getJEICategory(), + "tile.MachineBlock2.PrecisionSawmill.name", ProgressBar.PURPLE)); - addRecipeCategory(registry, MachineType.ENRICHMENT_CHAMBER, - new MachineRecipeCategory(guiHelper, Recipe.ENRICHMENT_CHAMBER.getJEICategory(), - "tile.MachineBlock.EnrichmentChamber.name", ProgressBar.BLUE)); - addRecipeCategory(registry, MachineType.CRUSHER, - new MachineRecipeCategory(guiHelper, Recipe.CRUSHER.getJEICategory(), "tile.MachineBlock.Crusher.name", - ProgressBar.CRUSH)); - addRecipeCategory(registry, MachineType.ENERGIZED_SMELTER, - new MachineRecipeCategory(guiHelper, Recipe.ENERGIZED_SMELTER.getJEICategory(), - "tile.MachineBlock.EnergizedSmelter.name", ProgressBar.BLUE)); + addRecipeCategory(registry, MachineType.ENRICHMENT_CHAMBER, new MachineRecipeCategory(guiHelper, Recipe.ENRICHMENT_CHAMBER.getJEICategory(), + "tile.MachineBlock.EnrichmentChamber.name", ProgressBar.BLUE)); + addRecipeCategory(registry, MachineType.CRUSHER, new MachineRecipeCategory(guiHelper, Recipe.CRUSHER.getJEICategory(), "tile.MachineBlock.Crusher.name", + ProgressBar.CRUSH)); + addRecipeCategory(registry, MachineType.ENERGIZED_SMELTER, new MachineRecipeCategory(guiHelper, Recipe.ENERGIZED_SMELTER.getJEICategory(), + "tile.MachineBlock.EnergizedSmelter.name", ProgressBar.BLUE)); //There is no config option to disable the thermal evaporation plant registry.addRecipeCategories(new ThermalEvaporationRecipeCategory(guiHelper)); } - private void addRecipeCategory(IRecipeCategoryRegistration registry, MachineType type, - BaseRecipeCategory category) { + private void addRecipeCategory(IRecipeCategoryRegistration registry, MachineType type, BaseRecipeCategory category) { if (type.isEnabled()) { registry.addRecipeCategories(category); } @@ -193,7 +178,6 @@ public class MekanismJEI implements IModPlugin { RecipeRegistryHelper.registerCondensentrator(registry); RecipeRegistryHelper.registerSmelter(registry); RecipeRegistryHelper.registerFormulaicAssemblicator(registry); - registry.getRecipeTransferRegistry() - .addRecipeTransferHandler(ContainerRobitInventory.class, VanillaRecipeCategoryUid.CRAFTING, 1, 9, 10, 36); + registry.getRecipeTransferRegistry().addRecipeTransferHandler(ContainerRobitInventory.class, VanillaRecipeCategoryUid.CRAFTING, 1, 9, 10, 36); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/jei/RecipeRegistryHelper.java b/src/main/java/mekanism/client/jei/RecipeRegistryHelper.java index 3b604c03c..8289d8996 100644 --- a/src/main/java/mekanism/client/jei/RecipeRegistryHelper.java +++ b/src/main/java/mekanism/client/jei/RecipeRegistryHelper.java @@ -41,6 +41,7 @@ import mekanism.client.jei.machine.other.PRCRecipeWrapper; import mekanism.client.jei.machine.other.RotaryCondensentratorRecipeWrapper; import mekanism.client.jei.machine.other.SolarNeutronRecipeWrapper; import mekanism.client.jei.machine.other.ThermalEvaporationRecipeWrapper; +import mekanism.common.Mekanism; import mekanism.common.base.IFactory.RecipeType; import mekanism.common.block.states.BlockStateBasic.BasicBlockType; import mekanism.common.block.states.BlockStateMachine.MachineType; @@ -72,7 +73,6 @@ import mezz.jei.api.IModRegistry; import mezz.jei.api.recipe.IRecipeWrapperFactory; import mezz.jei.api.recipe.VanillaRecipeCategoryUid; import net.minecraft.item.crafting.FurnaceRecipes; -import net.minecraftforge.fml.common.Loader; public class RecipeRegistryHelper { @@ -81,8 +81,7 @@ public class RecipeRegistryHelper { return; } addRecipes(registry, Recipe.ENRICHMENT_CHAMBER, EnrichmentRecipe.class, MachineRecipeWrapper::new); - registry.addRecipeClickArea(GuiEnrichmentChamber.class, 79, 40, 24, 7, - Recipe.ENRICHMENT_CHAMBER.getJEICategory()); + registry.addRecipeClickArea(GuiEnrichmentChamber.class, 79, 40, 24, 7, Recipe.ENRICHMENT_CHAMBER.getJEICategory()); registerRecipeItem(registry, MachineType.ENRICHMENT_CHAMBER, Recipe.ENRICHMENT_CHAMBER); } @@ -109,8 +108,7 @@ public class RecipeRegistryHelper { return; } addRecipes(registry, Recipe.PURIFICATION_CHAMBER, PurificationRecipe.class, AdvancedMachineRecipeWrapper::new); - registry.addRecipeClickArea(GuiPurificationChamber.class, 79, 40, 24, 7, - Recipe.PURIFICATION_CHAMBER.getJEICategory()); + registry.addRecipeClickArea(GuiPurificationChamber.class, 79, 40, 24, 7, Recipe.PURIFICATION_CHAMBER.getJEICategory()); registerRecipeItem(registry, MachineType.PURIFICATION_CHAMBER, Recipe.PURIFICATION_CHAMBER); } @@ -119,8 +117,7 @@ public class RecipeRegistryHelper { return; } addRecipes(registry, Recipe.OSMIUM_COMPRESSOR, OsmiumCompressorRecipe.class, AdvancedMachineRecipeWrapper::new); - registry - .addRecipeClickArea(GuiOsmiumCompressor.class, 79, 40, 24, 7, Recipe.OSMIUM_COMPRESSOR.getJEICategory()); + registry.addRecipeClickArea(GuiOsmiumCompressor.class, 79, 40, 24, 7, Recipe.OSMIUM_COMPRESSOR.getJEICategory()); registerRecipeItem(registry, MachineType.OSMIUM_COMPRESSOR, Recipe.OSMIUM_COMPRESSOR); } @@ -128,10 +125,8 @@ public class RecipeRegistryHelper { if (!MachineType.CHEMICAL_INJECTION_CHAMBER.isEnabled()) { return; } - addRecipes(registry, Recipe.CHEMICAL_INJECTION_CHAMBER, InjectionRecipe.class, - AdvancedMachineRecipeWrapper::new); - registry.addRecipeClickArea(GuiChemicalInjectionChamber.class, 79, 40, 24, 7, - Recipe.CHEMICAL_INJECTION_CHAMBER.getJEICategory()); + addRecipes(registry, Recipe.CHEMICAL_INJECTION_CHAMBER, InjectionRecipe.class, AdvancedMachineRecipeWrapper::new); + registry.addRecipeClickArea(GuiChemicalInjectionChamber.class, 79, 40, 24, 7, Recipe.CHEMICAL_INJECTION_CHAMBER.getJEICategory()); registerRecipeItem(registry, MachineType.CHEMICAL_INJECTION_CHAMBER, Recipe.CHEMICAL_INJECTION_CHAMBER); } @@ -140,8 +135,7 @@ public class RecipeRegistryHelper { return; } addRecipes(registry, Recipe.PRECISION_SAWMILL, SawmillRecipe.class, ChanceMachineRecipeWrapper::new); - registry - .addRecipeClickArea(GuiPrecisionSawmill.class, 79, 40, 24, 7, Recipe.PRECISION_SAWMILL.getJEICategory()); + registry.addRecipeClickArea(GuiPrecisionSawmill.class, 79, 40, 24, 7, Recipe.PRECISION_SAWMILL.getJEICategory()); registerRecipeItem(registry, MachineType.PRECISION_SAWMILL, Recipe.PRECISION_SAWMILL); } @@ -149,11 +143,8 @@ public class RecipeRegistryHelper { if (!MachineType.METALLURGIC_INFUSER.isEnabled()) { return; } - addRecipes(registry, Recipe.METALLURGIC_INFUSER, MetallurgicInfuserRecipe.class, - MetallurgicInfuserRecipeWrapper::new); - registry - .addRecipeClickArea(GuiMetallurgicInfuser.class, 72, 47, 32, 8, - Recipe.METALLURGIC_INFUSER.getJEICategory()); + addRecipes(registry, Recipe.METALLURGIC_INFUSER, MetallurgicInfuserRecipe.class, MetallurgicInfuserRecipeWrapper::new); + registry.addRecipeClickArea(GuiMetallurgicInfuser.class, 72, 47, 32, 8, Recipe.METALLURGIC_INFUSER.getJEICategory()); registerRecipeItem(registry, MachineType.METALLURGIC_INFUSER, Recipe.METALLURGIC_INFUSER); } @@ -161,10 +152,8 @@ public class RecipeRegistryHelper { if (!MachineType.CHEMICAL_CRYSTALLIZER.isEnabled()) { return; } - addRecipes(registry, Recipe.CHEMICAL_CRYSTALLIZER, CrystallizerRecipe.class, - ChemicalCrystallizerRecipeWrapper::new); - registry.addRecipeClickArea(GuiChemicalCrystallizer.class, 53, 62, 48, 8, - Recipe.CHEMICAL_CRYSTALLIZER.getJEICategory()); + addRecipes(registry, Recipe.CHEMICAL_CRYSTALLIZER, CrystallizerRecipe.class, ChemicalCrystallizerRecipeWrapper::new); + registry.addRecipeClickArea(GuiChemicalCrystallizer.class, 53, 62, 48, 8, Recipe.CHEMICAL_CRYSTALLIZER.getJEICategory()); registerRecipeItem(registry, MachineType.CHEMICAL_CRYSTALLIZER, Recipe.CHEMICAL_CRYSTALLIZER); } @@ -172,10 +161,8 @@ public class RecipeRegistryHelper { if (!MachineType.CHEMICAL_DISSOLUTION_CHAMBER.isEnabled()) { return; } - addRecipes(registry, Recipe.CHEMICAL_DISSOLUTION_CHAMBER, DissolutionRecipe.class, - ChemicalDissolutionChamberRecipeWrapper::new); - registry.addRecipeClickArea(GuiChemicalDissolutionChamber.class, 64, 40, 48, 8, - Recipe.CHEMICAL_DISSOLUTION_CHAMBER.getJEICategory()); + addRecipes(registry, Recipe.CHEMICAL_DISSOLUTION_CHAMBER, DissolutionRecipe.class, ChemicalDissolutionChamberRecipeWrapper::new); + registry.addRecipeClickArea(GuiChemicalDissolutionChamber.class, 64, 40, 48, 8, Recipe.CHEMICAL_DISSOLUTION_CHAMBER.getJEICategory()); registerRecipeItem(registry, MachineType.CHEMICAL_DISSOLUTION_CHAMBER, Recipe.CHEMICAL_DISSOLUTION_CHAMBER); } @@ -194,8 +181,7 @@ public class RecipeRegistryHelper { return; } addRecipes(registry, Recipe.CHEMICAL_OXIDIZER, OxidationRecipe.class, ChemicalOxidizerRecipeWrapper::new); - registry - .addRecipeClickArea(GuiChemicalOxidizer.class, 64, 40, 48, 8, Recipe.CHEMICAL_OXIDIZER.getJEICategory()); + registry.addRecipeClickArea(GuiChemicalOxidizer.class, 64, 40, 48, 8, Recipe.CHEMICAL_OXIDIZER.getJEICategory()); registerRecipeItem(registry, MachineType.CHEMICAL_OXIDIZER, Recipe.CHEMICAL_OXIDIZER); } @@ -213,8 +199,7 @@ public class RecipeRegistryHelper { return; } addRecipes(registry, Recipe.SOLAR_NEUTRON_ACTIVATOR, SolarNeutronRecipe.class, SolarNeutronRecipeWrapper::new); - registry.addRecipeClickArea(GuiSolarNeutronActivator.class, 64, 39, 48, 8, - Recipe.SOLAR_NEUTRON_ACTIVATOR.getJEICategory()); + registry.addRecipeClickArea(GuiSolarNeutronActivator.class, 64, 39, 48, 8, Recipe.SOLAR_NEUTRON_ACTIVATOR.getJEICategory()); registerRecipeItem(registry, MachineType.SOLAR_NEUTRON_ACTIVATOR, Recipe.SOLAR_NEUTRON_ACTIVATOR); } @@ -222,23 +207,15 @@ public class RecipeRegistryHelper { if (!MachineType.ELECTROLYTIC_SEPARATOR.isEnabled()) { return; } - addRecipes(registry, Recipe.ELECTROLYTIC_SEPARATOR, SeparatorRecipe.class, - ElectrolyticSeparatorRecipeWrapper::new); - - registry.addRecipeClickArea(GuiElectrolyticSeparator.class, 80, 30, 16, 6, - Recipe.ELECTROLYTIC_SEPARATOR.getJEICategory()); + addRecipes(registry, Recipe.ELECTROLYTIC_SEPARATOR, SeparatorRecipe.class, ElectrolyticSeparatorRecipeWrapper::new); + registry.addRecipeClickArea(GuiElectrolyticSeparator.class, 80, 30, 16, 6, Recipe.ELECTROLYTIC_SEPARATOR.getJEICategory()); registerRecipeItem(registry, MachineType.ELECTROLYTIC_SEPARATOR, Recipe.ELECTROLYTIC_SEPARATOR); } public static void registerEvaporationPlant(IModRegistry registry) { - addRecipes(registry, Recipe.THERMAL_EVAPORATION_PLANT, ThermalEvaporationRecipe.class, - ThermalEvaporationRecipeWrapper::new); - - registry.addRecipeClickArea(GuiThermalEvaporationController.class, 49, 20, 78, 38, - Recipe.THERMAL_EVAPORATION_PLANT.getJEICategory()); - - registry.addRecipeCatalyst(BasicBlockType.THERMAL_EVAPORATION_CONTROLLER.getStack(1), - Recipe.THERMAL_EVAPORATION_PLANT.getJEICategory()); + addRecipes(registry, Recipe.THERMAL_EVAPORATION_PLANT, ThermalEvaporationRecipe.class, ThermalEvaporationRecipeWrapper::new); + registry.addRecipeClickArea(GuiThermalEvaporationController.class, 49, 20, 78, 38, Recipe.THERMAL_EVAPORATION_PLANT.getJEICategory()); + registry.addRecipeCatalyst(BasicBlockType.THERMAL_EVAPORATION_CONTROLLER.getStack(1), Recipe.THERMAL_EVAPORATION_PLANT.getJEICategory()); } public static void registerReactionChamber(IModRegistry registry) { @@ -246,7 +223,6 @@ public class RecipeRegistryHelper { return; } addRecipes(registry, Recipe.PRESSURIZED_REACTION_CHAMBER, PressurizedRecipe.class, PRCRecipeWrapper::new); - registry.addRecipeClickArea(GuiPRC.class, 75, 37, 36, 10, Recipe.PRESSURIZED_REACTION_CHAMBER.getJEICategory()); registerRecipeItem(registry, MachineType.PRESSURIZED_REACTION_CHAMBER, Recipe.PRESSURIZED_REACTION_CHAMBER); } @@ -257,7 +233,6 @@ public class RecipeRegistryHelper { } List condensentratorRecipes = new ArrayList<>(); List decondensentratorRecipes = new ArrayList<>(); - for (Gas gas : GasRegistry.getRegisteredGasses()) { if (gas.hasFluid()) { condensentratorRecipes.add(new RotaryCondensentratorRecipeWrapper(gas.getFluid(), gas, true)); @@ -268,8 +243,7 @@ public class RecipeRegistryHelper { String decondensentrating = "mekanism.rotary_condensentrator_decondensentrating"; registry.addRecipes(condensentratorRecipes, condensentrating); registry.addRecipes(decondensentratorRecipes, decondensentrating); - registry - .addRecipeClickArea(GuiRotaryCondensentrator.class, 64, 39, 48, 8, condensentrating, decondensentrating); + registry.addRecipeClickArea(GuiRotaryCondensentrator.class, 64, 39, 48, 8, condensentrating, decondensentrating); registry.addRecipeCatalyst(MachineType.ROTARY_CONDENSENTRATOR.getStack(), condensentrating, decondensentrating); } @@ -277,13 +251,8 @@ public class RecipeRegistryHelper { if (!MachineType.ENERGIZED_SMELTER.isEnabled()) { return; } - registry.handleRecipes(SmeltingRecipe.class, MachineRecipeWrapper::new, - Recipe.ENERGIZED_SMELTER.getJEICategory()); - - boolean crafttweakerLoaded = Loader.isModLoaded("crafttweaker"); - - if (crafttweakerLoaded && EnergizedSmelter.hasRemovedRecipe()) // Removed / Removed + Added - { + registry.handleRecipes(SmeltingRecipe.class, MachineRecipeWrapper::new, Recipe.ENERGIZED_SMELTER.getJEICategory()); + if (Mekanism.hooks.CraftTweakerLoaded && EnergizedSmelter.hasRemovedRecipe()) {// Removed / Removed + Added // Add all recipes Collection recipeList = Recipe.ENERGIZED_SMELTER.get().values(); registry.addRecipes(recipeList.stream().map(MachineRecipeWrapper::new).collect(Collectors.toList()), @@ -292,18 +261,15 @@ public class RecipeRegistryHelper { registry .addRecipeClickArea(GuiEnergizedSmelter.class, 79, 40, 24, 7, Recipe.ENERGIZED_SMELTER.getJEICategory()); - } else if (crafttweakerLoaded && EnergizedSmelter.hasAddedRecipe()) // Added but not removed - { + } else if (Mekanism.hooks.CraftTweakerLoaded && EnergizedSmelter.hasAddedRecipe()) {// Added but not removed // Only add added recipes Map smeltingRecipes = Recipe.ENERGIZED_SMELTER.get(); - List smeltingWrapper = smeltingRecipes.entrySet().stream() - .filter(entry -> !FurnaceRecipes.instance().getSmeltingList().keySet() - .contains(entry.getKey().ingredient)).map(entry -> new MachineRecipeWrapper(entry.getValue())) - .collect(Collectors.toList()); + List smeltingWrapper = smeltingRecipes.entrySet().stream().filter(entry -> + !FurnaceRecipes.instance().getSmeltingList().keySet().contains(entry.getKey().ingredient)).map(entry -> + new MachineRecipeWrapper(entry.getValue())).collect(Collectors.toList()); registry.addRecipes(smeltingWrapper, Recipe.ENERGIZED_SMELTER.getJEICategory()); - registry.addRecipeClickArea(GuiEnergizedSmelter.class, 79, 40, 24, 7, VanillaRecipeCategoryUid.SMELTING, - Recipe.ENERGIZED_SMELTER.getJEICategory()); + registry.addRecipeClickArea(GuiEnergizedSmelter.class, 79, 40, 24, 7, VanillaRecipeCategoryUid.SMELTING, Recipe.ENERGIZED_SMELTER.getJEICategory()); registerVanillaSmeltingRecipeCatalyst(registry); } else { //Only use furnace list, so no extra registration. @@ -319,15 +285,12 @@ public class RecipeRegistryHelper { return; } registry.addRecipeCatalyst(MachineType.FORMULAIC_ASSEMBLICATOR.getStack(), VanillaRecipeCategoryUid.CRAFTING); - registry.getRecipeTransferRegistry() - .addRecipeTransferHandler(ContainerFormulaicAssemblicator.class, VanillaRecipeCategoryUid.CRAFTING, - 20, 9, 35, 36); + registry.getRecipeTransferRegistry().addRecipeTransferHandler(ContainerFormulaicAssemblicator.class, VanillaRecipeCategoryUid.CRAFTING, 20, 9, 35, 36); } private static void registerVanillaSmeltingRecipeCatalyst(IModRegistry registry) { registry.addRecipeCatalyst(MachineType.ENERGIZED_SMELTER.getStack(), VanillaRecipeCategoryUid.SMELTING); - FactoryTier.forEnabled(tier -> registry.addRecipeCatalyst(MekanismUtils.getFactory(tier, RecipeType.SMELTING), - VanillaRecipeCategoryUid.SMELTING)); + FactoryTier.forEnabled(tier -> registry.addRecipeCatalyst(MekanismUtils.getFactory(tier, RecipeType.SMELTING), VanillaRecipeCategoryUid.SMELTING)); } private static void addRecipes(IModRegistry registry, Recipe type, Class recipeClass, @@ -335,8 +298,7 @@ public class RecipeRegistryHelper { String recipeCategoryUid = type.getJEICategory(); registry.handleRecipes(recipeClass, factory, recipeCategoryUid); Collection recipeList = type.get().values(); - registry.addRecipes(recipeList.stream().map(factory::getRecipeWrapper).collect(Collectors.toList()), - recipeCategoryUid); + registry.addRecipes(recipeList.stream().map(factory::getRecipeWrapper).collect(Collectors.toList()), recipeCategoryUid); } private static void registerRecipeItem(IModRegistry registry, MachineType type, Recipe recipe) { @@ -350,8 +312,7 @@ public class RecipeRegistryHelper { } if (factoryType != null) { RecipeType finalFactoryType = factoryType; - FactoryTier.forEnabled(tier -> registry - .addRecipeCatalyst(MekanismUtils.getFactory(tier, finalFactoryType), recipe.getJEICategory())); + FactoryTier.forEnabled(tier -> registry.addRecipeCatalyst(MekanismUtils.getFactory(tier, finalFactoryType), recipe.getJEICategory())); } } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/jei/gas/GasStackRenderer.java b/src/main/java/mekanism/client/jei/gas/GasStackRenderer.java index 7a466b1ee..c6f1d994d 100644 --- a/src/main/java/mekanism/client/jei/gas/GasStackRenderer.java +++ b/src/main/java/mekanism/client/jei/gas/GasStackRenderer.java @@ -39,12 +39,10 @@ public class GasStackRenderer implements IIngredientRenderer { } public GasStackRenderer(int capacityMb, boolean showCapacity, int width, int height, @Nullable IDrawable overlay) { - this(capacityMb, showCapacity ? TooltipMode.SHOW_AMOUNT_AND_CAPACITY : TooltipMode.SHOW_AMOUNT, width, height, - overlay); + this(capacityMb, showCapacity ? TooltipMode.SHOW_AMOUNT_AND_CAPACITY : TooltipMode.SHOW_AMOUNT, width, height, overlay); } - public GasStackRenderer(int capacityMb, TooltipMode tooltipMode, int width, int height, - @Nullable IDrawable overlay) { + public GasStackRenderer(int capacityMb, TooltipMode tooltipMode, int width, int height, @Nullable IDrawable overlay) { this.capacityMb = capacityMb; this.tooltipMode = tooltipMode; this.width = width; @@ -72,8 +70,7 @@ public class GasStackRenderer implements IIngredientRenderer { GlStateManager.color(red, green, blue, 1.0F); } - private static void drawTextureWithMasking(double xCoord, double yCoord, TextureAtlasSprite textureSprite, - int maskTop, int maskRight, double zLevel) { + private static void drawTextureWithMasking(double xCoord, double yCoord, TextureAtlasSprite textureSprite, int maskTop, int maskRight, double zLevel) { double uMin = (double) textureSprite.getMinU(); double uMax = (double) textureSprite.getMaxU(); double vMin = (double) textureSprite.getMinV(); @@ -123,8 +120,8 @@ public class GasStackRenderer implements IIngredientRenderer { drawTiledSprite(minecraft, xPosition, yPosition, width, height, gas.getTint(), scaledAmount, getStillGasSprite(minecraft, gas)); } - private void drawTiledSprite(Minecraft minecraft, final int xPosition, final int yPosition, final int tiledWidth, - final int tiledHeight, int color, int scaledAmount, TextureAtlasSprite sprite) { + private void drawTiledSprite(Minecraft minecraft, final int xPosition, final int yPosition, final int tiledWidth, final int tiledHeight, int color, int scaledAmount, + TextureAtlasSprite sprite) { minecraft.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); setGLColorFromInt(color); @@ -161,8 +158,7 @@ public class GasStackRenderer implements IIngredientRenderer { String gasName = gasType.getLocalizedName(); tooltip.add(gasName); if (tooltipMode == TooltipMode.SHOW_AMOUNT_AND_CAPACITY) { - String amount = LangUtils - .localizeWithFormat("jei.tooltip.liquid.amount.with.capacity", gasStack.amount, capacityMb); + String amount = LangUtils.localizeWithFormat("jei.tooltip.liquid.amount.with.capacity", gasStack.amount, capacityMb); tooltip.add(TextFormatting.GRAY + amount); } else if (tooltipMode == TooltipMode.SHOW_AMOUNT) { String amount = LangUtils.localizeWithFormat("jei.tooltip.liquid.amount", gasStack.amount); diff --git a/src/main/java/mekanism/client/jei/gas/package-info.java b/src/main/java/mekanism/client/jei/gas/package-info.java index 31c2a5852..0aad2819d 100644 --- a/src/main/java/mekanism/client/jei/gas/package-info.java +++ b/src/main/java/mekanism/client/jei/gas/package-info.java @@ -5,4 +5,4 @@ package mekanism.client.jei.gas; import javax.annotation.ParametersAreNonnullByDefault; import mcp.MethodsReturnNonnullByDefault; -import mekanism.common.util.FieldsAreNonnullByDefault; +import mekanism.common.util.FieldsAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/mekanism/client/jei/machine/AdvancedMachineRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/AdvancedMachineRecipeCategory.java index 7130dc58f..4b19749b1 100644 --- a/src/main/java/mekanism/client/jei/machine/AdvancedMachineRecipeCategory.java +++ b/src/main/java/mekanism/client/jei/machine/AdvancedMachineRecipeCategory.java @@ -61,9 +61,8 @@ public class AdvancedMachineRecipeCategory extends BaseRecipeCategory { itemStacks.set(1, ((ItemStackOutput) tempRecipe.recipeOutput).output); itemStacks.set(2, ((AdvancedMachineRecipeWrapper) recipeWrapper).getFuelStacks(input.gasType)); IGuiIngredientGroup gasStacks = recipeLayout.getIngredientsGroup(MekanismJEI.TYPE_GAS); - initGas(gasStacks, 0, true, 33, 21, 6, 12, - new GasStack(input.gasType, TileEntityAdvancedElectricMachine.BASE_TICKS_REQUIRED - * TileEntityAdvancedElectricMachine.BASE_GAS_PER_TICK), false); + initGas(gasStacks, 0, true, 33, 21, 6, 12, new GasStack(input.gasType, TileEntityAdvancedElectricMachine.BASE_TICKS_REQUIRED + * TileEntityAdvancedElectricMachine.BASE_GAS_PER_TICK), false); } } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/jei/machine/AdvancedMachineRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/AdvancedMachineRecipeWrapper.java index 47cd9b3a3..f218c2432 100644 --- a/src/main/java/mekanism/client/jei/machine/AdvancedMachineRecipeWrapper.java +++ b/src/main/java/mekanism/client/jei/machine/AdvancedMachineRecipeWrapper.java @@ -26,8 +26,7 @@ public class AdvancedMachineRecipeWrapper implements IRecipeWrapper { public void getIngredients(IIngredients ingredients) { ingredients.setInput(VanillaTypes.ITEM, ((AdvancedMachineInput) recipe.getInput()).itemStack); ingredients.setInput(MekanismJEI.TYPE_GAS, new GasStack(((AdvancedMachineInput) recipe.getInput()).gasType, - TileEntityAdvancedElectricMachine.BASE_TICKS_REQUIRED - * TileEntityAdvancedElectricMachine.BASE_GAS_PER_TICK)); + TileEntityAdvancedElectricMachine.BASE_TICKS_REQUIRED * TileEntityAdvancedElectricMachine.BASE_GAS_PER_TICK)); ingredients.setOutput(VanillaTypes.ITEM, ((ItemStackOutput) recipe.getOutput()).output); } diff --git a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalDissolutionChamberRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalDissolutionChamberRecipeCategory.java index 0c2f976ba..79c349c24 100644 --- a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalDissolutionChamberRecipeCategory.java +++ b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalDissolutionChamberRecipeCategory.java @@ -19,8 +19,7 @@ public class ChemicalDissolutionChamberRecipeCategory extends BaseRecipeCategory public ChemicalDissolutionChamberRecipeCategory(IGuiHelper helper) { super(helper, "mekanism:gui/nei/GuiChemicalDissolutionChamber.png", - Recipe.CHEMICAL_DISSOLUTION_CHAMBER.getJEICategory(), "gui.chemicalDissolutionChamber.short", null, 3, 3, - 170, 79); + Recipe.CHEMICAL_DISSOLUTION_CHAMBER.getJEICategory(), "gui.chemicalDissolutionChamber.short", null, 3, 3, 170, 79); } @Override @@ -38,8 +37,7 @@ public class ChemicalDissolutionChamberRecipeCategory extends BaseRecipeCategory itemStacks.set(0, tempRecipe.getInput().ingredient); IGuiIngredientGroup gasStacks = recipeLayout.getIngredientsGroup(MekanismJEI.TYPE_GAS); initGas(gasStacks, 0, true, 6 - xOffset, 5 - yOffset, 16, 58, - new GasStack(MekanismFluids.SulfuricAcid, TileEntityChemicalDissolutionChamber.BASE_INJECT_USAGE - * TileEntityChemicalDissolutionChamber.BASE_TICKS_REQUIRED), + new GasStack(MekanismFluids.SulfuricAcid, TileEntityChemicalDissolutionChamber.BASE_INJECT_USAGE * TileEntityChemicalDissolutionChamber.BASE_TICKS_REQUIRED), true); initGas(gasStacks, 1, false, 134 - xOffset, 14 - yOffset, 16, 58, tempRecipe.getOutput().output, true); } diff --git a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalDissolutionChamberRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalDissolutionChamberRecipeWrapper.java index bca1757e3..206057d74 100644 --- a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalDissolutionChamberRecipeWrapper.java +++ b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalDissolutionChamberRecipeWrapper.java @@ -19,9 +19,7 @@ public class ChemicalDissolutionChamberRecipeWrapper implements IRecipeWrapper { @Override public void getIngredients(IIngredients ingredients) { - ingredients.setInput(MekanismJEI.TYPE_GAS, new GasStack(MekanismFluids.SulfuricAcid, - TileEntityChemicalDissolutionChamber.BASE_INJECT_USAGE - * TileEntityChemicalDissolutionChamber.BASE_TICKS_REQUIRED)); + ingredients.setInput(MekanismJEI.TYPE_GAS, new GasStack(MekanismFluids.SulfuricAcid, TileEntityChemicalDissolutionChamber.BASE_INJECT_USAGE * TileEntityChemicalDissolutionChamber.BASE_TICKS_REQUIRED)); ingredients.setInput(VanillaTypes.ITEM, recipe.recipeInput.ingredient); ingredients.setOutput(MekanismJEI.TYPE_GAS, recipe.recipeOutput.output); } diff --git a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalInfuserRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalInfuserRecipeWrapper.java index 706161062..010965119 100644 --- a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalInfuserRecipeWrapper.java +++ b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalInfuserRecipeWrapper.java @@ -16,8 +16,7 @@ public class ChemicalInfuserRecipeWrapper implements IRecipeWrapper { @Override public void getIngredients(IIngredients ingredients) { - ingredients - .setInputs(MekanismJEI.TYPE_GAS, Arrays.asList(recipe.recipeInput.leftGas, recipe.recipeInput.rightGas)); + ingredients.setInputs(MekanismJEI.TYPE_GAS, Arrays.asList(recipe.recipeInput.leftGas, recipe.recipeInput.rightGas)); ingredients.setOutput(MekanismJEI.TYPE_GAS, recipe.recipeOutput.output); } diff --git a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalWasherRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalWasherRecipeWrapper.java index 5c78d85c1..cbdea4633 100644 --- a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalWasherRecipeWrapper.java +++ b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalWasherRecipeWrapper.java @@ -19,8 +19,7 @@ public class ChemicalWasherRecipeWrapper implements IRecipeWrapper { @Override public void getIngredients(IIngredients ingredients) { - ingredients - .setInput(VanillaTypes.FLUID, new FluidStack(FluidRegistry.WATER, TileEntityChemicalWasher.WATER_USAGE)); + ingredients.setInput(VanillaTypes.FLUID, new FluidStack(FluidRegistry.WATER, TileEntityChemicalWasher.WATER_USAGE)); ingredients.setInput(MekanismJEI.TYPE_GAS, recipe.recipeInput.ingredient); ingredients.setOutput(MekanismJEI.TYPE_GAS, recipe.recipeOutput.output); } diff --git a/src/main/java/mekanism/client/jei/machine/chemical/package-info.java b/src/main/java/mekanism/client/jei/machine/chemical/package-info.java index 582f29019..2b9f1bab9 100644 --- a/src/main/java/mekanism/client/jei/machine/chemical/package-info.java +++ b/src/main/java/mekanism/client/jei/machine/chemical/package-info.java @@ -5,4 +5,4 @@ package mekanism.client.jei.machine.chemical; import javax.annotation.ParametersAreNonnullByDefault; import mcp.MethodsReturnNonnullByDefault; -import mekanism.common.util.FieldsAreNonnullByDefault; +import mekanism.common.util.FieldsAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/mekanism/client/jei/machine/other/ElectrolyticSeparatorRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/other/ElectrolyticSeparatorRecipeWrapper.java index cf9581ece..e2353cabf 100644 --- a/src/main/java/mekanism/client/jei/machine/other/ElectrolyticSeparatorRecipeWrapper.java +++ b/src/main/java/mekanism/client/jei/machine/other/ElectrolyticSeparatorRecipeWrapper.java @@ -18,8 +18,7 @@ public class ElectrolyticSeparatorRecipeWrapper implements IRecipeWrapper { @Override public void getIngredients(IIngredients ingredients) { ingredients.setInput(VanillaTypes.FLUID, recipe.recipeInput.ingredient); - ingredients.setOutputs(MekanismJEI.TYPE_GAS, - Arrays.asList(recipe.recipeOutput.leftGas, recipe.recipeOutput.rightGas)); + ingredients.setOutputs(MekanismJEI.TYPE_GAS, Arrays.asList(recipe.recipeOutput.leftGas, recipe.recipeOutput.rightGas)); } public SeparatorRecipe getRecipe() { diff --git a/src/main/java/mekanism/client/jei/machine/other/MetallurgicInfuserRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/other/MetallurgicInfuserRecipeCategory.java index 22d4f5350..47d52f646 100644 --- a/src/main/java/mekanism/client/jei/machine/other/MetallurgicInfuserRecipeCategory.java +++ b/src/main/java/mekanism/client/jei/machine/other/MetallurgicInfuserRecipeCategory.java @@ -31,8 +31,7 @@ public class MetallurgicInfuserRecipeCategory extends BaseRecipeCategory { } public static List getInfuseStacks(InfuseType type) { - return InfuseRegistry.getObjectMap().entrySet().stream() - .filter(obj -> obj.getValue().type == type).map(Entry::getKey).collect(Collectors.toList()); + return InfuseRegistry.getObjectMap().entrySet().stream().filter(obj -> obj.getValue().type == type).map(Entry::getKey).collect(Collectors.toList()); } @Override diff --git a/src/main/java/mekanism/client/jei/machine/other/PRCRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/other/PRCRecipeCategory.java index 85c3bf7aa..7233c33f2 100644 --- a/src/main/java/mekanism/client/jei/machine/other/PRCRecipeCategory.java +++ b/src/main/java/mekanism/client/jei/machine/other/PRCRecipeCategory.java @@ -67,8 +67,7 @@ public class PRCRecipeCategory extends BaseRecipeCategory { fluidStacks.set(0, tempRecipe.recipeInput.getFluid()); IGuiIngredientGroup gasStacks = recipeLayout.getIngredientsGroup(MekanismJEI.TYPE_GAS); initGas(gasStacks, 0, true, 29 - xOffset, 11 - yOffset, 16, 58, tempRecipe.recipeInput.getGas(), true); - initGas(gasStacks, 1, false, 141 - xOffset, 41 - yOffset, 16, 28, tempRecipe.recipeOutput.getGasOutput(), - true); + initGas(gasStacks, 1, false, 141 - xOffset, 41 - yOffset, 16, 28, tempRecipe.recipeOutput.getGasOutput(), true); } } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/jei/machine/other/RotaryCondensentratorRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/other/RotaryCondensentratorRecipeCategory.java index 4b0fffbbc..53152d039 100644 --- a/src/main/java/mekanism/client/jei/machine/other/RotaryCondensentratorRecipeCategory.java +++ b/src/main/java/mekanism/client/jei/machine/other/RotaryCondensentratorRecipeCategory.java @@ -18,8 +18,7 @@ public class RotaryCondensentratorRecipeCategory extends BaseRecipeCategory { public RotaryCondensentratorRecipeCategory(IGuiHelper helper, boolean condensentrating) { super(helper, "mekanism:gui/nei/GuiRotaryCondensentrator.png", - condensentrating ? "mekanism.rotary_condensentrator_condensentrating" - : "mekanism.rotary_condensentrator_decondensentrating", + condensentrating ? "mekanism.rotary_condensentrator_condensentrating" : "mekanism.rotary_condensentrator_decondensentrating", condensentrating ? "gui.condensentrating" : "gui.decondensentrating", null, 3, 12, 170, 71); this.condensentrating = condensentrating; } @@ -36,15 +35,12 @@ public class RotaryCondensentratorRecipeCategory extends BaseRecipeCategory { RotaryCondensentratorRecipeWrapper tempRecipe = (RotaryCondensentratorRecipeWrapper) recipeWrapper; IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks(); IGuiIngredientGroup gasStacks = recipeLayout.getIngredientsGroup(MekanismJEI.TYPE_GAS); - fluidStacks.init(0, !condensentrating, 134 - xOffset, 14 - yOffset, 16, 58, tempRecipe.FLUID_AMOUNT, - false, fluidOverlayLarge); + fluidStacks.init(0, !condensentrating, 134 - xOffset, 14 - yOffset, 16, 58, tempRecipe.FLUID_AMOUNT, false, fluidOverlayLarge); if (condensentrating) { - initGas(gasStacks, 0, true, 26 - xOffset, 14 - yOffset, 16, 58, - new GasStack(tempRecipe.getGasType(), tempRecipe.GAS_AMOUNT), true); + initGas(gasStacks, 0, true, 26 - xOffset, 14 - yOffset, 16, 58, new GasStack(tempRecipe.getGasType(), tempRecipe.GAS_AMOUNT), true); fluidStacks.set(0, ingredients.getOutputs(VanillaTypes.FLUID).get(0)); } else { - initGas(gasStacks, 0, false, 26 - xOffset, 14 - yOffset, 16, 58, - new GasStack(tempRecipe.getGasType(), tempRecipe.GAS_AMOUNT), true); + initGas(gasStacks, 0, false, 26 - xOffset, 14 - yOffset, 16, 58, new GasStack(tempRecipe.getGasType(), tempRecipe.GAS_AMOUNT), true); fluidStacks.set(0, ingredients.getInputs(VanillaTypes.FLUID).get(0)); } } diff --git a/src/main/java/mekanism/client/jei/machine/other/RotaryCondensentratorRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/other/RotaryCondensentratorRecipeWrapper.java index 29ba98c5a..98dc5b177 100644 --- a/src/main/java/mekanism/client/jei/machine/other/RotaryCondensentratorRecipeWrapper.java +++ b/src/main/java/mekanism/client/jei/machine/other/RotaryCondensentratorRecipeWrapper.java @@ -39,8 +39,8 @@ public class RotaryCondensentratorRecipeWrapper implements IRecipeWrapper { @Override public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { - minecraft.fontRenderer.drawString(condensentrating ? LangUtils.localize("gui.condensentrating") - : LangUtils.localize("gui.decondensentrating"), 6 - 3, 74 - 12, 0x404040, false); + minecraft.fontRenderer.drawString(condensentrating ? LangUtils.localize("gui.condensentrating") : LangUtils.localize("gui.decondensentrating"), + 6 - 3, 74 - 12, 0x404040, false); } public Gas getGasType() { diff --git a/src/main/java/mekanism/client/jei/machine/other/ThermalEvaporationRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/other/ThermalEvaporationRecipeCategory.java index eef57da4f..f006f047a 100644 --- a/src/main/java/mekanism/client/jei/machine/other/ThermalEvaporationRecipeCategory.java +++ b/src/main/java/mekanism/client/jei/machine/other/ThermalEvaporationRecipeCategory.java @@ -14,8 +14,7 @@ public class ThermalEvaporationRecipeCategory extends BaseRecipeCategory { public ThermalEvaporationRecipeCategory(IGuiHelper helper) { super(helper, "mekanism:gui/nei/GuiThermalEvaporationController.png", - Recipe.THERMAL_EVAPORATION_PLANT.getJEICategory(), "gui.thermalEvaporationController.short", null, 3, 12, - 170, 62); + Recipe.THERMAL_EVAPORATION_PLANT.getJEICategory(), "gui.thermalEvaporationController.short", null, 3, 12, 170, 62); } @Override diff --git a/src/main/java/mekanism/client/jei/machine/other/package-info.java b/src/main/java/mekanism/client/jei/machine/other/package-info.java index b7de5ac75..fcf3036fd 100644 --- a/src/main/java/mekanism/client/jei/machine/other/package-info.java +++ b/src/main/java/mekanism/client/jei/machine/other/package-info.java @@ -5,4 +5,4 @@ package mekanism.client.jei.machine.other; import javax.annotation.ParametersAreNonnullByDefault; import mcp.MethodsReturnNonnullByDefault; -import mekanism.common.util.FieldsAreNonnullByDefault; +import mekanism.common.util.FieldsAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/mekanism/client/jei/machine/package-info.java b/src/main/java/mekanism/client/jei/machine/package-info.java index 2f5483210..8ae0c5c29 100644 --- a/src/main/java/mekanism/client/jei/machine/package-info.java +++ b/src/main/java/mekanism/client/jei/machine/package-info.java @@ -5,4 +5,4 @@ package mekanism.client.jei.machine; import javax.annotation.ParametersAreNonnullByDefault; import mcp.MethodsReturnNonnullByDefault; -import mekanism.common.util.FieldsAreNonnullByDefault; +import mekanism.common.util.FieldsAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/mekanism/client/jei/package-info.java b/src/main/java/mekanism/client/jei/package-info.java index e3b96a9f1..75950863c 100644 --- a/src/main/java/mekanism/client/jei/package-info.java +++ b/src/main/java/mekanism/client/jei/package-info.java @@ -5,4 +5,4 @@ package mekanism.client.jei; import javax.annotation.ParametersAreNonnullByDefault; import mcp.MethodsReturnNonnullByDefault; -import mekanism.common.util.FieldsAreNonnullByDefault; +import mekanism.common.util.FieldsAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/mekanism/client/model/ModelArmoredJetpack.java b/src/main/java/mekanism/client/model/ModelArmoredJetpack.java index d268193fe..61d15183f 100644 --- a/src/main/java/mekanism/client/model/ModelArmoredJetpack.java +++ b/src/main/java/mekanism/client/model/ModelArmoredJetpack.java @@ -282,4 +282,4 @@ public class ModelArmoredJetpack extends ModelBase { model.rotateAngleY = y; model.rotateAngleZ = z; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/model/ModelAtomicDisassembler.java b/src/main/java/mekanism/client/model/ModelAtomicDisassembler.java index ffcaf46a4..2a10e8f42 100644 --- a/src/main/java/mekanism/client/model/ModelAtomicDisassembler.java +++ b/src/main/java/mekanism/client/model/ModelAtomicDisassembler.java @@ -157,4 +157,4 @@ public class ModelAtomicDisassembler extends ModelBase { model.rotateAngleY = y; model.rotateAngleZ = z; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/model/ModelChemicalCrystallizer.java b/src/main/java/mekanism/client/model/ModelChemicalCrystallizer.java index 36ebb852f..427351b4c 100644 --- a/src/main/java/mekanism/client/model/ModelChemicalCrystallizer.java +++ b/src/main/java/mekanism/client/model/ModelChemicalCrystallizer.java @@ -164,4 +164,4 @@ public class ModelChemicalCrystallizer extends ModelBase { model.rotateAngleY = y; model.rotateAngleZ = z; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/model/ModelChemicalDissolutionChamber.java b/src/main/java/mekanism/client/model/ModelChemicalDissolutionChamber.java index f0893da09..366511873 100644 --- a/src/main/java/mekanism/client/model/ModelChemicalDissolutionChamber.java +++ b/src/main/java/mekanism/client/model/ModelChemicalDissolutionChamber.java @@ -268,4 +268,4 @@ public class ModelChemicalDissolutionChamber extends ModelBase { model.rotateAngleY = y; model.rotateAngleZ = z; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/model/ModelDigitalMiner.java b/src/main/java/mekanism/client/model/ModelDigitalMiner.java index 1da4b9f00..66ec7bc1c 100644 --- a/src/main/java/mekanism/client/model/ModelDigitalMiner.java +++ b/src/main/java/mekanism/client/model/ModelDigitalMiner.java @@ -505,4 +505,4 @@ public class ModelDigitalMiner extends ModelBase { model.rotateAngleY = y; model.rotateAngleZ = z; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/model/ModelElectrolyticSeparator.java b/src/main/java/mekanism/client/model/ModelElectrolyticSeparator.java index c7a951cca..b706443f8 100644 --- a/src/main/java/mekanism/client/model/ModelElectrolyticSeparator.java +++ b/src/main/java/mekanism/client/model/ModelElectrolyticSeparator.java @@ -159,4 +159,4 @@ public class ModelElectrolyticSeparator extends ModelBase { model.rotateAngleY = y; model.rotateAngleZ = z; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/model/ModelEnergyCube.java b/src/main/java/mekanism/client/model/ModelEnergyCube.java index b125cf91e..45ad7d3e4 100644 --- a/src/main/java/mekanism/client/model/ModelEnergyCube.java +++ b/src/main/java/mekanism/client/model/ModelEnergyCube.java @@ -344,9 +344,9 @@ public class ModelEnergyCube extends ModelBase { leds2 = new ModelRenderer[]{ledBottom2, ledTop2, ledFront2, ledBack2, ledLeft2, ledRight2}; ports = new ModelRenderer[]{portBottomToggle, portTopToggle, portFrontToggle, portBackToggle, portLeftToggle, - portRightToggle}; + portRightToggle}; connectors = new ModelRenderer[]{connectorBottomToggle, connectorTopToggle, connectorFrontToggle, - connectorBackToggle, connectorLeftToggle, connectorRightToggle}; + connectorBackToggle, connectorLeftToggle, connectorRightToggle}; } public void render(float size, EnergyCubeTier tier, TextureManager manager, boolean renderMain) { @@ -401,9 +401,7 @@ public class ModelEnergyCube extends ModelBase { if (state == IOState.OUTPUT) { MekanismRenderer.glowOn(); renderer.bindTexture(RenderEnergyCube.resources.get(tier)); - ports[side.ordinal()].render(size); - MekanismRenderer.glowOff(); } } @@ -447,4 +445,4 @@ public class ModelEnergyCube extends ModelBase { cube.render(0.0625F); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/model/ModelFlamethrower.java b/src/main/java/mekanism/client/model/ModelFlamethrower.java index b7427b355..c43432786 100644 --- a/src/main/java/mekanism/client/model/ModelFlamethrower.java +++ b/src/main/java/mekanism/client/model/ModelFlamethrower.java @@ -208,4 +208,4 @@ public class ModelFlamethrower extends ModelBase { model.rotateAngleY = y; model.rotateAngleZ = z; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/model/ModelFluidTank.java b/src/main/java/mekanism/client/model/ModelFluidTank.java index 10f921ec3..53acff848 100644 --- a/src/main/java/mekanism/client/model/ModelFluidTank.java +++ b/src/main/java/mekanism/client/model/ModelFluidTank.java @@ -110,4 +110,4 @@ public class ModelFluidTank extends ModelBase { model.rotateAngleY = y; model.rotateAngleZ = z; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/model/ModelFreeRunners.java b/src/main/java/mekanism/client/model/ModelFreeRunners.java index 39edc3140..5ae42d69d 100644 --- a/src/main/java/mekanism/client/model/ModelFreeRunners.java +++ b/src/main/java/mekanism/client/model/ModelFreeRunners.java @@ -82,4 +82,4 @@ public class ModelFreeRunners extends ModelBase { model.rotateAngleY = y; model.rotateAngleZ = z; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/model/ModelQuantumEntangloporter.java b/src/main/java/mekanism/client/model/ModelQuantumEntangloporter.java index d6911669d..f443b51e9 100644 --- a/src/main/java/mekanism/client/model/ModelQuantumEntangloporter.java +++ b/src/main/java/mekanism/client/model/ModelQuantumEntangloporter.java @@ -380,4 +380,4 @@ public class ModelQuantumEntangloporter extends ModelBase { model.rotateAngleY = y; model.rotateAngleZ = z; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/model/ModelResistiveHeater.java b/src/main/java/mekanism/client/model/ModelResistiveHeater.java index 842ba8a41..4b05a43f2 100644 --- a/src/main/java/mekanism/client/model/ModelResistiveHeater.java +++ b/src/main/java/mekanism/client/model/ModelResistiveHeater.java @@ -14,10 +14,8 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ModelResistiveHeater extends ModelBase { - public static ResourceLocation OVERLAY_ON = MekanismUtils - .getResource(ResourceType.RENDER, "ResistiveHeater_OverlayOn.png"); - public static ResourceLocation OVERLAY_OFF = MekanismUtils - .getResource(ResourceType.RENDER, "ResistiveHeater_OverlayOff.png"); + public static ResourceLocation OVERLAY_ON = MekanismUtils.getResource(ResourceType.RENDER, "ResistiveHeater_OverlayOn.png"); + public static ResourceLocation OVERLAY_OFF = MekanismUtils.getResource(ResourceType.RENDER, "ResistiveHeater_OverlayOff.png"); ModelRenderer wallLeft; ModelRenderer base; @@ -214,4 +212,4 @@ public class ModelResistiveHeater extends ModelBase { model.rotateAngleY = y; model.rotateAngleZ = z; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/model/ModelRobit.java b/src/main/java/mekanism/client/model/ModelRobit.java index 61ecedfe9..0639e6786 100644 --- a/src/main/java/mekanism/client/model/ModelRobit.java +++ b/src/main/java/mekanism/client/model/ModelRobit.java @@ -176,4 +176,4 @@ public class ModelRobit extends ModelBase { model.rotateAngleY = y; model.rotateAngleZ = z; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/model/ModelRotaryCondensentrator.java b/src/main/java/mekanism/client/model/ModelRotaryCondensentrator.java index f67245241..d927a1913 100644 --- a/src/main/java/mekanism/client/model/ModelRotaryCondensentrator.java +++ b/src/main/java/mekanism/client/model/ModelRotaryCondensentrator.java @@ -199,4 +199,4 @@ public class ModelRotaryCondensentrator extends ModelBase { model.rotateAngleY = y; model.rotateAngleZ = z; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/model/ModelSecurityDesk.java b/src/main/java/mekanism/client/model/ModelSecurityDesk.java index 4b00a5d3f..405f0b46f 100644 --- a/src/main/java/mekanism/client/model/ModelSecurityDesk.java +++ b/src/main/java/mekanism/client/model/ModelSecurityDesk.java @@ -129,4 +129,4 @@ public class ModelSecurityDesk extends ModelBase { model.rotateAngleY = y; model.rotateAngleZ = z; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/model/ModelSeismicVibrator.java b/src/main/java/mekanism/client/model/ModelSeismicVibrator.java index 8c6e57ada..1dce8690a 100644 --- a/src/main/java/mekanism/client/model/ModelSeismicVibrator.java +++ b/src/main/java/mekanism/client/model/ModelSeismicVibrator.java @@ -391,4 +391,4 @@ public class ModelSeismicVibrator extends ModelBase { model.rotateAngleY = y; model.rotateAngleZ = z; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/model/ModelSolarNeutronActivator.java b/src/main/java/mekanism/client/model/ModelSolarNeutronActivator.java index cc032b7db..70549173e 100644 --- a/src/main/java/mekanism/client/model/ModelSolarNeutronActivator.java +++ b/src/main/java/mekanism/client/model/ModelSolarNeutronActivator.java @@ -400,4 +400,4 @@ public class ModelSolarNeutronActivator extends ModelBase { model.rotateAngleY = y; model.rotateAngleZ = z; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/model/ModelTransporterBox.java b/src/main/java/mekanism/client/model/ModelTransporterBox.java index 89b881e25..4c7a8e483 100644 --- a/src/main/java/mekanism/client/model/ModelTransporterBox.java +++ b/src/main/java/mekanism/client/model/ModelTransporterBox.java @@ -31,4 +31,4 @@ public class ModelTransporterBox extends ModelBase { model.rotateAngleY = y; model.rotateAngleZ = z; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/ColourTemperature.java b/src/main/java/mekanism/client/render/ColourTemperature.java index 92ba62a83..2ca29f301 100644 --- a/src/main/java/mekanism/client/render/ColourTemperature.java +++ b/src/main/java/mekanism/client/render/ColourTemperature.java @@ -105,23 +105,18 @@ public class ColourTemperature extends ColourRGBA { } ColourTemperature colourTemperature = new ColourTemperature(red, green, blue, alpha, temperature); - - cache.put((int) (absTemp), colourTemperature); - + cache.put((int) absTemp, colourTemperature); return colourTemperature.blendOnto(baseColour); } public ColourTemperature blendOnto(ColourRGBA baseColour) { - double sR = (valR & 0xFF) / 255D, sG = (valG & 0xFF) / 255D, sB = (valB & 0xFF) / 255D, sA = - (valA & 0xFF) / 255D; - double dR = (baseColour.valR & 0xFF) / 255D, dG = (baseColour.valG & 0xFF) / 255D, dB = - (baseColour.valB & 0xFF) / 255D, dA = (baseColour.valA & 0xFF) / 255D; + double sR = (valR & 0xFF) / 255D, sG = (valG & 0xFF) / 255D, sB = (valB & 0xFF) / 255D, sA = (valA & 0xFF) / 255D; + double dR = (baseColour.valR & 0xFF) / 255D, dG = (baseColour.valG & 0xFF) / 255D, dB = (baseColour.valB & 0xFF) / 255D, dA = (baseColour.valA & 0xFF) / 255D; double rR = sR * sA + dR * (1 - sA); double rG = sG * sA + dG * (1 - sA); double rB = sB * sA + dB * (1 - sA); double rA = dA * 1D + sA * (1 - dA); - return new ColourTemperature(rR, rG, rB, rA, temp); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/FluidRenderMap.java b/src/main/java/mekanism/client/render/FluidRenderMap.java index 1561e3212..92e06e044 100644 --- a/src/main/java/mekanism/client/render/FluidRenderMap.java +++ b/src/main/java/mekanism/client/render/FluidRenderMap.java @@ -6,8 +6,7 @@ import net.minecraftforge.fluids.FluidStack; /** - * Map which uses FluidStacks as keys, ignoring amount. Primary use: caching FluidStack aware fluid rendering (NBT, - * yay) + * Map which uses FluidStacks as keys, ignoring amount. Primary use: caching FluidStack aware fluid rendering (NBT, yay) */ public class FluidRenderMap extends Object2ObjectOpenCustomHashMap { @@ -37,10 +36,7 @@ public class FluidRenderMap extends Object2ObjectOpenCustomHashMap variants = new ArrayList<>(); - for (int i = 0; i < metaItem.getVariants(); i++) { if (metaItem.getTexture(i) == null) { continue; @@ -88,13 +87,11 @@ public class MekanismRenderer { return; } - ModelLoader - .setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory")); + ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory")); } public static void initFluidTextures(TextureMap map) { missingIcon = map.getMissingSprite(); - texMap = map; } @@ -102,7 +99,8 @@ public class MekanismRenderer { * Get a fluid texture when a stack does not exist. * * @param fluid the fluid to get - * @param type Still or Flowing + * @param type Still or Flowing + * * @return the sprite, or missing sprite if not found */ public static TextureAtlasSprite getBaseFluidTexture(Fluid fluid, FluidType type) { @@ -126,7 +124,6 @@ public class MekanismRenderer { } Fluid fluid = fluidStack.getFluid(); - ResourceLocation spriteLocation; if (type == FluidType.STILL) { spriteLocation = fluid.getStill(fluidStack); @@ -172,15 +169,12 @@ public class MekanismRenderer { int j = quad.getFormat().getIntegerSize() * i; int uvIndex = quad.getFormat().getUvOffsetById(0) / 4; if (j + uvIndex + 1 < vertices.length) { - vertices[j + uvIndex] = Float.floatToRawIntBits(sprite.getInterpolatedU( - quad.getSprite().getUnInterpolatedU(Float.intBitsToFloat(vertices[j + uvIndex])))); - vertices[j + uvIndex + 1] = Float.floatToRawIntBits(sprite.getInterpolatedV( - quad.getSprite().getUnInterpolatedV(Float.intBitsToFloat(vertices[j + uvIndex + 1])))); + vertices[j + uvIndex] = Float.floatToRawIntBits(sprite.getInterpolatedU(quad.getSprite().getUnInterpolatedU(Float.intBitsToFloat(vertices[j + uvIndex])))); + vertices[j + uvIndex + 1] = Float.floatToRawIntBits(sprite.getInterpolatedV(quad.getSprite().getUnInterpolatedV(Float.intBitsToFloat(vertices[j + uvIndex + 1])))); } } - return new BakedQuad(vertices, quad.getTintIndex(), quad.getFace(), sprite, quad.shouldApplyDiffuseLighting(), - quad.getFormat()); + return new BakedQuad(vertices, quad.getTintIndex(), quad.getFace(), sprite, quad.shouldApplyDiffuseLighting(), quad.getFormat()); } public static BakedQuad rotate(BakedQuad quad, int amount) { @@ -197,14 +191,12 @@ public class MekanismRenderer { } } - return new BakedQuad(vertices, quad.getTintIndex(), quad.getFace(), quad.getSprite(), - quad.shouldApplyDiffuseLighting(), quad.getFormat()); + return new BakedQuad(vertices, quad.getTintIndex(), quad.getFace(), quad.getSprite(), quad.shouldApplyDiffuseLighting(), quad.getFormat()); } public static void prepFlowing(Model3D model, FluidStack fluid) { TextureAtlasSprite still = getFluidTexture(fluid, FluidType.STILL); TextureAtlasSprite flowing = getFluidTexture(fluid, FluidType.FLOWING); - model.setTextures(still, still, flowing, flowing, flowing, flowing); } @@ -232,8 +224,7 @@ public class MekanismRenderer { } public static void color(EnumColor color, float alpha, float multiplier) { - GL11.glColor4f(color.getColor(0) * multiplier, color.getColor(1) * multiplier, color.getColor(2) * multiplier, - alpha); + GL11.glColor4f(color.getColor(0) * multiplier, color.getColor(1) * multiplier, color.getColor(2) * multiplier, alpha); } public static void resetColor() { @@ -337,13 +328,11 @@ public class MekanismRenderer { @SubscribeEvent public void onStitch(TextureStitchEvent.Pre event) { for (EnumColor color : EnumColor.values()) { - colors[color.ordinal()] = event.getMap() - .registerSprite(new ResourceLocation("mekanism:blocks/overlay/overlay_" + color.unlocalizedName)); + colors[color.ordinal()] = event.getMap().registerSprite(new ResourceLocation("mekanism:blocks/overlay/overlay_" + color.unlocalizedName)); } for (TransmissionType type : TransmissionType.values()) { - overlays.put(type, event.getMap().registerSprite( - new ResourceLocation("mekanism:blocks/overlay/" + type.getTransmission() + "Overlay"))); + overlays.put(type, event.getMap().registerSprite(new ResourceLocation("mekanism:blocks/overlay/" + type.getTransmission() + "Overlay"))); } energyIcon = event.getMap().registerSprite(new ResourceLocation("mekanism:blocks/liquid/LiquidEnergy")); @@ -498,4 +487,4 @@ public class MekanismRenderer { this.prevMode = prevMode; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/MinerVisualRenderer.java b/src/main/java/mekanism/client/render/MinerVisualRenderer.java index c80ed9f9a..3a3711de6 100644 --- a/src/main/java/mekanism/client/render/MinerVisualRenderer.java +++ b/src/main/java/mekanism/client/render/MinerVisualRenderer.java @@ -50,8 +50,7 @@ public final class MinerVisualRenderer { for (int x = -data.radius; x <= data.radius; x++) { for (int y = data.minY - data.yCoord; y <= data.maxY - data.yCoord; y++) { for (int z = -data.radius; z <= data.radius; z++) { - if (x == -data.radius || x == data.radius || y == data.minY - data.yCoord - || y == data.maxY - data.yCoord || z == -data.radius || z == data.radius) { + if (x == -data.radius || x == data.radius || y == data.minY - data.yCoord || y == data.maxY - data.yCoord || z == -data.radius || z == data.radius) { models.add(createModel(new Coord4D(x, y, z, mc.world.provider.getDimension()))); } } @@ -110,9 +109,8 @@ public final class MinerVisualRenderer { @Override public boolean equals(Object data) { - return data instanceof MinerRenderData && ((MinerRenderData) data).minY == minY && - ((MinerRenderData) data).maxY == maxY && ((MinerRenderData) data).radius == radius && - ((MinerRenderData) data).yCoord == yCoord; + return data instanceof MinerRenderData && ((MinerRenderData) data).minY == minY && ((MinerRenderData) data).maxY == maxY && + ((MinerRenderData) data).radius == radius && ((MinerRenderData) data).yCoord == yCoord; } @Override @@ -125,4 +123,4 @@ public final class MinerVisualRenderer { return code; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/ModelCustomArmor.java b/src/main/java/mekanism/client/render/ModelCustomArmor.java index fbb9b4f6b..0e854b948 100644 --- a/src/main/java/mekanism/client/render/ModelCustomArmor.java +++ b/src/main/java/mekanism/client/render/ModelCustomArmor.java @@ -50,7 +50,6 @@ public class ModelCustomArmor extends ModelBiped { } else if (type.armorSlot == 3) { return partRender == biped.bipedLeftLeg || partRender == biped.bipedRightLeg; } - return false; } @@ -64,11 +63,10 @@ public class ModelCustomArmor extends ModelBiped { biped.bipedLeftArm.showModel = index == EntityEquipmentSlot.CHEST; biped.bipedRightLeg.showModel = index == EntityEquipmentSlot.LEGS || index == EntityEquipmentSlot.FEET; biped.bipedLeftLeg.showModel = index == EntityEquipmentSlot.LEGS || index == EntityEquipmentSlot.FEET; - return biped; } - public void init(Entity entity, float f, float f1, float f2, float f3, float f4, float size) { + public void init(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float size) { reset(); isSneak = entity.isSneaking(); @@ -91,7 +89,7 @@ public class ModelCustomArmor extends ModelBiped { bipedRightLeg.showModel = true; } - setRotationAngles(f, f1, f2, f3, f4, size, entity); + setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, size, entity); } public void reset() { @@ -124,9 +122,9 @@ public class ModelCustomArmor extends ModelBiped { } @Override - public void render(@Nonnull 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 void render(@Nonnull Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + init(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); + super.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); } public enum ArmorModel { @@ -157,19 +155,16 @@ public class ModelCustomArmor extends ModelBiped { } @Override - public void render(@Nonnull Entity entity, float par2, float par3, float par4, float par5, float par6, - float par7) { + public void render(@Nonnull Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { isSneak = entity.isSneaking(); isRiding = entity.isRiding(); - if (entity instanceof EntityLivingBase) { isChild = ((EntityLivingBase) entity).isChild(); } - setRotationAngles(par2, par3, par4, par5, par6, par7, entity); - + setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entity); MekanismRenderer.glowOn(); - super.render(entity, par2, par3, par4, par5, par6, par7); + super.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); MekanismRenderer.glowOff(); } } @@ -190,9 +185,7 @@ public class ModelCustomArmor extends ModelBiped { if (ModelCustomArmor.this.modelType != null) { GlStateManager.pushMatrix(); GlStateManager.translate(0, 0, 0.06F); - mc.renderEngine.bindTexture(modelType.resource); - if (useModel(biped.modelType, partRender, biped)) { if (biped.modelType == ArmorModel.JETPACK) { ArmorModel.jetpackModel.render(0.0625F); @@ -205,7 +198,6 @@ public class ModelCustomArmor extends ModelBiped { ArmorModel.gasMaskModel.render(0.0625F); } else if (biped.modelType == ArmorModel.FREERUNNERS) { GlStateManager.scale(1.02F, 1.02F, 1.02F); - if (partRender == biped.bipedLeftLeg) { GlStateManager.translate(-0.1375F, -0.75F, -0.0625F); ArmorModel.freeRunnersModel.renderLeft(0.0625F); @@ -215,9 +207,8 @@ public class ModelCustomArmor extends ModelBiped { } } } - GlStateManager.popMatrix(); } } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/RenderResizableCuboid.java b/src/main/java/mekanism/client/render/RenderResizableCuboid.java index 460cccb67..9c4914436 100644 --- a/src/main/java/mekanism/client/render/RenderResizableCuboid.java +++ b/src/main/java/mekanism/client/render/RenderResizableCuboid.java @@ -1,9 +1,9 @@ package mekanism.client.render; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; +import java.util.ArrayList; import java.util.Arrays; +import java.util.EnumMap; import java.util.List; import java.util.Map; import mekanism.client.render.MekanismRenderer.Model3D; @@ -41,7 +41,7 @@ public class RenderResizableCuboid { /** * The AO map assumes that each direction in the world has a different amount of light going towards it. */ - private static final Map aoMap = Maps.newEnumMap(EnumFacing.class); + private static final Map aoMap = new EnumMap<>(EnumFacing.class); private static final int U_MIN = 0; private static final int U_MAX = 1; private static final int V_MIN = 2; @@ -67,11 +67,8 @@ public class RenderResizableCuboid { return new Vec3d(vector.x, value, vector.z); } else if (axis == Axis.Z) { return new Vec3d(vector.x, vector.y, value); - } else { - throw new RuntimeException( - "Was given a null axis! That was probably not intentional, consider this a bug! (Vector = " + vector - + ")"); } + throw new RuntimeException("Was given a null axis! That was probably not intentional, consider this a bug! (Vector = " + vector + ")"); } public static BlockPos convertFloor(Vec3d vec) { @@ -87,7 +84,6 @@ public class RenderResizableCuboid { return VEC_ZERO; } return new Vec3d(face.getXOffset(), face.getYOffset(), face.getZOffset()); - } public static EnumFacing[] getNeighbours(EnumFacing face) { @@ -125,11 +121,8 @@ public class RenderResizableCuboid { return vector.y; } else if (axis == Axis.Z) { return vector.z; - } else { - throw new RuntimeException( - "Was given a null axis! That was probably not intentional, consider this a bug! (Vector = " + vector - + ")"); } + throw new RuntimeException("Was given a null axis! That was probably not intentional, consider this a bug! (Vector = " + vector + ")"); } /** @@ -146,8 +139,7 @@ public class RenderResizableCuboid { renderCube(cuboid, EnumShadeArgument.NONE, null, null, null); } - public void renderCube(Model3D cube, EnumShadeArgument shadeTypes, IBlockLocation formula, - IFacingLocation faceFormula, IBlockAccess world) { + public void renderCube(Model3D cube, EnumShadeArgument shadeTypes, IBlockLocation formula, IFacingLocation faceFormula, IBlockAccess world) { if (faceFormula == null) { faceFormula = DefaultFacingLocation.INSTANCE; } @@ -161,8 +153,7 @@ public class RenderResizableCuboid { Vec3d textureStart = new Vec3d(cube.textureStartX / 16D, cube.textureStartY / 16D, cube.textureStartZ / 16D); Vec3d textureSize = new Vec3d(cube.textureSizeX / 16D, cube.textureSizeY / 16D, cube.textureSizeZ / 16D); - Vec3d textureOffset = new Vec3d(cube.textureOffsetX / 16D, cube.textureOffsetY / 16D, - cube.textureOffsetZ / 16D); + Vec3d textureOffset = new Vec3d(cube.textureOffsetX / 16D, cube.textureOffsetY / 16D, cube.textureOffsetZ / 16D); Vec3d size = new Vec3d(cube.sizeX(), cube.sizeY(), cube.sizeZ()); manager.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); @@ -178,8 +169,7 @@ public class RenderResizableCuboid { for (EnumFacing face : EnumFacing.values()) { if (cube.shouldSideRender(face)) { - renderCuboidFace(wr, face, sprites, flips, textureStart, textureSize, size, textureOffset, shadeTypes, - formula, faceFormula, world); + renderCuboidFace(wr, face, sprites, flips, textureStart, textureSize, size, textureOffset, shadeTypes, formula, faceFormula, world); } } @@ -190,11 +180,8 @@ public class RenderResizableCuboid { GlStateManager.enableFog(); } - private void renderCuboidFace(BufferBuilder wr, EnumFacing face, TextureAtlasSprite[] sprites, int[] flips, - Vec3d textureStart, Vec3d textureSize, - Vec3d size, Vec3d textureOffset, EnumShadeArgument shadeTypes, IBlockLocation locationFormula, - IFacingLocation faceFormula, - IBlockAccess access) { + private void renderCuboidFace(BufferBuilder wr, EnumFacing face, TextureAtlasSprite[] sprites, int[] flips, Vec3d textureStart, Vec3d textureSize, + Vec3d size, Vec3d textureOffset, EnumShadeArgument shadeTypes, IBlockLocation locationFormula, IFacingLocation faceFormula, IBlockAccess access) { int ordinal = face.ordinal(); if (sprites[ordinal] == null) { return; @@ -227,10 +214,8 @@ public class RenderResizableCuboid { } } - private void renderPoint(BufferBuilder wr, EnumFacing face, Axis u, Axis v, double other, RenderInfo ri, - boolean minU, boolean minV, - IBlockLocation locationFormula, IFacingLocation faceFormula, IBlockAccess access, - EnumShadeArgument shadeTypes) { + private void renderPoint(BufferBuilder wr, EnumFacing face, Axis u, Axis v, double other, RenderInfo ri, boolean minU, boolean minV, IBlockLocation locationFormula, + IFacingLocation faceFormula, IBlockAccess access, EnumShadeArgument shadeTypes) { int U_ARRAY = minU ? U_MIN : U_MAX; int V_ARRAY = minV ? V_MIN : V_MAX; @@ -258,9 +243,7 @@ public class RenderResizableCuboid { wr.endVertex(); } - private void applyLocalAO(BufferBuilder wr, EnumFacing face, IBlockLocation locationFormula, IBlockAccess access, - EnumShadeArgument shadeTypes, - Vec3d vertex) { + private void applyLocalAO(BufferBuilder wr, EnumFacing face, IBlockLocation locationFormula, IBlockAccess access, EnumShadeArgument shadeTypes, Vec3d vertex) { // This doesn't work. At all. boolean allAround = false; @@ -326,8 +309,8 @@ public class RenderResizableCuboid { } /** - * Note that this method DOES take into account its position. But not its rotation. (Open an issue on github if you - * need rotation, and a second method will be made that does all the trig required) + * Note that this method DOES take into account its position. But not its rotation. (Open an issue on github if you need rotation, and a second method will be made + * that does all the trig required) */ public void renderCubeStatic(List quads, Model3D cuboid) { TextureAtlasSprite[] sprites = cuboid.textures; @@ -360,8 +343,7 @@ public class RenderResizableCuboid { if (sprites[0] != null) { // Down float[] uv = getUVArray(sprites[0], flips[0], textureStartX, textureEndX, textureStartZ, textureEndZ); - for (RenderInfo ri : getRenderInfos(uv, sizeX, sizeZ, textureSizeX, textureSizeZ, textureOffsetX, - textureOffsetZ)) { + for (RenderInfo ri : getRenderInfos(uv, sizeX, sizeZ, textureSizeX, textureSizeZ, textureOffsetX, textureOffsetZ)) { ri = ri.offset(cuboid, Axis.Y); double[][] arr = new double[4][]; arr[0] = new double[]{ri.xyz[U_MAX], cuboid.posY, ri.xyz[V_MIN], -1, ri.uv[U_MAX], ri.uv[V_MIN], 0}; @@ -376,18 +358,13 @@ public class RenderResizableCuboid { // Up float[] uv = getUVArray(sprites[1], flips[1], textureStartX, textureEndX, textureStartZ, textureEndZ); - for (RenderInfo ri : getRenderInfos(uv, sizeX, sizeZ, textureSizeX, textureSizeZ, textureOffsetX, - textureOffsetZ)) { + for (RenderInfo ri : getRenderInfos(uv, sizeX, sizeZ, textureSizeX, textureSizeZ, textureOffsetX, textureOffsetZ)) { ri = ri.offset(cuboid, Axis.Y); double[][] arr = new double[4][]; - arr[0] = new double[]{ri.xyz[U_MAX], sizeY + cuboid.posY, ri.xyz[V_MIN], -1, ri.uv[U_MAX], ri.uv[V_MIN], - 0}; - arr[1] = new double[]{ri.xyz[U_MAX], sizeY + cuboid.posY, ri.xyz[V_MAX], -1, ri.uv[U_MAX], ri.uv[V_MAX], - 0}; - arr[2] = new double[]{ri.xyz[U_MIN], sizeY + cuboid.posY, ri.xyz[V_MAX], -1, ri.uv[U_MIN], ri.uv[V_MAX], - 0}; - arr[3] = new double[]{ri.xyz[U_MIN], sizeY + cuboid.posY, ri.xyz[V_MIN], -1, ri.uv[U_MIN], ri.uv[V_MIN], - 0}; + arr[0] = new double[]{ri.xyz[U_MAX], sizeY + cuboid.posY, ri.xyz[V_MIN], -1, ri.uv[U_MAX], ri.uv[V_MIN], 0}; + arr[1] = new double[]{ri.xyz[U_MAX], sizeY + cuboid.posY, ri.xyz[V_MAX], -1, ri.uv[U_MAX], ri.uv[V_MAX], 0}; + arr[2] = new double[]{ri.xyz[U_MIN], sizeY + cuboid.posY, ri.xyz[V_MAX], -1, ri.uv[U_MIN], ri.uv[V_MAX], 0}; + arr[3] = new double[]{ri.xyz[U_MIN], sizeY + cuboid.posY, ri.xyz[V_MIN], -1, ri.uv[U_MIN], ri.uv[V_MIN], 0}; convertToDoubleQuads(quads, arr, EnumFacing.UP, sprites[1]); } } @@ -396,8 +373,7 @@ public class RenderResizableCuboid { // North (-Z) float[] uv = getUVArray(sprites[2], flips[2], textureStartX, textureEndX, textureStartY, textureEndY); - for (RenderInfo ri : getRenderInfos(uv, sizeX, sizeY, textureSizeX, textureSizeY, textureOffsetX, - textureOffsetY)) { + for (RenderInfo ri : getRenderInfos(uv, sizeX, sizeY, textureSizeX, textureSizeY, textureOffsetX, textureOffsetY)) { ri = ri.offset(cuboid, Axis.Z); double[][] arr = new double[4][]; arr[0] = new double[]{ri.xyz[U_MAX], ri.xyz[V_MIN], cuboid.posZ, -1, ri.uv[U_MAX], ri.uv[V_MIN], 0}; @@ -412,18 +388,13 @@ public class RenderResizableCuboid { // South (+Z) float[] uv = getUVArray(sprites[3], flips[3], textureStartX, textureEndX, textureStartY, textureEndY); - for (RenderInfo ri : getRenderInfos(uv, sizeX, sizeY, textureSizeX, textureSizeY, textureOffsetX, - textureOffsetY)) { + for (RenderInfo ri : getRenderInfos(uv, sizeX, sizeY, textureSizeX, textureSizeY, textureOffsetX, textureOffsetY)) { ri = ri.offset(cuboid, Axis.Z); double[][] arr = new double[4][]; - arr[0] = new double[]{ri.xyz[U_MAX], ri.xyz[V_MIN], cuboid.posZ + sizeZ, -1, ri.uv[U_MAX], ri.uv[V_MIN], - 0}; - arr[1] = new double[]{ri.xyz[U_MAX], ri.xyz[V_MAX], cuboid.posZ + sizeZ, -1, ri.uv[U_MAX], ri.uv[V_MAX], - 0}; - arr[2] = new double[]{ri.xyz[U_MIN], ri.xyz[V_MAX], cuboid.posZ + sizeZ, -1, ri.uv[U_MIN], ri.uv[V_MAX], - 0}; - arr[3] = new double[]{ri.xyz[U_MIN], ri.xyz[V_MIN], cuboid.posZ + sizeZ, -1, ri.uv[U_MIN], ri.uv[V_MIN], - 0}; + arr[0] = new double[]{ri.xyz[U_MAX], ri.xyz[V_MIN], cuboid.posZ + sizeZ, -1, ri.uv[U_MAX], ri.uv[V_MIN], 0}; + arr[1] = new double[]{ri.xyz[U_MAX], ri.xyz[V_MAX], cuboid.posZ + sizeZ, -1, ri.uv[U_MAX], ri.uv[V_MAX], 0}; + arr[2] = new double[]{ri.xyz[U_MIN], ri.xyz[V_MAX], cuboid.posZ + sizeZ, -1, ri.uv[U_MIN], ri.uv[V_MAX], 0}; + arr[3] = new double[]{ri.xyz[U_MIN], ri.xyz[V_MIN], cuboid.posZ + sizeZ, -1, ri.uv[U_MIN], ri.uv[V_MIN], 0}; convertToDoubleQuads(quads, arr, EnumFacing.SOUTH, sprites[3]); } } @@ -432,8 +403,7 @@ public class RenderResizableCuboid { // West (-X) float[] uv = getUVArray(sprites[4], flips[4], textureStartZ, textureEndZ, textureStartY, textureEndY); - for (RenderInfo ri : getRenderInfos(uv, sizeZ, sizeY, textureSizeZ, textureSizeY, textureOffsetZ, - textureOffsetY)) { + for (RenderInfo ri : getRenderInfos(uv, sizeZ, sizeY, textureSizeZ, textureSizeY, textureOffsetZ, textureOffsetY)) { ri = ri.offset(cuboid, Axis.X); double[][] arr = new double[4][]; arr[0] = new double[]{cuboid.posX, ri.xyz[V_MIN], ri.xyz[U_MAX], -1, ri.uv[U_MAX], ri.uv[V_MIN], 0}; @@ -448,25 +418,19 @@ public class RenderResizableCuboid { // East (+X) float[] uv = getUVArray(sprites[5], flips[5], textureStartZ, textureEndZ, textureStartY, textureEndY); - for (RenderInfo ri : getRenderInfos(uv, sizeZ, sizeY, textureSizeZ, textureSizeY, textureOffsetZ, - textureOffsetY)) { + for (RenderInfo ri : getRenderInfos(uv, sizeZ, sizeY, textureSizeZ, textureSizeY, textureOffsetZ, textureOffsetY)) { ri = ri.offset(cuboid, Axis.X); double[][] arr = new double[4][]; - arr[0] = new double[]{cuboid.posX + sizeX, ri.xyz[V_MIN], ri.xyz[U_MAX], -1, ri.uv[U_MAX], ri.uv[V_MIN], - 0}; - arr[1] = new double[]{cuboid.posX + sizeX, ri.xyz[V_MAX], ri.xyz[U_MAX], -1, ri.uv[U_MAX], ri.uv[V_MAX], - 0}; - arr[2] = new double[]{cuboid.posX + sizeX, ri.xyz[V_MAX], ri.xyz[U_MIN], -1, ri.uv[U_MIN], ri.uv[V_MAX], - 0}; - arr[3] = new double[]{cuboid.posX + sizeX, ri.xyz[V_MIN], ri.xyz[U_MIN], -1, ri.uv[U_MIN], ri.uv[V_MIN], - 0}; + arr[0] = new double[]{cuboid.posX + sizeX, ri.xyz[V_MIN], ri.xyz[U_MAX], -1, ri.uv[U_MAX], ri.uv[V_MIN], 0}; + arr[1] = new double[]{cuboid.posX + sizeX, ri.xyz[V_MAX], ri.xyz[U_MAX], -1, ri.uv[U_MAX], ri.uv[V_MAX], 0}; + arr[2] = new double[]{cuboid.posX + sizeX, ri.xyz[V_MAX], ri.xyz[U_MIN], -1, ri.uv[U_MIN], ri.uv[V_MAX], 0}; + arr[3] = new double[]{cuboid.posX + sizeX, ri.xyz[V_MIN], ri.xyz[U_MIN], -1, ri.uv[U_MIN], ri.uv[V_MIN], 0}; convertToDoubleQuads(quads, arr, EnumFacing.EAST, sprites[5]); } } } - private void convertToDoubleQuads(List quads, double[][] points, EnumFacing face, - TextureAtlasSprite sprite) { + private void convertToDoubleQuads(List quads, double[][] points, EnumFacing face, TextureAtlasSprite sprite) { BakedQuad quad = convertToQuad(points, face, sprite); quads.add(quad); @@ -496,8 +460,7 @@ public class RenderResizableCuboid { /** * Returns an array containing [uMin, uMax, vMin, vMax]. start* and end* must be doubles between 0 and 1 */ - private float[] getUVArray(TextureAtlasSprite sprite, int flips, double startU, double endU, double startV, - double endV) { + private float[] getUVArray(TextureAtlasSprite sprite, int flips, double startU, double endU, double startV, double endV) { float minU = sprite.getInterpolatedU(startU * 16); float maxU = sprite.getInterpolatedU(endU * 16); float minV = sprite.getInterpolatedV(startV * 16); @@ -558,9 +521,8 @@ public class RenderResizableCuboid { * * @param rotation TODO */ - private List getRenderInfos(float[] uv, double sizeU, double sizeV, double textureSizeU, - double textureSizeV, double textureOffsetU, double textureOffsetV) { - List infos = Lists.newArrayList(); + private List getRenderInfos(float[] uv, double sizeU, double sizeV, double textureSizeU, double textureSizeV, double textureOffsetU, double textureOffsetV) { + List infos = new ArrayList<>(); boolean firstU = true; for (double u = 0; u < sizeU; u += textureSizeU) { float[] uvCu = Arrays.copyOf(uv, 4); @@ -580,8 +542,7 @@ public class RenderResizableCuboid { if (u + addU > sizeU) { addU = sizeU - u; if (firstU && textureOffsetU != 0) { - uvCu[U_MAX] = - uvCu[U_MIN] + (uvCu[U_MAX] - uvCu[U_MIN]) * (float) (addU / (textureSizeU - textureOffsetU)); + uvCu[U_MAX] = uvCu[U_MIN] + (uvCu[U_MAX] - uvCu[U_MIN]) * (float) (addU / (textureSizeU - textureOffsetU)); } else { uvCu[U_MAX] = uvCu[U_MIN] + (uvCu[U_MAX] - uvCu[U_MIN]) * (float) (addU / textureSizeU); } @@ -603,8 +564,7 @@ public class RenderResizableCuboid { if (v + addV > sizeV) { addV = sizeV - v; if (firstV && textureOffsetV != 0) { - uvCv[V_MAX] = uvCv[V_MIN] + (uvCv[V_MAX] - uvCv[V_MIN]) * (float) (addV / (textureSizeV - - textureOffsetV)); + uvCv[V_MAX] = uvCv[V_MIN] + (uvCv[V_MAX] - uvCv[V_MIN]) * (float) (addV / (textureSizeV - textureOffsetV)); } else { uvCv[V_MAX] = uvCv[V_MIN] + (uvCv[V_MAX] - uvCv[V_MIN]) * (float) (addV / textureSizeV); } @@ -704,20 +664,14 @@ public class RenderResizableCuboid { public RenderInfo offset(Model3D ent, Axis axis) { switch (axis) { - case X: { - return new RenderInfo(uv, - new double[]{xyz[0] + ent.posZ, xyz[1] + ent.posZ, xyz[2] + ent.posY, xyz[3] + ent.posY}); - } - case Y: { - return new RenderInfo(uv, - new double[]{xyz[0] + ent.posX, xyz[1] + ent.posX, xyz[2] + ent.posZ, xyz[3] + ent.posZ}); - } - case Z: { - return new RenderInfo(uv, - new double[]{xyz[0] + ent.posX, xyz[1] + ent.posX, xyz[2] + ent.posY, xyz[3] + ent.posY}); - } + case X: + return new RenderInfo(uv, new double[]{xyz[0] + ent.posZ, xyz[1] + ent.posZ, xyz[2] + ent.posY, xyz[3] + ent.posY}); + case Y: + return new RenderInfo(uv, new double[]{xyz[0] + ent.posX, xyz[1] + ent.posX, xyz[2] + ent.posZ, xyz[3] + ent.posZ}); + case Z: + return new RenderInfo(uv, new double[]{xyz[0] + ent.posX, xyz[1] + ent.posX, xyz[2] + ent.posY, xyz[3] + ent.posY}); } return new RenderInfo(uv, xyz); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/RenderTickHandler.java b/src/main/java/mekanism/client/render/RenderTickHandler.java index fdd7c0e3f..e68c73a33 100644 --- a/src/main/java/mekanism/client/render/RenderTickHandler.java +++ b/src/main/java/mekanism/client/render/RenderTickHandler.java @@ -47,21 +47,20 @@ public class RenderTickHandler { public void tickEnd(RenderTickEvent event) { if (event.phase == Phase.END) { if (mc.player != null && mc.world != null && !mc.isGamePaused()) { - EntityPlayer player = mc.player; - World world = mc.player.world; FontRenderer font = mc.fontRenderer; - RayTraceResult pos = player.rayTrace(40.0D, 1.0F); - if (font == null) { return; } + EntityPlayer player = mc.player; + World world = mc.player.world; + RayTraceResult pos = player.rayTrace(40.0D, 1.0F); if (pos != null) { Coord4D obj = new Coord4D(pos.getBlockPos(), world); Block block = obj.getBlock(world); if (block != null && MekanismAPI.debug && mc.currentScreen == null - && !mc.gameSettings.showDebugInfo) { + && !mc.gameSettings.showDebugInfo) { String tileDisplay = ""; if (obj.getTileEntity(world) != null) { @@ -79,8 +78,7 @@ public class RenderTickHandler { } //todo use vanilla status bar text? - if (modeSwitchTimer > 1 && mc.currentScreen == null && player.getHeldItemMainhand() - .getItem() instanceof ItemConfigurator) { + if (modeSwitchTimer > 1 && mc.currentScreen == null && player.getHeldItemMainhand().getItem() instanceof ItemConfigurator) { ItemStack stack = player.getHeldItemMainhand(); ScaledResolution scaledresolution = new ScaledResolution(mc); ConfiguratorMode mode = ((ItemConfigurator) stack.getItem()).getState(stack); @@ -98,8 +96,7 @@ public class RenderTickHandler { ClientTickHandler.wheelStatus = 0; } - if (mc.currentScreen == null && !mc.gameSettings.hideGUI && !player.isSpectator() && !player - .getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty()) { + if (mc.currentScreen == null && !mc.gameSettings.hideGUI && !player.isSpectator() && !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty()) { ItemStack stack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); ScaledResolution scaledresolution = new ScaledResolution(mc); @@ -109,14 +106,11 @@ public class RenderTickHandler { if (stack.getItem() instanceof ItemJetpack) { ItemJetpack jetpack = (ItemJetpack) stack.getItem(); - - drawString(scaledresolution, "Mode: " + jetpack.getMode(stack).getName(), alignLeft,y - 20, 0xc8c8c8); + drawString(scaledresolution, "Mode: " + jetpack.getMode(stack).getName(), alignLeft, y - 20, 0xc8c8c8); drawString(scaledresolution, "Hydrogen: " + jetpack.getStored(stack), alignLeft, y - 11, 0xc8c8c8); } else if (stack.getItem() instanceof ItemScubaTank) { ItemScubaTank scubaTank = (ItemScubaTank) stack.getItem(); - String state = (scubaTank.getFlowing(stack) ? EnumColor.DARK_GREEN + "On" - : EnumColor.DARK_RED + "Off"); - + String state = scubaTank.getFlowing(stack) ? EnumColor.DARK_GREEN + "On" : EnumColor.DARK_RED + "Off"; drawString(scaledresolution, "Mode: " + state, alignLeft, y - 20, 0xc8c8c8); drawString(scaledresolution, "Oxygen: " + scubaTank.getStored(stack), alignLeft, y - 11, 0xc8c8c8); } @@ -135,12 +129,9 @@ public class RenderTickHandler { float random = (rand.nextFloat() - 0.5F) * 0.1F; - Pos3D vLeft = new Pos3D(-0.43, -0.55, -0.54).rotatePitch(p.isSneaking() ? 20 : 0) - .rotateYaw(p.renderYawOffset); - Pos3D vRight = new Pos3D(0.43, -0.55, -0.54).rotatePitch(p.isSneaking() ? 20 : 0) - .rotateYaw(p.renderYawOffset); - Pos3D vCenter = new Pos3D((rand.nextFloat() - 0.5F) * 0.4F, -0.86, -0.30) - .rotatePitch(p.isSneaking() ? 25 : 0).rotateYaw(p.renderYawOffset); + Pos3D vLeft = new Pos3D(-0.43, -0.55, -0.54).rotatePitch(p.isSneaking() ? 20 : 0).rotateYaw(p.renderYawOffset); + Pos3D vRight = new Pos3D(0.43, -0.55, -0.54).rotatePitch(p.isSneaking() ? 20 : 0).rotateYaw(p.renderYawOffset); + Pos3D vCenter = new Pos3D((rand.nextFloat() - 0.5F) * 0.4F, -0.86, -0.30).rotatePitch(p.isSneaking() ? 25 : 0).rotateYaw(p.renderYawOffset); Pos3D rLeft = vLeft.scale(random); Pos3D rRight = vRight.scale(random); @@ -154,18 +145,15 @@ public class RenderTickHandler { Pos3D v = playerPos.translate(vLeft).translate(new Pos3D(p.motionX, p.motionY, p.motionZ)); spawnAndSetParticle(EnumParticleTypes.FLAME, world, v.x, v.y, v.z, mLeft.x, mLeft.y, mLeft.z); - spawnAndSetParticle(EnumParticleTypes.SMOKE_NORMAL, world, v.x, v.y, v.z, mLeft.x, mLeft.y, - mLeft.z); + spawnAndSetParticle(EnumParticleTypes.SMOKE_NORMAL, world, v.x, v.y, v.z, mLeft.x, mLeft.y, mLeft.z); v = playerPos.translate(vRight).translate(new Pos3D(p.motionX, p.motionY, p.motionZ)); spawnAndSetParticle(EnumParticleTypes.FLAME, world, v.x, v.y, v.z, mRight.x, mRight.y, mRight.z); - spawnAndSetParticle(EnumParticleTypes.SMOKE_NORMAL, world, v.x, v.y, v.z, mRight.x, mRight.y, - mRight.z); + spawnAndSetParticle(EnumParticleTypes.SMOKE_NORMAL, world, v.x, v.y, v.z, mRight.x, mRight.y, mRight.z); v = playerPos.translate(vCenter).translate(new Pos3D(p.motionX, p.motionY, p.motionZ)); spawnAndSetParticle(EnumParticleTypes.FLAME, world, v.x, v.y, v.z, mCenter.x, mCenter.y, mCenter.z); - spawnAndSetParticle(EnumParticleTypes.SMOKE_NORMAL, world, v.x, v.y, v.z, mCenter.x, mCenter.y, - mCenter.z); + spawnAndSetParticle(EnumParticleTypes.SMOKE_NORMAL, world, v.x, v.y, v.z, mCenter.x, mCenter.y, mCenter.z); } // Traverse a copy of gasmask state and do animations @@ -173,7 +161,6 @@ public class RenderTickHandler { if (world.getWorldTime() % 4 == 0) { for (UUID uuid : Mekanism.playerState.getActiveGasmasks()) { EntityPlayer p = mc.world.getPlayerEntityByUUID(uuid); - if (p == null || !p.isInWater()) { continue; } @@ -187,8 +174,7 @@ public class RenderTickHandler { Pos3D motion = vec.scale(0.2).translate(new Pos3D(p.motionX, p.motionY, p.motionZ)); Pos3D v = playerPos.translate(vec); - spawnAndSetParticle(EnumParticleTypes.WATER_BUBBLE, world, v.x, v.y, v.z, motion.x, - motion.y + 0.2, motion.z); + spawnAndSetParticle(EnumParticleTypes.WATER_BUBBLE, world, v.x, v.y, v.z, motion.x, motion.y + 0.2, motion.z); } } @@ -196,49 +182,35 @@ public class RenderTickHandler { // TODO: This means we're making a full copy of the state per render....might need to revisit if (world.getWorldTime() % 4 == 0) { for (EntityPlayer p : world.playerEntities) { - if (!Mekanism.playerState.isFlamethrowerOn(p) && !p.isSwingInProgress && !p.inventory - .getCurrentItem().isEmpty() && p.inventory.getCurrentItem() - .getItem() instanceof ItemFlamethrower) { - if (((ItemFlamethrower) p.inventory.getCurrentItem().getItem()) - .getGas(p.inventory.getCurrentItem()) != null) { + if (!Mekanism.playerState.isFlamethrowerOn(p) && !p.isSwingInProgress) { + ItemStack currentItem = p.inventory.getCurrentItem(); + if (!currentItem.isEmpty() && currentItem.getItem() instanceof ItemFlamethrower && ((ItemFlamethrower) currentItem.getItem()).getGas(currentItem) != null) { Pos3D playerPos = new Pos3D(p); Pos3D flameVec; - double flameXCoord = 0; double flameYCoord = 1.5; double flameZCoord = 0; - Pos3D flameMotion = new Pos3D(p.motionX, p.onGround ? 0 : p.motionY, p.motionZ); - if (player == p && mc.gameSettings.thirdPersonView == 0) { - flameVec = new Pos3D(1, 1, 1).multiply(p.getLook(1)).rotateYaw(5) - .translate(flameXCoord, flameYCoord + 0.1, flameZCoord); + flameVec = new Pos3D(1, 1, 1).multiply(p.getLook(1)).rotateYaw(5).translate(flameXCoord, flameYCoord + 0.1, flameZCoord); } else { flameXCoord += 0.25F; flameXCoord -= 0.45F; flameZCoord += 0.15F; - if (p.isSneaking()) { flameYCoord -= 0.55F; flameZCoord -= 0.15F; } - if (player == p) { flameYCoord -= 0.5F; } else { flameYCoord -= 0.5F; } - flameZCoord += 1.05F; - - flameVec = new Pos3D(flameXCoord, flameYCoord, flameZCoord) - .rotateYaw(p.renderYawOffset); + flameVec = new Pos3D(flameXCoord, flameYCoord, flameZCoord).rotateYaw(p.renderYawOffset); } - Pos3D mergedVec = playerPos.translate(flameVec); - - spawnAndSetParticle(EnumParticleTypes.FLAME, world, mergedVec.x, mergedVec.y, - mergedVec.z, flameMotion.x, flameMotion.y, flameMotion.z); + spawnAndSetParticle(EnumParticleTypes.FLAME, world, mergedVec.x, mergedVec.y, mergedVec.z, flameMotion.x, flameMotion.y, flameMotion.z); } } } @@ -247,10 +219,8 @@ public class RenderTickHandler { } } - public void spawnAndSetParticle(EnumParticleTypes s, World world, double x, double y, double z, double velX, - double velY, double velZ) { + public void spawnAndSetParticle(EnumParticleTypes s, World world, double x, double y, double z, double velX, double velY, double velZ) { Particle fx = null; - if (s.equals(EnumParticleTypes.FLAME)) { fx = new EntityJetpackFlameFX(world, x, y, z, velX, velY, velZ); } else if (s.equals(EnumParticleTypes.SMOKE_NORMAL)) { @@ -258,13 +228,11 @@ public class RenderTickHandler { } else if (s.equals(EnumParticleTypes.WATER_BUBBLE)) { fx = new EntityScubaBubbleFX(world, x, y, z, velX, velY, velZ); } - mc.effectRenderer.addEffect(fx); } private void drawString(ScaledResolution res, String s, boolean leftSide, int y, int color) { FontRenderer font = mc.fontRenderer; - // Note that we always offset by 2 pixels when left or right aligned if (leftSide) { font.drawStringWithShadow(s, 2, y, color); @@ -273,4 +241,4 @@ public class RenderTickHandler { font.drawStringWithShadow(s, res.getScaledWidth() - width, y, color); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/entity/RenderBalloon.java b/src/main/java/mekanism/client/render/entity/RenderBalloon.java index 17d066825..b8d53a585 100644 --- a/src/main/java/mekanism/client/render/entity/RenderBalloon.java +++ b/src/main/java/mekanism/client/render/entity/RenderBalloon.java @@ -37,12 +37,9 @@ public class RenderBalloon extends Render { double renderPosZ = z - (balloon.lastTickPosZ + (balloon.posZ - balloon.lastTickPosZ) * partialTick); 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 = 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 += renderPosX; y += renderPosY; @@ -58,11 +55,8 @@ public class RenderBalloon extends Render { GlStateManager.pushMatrix(); GL11.glTranslated(x, y, z); GlStateManager.rotate(180, 1, 0, 0); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Balloon.png")); - model.render(0.0625F, color); - GlStateManager.popMatrix(); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/entity/RenderFlame.java b/src/main/java/mekanism/client/render/entity/RenderFlame.java index d4038062e..8344262a6 100644 --- a/src/main/java/mekanism/client/render/entity/RenderFlame.java +++ b/src/main/java/mekanism/client/render/entity/RenderFlame.java @@ -39,12 +39,8 @@ public class RenderFlame extends Render { bindTexture(getEntityTexture(entity)); GlStateManager.translate((float) x, (float) y, (float) z); - GlStateManager - .rotate((entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTick) - 90F, - 0.0F, 1.0F, 0.0F); - GlStateManager - .rotate(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTick, 0.0F, - 0.0F, 1.0F); + GlStateManager.rotate((entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTick) - 90F, 0.0F, 1.0F, 0.0F); + GlStateManager.rotate(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTick, 0.0F, 0.0F, 1.0F); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder worldrenderer = tessellator.getBuffer(); diff --git a/src/main/java/mekanism/client/render/entity/RenderObsidianTNTPrimed.java b/src/main/java/mekanism/client/render/entity/RenderObsidianTNTPrimed.java index eff99cc38..b1e0a3be0 100644 --- a/src/main/java/mekanism/client/render/entity/RenderObsidianTNTPrimed.java +++ b/src/main/java/mekanism/client/render/entity/RenderObsidianTNTPrimed.java @@ -25,8 +25,7 @@ public class RenderObsidianTNTPrimed extends Render { } @Override - public void doRender(@Nonnull EntityObsidianTNT entityobsidiantnt, double x, double y, double z, float entityYaw, - float partialTicks) { + public void doRender(@Nonnull EntityObsidianTNT entityobsidiantnt, double x, double y, double z, float entityYaw, float partialTicks) { BlockRendererDispatcher renderer = Minecraft.getMinecraft().getBlockRendererDispatcher(); GlStateManager.pushMatrix(); GlStateManager.translate((float) x, (float) y + 0.5F, (float) z); @@ -70,4 +69,4 @@ public class RenderObsidianTNTPrimed extends Render { protected ResourceLocation getEntityTexture(@Nonnull EntityObsidianTNT entity) { return TextureMap.LOCATION_BLOCKS_TEXTURE; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/entity/RenderRobit.java b/src/main/java/mekanism/client/render/entity/RenderRobit.java index 9e2bf489a..7afef1372 100644 --- a/src/main/java/mekanism/client/render/entity/RenderRobit.java +++ b/src/main/java/mekanism/client/render/entity/RenderRobit.java @@ -25,7 +25,6 @@ public class RenderRobit extends RenderLiving { robit.texTick = !robit.texTick; } } - return MekanismUtils.getResource(ResourceType.RENDER, "Robit" + (robit.texTick ? "2" : "") + ".png"); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/item/ItemLayerWrapper.java b/src/main/java/mekanism/client/render/item/ItemLayerWrapper.java index a546ae3d9..f627809c0 100644 --- a/src/main/java/mekanism/client/render/item/ItemLayerWrapper.java +++ b/src/main/java/mekanism/client/render/item/ItemLayerWrapper.java @@ -9,6 +9,7 @@ import javax.vecmath.Vector3f; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.IBakedModel; +import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; import net.minecraft.client.renderer.block.model.ItemOverrideList; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -61,11 +62,12 @@ public class ItemLayerWrapper implements IBakedModel { return internal.getParticleTexture(); } - //TODO: Is this needed - /*@Nonnull + @Nonnull + @Deprecated + @Override public ItemCameraTransforms getItemCameraTransforms() { return internal.getItemCameraTransforms(); - }*/ + } @Nonnull @Override @@ -105,5 +107,4 @@ public class ItemLayerWrapper implements IBakedModel { return new TRSRTransformation(new Vector3f(tx / 16, ty / 16, tz / 16), TRSRTransformation.quatFromXYZDegrees(new Vector3f(ax, ay, az)), new Vector3f(s, s, s), null); } - } \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/item/RenderEnergyCubeItem.java b/src/main/java/mekanism/client/render/item/RenderEnergyCubeItem.java index d9ba00586..0b8d74aa7 100644 --- a/src/main/java/mekanism/client/render/item/RenderEnergyCubeItem.java +++ b/src/main/java/mekanism/client/render/item/RenderEnergyCubeItem.java @@ -7,8 +7,8 @@ import mekanism.client.model.ModelEnergyCube.ModelEnergyCore; import mekanism.client.render.MekanismRenderer; import mekanism.client.render.tileentity.RenderEnergyCube; import mekanism.common.SideData.IOState; -import mekanism.common.tier.EnergyCubeTier; import mekanism.common.base.ITierItem; +import mekanism.common.tier.EnergyCubeTier; import mekanism.common.util.ItemDataUtils; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; @@ -42,8 +42,7 @@ public class RenderEnergyCubeItem extends MekanismItemStackRenderer { for (EnumFacing side : EnumFacing.VALUES) { MekanismRenderer.bindTexture(RenderEnergyCube.baseTexture); - energyCube.renderSide(0.0625F, side, side == EnumFacing.NORTH ? IOState.OUTPUT : IOState.INPUT, tier, - Minecraft.getMinecraft().renderEngine); + energyCube.renderSide(0.0625F, side, side == EnumFacing.NORTH ? IOState.OUTPUT : IOState.INPUT, tier, Minecraft.getMinecraft().renderEngine); } MekanismRenderer.blendOff(); @@ -62,8 +61,7 @@ public class RenderEnergyCubeItem extends MekanismItemStackRenderer { GlStateManager.pushMatrix(); GlStateManager.scale(0.4F, 0.4F, 0.4F); - GL11.glColor4f((float) c[0] / 255F, (float) c[1] / 255F, (float) c[2] / 255F, - (float) (energy / tier.getMaxEnergy())); + GL11.glColor4f((float) c[0] / 255F, (float) c[1] / 255F, (float) c[2] / 255F, (float) (energy / tier.getMaxEnergy())); GlStateManager.translate(0, (float) Math.sin(Math.toRadians(MekanismClient.ticksPassed * 3)) / 7, 0); GlStateManager.rotate(MekanismClient.ticksPassed * 4, 0, 1, 0); GlStateManager.rotate(36F + MekanismClient.ticksPassed * 4, 0, 1, 1); diff --git a/src/main/java/mekanism/client/render/item/basicblock/RenderBasicBlockItem.java b/src/main/java/mekanism/client/render/item/basicblock/RenderBasicBlockItem.java index 01bf9ace2..64fd1b110 100644 --- a/src/main/java/mekanism/client/render/item/basicblock/RenderBasicBlockItem.java +++ b/src/main/java/mekanism/client/render/item/basicblock/RenderBasicBlockItem.java @@ -25,7 +25,6 @@ public class RenderBasicBlockItem extends SubTypeItemRenderer { @Override protected void renderBlockSpecific(@Nonnull ItemStack stack, TransformType transformType) { BasicBlockType basicType = BasicBlockType.get(stack); - if (basicType != null) { if (basicType == BasicBlockType.BIN) { RenderBinItem.renderStack(stack, transformType); @@ -37,7 +36,6 @@ public class RenderBasicBlockItem extends SubTypeItemRenderer { @Override protected void renderItemSpecific(@Nonnull ItemStack stack, TransformType transformType) { - } @Nullable diff --git a/src/main/java/mekanism/client/render/item/basicblock/RenderSecurityDeskItem.java b/src/main/java/mekanism/client/render/item/basicblock/RenderSecurityDeskItem.java index 0079f7efa..229ce999f 100644 --- a/src/main/java/mekanism/client/render/item/basicblock/RenderSecurityDeskItem.java +++ b/src/main/java/mekanism/client/render/item/basicblock/RenderSecurityDeskItem.java @@ -14,6 +14,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderSecurityDeskItem { + private static ModelSecurityDesk securityDesk = new ModelSecurityDesk(); public static void renderStack(@Nonnull ItemStack stack, TransformType transformType) { diff --git a/src/main/java/mekanism/client/render/item/gear/RenderAtomicDisassembler.java b/src/main/java/mekanism/client/render/item/gear/RenderAtomicDisassembler.java index b406a6d62..17c7011e2 100644 --- a/src/main/java/mekanism/client/render/item/gear/RenderAtomicDisassembler.java +++ b/src/main/java/mekanism/client/render/item/gear/RenderAtomicDisassembler.java @@ -29,8 +29,7 @@ public class RenderAtomicDisassembler extends MekanismItemStackRenderer { GlStateManager.scale(1.4F, 1.4F, 1.4F); GlStateManager.rotate(180, 0.0F, 0.0F, 1.0F); - if (transformType == TransformType.THIRD_PERSON_RIGHT_HAND - || transformType == TransformType.THIRD_PERSON_LEFT_HAND) { + if (transformType == TransformType.THIRD_PERSON_RIGHT_HAND || transformType == TransformType.THIRD_PERSON_LEFT_HAND) { if (transformType == TransformType.THIRD_PERSON_LEFT_HAND) { GlStateManager.rotate(-90, 0.0F, 1.0F, 0.0F); } @@ -48,7 +47,6 @@ public class RenderAtomicDisassembler extends MekanismItemStackRenderer { if (transformType == TransformType.FIRST_PERSON_LEFT_HAND) { GlStateManager.rotate(90, 0.0F, 1.0F, 0.0F); } - GlStateManager.rotate(45, 0.0F, 1.0F, 0.0F); GlStateManager.translate(0.0F, -0.7F, 0.0F); } diff --git a/src/main/java/mekanism/client/render/item/gear/RenderFlameThrower.java b/src/main/java/mekanism/client/render/item/gear/RenderFlameThrower.java index 18b28afe4..32090c35a 100644 --- a/src/main/java/mekanism/client/render/item/gear/RenderFlameThrower.java +++ b/src/main/java/mekanism/client/render/item/gear/RenderFlameThrower.java @@ -33,10 +33,8 @@ public class RenderFlameThrower extends MekanismItemStackRenderer { GlStateManager.rotate(135, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(-20, 0.0F, 0.0F, 1.0F); - if (transformType == TransformType.FIRST_PERSON_RIGHT_HAND - || transformType == TransformType.THIRD_PERSON_RIGHT_HAND - || transformType == TransformType.FIRST_PERSON_LEFT_HAND - || transformType == TransformType.THIRD_PERSON_LEFT_HAND) { + if (transformType == TransformType.FIRST_PERSON_RIGHT_HAND || transformType == TransformType.THIRD_PERSON_RIGHT_HAND + || transformType == TransformType.FIRST_PERSON_LEFT_HAND || transformType == TransformType.THIRD_PERSON_LEFT_HAND) { if (transformType == TransformType.FIRST_PERSON_RIGHT_HAND) { GlStateManager.rotate(55, 0.0F, 1.0F, 0.0F); } else if (transformType == TransformType.FIRST_PERSON_LEFT_HAND) { @@ -45,11 +43,9 @@ public class RenderFlameThrower extends MekanismItemStackRenderer { } else if (transformType == TransformType.THIRD_PERSON_RIGHT_HAND) { GlStateManager.translate(0.0F, 0.7F, 0.0F); GlStateManager.rotate(75, 0.0F, 1.0F, 0.0F); - } else //if(type == TransformType.THIRD_PERSON_LEFT_HAND) - { + } else {//if(type == TransformType.THIRD_PERSON_LEFT_HAND) GlStateManager.translate(-0.5F, 0.7F, 0.0F); } - GlStateManager.scale(2.5F, 2.5F, 2.5F); GlStateManager.translate(0.0F, -1.0F, -0.5F); } else if (transformType == TransformType.GUI) { diff --git a/src/main/java/mekanism/client/render/item/machine/RenderChemicalDissolutionChamberItem.java b/src/main/java/mekanism/client/render/item/machine/RenderChemicalDissolutionChamberItem.java index bc6b67741..4d301c2f7 100644 --- a/src/main/java/mekanism/client/render/item/machine/RenderChemicalDissolutionChamberItem.java +++ b/src/main/java/mekanism/client/render/item/machine/RenderChemicalDissolutionChamberItem.java @@ -19,8 +19,7 @@ public class RenderChemicalDissolutionChamberItem { public static void renderStack(@Nonnull ItemStack stack, TransformType transformType) { GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F); GlStateManager.translate(0.05F, -1.001F, 0.05F); - MekanismRenderer - .bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalDissolutionChamber.png")); + MekanismRenderer.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalDissolutionChamber.png")); chemicalDissolutionChamber.render(0.0625F); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/item/machine/RenderDigitalMinerItem.java b/src/main/java/mekanism/client/render/item/machine/RenderDigitalMinerItem.java index 78fae8707..5bd0169d9 100644 --- a/src/main/java/mekanism/client/render/item/machine/RenderDigitalMinerItem.java +++ b/src/main/java/mekanism/client/render/item/machine/RenderDigitalMinerItem.java @@ -29,8 +29,7 @@ public class RenderDigitalMinerItem { } GL11.glTranslatef(0.35F, 0.1F, 0.0F); MekanismRenderer.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "DigitalMiner.png")); - digitalMiner.render(0.022F, ItemDataUtils.getDouble(stack, "energyStored") > 0, - Minecraft.getMinecraft().renderEngine, true); + digitalMiner.render(0.022F, ItemDataUtils.getDouble(stack, "energyStored") > 0, Minecraft.getMinecraft().renderEngine, true); GlStateManager.popMatrix(); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/item/machine/RenderFluidTankItem.java b/src/main/java/mekanism/client/render/item/machine/RenderFluidTankItem.java index 252fa28d1..d79ddd5b3 100644 --- a/src/main/java/mekanism/client/render/item/machine/RenderFluidTankItem.java +++ b/src/main/java/mekanism/client/render/item/machine/RenderFluidTankItem.java @@ -7,8 +7,8 @@ import mekanism.client.render.MekanismRenderer; import mekanism.client.render.MekanismRenderer.DisplayInteger; import mekanism.client.render.MekanismRenderer.FluidType; import mekanism.client.render.MekanismRenderer.Model3D; -import mekanism.common.tier.FluidTankTier; import mekanism.common.item.ItemBlockMachine; +import mekanism.common.tier.FluidTankTier; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.GlStateManager; @@ -31,9 +31,7 @@ public class RenderFluidTankItem { public static void renderStack(@Nonnull ItemStack stack, TransformType transformType) { ItemBlockMachine itemMachine = (ItemBlockMachine) stack.getItem(); - float fluidScale = - (float) (itemMachine.getFluidStack(stack) != null ? itemMachine.getFluidStack(stack).amount : 0) - / itemMachine.getCapacity(stack); + float fluidScale = (float) (itemMachine.getFluidStack(stack) != null ? itemMachine.getFluidStack(stack).amount : 0) / itemMachine.getCapacity(stack); FluidTankTier tier = FluidTankTier.values()[itemMachine.getBaseTier(stack).ordinal()]; FluidStack fluid = itemMachine.getFluidStack(stack); diff --git a/src/main/java/mekanism/client/render/item/machine/RenderQuantumEntangloporterItem.java b/src/main/java/mekanism/client/render/item/machine/RenderQuantumEntangloporterItem.java index aa3aff606..d2a1f3fe2 100644 --- a/src/main/java/mekanism/client/render/item/machine/RenderQuantumEntangloporterItem.java +++ b/src/main/java/mekanism/client/render/item/machine/RenderQuantumEntangloporterItem.java @@ -14,13 +14,13 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderQuantumEntangloporterItem { + private static ModelQuantumEntangloporter quantumEntangloporter = new ModelQuantumEntangloporter(); public static void renderStack(@Nonnull ItemStack stack, TransformType transformType) { GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F); GlStateManager.translate(0.0F, -1.0F, 0.0F); - MekanismRenderer - .bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "QuantumEntangloporter.png")); + MekanismRenderer.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "QuantumEntangloporter.png")); quantumEntangloporter.render(0.0625F, Minecraft.getMinecraft().renderEngine, true); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/item/machine/RenderResistiveHeaterItem.java b/src/main/java/mekanism/client/render/item/machine/RenderResistiveHeaterItem.java index 3483f11c4..46572d8dd 100644 --- a/src/main/java/mekanism/client/render/item/machine/RenderResistiveHeaterItem.java +++ b/src/main/java/mekanism/client/render/item/machine/RenderResistiveHeaterItem.java @@ -22,7 +22,6 @@ public class RenderResistiveHeaterItem { GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F); GlStateManager.translate(0.05F, -0.96F, 0.05F); MekanismRenderer.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ResistiveHeater.png")); - resistiveHeater.render(0.0625F, ItemDataUtils.getDouble(stack, "energyStored") > 0, - Minecraft.getMinecraft().renderEngine, true); + resistiveHeater.render(0.0625F, ItemDataUtils.getDouble(stack, "energyStored") > 0, Minecraft.getMinecraft().renderEngine, true); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/item/machine/RenderSolarNeutronActivatorItem.java b/src/main/java/mekanism/client/render/item/machine/RenderSolarNeutronActivatorItem.java index 3b2f60ff7..b3877197d 100644 --- a/src/main/java/mekanism/client/render/item/machine/RenderSolarNeutronActivatorItem.java +++ b/src/main/java/mekanism/client/render/item/machine/RenderSolarNeutronActivatorItem.java @@ -20,8 +20,7 @@ public class RenderSolarNeutronActivatorItem { GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F); GlStateManager.scale(0.6F, 0.6F, 0.6F); GlStateManager.translate(0.0F, -0.55F, 0.0F); - MekanismRenderer - .bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "SolarNeutronActivator.png")); + MekanismRenderer.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "SolarNeutronActivator.png")); solarNeutronActivator.render(0.0625F); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/obj/GlowPanelModel.java b/src/main/java/mekanism/client/render/obj/GlowPanelModel.java index 6ad7a5f5e..1bc37a9d6 100644 --- a/src/main/java/mekanism/client/render/obj/GlowPanelModel.java +++ b/src/main/java/mekanism/client/render/obj/GlowPanelModel.java @@ -2,7 +2,7 @@ package mekanism.client.render.obj; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -56,8 +56,8 @@ public class GlowPanelModel extends OBJBakedModelBase { private ItemStack tempStack; private GlowPanelOverride override = new GlowPanelOverride(); - public GlowPanelModel(IBakedModel base, OBJModel model, IModelState state, VertexFormat format, - ImmutableMap textures, HashMap transform) { + public GlowPanelModel(IBakedModel base, OBJModel model, IModelState state, VertexFormat format, ImmutableMap textures, + Map transform) { super(base, model, state, format, textures, transform); } @@ -67,11 +67,8 @@ public class GlowPanelModel extends OBJBakedModelBase { } private static TRSRTransformation get(float tx, float ty, float tz, float ax, float ay, float az, float s) { - return new TRSRTransformation( - new Vector3f(tx / 16, ty / 16, tz / 16), - TRSRTransformation.quatFromXYZDegrees(new Vector3f(ax, ay, az)), - new Vector3f(s, s, s), - null); + return new TRSRTransformation(new Vector3f(tx / 16, ty / 16, tz / 16), TRSRTransformation.quatFromXYZDegrees(new Vector3f(ax, ay, az)), + new Vector3f(s, s, s), null); } public EnumColor getColor() { @@ -101,17 +98,13 @@ public class GlowPanelModel extends OBJBakedModelBase { if (state != null && tempState == null) { int hash = TileEntityGlowPanel.hash((IExtendedBlockState) state); - if (!glowPanelCache.containsKey(hash)) { - GlowPanelModel model = new GlowPanelModel(baseModel, getModel(), getState(), vertexFormat, textureMap, - transformationMap); + GlowPanelModel model = new GlowPanelModel(baseModel, getModel(), getState(), vertexFormat, textureMap, transformationMap); model.tempState = state; glowPanelCache.put(hash, model.getQuads(state, side, rand)); } - return glowPanelCache.get(hash); } - return super.getQuads(state, side, rand); } @@ -121,7 +114,6 @@ public class GlowPanelModel extends OBJBakedModelBase { EnumColor c = getColor(); return new float[]{c.getColor(0), c.getColor(1), c.getColor(2), 1}; } - return null; } @@ -134,55 +126,42 @@ public class GlowPanelModel extends OBJBakedModelBase { GlStateManager.translate(0.65F, 0.45F, 0.0F); GlStateManager.rotate(90, 1, 0, 0); GlStateManager.scale(1.6F, 1.6F, 1.6F); - return Pair.of(this, null); - } else if (transformType == TransformType.FIRST_PERSON_RIGHT_HAND - || transformType == TransformType.FIRST_PERSON_LEFT_HAND) { + } else if (transformType == TransformType.FIRST_PERSON_RIGHT_HAND || transformType == TransformType.FIRST_PERSON_LEFT_HAND) { GlStateManager.translate(0.0F, 0.2F, 0.0F); - } else if (transformType == TransformType.THIRD_PERSON_RIGHT_HAND - || transformType == TransformType.THIRD_PERSON_LEFT_HAND) { + } else if (transformType == TransformType.THIRD_PERSON_RIGHT_HAND || transformType == TransformType.THIRD_PERSON_LEFT_HAND) { ForgeHooksClient.multiplyCurrentGlMatrix(transforms.get(transformType).getMatrix()); GlStateManager.translate(0.0F, 0.3F, 0.2F); - return Pair.of(this, null); } - return Pair.of(this, transforms.get(transformType).getMatrix()); } private class GlowPanelOverride extends ItemOverrideList { public GlowPanelOverride() { - super(Lists.newArrayList()); + super(new ArrayList<>()); } @Nonnull @Override - public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, ItemStack stack, World world, - EntityLivingBase entity) { + public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) { if (glowPanelItemCache.containsKey(stack.getItemDamage())) { return glowPanelItemCache.get(stack.getItemDamage()); } - ImmutableMap.Builder builder = ImmutableMap.builder(); builder.put(ModelLoader.White.LOCATION.toString(), ModelLoader.White.INSTANCE); - TextureAtlasSprite missing = Minecraft.getMinecraft().getTextureMapBlocks() - .getAtlasSprite(new ResourceLocation("missingno").toString()); + TextureAtlasSprite missing = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(new ResourceLocation("missingno").toString()); for (String s : getModel().getMatLib().getMaterialNames()) { - TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite( - getModel().getMatLib().getMaterial(s).getTexture().getTextureLocation().toString()); - - builder.put(s, sprite); + builder.put(s, Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(getModel().getMatLib().getMaterial(s).getTexture().getTextureLocation().toString())); } builder.put("missingno", missing); - GlowPanelModel bakedModel = new GlowPanelModel(baseModel, getModel(), getState(), vertexFormat, - builder.build(), transformationMap); + GlowPanelModel bakedModel = new GlowPanelModel(baseModel, getModel(), getState(), vertexFormat, builder.build(), transformationMap); bakedModel.tempStack = stack; glowPanelItemCache.put(stack.getItemDamage(), bakedModel); - return bakedModel; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/obj/MekanismOBJLoader.java b/src/main/java/mekanism/client/render/obj/MekanismOBJLoader.java index 7bac05e97..1cfb8309d 100644 --- a/src/main/java/mekanism/client/render/obj/MekanismOBJLoader.java +++ b/src/main/java/mekanism/client/render/obj/MekanismOBJLoader.java @@ -27,7 +27,6 @@ import net.minecraftforge.client.model.obj.OBJModel; import net.minecraftforge.client.model.obj.OBJModel.OBJBakedModel; import net.minecraftforge.client.model.obj.OBJModel.OBJState; import net.minecraftforge.common.model.IModelState; -import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class MekanismOBJLoader implements ICustomModelLoader { @@ -45,16 +44,14 @@ public class MekanismOBJLoader implements ICustomModelLoader { for (String s : OBJ_RENDERS) { ModelResourceLocation model = new ModelResourceLocation("mekanism:" + s, "inventory"); IBakedModel bakedModel = modelRegistry.getObject(model); - modelRegistry.putObject(model, createBakedObjItemModel(bakedModel, "mekanism:models/block/" + s + - ".obj.mek", new OBJState(Lists.newArrayList(OBJModel.Group.ALL), true), DefaultVertexFormats.ITEM)); + modelRegistry.putObject(model, createBakedObjItemModel(bakedModel, "mekanism:models/block/" + s + ".obj.mek", + new OBJState(Lists.newArrayList(OBJModel.Group.ALL), true), DefaultVertexFormats.ITEM)); } } - public OBJBakedModel createBakedObjItemModel(IBakedModel existingModel, String name, IModelState state, - VertexFormat format) { + public OBJBakedModel createBakedObjItemModel(IBakedModel existingModel, String name, IModelState state, VertexFormat format) { try { - Function textureGetter = location -> Minecraft.getMinecraft() - .getTextureMapBlocks().getAtlasSprite(location.toString()); + Function textureGetter = location -> Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString()); ResourceLocation modelLocation = new ResourceLocation(name); OBJModel objModel = (OBJModel) OBJLoader.INSTANCE.loadModel(modelLocation); @@ -66,8 +63,7 @@ public class MekanismOBJLoader implements ICustomModelLoader { for (String s : objModel.getMatLib().getMaterialNames()) { ResourceLocation texture = objModel.getMatLib().getMaterial(s).getTexture().getTextureLocation(); if (texture.getPath().startsWith("#")) { - Mekanism.logger.error("OBJLoader: Unresolved texture '{}' for obj model '{}'", texture.getPath(), - modelLocation); + Mekanism.logger.error("OBJLoader: Unresolved texture '{}' for obj model '{}'", texture.getPath(), modelLocation); builder.put(s, missing); } else { builder.put(s, textureGetter.apply(texture)); @@ -75,12 +71,10 @@ public class MekanismOBJLoader implements ICustomModelLoader { } builder.put("missingno", missing); - return new GlowPanelModel(existingModel, objModel, state, format, builder.build(), new HashMap<>()); } catch (Exception e) { e.printStackTrace(); } - return null; } @@ -93,29 +87,23 @@ public class MekanismOBJLoader implements ICustomModelLoader { @Override public IModel loadModel(@Nonnull ResourceLocation loc) throws Exception { ResourceLocation file = new ResourceLocation(loc.getNamespace(), loc.getPath()); - if (!modelCache.containsKey(file)) { IModel model = OBJLoader.INSTANCE.loadModel(file); - if (model instanceof OBJModel) { if (file.getPath().contains("glow_panel")) { - MekanismOBJModel mekModel = new MekanismOBJModel(OBJModelType.GLOW_PANEL, - ((OBJModel) model).getMatLib(), file); + MekanismOBJModel mekModel = new MekanismOBJModel(OBJModelType.GLOW_PANEL, ((OBJModel) model).getMatLib(), file); modelCache.put(file, mekModel); } else if (file.getPath().contains("transmitter")) { - MekanismOBJModel mekModel = new MekanismOBJModel(OBJModelType.TRANSMITTER, - ((OBJModel) model).getMatLib(), file); + MekanismOBJModel mekModel = new MekanismOBJModel(OBJModelType.TRANSMITTER, ((OBJModel) model).getMatLib(), file); modelCache.put(file, mekModel); } } } MekanismOBJModel mekModel = modelCache.get(file); - if (mekModel == null) { return ModelLoaderRegistry.getMissingModel(); } - return mekModel; } @@ -123,4 +111,4 @@ public class MekanismOBJLoader implements ICustomModelLoader { public void onResourceManagerReload(@Nonnull IResourceManager resourceManager) { modelCache.clear(); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/obj/MekanismOBJModel.java b/src/main/java/mekanism/client/render/obj/MekanismOBJModel.java index 3ef13486d..7f0a9fdfc 100644 --- a/src/main/java/mekanism/client/render/obj/MekanismOBJModel.java +++ b/src/main/java/mekanism/client/render/obj/MekanismOBJModel.java @@ -20,23 +20,18 @@ public class MekanismOBJModel extends OBJModel { public MekanismOBJModel(OBJModelType type, MaterialLibrary matLib, ResourceLocation modelLocation) { super(matLib, modelLocation); - modelType = type; location = modelLocation; } @Nonnull @Override - public IBakedModel bake(@Nonnull IModelState state, @Nonnull VertexFormat format, - Function bakedTextureGetter) { + public IBakedModel bake(@Nonnull IModelState state, @Nonnull VertexFormat format, Function bakedTextureGetter) { IBakedModel preBaked = super.bake(state, format, bakedTextureGetter); - if (modelType == OBJModelType.GLOW_PANEL) { - return new GlowPanelModel(preBaked, this, state, format, GlowPanelModel.getTexturesForOBJModel(preBaked), - null); + return new GlowPanelModel(preBaked, this, state, format, GlowPanelModel.getTexturesForOBJModel(preBaked), null); } else if (modelType == OBJModelType.TRANSMITTER) { - return new TransmitterModel(preBaked, this, state, format, - TransmitterModel.getTexturesForOBJModel(preBaked), null); + return new TransmitterModel(preBaked, this, state, format, TransmitterModel.getTexturesForOBJModel(preBaked), null); } return preBaked; @@ -64,4 +59,4 @@ public class MekanismOBJModel extends OBJModel { GLOW_PANEL, TRANSMITTER } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/obj/OBJBakedModelBase.java b/src/main/java/mekanism/client/render/obj/OBJBakedModelBase.java index b96d56951..5ca1bae59 100644 --- a/src/main/java/mekanism/client/render/obj/OBJBakedModelBase.java +++ b/src/main/java/mekanism/client/render/obj/OBJBakedModelBase.java @@ -2,7 +2,6 @@ package mekanism.client.render.obj; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; @@ -45,10 +44,10 @@ public abstract class OBJBakedModelBase extends OBJBakedModel { protected TextureAtlasSprite tempSprite = ModelLoader.White.INSTANCE; protected VertexFormat vertexFormat; protected ImmutableMap textureMap; - protected HashMap transformationMap; + protected Map transformationMap; - public OBJBakedModelBase(IBakedModel base, OBJModel model, IModelState state, VertexFormat format, - ImmutableMap textures, HashMap transform) { + public OBJBakedModelBase(IBakedModel base, OBJModel model, IModelState state, VertexFormat format, ImmutableMap textures, + Map transform) { model.super(model, state, format, textures); baseModel = base; transformationMap = transform; @@ -60,8 +59,7 @@ public abstract class OBJBakedModelBase extends OBJBakedModel { } } - public static void putVertexData(UnpackedBakedQuad.Builder builder, Vertex v, Normal faceNormal, - TextureCoordinate defUV, TextureAtlasSprite sprite, VertexFormat format, float[] color) { + public static void putVertexData(UnpackedBakedQuad.Builder builder, Vertex v, Normal faceNormal, TextureCoordinate defUV, TextureAtlasSprite sprite, VertexFormat format, float[] color) { for (int e = 0; e < format.getElementCount(); e++) { switch (format.getElement(e).getUsage()) { case POSITION: @@ -69,27 +67,21 @@ public abstract class OBJBakedModelBase extends OBJBakedModel { break; case COLOR: float d; - if (v.hasNormal()) { d = LightUtil.diffuseLight(v.getNormal().x, v.getNormal().y, v.getNormal().z); } else { d = LightUtil.diffuseLight(faceNormal.x, faceNormal.y, faceNormal.z); } - - builder.put(e, d * v.getMaterial().getColor().x * color[0], - d * v.getMaterial().getColor().y * color[1], d * v.getMaterial().getColor().z * color[2], + builder.put(e, d * v.getMaterial().getColor().x * color[0], d * v.getMaterial().getColor().y * color[1], d * v.getMaterial().getColor().z * color[2], v.getMaterial().getColor().w * color[3]); break; case UV: if (!v.hasTextureCoordinate()) { - builder.put(e, sprite.getInterpolatedU(defUV.u * 16), - sprite.getInterpolatedV((1 - defUV.v) * 16), 0, 1); + builder.put(e, sprite.getInterpolatedU(defUV.u * 16), sprite.getInterpolatedV((1 - defUV.v) * 16), 0, 1); } else { - builder.put(e, sprite.getInterpolatedU(v.getTextureCoordinate().u * 16), - sprite.getInterpolatedV((1 - v.getTextureCoordinate().v) * 16), 0, 1); + builder.put(e, sprite.getInterpolatedU(v.getTextureCoordinate().u * 16), sprite.getInterpolatedV((1 - v.getTextureCoordinate().v) * 16), 0, 1); } - break; case NORMAL: if (!v.hasNormal()) { @@ -97,7 +89,6 @@ public abstract class OBJBakedModelBase extends OBJBakedModel { } else { builder.put(e, v.getNormal().x, v.getNormal().y, v.getNormal().z, 0); } - break; default: builder.put(e); @@ -112,12 +103,10 @@ public abstract class OBJBakedModelBase extends OBJBakedModel { f_textures = OBJBakedModel.class.getDeclaredField("textures"); f_textures.setAccessible(true); } - return (ImmutableMap) f_textures.get(model); } catch (Exception e) { e.printStackTrace(); } - return null; } @@ -146,7 +135,6 @@ public abstract class OBJBakedModelBase extends OBJBakedModel { if (state.getGroupsWithVisibility(true).contains(g.getName())) { Set groupFaces = g.applyTransform(transform); - for (Face f : groupFaces) { groupNameMap.put(f, g.getName()); faces.add(f); @@ -175,12 +163,10 @@ public abstract class OBJBakedModelBase extends OBJBakedModel { v.setMaterial(getModel().getMatLib().getMaterial(v.getMaterial().getName())); } } - tempSprite = ModelLoader.White.INSTANCE; } else { tempSprite = textureMap.get(f.getMaterialName()); } - float[] color = new float[]{1, 1, 1, 1}; float[] overrideColor = getOverrideColor(f, groupName); @@ -198,24 +184,17 @@ public abstract class OBJBakedModelBase extends OBJBakedModel { Normal faceNormal = f.getNormal(); boolean rotate = shouldRotate(f, groupName); - putVertexData(builder, f.getVertices()[0], faceNormal, TextureCoordinate.getDefaultUVs()[0], tempSprite, - vertexFormat, color); - putVertexData(builder, f.getVertices()[1], faceNormal, TextureCoordinate.getDefaultUVs()[1], tempSprite, - vertexFormat, color); - putVertexData(builder, f.getVertices()[2], faceNormal, TextureCoordinate.getDefaultUVs()[2], tempSprite, - vertexFormat, color); - putVertexData(builder, f.getVertices()[3], faceNormal, TextureCoordinate.getDefaultUVs()[3], tempSprite, - vertexFormat, color); + putVertexData(builder, f.getVertices()[0], faceNormal, TextureCoordinate.getDefaultUVs()[0], tempSprite, vertexFormat, color); + putVertexData(builder, f.getVertices()[1], faceNormal, TextureCoordinate.getDefaultUVs()[1], tempSprite, vertexFormat, color); + putVertexData(builder, f.getVertices()[2], faceNormal, TextureCoordinate.getDefaultUVs()[2], tempSprite, vertexFormat, color); + putVertexData(builder, f.getVertices()[3], faceNormal, TextureCoordinate.getDefaultUVs()[3], tempSprite, vertexFormat, color); BakedQuad quad = builder.build(); - if (rotate) { quad = MekanismRenderer.rotate(quad, 1); } - bakedQuads.add(quad); } - return bakedQuads; } @@ -223,11 +202,9 @@ public abstract class OBJBakedModelBase extends OBJBakedModel { protected void updateStateVisibilityMap(OBJState state) { try { if (m_updateStateVisibilityMap == null) { - m_updateStateVisibilityMap = OBJBakedModel.class - .getDeclaredMethod("updateStateVisibilityMap", OBJState.class); + m_updateStateVisibilityMap = OBJBakedModel.class.getDeclaredMethod("updateStateVisibilityMap", OBJState.class); m_updateStateVisibilityMap.setAccessible(true); } - m_updateStateVisibilityMap.invoke(this, state); } catch (Exception e) { e.printStackTrace(); @@ -251,4 +228,4 @@ public abstract class OBJBakedModelBase extends OBJBakedModel { protected boolean shouldRotate(Face f, String groupName) { return false; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/obj/TransmitterModel.java b/src/main/java/mekanism/client/render/obj/TransmitterModel.java index 0ee7af6c0..132dfc4e5 100644 --- a/src/main/java/mekanism/client/render/obj/TransmitterModel.java +++ b/src/main/java/mekanism/client/render/obj/TransmitterModel.java @@ -2,7 +2,6 @@ package mekanism.client.render.obj; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -71,39 +70,28 @@ public class TransmitterModel extends OBJBakedModelBase { private TextureAtlasSprite particle; private TransmitterOverride override = new TransmitterOverride(); - public TransmitterModel(IBakedModel base, OBJModel model, IModelState state, VertexFormat format, - ImmutableMap textures, HashMap transform) { + public TransmitterModel(IBakedModel base, OBJModel model, IModelState state, VertexFormat format, ImmutableMap textures, + Map transform) { super(base, model, state, format, textures, transform); particle = textureMap.getOrDefault("None_Center", textureMap.getOrDefault("CentreMaterial", tempSprite)); modelInstances.add(this); } private static TRSRTransformation get(float tx, float ty, float tz, float ax, float ay, float az, float s) { - return new TRSRTransformation( - new Vector3f(tx / 16, ty / 16, tz / 16), - TRSRTransformation.quatFromXYZDegrees(new Vector3f(ax, ay, az)), - new Vector3f(s, s, s), - null); + return new TRSRTransformation(new Vector3f(tx / 16, ty / 16, tz / 16), TRSRTransformation.quatFromXYZDegrees(new Vector3f(ax, ay, az)), + new Vector3f(s, s, s), null); } public static void registerIcons(TextureMap map) { - transporter_center[0] = map - .registerSprite(new ResourceLocation("mekanism:blocks/models/multipart/LogisticalTransporterGlass")); - transporter_center_color[0] = map.registerSprite( - new ResourceLocation("mekanism:blocks/models/multipart/LogisticalTransporterGlassColored")); - transporter_side[0] = map.registerSprite( - new ResourceLocation("mekanism:blocks/models/multipart/LogisticalTransporterVerticalGlass")); - transporter_side_color[0] = map.registerSprite( - new ResourceLocation("mekanism:blocks/models/multipart/LogisticalTransporterVerticalGlassColored")); + transporter_center[0] = map.registerSprite(new ResourceLocation("mekanism:blocks/models/multipart/LogisticalTransporterGlass")); + transporter_center_color[0] = map.registerSprite(new ResourceLocation("mekanism:blocks/models/multipart/LogisticalTransporterGlassColored")); + transporter_side[0] = map.registerSprite(new ResourceLocation("mekanism:blocks/models/multipart/LogisticalTransporterVerticalGlass")); + transporter_side_color[0] = map.registerSprite(new ResourceLocation("mekanism:blocks/models/multipart/LogisticalTransporterVerticalGlassColored")); - transporter_center[1] = map.registerSprite( - new ResourceLocation("mekanism:blocks/models/multipart/opaque/LogisticalTransporterGlass")); - transporter_center_color[1] = map.registerSprite( - new ResourceLocation("mekanism:blocks/models/multipart/opaque/LogisticalTransporterGlassColored")); - transporter_side[1] = map.registerSprite( - new ResourceLocation("mekanism:blocks/models/multipart/opaque/LogisticalTransporterVerticalGlass")); - transporter_side_color[1] = map.registerSprite(new ResourceLocation( - "mekanism:blocks/models/multipart/opaque/LogisticalTransporterVerticalGlassColored")); + transporter_center[1] = map.registerSprite(new ResourceLocation("mekanism:blocks/models/multipart/opaque/LogisticalTransporterGlass")); + transporter_center_color[1] = map.registerSprite(new ResourceLocation("mekanism:blocks/models/multipart/opaque/LogisticalTransporterGlassColored")); + transporter_side[1] = map.registerSprite(new ResourceLocation("mekanism:blocks/models/multipart/opaque/LogisticalTransporterVerticalGlass")); + transporter_side_color[1] = map.registerSprite(new ResourceLocation("mekanism:blocks/models/multipart/opaque/LogisticalTransporterVerticalGlassColored")); } public static void clearCache() { @@ -143,17 +131,14 @@ public class TransmitterModel extends OBJBakedModelBase { } try { - int hash = Objects.hash(layer.ordinal(), color, - PropertyConnection.INSTANCE.valueToString(extended.getValue(PropertyConnection.INSTANCE))); + int hash = Objects.hash(layer.ordinal(), color, PropertyConnection.INSTANCE.valueToString(extended.getValue(PropertyConnection.INSTANCE))); - if (obj.getVisibilityMap().containsKey(Group.ALL) || obj.getVisibilityMap() - .containsKey(Group.ALL_EXCEPT)) { + if (obj.getVisibilityMap().containsKey(Group.ALL) || obj.getVisibilityMap().containsKey(Group.ALL_EXCEPT)) { updateStateVisibilityMap(obj); } if (!modelCache.containsKey(hash)) { - TransmitterModel model = new TransmitterModel(baseModel, getModel(), obj, vertexFormat, textureMap, - transformationMap); + TransmitterModel model = new TransmitterModel(baseModel, getModel(), obj, vertexFormat, textureMap, transformationMap); model.tempState = state; modelCache.put(hash, model.getQuads(state, side, rand)); } @@ -171,12 +156,10 @@ public class TransmitterModel extends OBJBakedModelBase { if (tempState != null) { PropertyColor prop = ((IExtendedBlockState) tempState).getValue(PropertyColor.INSTANCE); - if (MinecraftForgeClient.getRenderLayer() == BlockRenderLayer.TRANSLUCENT && prop != null - && prop.color != null) { + if (MinecraftForgeClient.getRenderLayer() == BlockRenderLayer.TRANSLUCENT && prop != null && prop.color != null) { return new float[]{prop.color.getColor(0), prop.color.getColor(1), prop.color.getColor(2), 1}; } } - return null; } @@ -196,29 +179,21 @@ public class TransmitterModel extends OBJBakedModelBase { if (MinecraftForgeClient.getRenderLayer() == BlockRenderLayer.TRANSLUCENT) { int opaqueVal = MekanismConfig.current().client.opaqueTransmitters.val() ? 1 : 0; - if (prop != null && prop.color != null) { - return (!sideIconOverride && f.getMaterialName().contains("Center")) - ? transporter_center_color[opaqueVal] : transporter_side_color[opaqueVal]; - } else { - return (!sideIconOverride && f.getMaterialName().contains("Center")) ? transporter_center[opaqueVal] - : transporter_side[opaqueVal]; + return (!sideIconOverride && f.getMaterialName().contains("Center")) ? transporter_center_color[opaqueVal] : transporter_side_color[opaqueVal]; } - } else { - if (groupName.endsWith("NONE") && sideIconOverride) { - for (String s : getModel().getMatLib().getMaterialNames()) { - if (s.contains("Texture.Name")) { - continue; - } - - if (!s.contains("Center") && !s.contains("Centre") && ( - MekanismConfig.current().client.opaqueTransmitters.val() == s.contains("Opaque"))) { - return textureMap.get(s); - } + return (!sideIconOverride && f.getMaterialName().contains("Center")) ? transporter_center[opaqueVal] : transporter_side[opaqueVal]; + } else if (groupName.endsWith("NONE") && sideIconOverride) { + for (String s : getModel().getMatLib().getMaterialNames()) { + if (s.contains("Texture.Name")) { + continue; + } + if (!s.contains("Center") && !s.contains("Centre") && (MekanismConfig.current().client.opaqueTransmitters.val() == s.contains("Opaque"))) { + return textureMap.get(s); } - } else if (MekanismConfig.current().client.opaqueTransmitters.val()) { - return textureMap.get(f.getMaterialName() + "_Opaque"); } + } else if (MekanismConfig.current().client.opaqueTransmitters.val()) { + return textureMap.get(f.getMaterialName() + "_Opaque"); } } @@ -230,17 +205,13 @@ public class TransmitterModel extends OBJBakedModelBase { if (tempState != null) { EnumFacing side = EnumFacing.getFacingFromVector(f.getNormal().x, f.getNormal().y, f.getNormal().z); PropertyConnection connection = ((IExtendedBlockState) tempState).getValue(PropertyConnection.INSTANCE); - return connection != null && groupName.endsWith("NONE") && getIconStatus(side, connection) == 2; } - return false; } public byte getIconStatus(EnumFacing side, PropertyConnection connection) { - ConnectionType type = TileEntitySidedPipe - .getConnectionType(side, connection.connectionByte, connection.transmitterConnections, - connection.connectionTypes); + ConnectionType type = TileEntitySidedPipe.getConnectionType(side, connection.connectionByte, connection.transmitterConnections, connection.connectionTypes); if (type == ConnectionType.NONE) { if (connection.renderCenter) { @@ -255,27 +226,24 @@ public class TransmitterModel extends OBJBakedModelBase { return (byte) 2; } } - return (byte) 0; } @Nonnull @Override - public Pair handlePerspective( - ItemCameraTransforms.TransformType cameraTransformType) { + public Pair handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) { return Pair.of(this, transforms.get(cameraTransformType).getMatrix()); } private class TransmitterOverride extends ItemOverrideList { public TransmitterOverride() { - super(Lists.newArrayList()); + super(new ArrayList<>()); } @Nonnull @Override - public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, ItemStack stack, World world, - EntityLivingBase entity) { + public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) { if (itemCache == null) { List visible = new ArrayList<>(); @@ -283,12 +251,10 @@ public class TransmitterModel extends OBJBakedModelBase { visible.add(side.getName() + (side.getAxis() == Axis.Y ? "NORMAL" : "NONE")); } - itemCache = new TransmitterModel(baseModel, getModel(), new OBJState(visible, true), vertexFormat, - textureMap, transformationMap); + itemCache = new TransmitterModel(baseModel, getModel(), new OBJState(visible, true), vertexFormat, textureMap, transformationMap); itemCache.tempStack = stack; } - return itemCache; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/particle/EntityJetpackFlameFX.java b/src/main/java/mekanism/client/render/particle/EntityJetpackFlameFX.java index 9d6ed10ef..4430c2812 100644 --- a/src/main/java/mekanism/client/render/particle/EntityJetpackFlameFX.java +++ b/src/main/java/mekanism/client/render/particle/EntityJetpackFlameFX.java @@ -14,22 +14,19 @@ public class EntityJetpackFlameFX extends ParticleFlame { private static Minecraft mc = FMLClientHandler.instance().getClient(); - public EntityJetpackFlameFX(World world, double posX, double posY, double posZ, double velX, double velY, - double velZ) { + public EntityJetpackFlameFX(World world, double posX, double posY, double posZ, double velX, double velY, double velZ) { super(world, posX, posY, posZ, velX, velY, velZ); } @Override - public int getBrightnessForRender(float p_70013_1_) { + public int getBrightnessForRender(float partialTick) { return 190 + (int) (20F * (1.0F - mc.gameSettings.gammaSetting)); } @Override - public void renderParticle(BufferBuilder worldRendererIn, Entity entityIn, float partialTicks, float p_180434_4_, - float p_180434_5_, float p_180434_6_, float p_180434_7_, float p_180434_8_) { + public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) { if (particleAge > 0) { - super.renderParticle(worldRendererIn, entityIn, partialTicks, p_180434_4_, p_180434_5_, p_180434_6_, - p_180434_7_, p_180434_8_); + super.renderParticle(buffer, entityIn, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/particle/EntityJetpackSmokeFX.java b/src/main/java/mekanism/client/render/particle/EntityJetpackSmokeFX.java index fc07360f9..defcec58b 100644 --- a/src/main/java/mekanism/client/render/particle/EntityJetpackSmokeFX.java +++ b/src/main/java/mekanism/client/render/particle/EntityJetpackSmokeFX.java @@ -14,22 +14,19 @@ public class EntityJetpackSmokeFX extends ParticleSmokeNormal { private static Minecraft mc = FMLClientHandler.instance().getClient(); - public EntityJetpackSmokeFX(World world, double posX, double posY, double posZ, double velX, double velY, - double velZ) { + public EntityJetpackSmokeFX(World world, double posX, double posY, double posZ, double velX, double velY, double velZ) { super(world, posX, posY, posZ, velX, velY, velZ, 1.0F); } @Override - public int getBrightnessForRender(float p_70013_1_) { + public int getBrightnessForRender(float partialTick) { return 190 + (int) (20F * (1.0F - mc.gameSettings.gammaSetting)); } @Override - public void renderParticle(BufferBuilder worldRendererIn, Entity entityIn, float partialTicks, float p_180434_4_, - float p_180434_5_, float p_180434_6_, float p_180434_7_, float p_180434_8_) { + public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) { if (particleAge > 0) { - super.renderParticle(worldRendererIn, entityIn, partialTicks, p_180434_4_, p_180434_5_, p_180434_6_, - p_180434_7_, p_180434_8_); + super.renderParticle(buffer, entityIn, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/particle/EntityScubaBubbleFX.java b/src/main/java/mekanism/client/render/particle/EntityScubaBubbleFX.java index 882200c60..c17abc4be 100644 --- a/src/main/java/mekanism/client/render/particle/EntityScubaBubbleFX.java +++ b/src/main/java/mekanism/client/render/particle/EntityScubaBubbleFX.java @@ -14,10 +14,8 @@ public class EntityScubaBubbleFX extends ParticleBubble { private static Minecraft mc = FMLClientHandler.instance().getClient(); - public EntityScubaBubbleFX(World world, double posX, double posY, double posZ, double velX, double velY, - double velZ) { + public EntityScubaBubbleFX(World world, double posX, double posY, double posZ, double velX, double velY, double velZ) { super(world, posX, posY, posZ, velX, velY, velZ); - particleScale = (rand.nextFloat() * 0.2F) + 0.3F; particleMaxAge *= 2; } @@ -25,16 +23,13 @@ public class EntityScubaBubbleFX extends ParticleBubble { @Override public void onUpdate() { super.onUpdate(); - particleAge++; } @Override - public void renderParticle(BufferBuilder worldRendererIn, Entity entityIn, float partialTicks, float p_180434_4_, - float p_180434_5_, float p_180434_6_, float p_180434_7_, float p_180434_8_) { + public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) { if (particleAge > 0) { - super.renderParticle(worldRendererIn, entityIn, partialTicks, p_180434_4_, p_180434_5_, p_180434_6_, - p_180434_7_, p_180434_8_); + super.renderParticle(buffer, entityIn, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/particle/MekanismParticleHelper.java b/src/main/java/mekanism/client/render/particle/MekanismParticleHelper.java index c60f75740..a2c1abdc4 100644 --- a/src/main/java/mekanism/client/render/particle/MekanismParticleHelper.java +++ b/src/main/java/mekanism/client/render/particle/MekanismParticleHelper.java @@ -25,13 +25,15 @@ public class MekanismParticleHelper { /** * Adds block hit particles for the specified block, accounting for tier colour - * @see ParticleManager#addBlockHitEffects(net.minecraft.util.math.BlockPos, net.minecraft.util.EnumFacing) for source of copy * - * @param world relevant world - * @param pos position of block - * @param side which side was hit + * @param world relevant world + * @param pos position of block + * @param side which side was hit * @param manager vanilla particle manager in use + * * @return true if handled (always true) + * + * @see ParticleManager#addBlockHitEffects(net.minecraft.util.math.BlockPos, net.minecraft.util.EnumFacing) for source of copy */ public static boolean addBlockHitEffects(World world, BlockPos pos, EnumFacing side, ParticleManager manager) { TileEntity tile = MekanismUtils.getTileEntitySafe(world, pos); @@ -48,12 +50,9 @@ public class MekanismParticleHelper { int blockY = pos.getY(); int blockZ = pos.getZ(); AxisAlignedBB axisalignedbb = iblockstate.getBoundingBox(world, pos); - double particleX = (double) blockX + world.rand.nextDouble() * (axisalignedbb.maxX - axisalignedbb.minX - - OFFSET_1) + OFFSET_2 + axisalignedbb.minX; - double particleY = (double) blockY + world.rand.nextDouble() * (axisalignedbb.maxY - axisalignedbb.minY - - OFFSET_1) + OFFSET_2 + axisalignedbb.minY; - double particleZ = (double) blockZ + world.rand.nextDouble() * (axisalignedbb.maxZ - axisalignedbb.minZ - - OFFSET_1) + OFFSET_2 + axisalignedbb.minZ; + double particleX = (double) blockX + world.rand.nextDouble() * (axisalignedbb.maxX - axisalignedbb.minX - OFFSET_1) + OFFSET_2 + axisalignedbb.minX; + double particleY = (double) blockY + world.rand.nextDouble() * (axisalignedbb.maxY - axisalignedbb.minY - OFFSET_1) + OFFSET_2 + axisalignedbb.minY; + double particleZ = (double) blockZ + world.rand.nextDouble() * (axisalignedbb.maxZ - axisalignedbb.minZ - OFFSET_1) + OFFSET_2 + axisalignedbb.minZ; if (side == EnumFacing.DOWN) { particleY = (double) blockY + axisalignedbb.minY - OFFSET_2; diff --git a/src/main/java/mekanism/client/render/particle/TieredParticleDigging.java b/src/main/java/mekanism/client/render/particle/TieredParticleDigging.java index e1ff4a73a..bc84a616a 100644 --- a/src/main/java/mekanism/client/render/particle/TieredParticleDigging.java +++ b/src/main/java/mekanism/client/render/particle/TieredParticleDigging.java @@ -15,8 +15,7 @@ public class TieredParticleDigging extends ParticleDigging { @Nullable private final EnumColor color; - public TieredParticleDigging(World world, double xCoord, double yCoord, double zCoord, double xSpeed, - double ySpeed, double zSpeed, IBlockState state, EnumColor color) { + public TieredParticleDigging(World world, double xCoord, double yCoord, double zCoord, double xSpeed, double ySpeed, double zSpeed, IBlockState state, EnumColor color) { super(world, xCoord, yCoord, zCoord, xSpeed, ySpeed, zSpeed, state); this.color = color; } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderBin.java b/src/main/java/mekanism/client/render/tileentity/RenderBin.java index 38bc5f350..9917c34e0 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderBin.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderBin.java @@ -20,31 +20,22 @@ public class RenderBin extends TileEntitySpecialRenderer { private final RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); @Override - public void render(TileEntityBin tileEntity, double x, double y, double z, float partialTick, int destroyStage, - float alpha) { + public void render(TileEntityBin tileEntity, double x, double y, double z, float partialTick, int destroyStage, float alpha) { Coord4D obj = Coord4D.get(tileEntity).offset(tileEntity.facing); - - if (obj.getBlockState(tileEntity.getWorld()) - .isSideSolid(tileEntity.getWorld(), obj.getPos(), tileEntity.facing.getOpposite())) { + if (obj.getBlockState(tileEntity.getWorld()).isSideSolid(tileEntity.getWorld(), obj.getPos(), tileEntity.facing.getOpposite())) { return; } - render(tileEntity.facing, tileEntity.itemType, tileEntity.clientAmount, true, x, y, z); } - public void render(EnumFacing facing, ItemStack itemType, int clientAmount, boolean text, double x, double y, - double z) { + public void render(EnumFacing facing, ItemStack itemType, int clientAmount, boolean text, double x, double y, double z) { String amount = ""; - if (!itemType.isEmpty()) { amount = Integer.toString(clientAmount); - if (clientAmount == Integer.MAX_VALUE) { amount = LangUtils.localize("gui.infinite"); } - GlStateManager.pushMatrix(); - switch (facing) { case NORTH: GL11.glTranslated(x + 0.73, y + 0.83, z - 0.0001); @@ -67,15 +58,11 @@ public class RenderBin extends TileEntitySpecialRenderer { float scale = 0.03125F; float scaler = 0.9F; - GlStateManager.scale(scale * scaler, scale * scaler, -0.0001F); GlStateManager.rotate(180, 0, 0, 1); - renderItem.renderItemAndEffectIntoGUI(itemType, 0, 0); - GlStateManager.popMatrix(); } - if (text && !amount.equals("")) { renderText(amount, facing, 0.02F, x, y - 0.3725F, z); } @@ -84,10 +71,9 @@ public class RenderBin extends TileEntitySpecialRenderer { @SuppressWarnings("incomplete-switch") private void renderText(String text, EnumFacing side, float maxScale, double x, double y, double z) { GlStateManager.pushMatrix(); - GlStateManager.doPolygonOffset(-10, -10); GlStateManager.enablePolygonOffset(); - + //TODO: Look into this because it gets cast to 1 due to division float displayWidth = 1 - (2 / 16); float displayHeight = 1 - (2 / 16); GlStateManager.translate(x, y, z); @@ -121,10 +107,9 @@ public class RenderBin extends TileEntitySpecialRenderer { FontRenderer fontRenderer = getFontRenderer(); int requiredWidth = Math.max(fontRenderer.getStringWidth(text), 1); - int lineHeight = fontRenderer.FONT_HEIGHT + 2; - int requiredHeight = lineHeight; + int requiredHeight = fontRenderer.FONT_HEIGHT + 2; float scaler = 0.4F; - float scaleX = (displayWidth / requiredWidth); + float scaleX = displayWidth / requiredWidth; float scale = scaleX * scaler; if (maxScale > 0) { @@ -148,4 +133,4 @@ public class RenderBin extends TileEntitySpecialRenderer { GlStateManager.popMatrix(); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/tileentity/RenderChemicalCrystallizer.java b/src/main/java/mekanism/client/render/tileentity/RenderChemicalCrystallizer.java index 2c9ea411c..fb464082d 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderChemicalCrystallizer.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderChemicalCrystallizer.java @@ -16,8 +16,7 @@ public class RenderChemicalCrystallizer extends TileEntitySpecialRenderer> cachedOverlays = new HashMap<>(); + private Map> cachedOverlays = new HashMap<>(); public RenderConfigurableMachine() { rendererDispatcher = TileEntityRendererDispatcher.instance; @@ -47,16 +48,14 @@ public class RenderConfigurableMachine map = new HashMap<>(); + Map map = new HashMap<>(); map.put(type, display); cachedOverlays.put(side, map); } @@ -183,4 +182,4 @@ public class RenderConfigurableMachine { @Override - public void render(TileEntityDynamicTank tileEntity, double x, double y, double z, float partialTick, - int destroyStage, float alpha) { - if (tileEntity.clientHasStructure && tileEntity.isRendering && tileEntity.structure != null - && tileEntity.structure.fluidStored != null && tileEntity.structure.fluidStored.amount != 0) { + public void render(TileEntityDynamicTank tileEntity, double x, double y, double z, float partialTick, int destroyStage, float alpha) { + 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; @@ -38,9 +37,8 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer { - public static int[][] COLORS = new int[][]{new int[]{100, 210, 125}, new int[]{215, 85, 70}, - new int[]{80, 125, 230}, - new int[]{154, 120, 200}, new int[]{0, 0, 0}}; + public static int[][] COLORS = new int[][]{new int[]{100, 210, 125}, new int[]{215, 85, 70}, new int[]{80, 125, 230}, new int[]{154, 120, 200}, new int[]{0, 0, 0}}; public static Map resources = new HashMap<>(); public static ResourceLocation baseTexture = MekanismUtils.getResource(ResourceType.RENDER, "EnergyCube.png"); public static ResourceLocation coreTexture = MekanismUtils.getResource(ResourceType.RENDER, "EnergyCore.png"); @@ -32,8 +30,7 @@ public class RenderEnergyCube extends TileEntitySpecialRenderer 0 ? tileEntity.valveFluid : null, x, y, z); + render(tileEntity.tier, fluid, tileEntity.prevScale, tileEntity.isActive, tileEntity.valve > 0 ? tileEntity.valveFluid : null, x, y, z); } - public void render(FluidTankTier tier, FluidStack fluid, float fluidScale, boolean active, FluidStack valveFluid, - double x, double y, double z) { + public void render(FluidTankTier tier, FluidStack fluid, float fluidScale, boolean active, FluidStack valveFluid, double x, double y, double z) { if (fluid != null && fluidScale > 0) { push(); @@ -167,4 +164,4 @@ public class RenderFluidTank extends TileEntitySpecialRenderer { @Override - public void render(TileEntityGasTank tileEntity, double x, double y, double z, float partialTick, int destroyStage, - float alpha) { + public void render(TileEntityGasTank tileEntity, double x, double y, double z, float partialTick, int destroyStage, float alpha) { MekanismRenderer.machineRenderer.render(tileEntity, x, y, z, partialTick, destroyStage, alpha); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/tileentity/RenderPersonalChest.java b/src/main/java/mekanism/client/render/tileentity/RenderPersonalChest.java index 7c10ac9ac..c57e5fe81 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderPersonalChest.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderPersonalChest.java @@ -15,8 +15,7 @@ public class RenderPersonalChest extends TileEntitySpecialRenderer cachedOverlays = new HashMap<>(); @Override - public void render(TileEntityTeleporter tileEntity, double x, double y, double z, float partialTick, - int destroyStage, float alpha) { + public void render(TileEntityTeleporter tileEntity, double x, double y, double z, float partialTick, int destroyStage, float alpha) { if (tileEntity.shouldRender) { push(); @@ -31,12 +30,9 @@ public class RenderTeleporter extends TileEntitySpecialRenderer { +public class RenderThermalEvaporationController extends TileEntitySpecialRenderer { private static final int LEVELS = 16; private static final int ALL_LEVELS = LEVELS + 2; @@ -32,12 +31,9 @@ public class RenderThermalEvaporationController extends } @Override - public void render(TileEntityThermalEvaporationController tileEntity, double x, double y, double z, - float partialTick, int destroyStage, float alpha) { + public void render(TileEntityThermalEvaporationController tileEntity, double x, double y, double z, float partialTick, int destroyStage, float alpha) { if (tileEntity.structured && tileEntity.inputTank.getFluid() != null) { - bindTexture(MekanismRenderer.getBlocksTexture()); - if (tileEntity.height - 2 >= 1 && tileEntity.inputTank.getCapacity() > 0) { push(); @@ -46,12 +42,9 @@ public class RenderThermalEvaporationController extends MekanismRenderer.colorFluid(tileEntity.inputTank.getFluid()); DisplayInteger[] displayList = getListAndRender(tileEntity.inputTank.getFluid()); - float levels = Math - .min(((float) tileEntity.inputTank.getFluidAmount() / tileEntity.inputTank.getCapacity()), 1); - levels *= (tileEntity.height - 2); - + float levels = Math.min((float) tileEntity.inputTank.getFluidAmount() / tileEntity.inputTank.getCapacity(), 1); + levels *= tileEntity.height - 2; int partialLevels = (int) ((levels - (int) levels) * 16); - switch (tileEntity.facing) { case SOUTH: GlStateManager.translate(-1, 0, -1); @@ -67,11 +60,9 @@ public class RenderThermalEvaporationController extends } GlStateManager.translate(0, 0.01, 0); - if ((int) levels > 0) { displayList[CONCAVE_INDEX].render(); GlStateManager.translate(0, 1, 0); - for (int i = 1; i < (int) levels; i++) { displayList[RING_INDEX].render(); GlStateManager.translate(0, 1, 0); @@ -155,4 +146,4 @@ public class RenderThermalEvaporationController extends return displayInteger; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/tileentity/RenderThermoelectricBoiler.java b/src/main/java/mekanism/client/render/tileentity/RenderThermoelectricBoiler.java index 31a202561..bfce45791 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderThermoelectricBoiler.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderThermoelectricBoiler.java @@ -28,15 +28,14 @@ public class RenderThermoelectricBoiler extends TileEntitySpecialRenderer renderer = Minecraft.getMinecraft().getRenderManager() - .getEntityClassRenderObject(EntityItem.class); - - public RenderLogisticalTransporter() { - super(); - } + private Render renderer = Minecraft.getMinecraft().getRenderManager().getEntityClassRenderObject(EntityItem.class); public static void onStitch(TextureMap map) { cachedOverlays.clear(); @@ -52,8 +47,7 @@ public class RenderLogisticalTransporter extends RenderTransmitterBase> cachedLiquids = new HashMap<>(); - public RenderMechanicalPipe() { - super(); - } - public static void onStitch() { cachedLiquids.clear(); } @Override - public void render(TileEntityMechanicalPipe pipe, double x, double y, double z, float partialTick, int destroyStage, - float alpha) { + public void render(TileEntityMechanicalPipe pipe, double x, double y, double z, float partialTick, int destroyStage, float alpha) { if (MekanismConfig.current().client.opaqueTransmitters.val()) { return; } @@ -259,4 +254,4 @@ public class RenderMechanicalPipe extends RenderTransmitterBase { - public RenderPressurizedTube() { - super(); - } - @Override - public void render(TileEntityPressurizedTube tube, double x, double y, double z, float partialTick, - int destroyStage, float alpha) { + public void render(TileEntityPressurizedTube tube, double x, double y, double z, float partialTick, int destroyStage, float alpha) { if (MekanismConfig.current().client.opaqueTransmitters.val() || !tube.getTransmitter().hasTransmitterNetwork() - || tube.getTransmitter().getTransmitterNetwork().refGas == null - || tube.getTransmitter().getTransmitterNetwork().gasScale == 0) { + || tube.getTransmitter().getTransmitterNetwork().refGas == null || tube.getTransmitter().getTransmitterNetwork().gasScale == 0) { return; } @@ -50,4 +44,4 @@ public class RenderPressurizedTube extends RenderTransmitterBase { - public RenderThermodynamicConductor() { - super(); - } - @Override - public void render(TileEntityThermodynamicConductor transmitter, double x, double y, double z, float partialTick, - int destroyStage, float alpha) { + public void render(TileEntityThermodynamicConductor transmitter, double x, double y, double z, float partialTick, int destroyStage, float alpha) { if (MekanismConfig.current().client.opaqueTransmitters.val()) { return; } @@ -41,7 +36,6 @@ public class RenderThermodynamicConductor extends RenderTransmitterBase ext public RenderTransmitterBase() { if (contentsModel == null) { try { - contentsModel = (OBJModel) OBJLoader.INSTANCE - .loadModel(MekanismUtils.getResource(ResourceType.MODEL, "transmitter_contents.obj")); + contentsModel = (OBJModel) OBJLoader.INSTANCE.loadModel(MekanismUtils.getResource(ResourceType.MODEL, "transmitter_contents.obj")); contentsMap = buildModelMap(contentsModel); } catch (Exception e) { e.printStackTrace(); @@ -53,12 +52,10 @@ public abstract class RenderTransmitterBase ext if (!keys.isEmpty()) { for (String key : keys) { if (!modelParts.containsKey(key)) { - modelParts.put(key, objModel.bake(new OBJState(Collections.singletonList(key), false), - Attributes.DEFAULT_BAKED_FORMAT, textureGetterFlipV)); + modelParts.put(key, objModel.bake(new OBJState(Collections.singletonList(key), false), Attributes.DEFAULT_BAKED_FORMAT, textureGetterFlipV)); } } } - return modelParts; } @@ -98,7 +95,6 @@ public abstract class RenderTransmitterBase ext String sideName = side.name().toLowerCase(Locale.ROOT); String typeName = part.getConnectionType(side).name().toUpperCase(); String name = sideName + typeName; - return contentsMap.get(name); } @@ -120,4 +116,4 @@ public abstract class RenderTransmitterBase ext return (float) v / -16; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/transmitter/RenderUniversalCable.java b/src/main/java/mekanism/client/render/transmitter/RenderUniversalCable.java index c488229f6..48454a301 100644 --- a/src/main/java/mekanism/client/render/transmitter/RenderUniversalCable.java +++ b/src/main/java/mekanism/client/render/transmitter/RenderUniversalCable.java @@ -11,13 +11,8 @@ import org.lwjgl.opengl.GL11; public class RenderUniversalCable extends RenderTransmitterBase { - public RenderUniversalCable() { - super(); - } - @Override - public void render(TileEntityUniversalCable cable, double x, double y, double z, float partialTick, - int destroyStage, float alpha) { + public void render(TileEntityUniversalCable cable, double x, double y, double z, float partialTick, int destroyStage, float alpha) { if (MekanismConfig.current().client.opaqueTransmitters.val() || cable.currentPower == 0) { return; } @@ -41,7 +36,6 @@ public class RenderUniversalCable extends RenderTransmitterBase 0.0f) { // Not yet fully muted, fade down - if (volume > 0.0f) { - volume = Math.max(0.0f, (volume - fadeDownStep)); - } + volume = Math.max(0.0f, volume - fadeDownStep); } } @@ -77,4 +75,4 @@ public abstract class PlayerSound extends PositionedSound implements ITickableSo public float getVolume() { return (float) (super.getVolume() * MekanismConfig.current().client.baseSoundVolume.val()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/sound/SoundHandler.java b/src/main/java/mekanism/client/sound/SoundHandler.java index cd36ab69f..ad36d42dc 100644 --- a/src/main/java/mekanism/client/sound/SoundHandler.java +++ b/src/main/java/mekanism/client/sound/SoundHandler.java @@ -48,7 +48,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class SoundHandler { - private static IdentityHashMap jetpackSounds = new IdentityHashMap(); + private static IdentityHashMap jetpackSounds = new IdentityHashMap<>(); private static IdentityHashMap gasmaskSounds = new IdentityHashMap<>(); private static Map soundMap = new HashMap<>(); @@ -72,8 +72,7 @@ public class SoundHandler { } public static void playSound(SoundEvent sound) { - playSound(PositionedSoundRecord - .getRecord(sound, 1.0F, (float) MekanismConfig.current().client.baseSoundVolume.val())); + playSound(PositionedSoundRecord.getRecord(sound, 1.0F, (float) MekanismConfig.current().client.baseSoundVolume.val())); } public static void playSound(ISound sound) { @@ -85,10 +84,8 @@ public class SoundHandler { ISound s = soundMap.get(pos.toLong()); if (s == null || !Minecraft.getMinecraft().getSoundHandler().isSoundPlaying(s)) { // No sound playing, start one up - we assume that tile sounds will play until explicitly stopped - s = new PositionedSoundRecord(soundLoc, SoundCategory.BLOCKS, - (float) (volume * MekanismConfig.current().client.baseSoundVolume.val()), 1.0f, - true, 0, ISound.AttenuationType.LINEAR, - pos.getX() + 0.5f, pos.getY() + 0.5f, pos.getZ() + 0.5f); + s = new PositionedSoundRecord(soundLoc, SoundCategory.BLOCKS, (float) (volume * MekanismConfig.current().client.baseSoundVolume.val()), 1.0f, + true, 0, ISound.AttenuationType.LINEAR, pos.getX() + 0.5f, pos.getY() + 0.5f, pos.getZ() + 0.5f); // Force the underlying sound to get initialized // TODO: Understand what this is doing exactly @@ -152,8 +149,7 @@ public class SoundHandler { // Finally, update our soundMap so that we can actually have a shot at stopping this sound; note that we also // need to "unoffset" the sound position so that we build the correct key for the sound map // Aside: I really, really, wish Forge returned the final result sound as part of playSound :/ - BlockPos pos = new BlockPos(resultSound.getXPosF() - 0.5f, resultSound.getYPosF() - 0.5f, - resultSound.getZPosF() - 0.5); + BlockPos pos = new BlockPos(resultSound.getXPosF() - 0.5f, resultSound.getYPosF() - 0.5f, resultSound.getZPosF() - 0.5); soundMap.put(pos.toLong(), resultSound); } @@ -203,8 +199,7 @@ public class SoundHandler { private float getMufflingFactor() { // Pull the TE from the sound position and see if supports muffling upgrades. If it does, calculate what // percentage of the original volume should be muted - TileEntity te = mc.world - .getTileEntity(new BlockPos(original.getXPosF(), original.getYPosF(), original.getZPosF())); + TileEntity te = mc.world.getTileEntity(new BlockPos(original.getXPosF(), original.getYPosF(), original.getZPosF())); if (te instanceof IUpgradeTile && ((IUpgradeTile) te).getComponent().supports(Upgrade.MUFFLING)) { int mufflerCount = ((IUpgradeTile) te).getComponent().getUpgrades(Upgrade.MUFFLING); return 1.0f - (mufflerCount / (float) Upgrade.MUFFLING.getMax()); @@ -281,7 +276,5 @@ public class SoundHandler { public AttenuationType getAttenuationType() { return original.getAttenuationType(); } - - } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/sound/TileSound.java b/src/main/java/mekanism/client/sound/TileSound.java index 974092dd7..f17f31187 100644 --- a/src/main/java/mekanism/client/sound/TileSound.java +++ b/src/main/java/mekanism/client/sound/TileSound.java @@ -1,5 +1,4 @@ package mekanism.client.sound; public class TileSound { - -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/client/voice/VoiceInput.java b/src/main/java/mekanism/client/voice/VoiceInput.java index ffe7054cd..391d4e435 100644 --- a/src/main/java/mekanism/client/voice/VoiceInput.java +++ b/src/main/java/mekanism/client/voice/VoiceInput.java @@ -31,7 +31,7 @@ public class VoiceInput extends Thread { Mekanism.logger.info("No audio system available."); return; } - targetLine = ((TargetDataLine) AudioSystem.getLine(microphone)); + targetLine = (TargetDataLine) AudioSystem.getLine(microphone); targetLine.open(voiceClient.getAudioFormat(), 2200); targetLine.start(); AudioInputStream audioInput = new AudioInputStream(targetLine); diff --git a/src/main/java/mekanism/client/voice/VoiceOutput.java b/src/main/java/mekanism/client/voice/VoiceOutput.java index 729a0571c..f5bad07ee 100644 --- a/src/main/java/mekanism/client/voice/VoiceOutput.java +++ b/src/main/java/mekanism/client/voice/VoiceOutput.java @@ -26,7 +26,7 @@ public class VoiceOutput extends Thread { @Override public void run() { try { - sourceLine = ((SourceDataLine) AudioSystem.getLine(speaker)); + sourceLine = (SourceDataLine) AudioSystem.getLine(speaker); sourceLine.open(voiceClient.getAudioFormat(), 2200); sourceLine.start(); byte[] audioData = new byte[4096]; //less allocation/gc (if done outside the loop) diff --git a/src/main/java/mekanism/common/BoxBlacklistParser.java b/src/main/java/mekanism/common/BoxBlacklistParser.java index 82e3b40e8..615aaebaf 100644 --- a/src/main/java/mekanism/common/BoxBlacklistParser.java +++ b/src/main/java/mekanism/common/BoxBlacklistParser.java @@ -28,7 +28,6 @@ public final class BoxBlacklistParser { private static void generateFiles() throws IOException { mekanismDir.mkdirs(); - if (!boxBlacklistFile.exists()) { boxBlacklistFile.createNewFile(); writeExamples(); @@ -45,38 +44,31 @@ public final class BoxBlacklistParser { } private static void readBlacklist() throws IOException { - try (BufferedReader reader = new BufferedReader(new FileReader((boxBlacklistFile)))) { + try (BufferedReader reader = new BufferedReader(new FileReader(boxBlacklistFile))) { int entries = 0; - String readingLine; int line = 0; while ((readingLine = reader.readLine()) != null) { line++; - if (readingLine.startsWith("#") || readingLine.trim().isEmpty()) { continue; } String[] split = readingLine.split(" "); - if (split.length != 2 || !isInteger(split[split.length - 1])) { Mekanism.logger.error("BoxBlacklist.txt: Couldn't parse blacklist data on line " + line); continue; } String blockName = split[0].trim(); - Block block = Block.getBlockFromName(blockName); - if (block == null) { Mekanism.logger.error("BoxBlacklist.txt: Couldn't find specified block on line " + line); continue; } - MekanismAPI.addBoxBlacklist(block, Integer.parseInt(split[split.length - 1])); entries++; - } Mekanism.logger.info("Finished loading Cardboard Box blacklist (loaded " + entries + " entries)"); } @@ -84,14 +76,11 @@ public final class BoxBlacklistParser { private static void writeExamples() throws IOException { try (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 \"NAME META\". Example (for stone):"); writer.newLine(); - writer.append("# minecraft:stone 0"); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/ColourRGBA.java b/src/main/java/mekanism/common/ColourRGBA.java index f3518c35c..112468618 100644 --- a/src/main/java/mekanism/common/ColourRGBA.java +++ b/src/main/java/mekanism/common/ColourRGBA.java @@ -34,4 +34,4 @@ public class ColourRGBA { valG = (byte) ((color >> 8) & 0xFF); valB = (byte) (color & 0xFF); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/CommonPlayerTickHandler.java b/src/main/java/mekanism/common/CommonPlayerTickHandler.java index 67344794a..297b5d8b7 100644 --- a/src/main/java/mekanism/common/CommonPlayerTickHandler.java +++ b/src/main/java/mekanism/common/CommonPlayerTickHandler.java @@ -28,12 +28,10 @@ public class CommonPlayerTickHandler { int x = MathHelper.floor(player.posX); int y = MathHelper.floor(player.posY - 0.01); int z = MathHelper.floor(player.posZ); - BlockPos pos = new BlockPos(x, y, z); IBlockState s = player.world.getBlockState(pos); AxisAlignedBB box = s.getBoundingBox(player.world, pos).offset(pos); AxisAlignedBB playerBox = player.getEntityBoundingBox(); - return !s.getBlock().isAir(s, player.world, pos) && playerBox.offset(0, -0.01, 0).intersects(box); } @@ -41,26 +39,21 @@ public class CommonPlayerTickHandler { public static boolean isGasMaskOn(EntityPlayer player) { ItemStack tank = player.inventory.armorInventory.get(2); ItemStack mask = player.inventory.armorInventory.get(3); - if (!tank.isEmpty() && !mask.isEmpty()) { if (tank.getItem() instanceof ItemScubaTank && mask.getItem() instanceof ItemGasMask) { ItemScubaTank scubaTank = (ItemScubaTank) tank.getItem(); - if (scubaTank.getGas(tank) != null) { return scubaTank.getFlowing(tank); } } } - return false; } public static boolean isFlamethrowerOn(EntityPlayer player) { if (Mekanism.playerState.isFlamethrowerOn(player)) { - return !player.inventory.getCurrentItem().isEmpty() && player.inventory.getCurrentItem() - .getItem() instanceof ItemFlamethrower; + return !player.inventory.getCurrentItem().isEmpty() && player.inventory.getCurrentItem().getItem() instanceof ItemFlamethrower; } - return false; } @@ -73,7 +66,6 @@ public class CommonPlayerTickHandler { public void tickEnd(EntityPlayer player) { ItemStack feetStack = player.getItemStackFromSlot(EntityEquipmentSlot.FEET); - if (!feetStack.isEmpty() && feetStack.getItem() instanceof ItemFreeRunners && !player.isSneaking()) { player.stepHeight = 1.002F; } else if (player.stepHeight == 1.002F) { @@ -82,17 +74,14 @@ public class CommonPlayerTickHandler { if (isFlamethrowerOn(player)) { player.world.spawnEntity(new EntityFlame(player)); - if (!(player.isCreative() || player.isSpectator())) { - ((ItemFlamethrower) player.inventory.getCurrentItem().getItem()) - .useGas(player.inventory.getCurrentItem()); + ((ItemFlamethrower) player.inventory.getCurrentItem().getItem()).useGas(player.inventory.getCurrentItem()); } } if (isJetpackOn(player)) { ItemStack stack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); ItemJetpack jetpack = (ItemJetpack) stack.getItem(); - if (jetpack.getMode(stack) == JetpackMode.NORMAL) { player.motionY = Math.min(player.motionY + 0.15D, 0.5D); } else if (jetpack.getMode(stack) == JetpackMode.HOVER) { @@ -105,39 +94,30 @@ public class CommonPlayerTickHandler { player.motionY = Math.min(player.motionY + 0.15D, 0); } } - } else { - if (Mekanism.keyMap.has(player, KeySync.ASCEND)) { - player.motionY = Math.min(player.motionY + 0.15D, 0.2D); - } else if (Mekanism.keyMap.has(player, KeySync.DESCEND)) { - if (!isOnGround(player)) { - player.motionY = Math.max(player.motionY - 0.15D, -0.2D); - } + } else if (Mekanism.keyMap.has(player, KeySync.ASCEND)) { + player.motionY = Math.min(player.motionY + 0.15D, 0.2D); + } else if (Mekanism.keyMap.has(player, KeySync.DESCEND)) { + if (!isOnGround(player)) { + player.motionY = Math.max(player.motionY - 0.15D, -0.2D); } } } - player.fallDistance = 0.0F; - if (player instanceof EntityPlayerMP) { ((EntityPlayerMP) player).connection.floatingTickCount = 0; } - jetpack.useGas(stack); } if (isGasMaskOn(player)) { ItemStack stack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); ItemScubaTank tank = (ItemScubaTank) stack.getItem(); - final int max = 300; - tank.useGas(stack); GasStack received = tank.useGas(stack, max - player.getAir()); - if (received != null) { player.setAir(player.getAir() + received.amount); } - if (player.getAir() == max) { for (Object obj : player.getActivePotionEffects()) { if (obj instanceof PotionEffect) { @@ -152,29 +132,24 @@ public class CommonPlayerTickHandler { public boolean isJetpackOn(EntityPlayer player) { ItemStack stack = player.inventory.armorInventory.get(2); - if (!stack.isEmpty() && !(player.isCreative() || player.isSpectator())) { 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)) { + if (Mekanism.keyMap.has(player, KeySync.ASCEND) && jetpack.getMode(stack) == JetpackMode.NORMAL) { return true; } else if (jetpack.getMode(stack) == JetpackMode.HOVER) { - if ((!Mekanism.keyMap.has(player, KeySync.ASCEND) && !Mekanism.keyMap - .has(player, KeySync.DESCEND)) || (Mekanism.keyMap.has(player, KeySync.ASCEND) - && Mekanism.keyMap.has(player, KeySync.DESCEND))) { + if ((!Mekanism.keyMap.has(player, KeySync.ASCEND) && !Mekanism.keyMap.has(player, KeySync.DESCEND)) || + (Mekanism.keyMap.has(player, KeySync.ASCEND) && Mekanism.keyMap.has(player, KeySync.DESCEND))) { return !isOnGround(player); } else if (Mekanism.keyMap.has(player, KeySync.DESCEND)) { return !isOnGround(player); } - return true; } } } } - return false; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/CommonPlayerTracker.java b/src/main/java/mekanism/common/CommonPlayerTracker.java index 2b82b52d9..5bd17cf1c 100644 --- a/src/main/java/mekanism/common/CommonPlayerTracker.java +++ b/src/main/java/mekanism/common/CommonPlayerTracker.java @@ -27,21 +27,15 @@ public class CommonPlayerTracker { MinecraftServer server = event.player.getServer(); if (!event.player.world.isRemote) { if (server == null || !server.isSinglePlayer()) { - Mekanism.packetHandler - .sendTo(new ConfigSyncMessage(MekanismConfig.local()), (EntityPlayerMP) event.player); + Mekanism.packetHandler.sendTo(new ConfigSyncMessage(MekanismConfig.local()), (EntityPlayerMP) event.player); Mekanism.logger.info("Sent config to '" + event.player.getDisplayNameString() + ".'"); } Mekanism.packetHandler.sendTo(new BoxBlacklistMessage(), (EntityPlayerMP) event.player); // TODO: Coalesce all these sync events into a single message - Mekanism.packetHandler.sendTo(JetpackDataMessage.FULL(Mekanism.playerState.getActiveJetpacks()), - (EntityPlayerMP) event.player); - Mekanism.packetHandler.sendTo(ScubaTankDataMessage.FULL(Mekanism.playerState.getActiveGasmasks()), - (EntityPlayerMP) event.player); - Mekanism.packetHandler - .sendTo(new SecurityUpdateMessage(SecurityPacket.FULL, null, null), (EntityPlayerMP) event.player); - Mekanism.packetHandler.sendTo( - new PacketFreeRunnerData.FreeRunnerDataMessage(PacketFreeRunnerData.FreeRunnerPacket.FULL, null, - false), (EntityPlayerMP) event.player); + Mekanism.packetHandler.sendTo(JetpackDataMessage.FULL(Mekanism.playerState.getActiveJetpacks()), (EntityPlayerMP) event.player); + Mekanism.packetHandler.sendTo(ScubaTankDataMessage.FULL(Mekanism.playerState.getActiveGasmasks()), (EntityPlayerMP) event.player); + Mekanism.packetHandler.sendTo(new SecurityUpdateMessage(SecurityPacket.FULL, null, null), (EntityPlayerMP) event.player); + Mekanism.packetHandler.sendTo(new PacketFreeRunnerData.FreeRunnerDataMessage(PacketFreeRunnerData.FreeRunnerPacket.FULL, null, false), (EntityPlayerMP) event.player); } } @@ -55,15 +49,10 @@ public class CommonPlayerTracker { public void onPlayerDimChangedEvent(PlayerChangedDimensionEvent event) { Mekanism.playerState.clearPlayer(event.player); Mekanism.freeRunnerOn.remove(event.player.getUniqueID()); - if (!event.player.world.isRemote) { - Mekanism.packetHandler.sendTo(JetpackDataMessage.FULL(Mekanism.playerState.getActiveJetpacks()), - (EntityPlayerMP) event.player); - Mekanism.packetHandler.sendTo(ScubaTankDataMessage.FULL(Mekanism.playerState.getActiveGasmasks()), - (EntityPlayerMP) event.player); - Mekanism.packetHandler.sendTo( - new PacketFreeRunnerData.FreeRunnerDataMessage(PacketFreeRunnerData.FreeRunnerPacket.FULL, null, - false), (EntityPlayerMP) event.player); + Mekanism.packetHandler.sendTo(JetpackDataMessage.FULL(Mekanism.playerState.getActiveJetpacks()), (EntityPlayerMP) event.player); + Mekanism.packetHandler.sendTo(ScubaTankDataMessage.FULL(Mekanism.playerState.getActiveGasmasks()), (EntityPlayerMP) event.player); + Mekanism.packetHandler.sendTo(new PacketFreeRunnerData.FreeRunnerDataMessage(PacketFreeRunnerData.FreeRunnerPacket.FULL, null, false), (EntityPlayerMP) event.player); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/CommonProxy.java b/src/main/java/mekanism/common/CommonProxy.java index 34555e77e..3d64fc862 100644 --- a/src/main/java/mekanism/common/CommonProxy.java +++ b/src/main/java/mekanism/common/CommonProxy.java @@ -8,7 +8,6 @@ import mekanism.api.Pos3D; import mekanism.client.SparkleAnimation.INodeChecker; import mekanism.common.base.IGuiProvider; import mekanism.common.base.IUpgradeTile; -import mekanism.common.block.states.BlockStateMachine; import mekanism.common.block.states.BlockStateMachine.MachineType; import mekanism.common.config.MekanismConfig; import mekanism.common.entity.EntityRobit; @@ -119,7 +118,7 @@ import net.minecraftforge.oredict.OreDictionary; public class CommonProxy implements IGuiProvider { protected final String[] API_PRESENT_MESSAGE = {"Mekanism API jar detected (Mekanism--api.jar),", - "please delete it from your mods folder and restart the game."}; + "please delete it from your mods folder and restart the game."}; /** * Register tile entities that have special models. Overwritten in client to register TESRs. @@ -134,13 +133,12 @@ public class CommonProxy implements IGuiProvider { * Handles an PERSONAL_CHEST_CLIENT_OPEN packet via the proxy, not handled on the server-side. * * @param entityplayer - player the packet was sent from - * @param id - the gui ID to open - * @param windowId - the container-specific window ID - * @param isBlock - if the chest is a block - * @param pos - coordinates + * @param id - the gui ID to open + * @param windowId - the container-specific window ID + * @param isBlock - if the chest is a block + * @param pos - coordinates */ - public void openPersonalChest(EntityPlayer entityplayer, int id, int windowId, boolean isBlock, BlockPos pos, - EnumHand hand) { + public void openPersonalChest(EntityPlayer entityplayer, int id, int windowId, boolean isBlock, BlockPos pos, EnumHand hand) { } /** @@ -162,7 +160,6 @@ public class CommonProxy implements IGuiProvider { MekanismConfig.local().general.load(Mekanism.configuration); MekanismConfig.local().usage.load(Mekanism.configuration); MekanismConfig.local().storage.load(Mekanism.configuration); - if (Mekanism.configuration.hasChanged()) { Mekanism.configuration.save(); } @@ -197,8 +194,7 @@ public class CommonProxy implements IGuiProvider { /** * Does the multiblock creation animation, starting from the rendering block. */ - public void doMultiblockSparkle(TileEntity tileEntity, BlockPos renderLoc, int length, int width, int height, - INodeChecker checker) { + public void doMultiblockSparkle(TileEntity tileEntity, BlockPos renderLoc, int length, int width, int height, INodeChecker checker) { } @Override @@ -209,7 +205,6 @@ public class CommonProxy implements IGuiProvider { @Override public Container getServerGui(int ID, EntityPlayer player, World world, BlockPos pos) { TileEntity tileEntity = world.getTileEntity(pos); - switch (ID) { case 0: return new ContainerDictionary(player.inventory); @@ -218,16 +213,13 @@ public class CommonProxy implements IGuiProvider { case 3: return new ContainerElectricMachine(player.inventory, (TileEntityElectricMachine) tileEntity); case 4: - return new ContainerAdvancedElectricMachine(player.inventory, - (TileEntityAdvancedElectricMachine) tileEntity); + return new ContainerAdvancedElectricMachine(player.inventory, (TileEntityAdvancedElectricMachine) tileEntity); case 5: - return new ContainerDoubleElectricMachine(player.inventory, - (TileEntityDoubleElectricMachine) tileEntity); + return new ContainerDoubleElectricMachine(player.inventory, (TileEntityDoubleElectricMachine) tileEntity); case 6: return new ContainerElectricMachine(player.inventory, (TileEntityElectricMachine) tileEntity); case 7: - return new ContainerRotaryCondensentrator(player.inventory, - (TileEntityRotaryCondensentrator) tileEntity); + return new ContainerRotaryCondensentrator(player.inventory, (TileEntityRotaryCondensentrator) tileEntity); case 8: return new ContainerEnergyCube(player.inventory, (TileEntityEnergyCube) tileEntity); case 9: @@ -242,15 +234,12 @@ public class CommonProxy implements IGuiProvider { return new ContainerTeleporter(player.inventory, (TileEntityTeleporter) tileEntity); case 14: ItemStack itemStack = player.getHeldItem(EnumHand.values()[pos.getX()]); - if (!itemStack.isEmpty() && itemStack.getItem() instanceof ItemPortableTeleporter) { return new ContainerNull(); } - return null; case 15: - return new ContainerAdvancedElectricMachine(player.inventory, - (TileEntityAdvancedElectricMachine) tileEntity); + return new ContainerAdvancedElectricMachine(player.inventory, (TileEntityAdvancedElectricMachine) tileEntity); case 16: return new ContainerElectricMachine(player.inventory, (TileEntityElectricMachine) tileEntity); case 17: @@ -259,43 +248,33 @@ public class CommonProxy implements IGuiProvider { return new ContainerDynamicTank(player.inventory, (TileEntityDynamicTank) tileEntity); case 21: EntityRobit robit = (EntityRobit) world.getEntityByID(pos.getX()); - if (robit != null) { return new ContainerRobitMain(player.inventory, robit); } - return null; case 22: robit = (EntityRobit) world.getEntityByID(pos.getX()); - if (robit != null) { return new ContainerRobitCrafting(player.inventory, robit); } - return null; case 23: robit = (EntityRobit) world.getEntityByID(pos.getX()); - if (robit != null) { return new ContainerRobitInventory(player.inventory, robit); } - return null; case 24: robit = (EntityRobit) world.getEntityByID(pos.getX()); - if (robit != null) { return new ContainerRobitSmelting(player.inventory, robit); } - return null; case 25: robit = (EntityRobit) world.getEntityByID(pos.getX()); - if (robit != null) { return new ContainerRobitRepair(player.inventory, robit); } - return null; case 26: return new ContainerNull(player, (TileEntityContainerBlock) tileEntity); @@ -308,19 +287,15 @@ public class CommonProxy implements IGuiProvider { case 30: return new ContainerChemicalInfuser(player.inventory, (TileEntityChemicalInfuser) tileEntity); case 31: - return new ContainerAdvancedElectricMachine(player.inventory, - (TileEntityAdvancedElectricMachine) tileEntity); + return new ContainerAdvancedElectricMachine(player.inventory, (TileEntityAdvancedElectricMachine) tileEntity); case 32: - return new ContainerElectrolyticSeparator(player.inventory, - (TileEntityElectrolyticSeparator) tileEntity); + return new ContainerElectrolyticSeparator(player.inventory, (TileEntityElectrolyticSeparator) tileEntity); case 33: - return new ContainerThermalEvaporationController(player.inventory, - (TileEntityThermalEvaporationController) tileEntity); + return new ContainerThermalEvaporationController(player.inventory, (TileEntityThermalEvaporationController) tileEntity); case 34: return new ContainerChanceMachine(player.inventory, (TileEntityChanceMachine) tileEntity); case 35: - return new ContainerChemicalDissolutionChamber(player.inventory, - (TileEntityChemicalDissolutionChamber) tileEntity); + return new ContainerChemicalDissolutionChamber(player.inventory, (TileEntityChemicalDissolutionChamber) tileEntity); case 36: return new ContainerChemicalWasher(player.inventory, (TileEntityChemicalWasher) tileEntity); case 37: @@ -340,11 +315,9 @@ public class CommonProxy implements IGuiProvider { case 45: return new ContainerLaserTractorBeam(player.inventory, (TileEntityLaserTractorBeam) tileEntity); case 46: - return new ContainerQuantumEntangloporter(player.inventory, - (TileEntityQuantumEntangloporter) tileEntity); + return new ContainerQuantumEntangloporter(player.inventory, (TileEntityQuantumEntangloporter) tileEntity); case 47: - return new ContainerSolarNeutronActivator(player.inventory, - (TileEntitySolarNeutronActivator) tileEntity); + return new ContainerSolarNeutronActivator(player.inventory, (TileEntitySolarNeutronActivator) tileEntity); case 48: return new ContainerNull(player, (TileEntityContainerBlock) tileEntity); case 49: @@ -362,8 +335,7 @@ public class CommonProxy implements IGuiProvider { case 55: return new ContainerNull(player, (TileEntityContainerBlock) tileEntity); case 56: - return new ContainerFormulaicAssemblicator(player.inventory, - (TileEntityFormulaicAssemblicator) tileEntity); + return new ContainerFormulaicAssemblicator(player.inventory, (TileEntityFormulaicAssemblicator) tileEntity); case 57: return new ContainerSecurityDesk(player.inventory, (TileEntitySecurityDesk) tileEntity); case 58: @@ -371,7 +343,6 @@ public class CommonProxy implements IGuiProvider { case 59: return new ContainerNull(player, (TileEntityContainerBlock) tileEntity); } - return null; } @@ -382,7 +353,6 @@ public class CommonProxy implements IGuiProvider { if (player instanceof EntityPlayerMP) { return player.getEntityAttribute(EntityPlayer.REACH_DISTANCE).getAttributeValue(); } - return 0; } @@ -401,7 +371,6 @@ public class CommonProxy implements IGuiProvider { } else { MekanismAPI.addBoxBlacklist(Blocks.MOB_SPAWNER, OreDictionary.WILDCARD_VALUE); } - if (MekanismConfig.current().general.voiceServerEnabled.val() && Mekanism.voiceManager == null) { Mekanism.voiceManager = new VoiceServerManager(); } @@ -440,7 +409,6 @@ public class CommonProxy implements IGuiProvider { } else if (block == MekanismBlocks.EnergyCube) { return 8; } - return -1; } @@ -454,4 +422,4 @@ public class CommonProxy implements IGuiProvider { public void throwApiPresentException() { throw new RuntimeException(String.join(" ", API_PRESENT_MESSAGE)); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/CommonWorldTickHandler.java b/src/main/java/mekanism/common/CommonWorldTickHandler.java index b64202267..50e6e38c1 100644 --- a/src/main/java/mekanism/common/CommonWorldTickHandler.java +++ b/src/main/java/mekanism/common/CommonWorldTickHandler.java @@ -24,15 +24,12 @@ public class CommonWorldTickHandler { if (chunkRegenMap == null) { chunkRegenMap = new HashMap<>(); } - if (!chunkRegenMap.containsKey(dimensionId)) { LinkedList list = new LinkedList<>(); list.add(chunkCoord); chunkRegenMap.put(dimensionId, list); - } else { - if (!chunkRegenMap.get(dimensionId).contains(chunkCoord)) { - chunkRegenMap.get(dimensionId).add(chunkCoord); - } + } else if (!chunkRegenMap.get(dimensionId).contains(chunkCoord)) { + chunkRegenMap.get(dimensionId).add(chunkCoord); } } @@ -65,13 +62,11 @@ public class CommonWorldTickHandler { if (!world.isRemote) { MultiblockManager.tick(world); FrequencyManager.tick(world); - if (chunkRegenMap == null) { return; } int dimensionId = world.provider.getDimension(); - //Credit to E. Beef if (chunkRegenMap.containsKey(dimensionId)) { Queue chunksToGen = chunkRegenMap.get(dimensionId); @@ -79,7 +74,6 @@ public class CommonWorldTickHandler { while (System.nanoTime() - startTime < maximumDeltaTimeNanoSecs && !chunksToGen.isEmpty()) { ChunkPos nextChunk = chunksToGen.poll(); - if (nextChunk == null) { break; } @@ -88,16 +82,13 @@ public class CommonWorldTickHandler { long xSeed = fmlRandom.nextLong() >> 2 + 1L; long zSeed = fmlRandom.nextLong() >> 2 + 1L; fmlRandom.setSeed((xSeed * nextChunk.x + zSeed * nextChunk.z) ^ world.getSeed()); - - Mekanism.genHandler.generate(fmlRandom, nextChunk.x, nextChunk.z, world, - ((ChunkProviderServer) world.getChunkProvider()).chunkGenerator, world.getChunkProvider()); + Mekanism.genHandler.generate(fmlRandom, nextChunk.x, nextChunk.z, world, ((ChunkProviderServer) world.getChunkProvider()).chunkGenerator, world.getChunkProvider()); Mekanism.logger.info("Regenerating ores at chunk " + nextChunk); } - if (chunksToGen.isEmpty()) { chunkRegenMap.remove(dimensionId); } } } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/CoreGuiHandler.java b/src/main/java/mekanism/common/CoreGuiHandler.java index 8db64dad9..8e03ddab7 100644 --- a/src/main/java/mekanism/common/CoreGuiHandler.java +++ b/src/main/java/mekanism/common/CoreGuiHandler.java @@ -6,8 +6,7 @@ import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; /** - * Client and server GUI hander for Mekanism. Uses CommonProxy to get the server GUI and ClientProxy for the client - * GUI. + * Client and server GUI hander for Mekanism. Uses CommonProxy to get the server GUI and ClientProxy for the client GUI. * * @author AidanBrady */ @@ -22,4 +21,4 @@ public class CoreGuiHandler implements IGuiHandler { public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { return Mekanism.proxy.getClientGui(ID, player, world, new BlockPos(x, y, z)); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/CreativeTabMekanism.java b/src/main/java/mekanism/common/CreativeTabMekanism.java index d044a33fa..b95744e0e 100644 --- a/src/main/java/mekanism/common/CreativeTabMekanism.java +++ b/src/main/java/mekanism/common/CreativeTabMekanism.java @@ -15,4 +15,4 @@ public class CreativeTabMekanism extends CreativeTabs { public ItemStack createIcon() { return new ItemStack(MekanismItems.AtomicAlloy); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/FluidSlot.java b/src/main/java/mekanism/common/FluidSlot.java index 7c47b7065..3b196f895 100644 --- a/src/main/java/mekanism/common/FluidSlot.java +++ b/src/main/java/mekanism/common/FluidSlot.java @@ -26,7 +26,7 @@ public class FluidSlot { * Creates a FluidSlot with a defined fluid ID and max fluid. The fluid stored starts at 0. * * @param max - max fluid - * @param id - fluid id + * @param id - fluid id */ public FluidSlot(int max, int id) { MAX_FLUID = max; @@ -41,4 +41,4 @@ public class FluidSlot { public void setFluid(int amount) { fluidStored = Math.max(Math.min(amount, MAX_FLUID), 0); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/FuelHandler.java b/src/main/java/mekanism/common/FuelHandler.java index 393efc260..1c39ca415 100644 --- a/src/main/java/mekanism/common/FuelHandler.java +++ b/src/main/java/mekanism/common/FuelHandler.java @@ -23,25 +23,20 @@ public class FuelHandler { if (fuels.containsKey(gas.getName())) { return fuels.get(gas.getName()); } - if (BCPresent() && gas.hasFluid() && BuildcraftFuelRegistry.fuel != null) { IFuel bcFuel = BuildcraftFuelRegistry.fuel.getFuel(new FluidStack(gas.getFluid(), 1)); - if (bcFuel != null) { FuelGas fuel = new FuelGas(bcFuel); fuels.put(gas.getName(), fuel); - return fuel; } } - return null; } public static boolean BCPresent() { - return ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|fuels") && MekanismUtils - .classExists("buildcraft.api.fuels.BuildcraftFuelRegistry") && MekanismUtils - .classExists("buildcraft.api.fuels.IFuel"); + return ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|fuels") && MekanismUtils.classExists("buildcraft.api.fuels.BuildcraftFuelRegistry") && + MekanismUtils.classExists("buildcraft.api.fuels.IFuel"); } public static class FuelGas { @@ -59,8 +54,7 @@ public class FuelHandler { // getPowerPerCycle returns value in 1 BuildCraft micro MJ // 1 BuildCraft MJ equals 20 RF - energyPerTick = - bcFuel.getPowerPerCycle() / (double) MjAPI.MJ * 20 * MekanismConfig.current().general.FROM_RF.val(); + energyPerTick = bcFuel.getPowerPerCycle() / (double) MjAPI.MJ * 20 * MekanismConfig.current().general.FROM_RF.val(); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/HashList.java b/src/main/java/mekanism/common/HashList.java index 2d006d484..da6fec17a 100644 --- a/src/main/java/mekanism/common/HashList.java +++ b/src/main/java/mekanism/common/HashList.java @@ -27,7 +27,6 @@ public class HashList implements Iterable { if (index > size() - 1) { return null; } - return list.get(index); } @@ -44,7 +43,6 @@ public class HashList implements Iterable { list.add(i, null); } } - list.add(index, obj); } } @@ -57,7 +55,6 @@ public class HashList implements Iterable { if (isEmpty() || index > size() - 1) { return; } - list.remove(index); } @@ -65,7 +62,6 @@ public class HashList implements Iterable { if (get(index) != null) { remove(index); } - add(index, obj); } @@ -97,7 +93,6 @@ public class HashList implements Iterable { if (source >= list.size() || target >= list.size()) { return; } - // Perform swap T temp = list.get(source); list.set(source, list.get(target)); @@ -119,4 +114,4 @@ public class HashList implements Iterable { public Iterator iterator() { return list.iterator(); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/KeySync.java b/src/main/java/mekanism/common/KeySync.java index a38c2908e..fb58981bd 100644 --- a/src/main/java/mekanism/common/KeySync.java +++ b/src/main/java/mekanism/common/KeySync.java @@ -22,7 +22,6 @@ public class KeySync { keys.put(player, new KeySet(key)); return; } - keys.get(player).keysActive.add(key); } @@ -30,7 +29,6 @@ public class KeySync { if (!keys.containsKey(player)) { return; } - keys.get(player).keysActive.remove(key); } @@ -38,7 +36,6 @@ public class KeySync { if (!keys.containsKey(player)) { return false; } - return keys.get(player).keysActive.contains(key); } @@ -58,4 +55,4 @@ public class KeySync { keysActive.add(key); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/LaserManager.java b/src/main/java/mekanism/common/LaserManager.java index aced196f5..21a046813 100644 --- a/src/main/java/mekanism/common/LaserManager.java +++ b/src/main/java/mekanism/common/LaserManager.java @@ -32,40 +32,31 @@ public class LaserManager { public static LaserInfo fireLaser(Pos3D from, EnumFacing direction, double energy, World world) { Pos3D to = from.clone().translate(direction, MekanismConfig.current().general.laserRange.val() - 0.002); - RayTraceResult mop = world.rayTraceBlocks(from, to); - if (mop != null) { to = new Pos3D(mop.hitVec); Coord4D toCoord = new Coord4D(mop.getBlockPos(), world); TileEntity tile = toCoord.getTileEntity(world); - if (isReceptor(tile, mop.sideHit)) { ILaserReceptor receptor = getReceptor(tile, mop.sideHit); - - if (!(receptor.canLasersDig())) { + if (!receptor.canLasersDig()) { receptor.receiveLaserEnergy(energy, mop.sideHit); } } } - from.translateExcludingSide(direction, -0.1); to.translateExcludingSide(direction, 0.1); boolean foundEntity = false; - for (Entity e : world.getEntitiesWithinAABB(Entity.class, Pos3D.getAABB(from, to))) { foundEntity = true; - if (!e.isImmuneToFire()) { e.setFire((int) (energy / 1000)); } - if (energy > 256) { e.attackEntityFrom(DamageSource.GENERIC, (float) energy / 1000F); } } - return new LaserInfo(mop, foundEntity); } @@ -76,15 +67,12 @@ public class LaserManager { IBlockState state = blockCoord.getBlockState(world); Block blockHit = state.getBlock(); - EntityPlayer dummy = Mekanism.proxy.getDummyPlayer((WorldServer) world, laserPos).get(); BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, blockCoord.getPos(), state, dummy); MinecraftForge.EVENT_BUS.post(event); - if (event.isCanceled()) { return null; } - NonNullList ret = null; if (dropAtBlock) { blockHit.dropBlockAsItem(world, blockCoord.getPos(), state, 0); @@ -92,11 +80,9 @@ public class LaserManager { ret = NonNullList.create(); blockHit.getDrops(ret, world, blockCoord.getPos(), state, 0); } - blockHit.breakBlock(world, blockCoord.getPos(), state); world.setBlockToAir(blockCoord.getPos()); world.playEvent(WorldEvents.BREAK_BLOCK_EFFECTS, blockCoord.getPos(), Block.getStateId(state)); - return ret; } @@ -107,14 +93,11 @@ public class LaserManager { public static RayTraceResult fireLaserClient(Pos3D from, EnumFacing direction, double energy, World world) { Pos3D to = from.clone().translate(direction, MekanismConfig.current().general.laserRange.val() - 0.002); RayTraceResult mop = world.rayTraceBlocks(from, to); - if (mop != null) { to = new Pos3D(mop.hitVec); } - from.translate(direction, -0.501); Mekanism.proxy.renderLaser(world, from, to, direction, energy); - return mop; } diff --git a/src/main/java/mekanism/common/MekFakePlayer.java b/src/main/java/mekanism/common/MekFakePlayer.java index e67c0482c..20bdcf519 100644 --- a/src/main/java/mekanism/common/MekFakePlayer.java +++ b/src/main/java/mekanism/common/MekFakePlayer.java @@ -64,4 +64,4 @@ public class MekFakePlayer extends FakePlayer { public boolean isPotionApplicable(@Nonnull PotionEffect effect) { return false; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/Mekanism.java b/src/main/java/mekanism/common/Mekanism.java index 0a31b30b3..067bdec51 100644 --- a/src/main/java/mekanism/common/Mekanism.java +++ b/src/main/java/mekanism/common/Mekanism.java @@ -185,8 +185,7 @@ import net.minecraftforge.oredict.OreDictionary; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -@Mod(modid = Mekanism.MODID, useMetadata = true, guiFactory = "mekanism.client.gui.ConfigGuiFactory", - acceptedMinecraftVersions = "[1.12,1.13)", version = "${version}") +@Mod(modid = Mekanism.MODID, useMetadata = true, guiFactory = "mekanism.client.gui.ConfigGuiFactory", acceptedMinecraftVersions = "[1.12,1.13)", version = "${version}") @Mod.EventBusSubscriber() public class Mekanism { @@ -237,11 +236,9 @@ public class Mekanism { */ public static FrequencyManager publicTeleporters = new FrequencyManager(Frequency.class, Frequency.TELEPORTER); public static Map privateTeleporters = new HashMap<>(); - public static FrequencyManager publicEntangloporters = new FrequencyManager(InventoryFrequency.class, - InventoryFrequency.ENTANGLOPORTER); + public static FrequencyManager publicEntangloporters = new FrequencyManager(InventoryFrequency.class, InventoryFrequency.ENTANGLOPORTER); public static Map privateEntangloporters = new HashMap<>(); - public static FrequencyManager securityFrequencies = new FrequencyManager(SecurityFrequency.class, - SecurityFrequency.SECURITY); + public static FrequencyManager securityFrequencies = new FrequencyManager(SecurityFrequency.class, SecurityFrequency.SECURITY); /** * Mekanism creative tab */ @@ -259,8 +256,7 @@ public class Mekanism { */ public static GenHandler genHandler = new GenHandler(); /** - * The version of ore generation in this version of Mekanism. Increment this every time the default ore generation - * changes. + * The version of ore generation in this version of Mekanism. Increment this every time the default ore generation changes. */ public static int baseWorldGenVersion = 0; /** @@ -270,8 +266,7 @@ public class Mekanism { /** * The GameProfile used by the dummy Mekanism player */ - public static GameProfile gameProfile = new GameProfile(UUID.nameUUIDFromBytes("mekanism.common".getBytes()), - Mekanism.LOG_TAG); + public static GameProfile gameProfile = new GameProfile(UUID.nameUUIDFromBytes("mekanism.common".getBytes()), Mekanism.LOG_TAG); public static KeySync keyMap = new KeySync(); public static Set activeVibrators = new HashSet<>(); @@ -296,16 +291,11 @@ public class Mekanism { @SubscribeEvent public static void registerEntities(RegistryEvent.Register event) { - EntityRegistry.registerModEntity(new ResourceLocation(MODID, "ObsidianTNT"), EntityObsidianTNT.class, - "ObsidianTNT", 0, Mekanism.instance, 64, 5, true); - EntityRegistry.registerModEntity(new ResourceLocation(MODID, "Robit"), EntityRobit.class, "Robit", 1, - Mekanism.instance, 64, 2, true); - EntityRegistry.registerModEntity(new ResourceLocation(MODID, "Balloon"), EntityBalloon.class, "Balloon", 2, - Mekanism.instance, 64, 1, true); - EntityRegistry.registerModEntity(new ResourceLocation(MODID, "BabySkeleton"), EntityBabySkeleton.class, - "BabySkeleton", 3, Mekanism.instance, 64, 5, true, 0xFFFFFF, 0x800080); - EntityRegistry.registerModEntity(new ResourceLocation(MODID, "Flame"), EntityFlame.class, "Flame", 4, - Mekanism.instance, 64, 5, true); + EntityRegistry.registerModEntity(new ResourceLocation(MODID, "ObsidianTNT"), EntityObsidianTNT.class, "ObsidianTNT", 0, Mekanism.instance, 64, 5, true); + EntityRegistry.registerModEntity(new ResourceLocation(MODID, "Robit"), EntityRobit.class, "Robit", 1, Mekanism.instance, 64, 2, true); + EntityRegistry.registerModEntity(new ResourceLocation(MODID, "Balloon"), EntityBalloon.class, "Balloon", 2, Mekanism.instance, 64, 1, true); + EntityRegistry.registerModEntity(new ResourceLocation(MODID, "BabySkeleton"), EntityBabySkeleton.class, "BabySkeleton", 3, Mekanism.instance, 64, 5, true, 0xFFFFFF, 0x800080); + EntityRegistry.registerModEntity(new ResourceLocation(MODID, "Flame"), EntityFlame.class, "Flame", 4, Mekanism.instance, 64, 5, true); } @SubscribeEvent @@ -332,92 +322,62 @@ public class Mekanism { */ public static void addRecipes() { //Furnace Recipes - GameRegistry.addSmelting(new ItemStack(MekanismBlocks.OreBlock, 1, 0), new ItemStack(MekanismItems.Ingot, 1, 1), - 1.0F); - GameRegistry.addSmelting(new ItemStack(MekanismBlocks.OreBlock, 1, 1), new ItemStack(MekanismItems.Ingot, 1, 5), - 1.0F); - GameRegistry.addSmelting(new ItemStack(MekanismBlocks.OreBlock, 1, 2), new ItemStack(MekanismItems.Ingot, 1, 6), - 1.0F); - GameRegistry.addSmelting(new ItemStack(MekanismItems.Dust, 1, Resource.OSMIUM.ordinal()), - new ItemStack(MekanismItems.Ingot, 1, 1), 0.0F); - GameRegistry.addSmelting(new ItemStack(MekanismItems.Dust, 1, Resource.IRON.ordinal()), - new ItemStack(Items.IRON_INGOT), 0.0F); - GameRegistry.addSmelting(new ItemStack(MekanismItems.Dust, 1, Resource.GOLD.ordinal()), - new ItemStack(Items.GOLD_INGOT), 0.0F); - GameRegistry.addSmelting(new ItemStack(MekanismItems.OtherDust, 1, 1), new ItemStack(MekanismItems.Ingot, 1, 4), - 0.0F); - GameRegistry.addSmelting(new ItemStack(MekanismItems.Dust, 1, Resource.COPPER.ordinal()), - new ItemStack(MekanismItems.Ingot, 1, 5), 0.0F); - GameRegistry.addSmelting(new ItemStack(MekanismItems.Dust, 1, Resource.TIN.ordinal()), - new ItemStack(MekanismItems.Ingot, 1, 6), 0.0F); + GameRegistry.addSmelting(new ItemStack(MekanismBlocks.OreBlock, 1, 0), new ItemStack(MekanismItems.Ingot, 1, 1), 1.0F); + GameRegistry.addSmelting(new ItemStack(MekanismBlocks.OreBlock, 1, 1), new ItemStack(MekanismItems.Ingot, 1, 5), 1.0F); + GameRegistry.addSmelting(new ItemStack(MekanismBlocks.OreBlock, 1, 2), new ItemStack(MekanismItems.Ingot, 1, 6), 1.0F); + GameRegistry.addSmelting(new ItemStack(MekanismItems.Dust, 1, Resource.OSMIUM.ordinal()), new ItemStack(MekanismItems.Ingot, 1, 1), 0.0F); + GameRegistry.addSmelting(new ItemStack(MekanismItems.Dust, 1, Resource.IRON.ordinal()), new ItemStack(Items.IRON_INGOT), 0.0F); + GameRegistry.addSmelting(new ItemStack(MekanismItems.Dust, 1, Resource.GOLD.ordinal()), new ItemStack(Items.GOLD_INGOT), 0.0F); + GameRegistry.addSmelting(new ItemStack(MekanismItems.OtherDust, 1, 1), new ItemStack(MekanismItems.Ingot, 1, 4), 0.0F); + GameRegistry.addSmelting(new ItemStack(MekanismItems.Dust, 1, Resource.COPPER.ordinal()), new ItemStack(MekanismItems.Ingot, 1, 5), 0.0F); + GameRegistry.addSmelting(new ItemStack(MekanismItems.Dust, 1, Resource.TIN.ordinal()), new ItemStack(MekanismItems.Ingot, 1, 6), 0.0F); //Enrichment Chamber Recipes if (MekanismConfig.current().general.machinesManager.isEnabled(MachineType.ENRICHMENT_CHAMBER)) { - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.OBSIDIAN), - new ItemStack(MekanismItems.OtherDust, 4, 6)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Items.COAL, 1, 0), - new ItemStack(MekanismItems.CompressedCarbon)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Items.COAL, 1, 1), - new ItemStack(MekanismItems.CompressedCarbon)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Items.REDSTONE), - new ItemStack(MekanismItems.CompressedRedstone)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.MOSSY_COBBLESTONE), - new ItemStack(Blocks.COBBLESTONE)); - RecipeHandler - .addEnrichmentChamberRecipe(new ItemStack(Blocks.STONE), new ItemStack(Blocks.STONEBRICK, 1, 2)); + RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.OBSIDIAN), new ItemStack(MekanismItems.OtherDust, 4, 6)); + RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Items.COAL, 1, 0), new ItemStack(MekanismItems.CompressedCarbon)); + RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Items.COAL, 1, 1), new ItemStack(MekanismItems.CompressedCarbon)); + RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Items.REDSTONE), new ItemStack(MekanismItems.CompressedRedstone)); + RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.MOSSY_COBBLESTONE), new ItemStack(Blocks.COBBLESTONE)); + RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.STONE), new ItemStack(Blocks.STONEBRICK, 1, 2)); RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.SAND), new ItemStack(Blocks.GRAVEL)); RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.GRAVEL), new ItemStack(Blocks.COBBLESTONE)); RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Items.GUNPOWDER), new ItemStack(Items.FLINT)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.STONEBRICK, 1, 2), - new ItemStack(Blocks.STONEBRICK, 1, 0)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.STONEBRICK, 1, 0), - new ItemStack(Blocks.STONEBRICK, 1, 3)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.STONEBRICK, 1, 1), - new ItemStack(Blocks.STONEBRICK, 1, 0)); - RecipeHandler - .addEnrichmentChamberRecipe(new ItemStack(Blocks.GLOWSTONE), new ItemStack(Items.GLOWSTONE_DUST, 4)); + RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.STONEBRICK, 1, 2), new ItemStack(Blocks.STONEBRICK, 1, 0)); + RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.STONEBRICK, 1, 0), new ItemStack(Blocks.STONEBRICK, 1, 3)); + RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.STONEBRICK, 1, 1), new ItemStack(Blocks.STONEBRICK, 1, 0)); + RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.GLOWSTONE), new ItemStack(Items.GLOWSTONE_DUST, 4)); RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.CLAY), new ItemStack(Items.CLAY_BALL, 4)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(MekanismBlocks.SaltBlock), - new ItemStack(MekanismItems.Salt, 4)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Items.DIAMOND), - new ItemStack(MekanismItems.CompressedDiamond)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(MekanismItems.Polyethene, 3, 0), - new ItemStack(MekanismItems.Polyethene, 1, 2)); + RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(MekanismBlocks.SaltBlock), new ItemStack(MekanismItems.Salt, 4)); + RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Items.DIAMOND), new ItemStack(MekanismItems.CompressedDiamond)); + RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(MekanismItems.Polyethene, 3, 0), new ItemStack(MekanismItems.Polyethene, 1, 2)); for (int i = 0; i < EnumColor.DYES.length; i++) { - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(MekanismBlocks.PlasticBlock, 1, i), - new ItemStack(MekanismBlocks.SlickPlasticBlock, 1, i)); + RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(MekanismBlocks.PlasticBlock, 1, i), new ItemStack(MekanismBlocks.SlickPlasticBlock, 1, i)); } } //Combiner recipes if (MekanismConfig.current().general.machinesManager.isEnabled(MachineType.COMBINER)) { - RecipeHandler.addCombinerRecipe(new ItemStack(Items.FLINT), new ItemStack(Blocks.COBBLESTONE), - new ItemStack(Blocks.GRAVEL)); - RecipeHandler.addCombinerRecipe(new ItemStack(Items.COAL, 3), new ItemStack(Blocks.COBBLESTONE), - new ItemStack(Blocks.COAL_ORE)); + RecipeHandler.addCombinerRecipe(new ItemStack(Items.FLINT), new ItemStack(Blocks.COBBLESTONE), new ItemStack(Blocks.GRAVEL)); + RecipeHandler.addCombinerRecipe(new ItemStack(Items.COAL, 3), new ItemStack(Blocks.COBBLESTONE), new ItemStack(Blocks.COAL_ORE)); } //Osmium Compressor Recipes if (MekanismConfig.current().general.machinesManager.isEnabled(MachineType.OSMIUM_COMPRESSOR)) { - RecipeHandler.addOsmiumCompressorRecipe(new ItemStack(Items.GLOWSTONE_DUST), - new ItemStack(MekanismItems.Ingot, 1, 3)); + RecipeHandler.addOsmiumCompressorRecipe(new ItemStack(Items.GLOWSTONE_DUST), new ItemStack(MekanismItems.Ingot, 1, 3)); } //Crusher Recipes if (MekanismConfig.current().general.machinesManager.isEnabled(MachineType.CRUSHER)) { - RecipeHandler.addCrusherRecipe(new ItemStack(Items.IRON_INGOT), - new ItemStack(MekanismItems.Dust, 1, Resource.IRON.ordinal())); - RecipeHandler.addCrusherRecipe(new ItemStack(Items.GOLD_INGOT), - new ItemStack(MekanismItems.Dust, 1, Resource.GOLD.ordinal())); + RecipeHandler.addCrusherRecipe(new ItemStack(Items.IRON_INGOT), new ItemStack(MekanismItems.Dust, 1, Resource.IRON.ordinal())); + RecipeHandler.addCrusherRecipe(new ItemStack(Items.GOLD_INGOT), new ItemStack(MekanismItems.Dust, 1, Resource.GOLD.ordinal())); RecipeHandler.addCrusherRecipe(new ItemStack(Blocks.GRAVEL), new ItemStack(Blocks.SAND)); RecipeHandler.addCrusherRecipe(new ItemStack(Blocks.STONE), new ItemStack(Blocks.COBBLESTONE)); RecipeHandler.addCrusherRecipe(new ItemStack(Blocks.COBBLESTONE), new ItemStack(Blocks.GRAVEL)); RecipeHandler.addCrusherRecipe(new ItemStack(Blocks.STONEBRICK, 1, 2), new ItemStack(Blocks.STONE)); - RecipeHandler - .addCrusherRecipe(new ItemStack(Blocks.STONEBRICK, 1, 0), new ItemStack(Blocks.STONEBRICK, 1, 2)); - RecipeHandler - .addCrusherRecipe(new ItemStack(Blocks.STONEBRICK, 1, 3), new ItemStack(Blocks.STONEBRICK, 1, 0)); + RecipeHandler.addCrusherRecipe(new ItemStack(Blocks.STONEBRICK, 1, 0), new ItemStack(Blocks.STONEBRICK, 1, 2)); + RecipeHandler.addCrusherRecipe(new ItemStack(Blocks.STONEBRICK, 1, 3), new ItemStack(Blocks.STONEBRICK, 1, 0)); RecipeHandler.addCrusherRecipe(new ItemStack(Items.FLINT), new ItemStack(Items.GUNPOWDER)); RecipeHandler.addCrusherRecipe(new ItemStack(Blocks.SANDSTONE), new ItemStack(Blocks.SAND, 2)); @@ -440,11 +400,9 @@ public class Mekanism { RecipeHandler.addCrusherRecipe(new ItemStack(Items.MELON), new ItemStack(MekanismItems.BioFuel, 4)); RecipeHandler.addCrusherRecipe(new ItemStack(Blocks.PUMPKIN), new ItemStack(MekanismItems.BioFuel, 6)); RecipeHandler.addCrusherRecipe(new ItemStack(Items.BAKED_POTATO), new ItemStack(MekanismItems.BioFuel, 4)); - RecipeHandler - .addCrusherRecipe(new ItemStack(Items.POISONOUS_POTATO), new ItemStack(MekanismItems.BioFuel, 4)); + RecipeHandler.addCrusherRecipe(new ItemStack(Items.POISONOUS_POTATO), new ItemStack(MekanismItems.BioFuel, 4)); RecipeHandler.addCrusherRecipe(new ItemStack(Items.BEETROOT), new ItemStack(MekanismItems.BioFuel, 4)); - RecipeHandler - .addCrusherRecipe(new ItemStack(Items.BEETROOT_SEEDS), new ItemStack(MekanismItems.BioFuel, 2)); + RecipeHandler.addCrusherRecipe(new ItemStack(Items.BEETROOT_SEEDS), new ItemStack(MekanismItems.BioFuel, 2)); RecipeHandler.addCrusherRecipe(new ItemStack(Blocks.CACTUS), new ItemStack(MekanismItems.BioFuel, 2)); } @@ -455,217 +413,133 @@ public class Mekanism { //Chemical Injection Chamber Recipes if (MekanismConfig.current().general.machinesManager.isEnabled(MachineType.CHEMICAL_INJECTION_CHAMBER)) { - RecipeHandler.addChemicalInjectionChamberRecipe(new ItemStack(Blocks.DIRT), MekanismFluids.Water, - new ItemStack(Blocks.CLAY)); - RecipeHandler.addChemicalInjectionChamberRecipe(new ItemStack(Blocks.HARDENED_CLAY), MekanismFluids.Water, - new ItemStack(Blocks.CLAY)); - RecipeHandler.addChemicalInjectionChamberRecipe(new ItemStack(Items.BRICK), MekanismFluids.Water, - new ItemStack(Items.CLAY_BALL)); - RecipeHandler - .addChemicalInjectionChamberRecipe(new ItemStack(Items.GUNPOWDER), MekanismFluids.HydrogenChloride, - new ItemStack(MekanismItems.OtherDust, 1, 3)); + RecipeHandler.addChemicalInjectionChamberRecipe(new ItemStack(Blocks.DIRT), MekanismFluids.Water, new ItemStack(Blocks.CLAY)); + RecipeHandler.addChemicalInjectionChamberRecipe(new ItemStack(Blocks.HARDENED_CLAY), MekanismFluids.Water, new ItemStack(Blocks.CLAY)); + RecipeHandler.addChemicalInjectionChamberRecipe(new ItemStack(Items.BRICK), MekanismFluids.Water, new ItemStack(Items.CLAY_BALL)); + RecipeHandler.addChemicalInjectionChamberRecipe(new ItemStack(Items.GUNPOWDER), MekanismFluids.HydrogenChloride, new ItemStack(MekanismItems.OtherDust, 1, 3)); } //Precision Sawmill Recipes if (MekanismConfig.current().general.machinesManager.isEnabled(MachineType.PRECISION_SAWMILL)) { RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.LADDER, 3), new ItemStack(Items.STICK, 7)); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.TORCH, 4), new ItemStack(Items.STICK), - new ItemStack(Items.COAL), 1); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.TORCH, 4), new ItemStack(Items.STICK), new ItemStack(Items.COAL), 1); RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.CHEST), new ItemStack(Blocks.PLANKS, 8)); RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.TRAPDOOR), new ItemStack(Blocks.PLANKS, 3)); RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Items.BOAT), new ItemStack(Blocks.PLANKS, 5)); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Items.BED), new ItemStack(Blocks.PLANKS, 3), - new ItemStack(Blocks.WOOL, 3), 1); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Items.BED), new ItemStack(Blocks.PLANKS, 3), new ItemStack(Blocks.WOOL, 3), 1); RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Items.OAK_DOOR), new ItemStack(Blocks.PLANKS, 2, 0)); - RecipeHandler - .addPrecisionSawmillRecipe(new ItemStack(Items.SPRUCE_DOOR), new ItemStack(Blocks.PLANKS, 2, 1)); - RecipeHandler - .addPrecisionSawmillRecipe(new ItemStack(Items.BIRCH_DOOR), new ItemStack(Blocks.PLANKS, 2, 2)); - RecipeHandler - .addPrecisionSawmillRecipe(new ItemStack(Items.JUNGLE_DOOR), new ItemStack(Blocks.PLANKS, 2, 3)); - RecipeHandler - .addPrecisionSawmillRecipe(new ItemStack(Items.ACACIA_DOOR), new ItemStack(Blocks.PLANKS, 2, 4)); - RecipeHandler - .addPrecisionSawmillRecipe(new ItemStack(Items.DARK_OAK_DOOR), new ItemStack(Blocks.PLANKS, 2, 5)); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.JUKEBOX), new ItemStack(Blocks.PLANKS, 8), - new ItemStack(Items.DIAMOND), 1); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.BOOKSHELF), new ItemStack(Blocks.PLANKS, 6), - new ItemStack(Items.BOOK, 3), 1); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.WOODEN_PRESSURE_PLATE), - new ItemStack(Blocks.PLANKS, 2)); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Items.SPRUCE_DOOR), new ItemStack(Blocks.PLANKS, 2, 1)); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Items.BIRCH_DOOR), new ItemStack(Blocks.PLANKS, 2, 2)); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Items.JUNGLE_DOOR), new ItemStack(Blocks.PLANKS, 2, 3)); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Items.ACACIA_DOOR), new ItemStack(Blocks.PLANKS, 2, 4)); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Items.DARK_OAK_DOOR), new ItemStack(Blocks.PLANKS, 2, 5)); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.JUKEBOX), new ItemStack(Blocks.PLANKS, 8), new ItemStack(Items.DIAMOND), 1); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.BOOKSHELF), new ItemStack(Blocks.PLANKS, 6), new ItemStack(Items.BOOK, 3), 1); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.WOODEN_PRESSURE_PLATE), new ItemStack(Blocks.PLANKS, 2)); RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.OAK_FENCE), new ItemStack(Items.STICK, 3)); RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.SPRUCE_FENCE), new ItemStack(Items.STICK, 3)); RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.BIRCH_FENCE), new ItemStack(Items.STICK, 3)); RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.JUNGLE_FENCE), new ItemStack(Items.STICK, 3)); RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.ACACIA_FENCE), new ItemStack(Items.STICK, 3)); - RecipeHandler - .addPrecisionSawmillRecipe(new ItemStack(Blocks.DARK_OAK_FENCE), new ItemStack(Items.STICK, 3)); - RecipeHandler - .addPrecisionSawmillRecipe(new ItemStack(Blocks.OAK_FENCE_GATE), new ItemStack(Blocks.PLANKS, 2, 0), - new ItemStack(Items.STICK, 4), 1); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.SPRUCE_FENCE_GATE), - new ItemStack(Blocks.PLANKS, 2, 1), new ItemStack(Items.STICK, 4), 1); - RecipeHandler - .addPrecisionSawmillRecipe(new ItemStack(Blocks.BIRCH_FENCE_GATE), new ItemStack(Blocks.PLANKS, 2, 2), - new ItemStack(Items.STICK, 4), 1); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.JUNGLE_FENCE_GATE), - new ItemStack(Blocks.PLANKS, 2, 3), new ItemStack(Items.STICK, 4), 1); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.ACACIA_FENCE_GATE), - new ItemStack(Blocks.PLANKS, 2, 4), new ItemStack(Items.STICK, 4), 1); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.DARK_OAK_FENCE_GATE), - new ItemStack(Blocks.PLANKS, 2, 5), new ItemStack(Items.STICK, 4), 1); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.NOTEBLOCK), new ItemStack(Blocks.PLANKS, 8), - new ItemStack(Items.REDSTONE), 1); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.REDSTONE_TORCH), new ItemStack(Items.STICK), - new ItemStack(Items.REDSTONE), 1); - RecipeHandler - .addPrecisionSawmillRecipe(new ItemStack(Blocks.CRAFTING_TABLE), new ItemStack(Blocks.PLANKS, 4)); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.DARK_OAK_FENCE), new ItemStack(Items.STICK, 3)); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.OAK_FENCE_GATE), new ItemStack(Blocks.PLANKS, 2, 0), new ItemStack(Items.STICK, 4), 1); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.SPRUCE_FENCE_GATE), new ItemStack(Blocks.PLANKS, 2, 1), new ItemStack(Items.STICK, 4), 1); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.BIRCH_FENCE_GATE), new ItemStack(Blocks.PLANKS, 2, 2), new ItemStack(Items.STICK, 4), 1); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.JUNGLE_FENCE_GATE), new ItemStack(Blocks.PLANKS, 2, 3), new ItemStack(Items.STICK, 4), 1); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.ACACIA_FENCE_GATE), new ItemStack(Blocks.PLANKS, 2, 4), new ItemStack(Items.STICK, 4), 1); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.DARK_OAK_FENCE_GATE), new ItemStack(Blocks.PLANKS, 2, 5), new ItemStack(Items.STICK, 4), 1); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.NOTEBLOCK), new ItemStack(Blocks.PLANKS, 8), new ItemStack(Items.REDSTONE), 1); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.REDSTONE_TORCH), new ItemStack(Items.STICK), new ItemStack(Items.REDSTONE), 1); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.CRAFTING_TABLE), new ItemStack(Blocks.PLANKS, 4)); } //Metallurgic Infuser Recipes if (MekanismConfig.current().general.machinesManager.isEnabled(MachineType.METALLURGIC_INFUSER)) { - RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("CARBON"), 10, new ItemStack(Items.IRON_INGOT), - new ItemStack(MekanismItems.EnrichedIron)); - RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("CARBON"), 10, - new ItemStack(MekanismItems.EnrichedIron), new ItemStack(MekanismItems.OtherDust, 1, 1)); - RecipeHandler - .addMetallurgicInfuserRecipe(InfuseRegistry.get("REDSTONE"), 10, new ItemStack(Items.IRON_INGOT), - new ItemStack(MekanismItems.EnrichedAlloy)); - RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("FUNGI"), 10, new ItemStack(Blocks.DIRT), - new ItemStack(Blocks.MYCELIUM)); - RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("BIO"), 10, new ItemStack(Blocks.COBBLESTONE), - new ItemStack(Blocks.MOSSY_COBBLESTONE)); - RecipeHandler - .addMetallurgicInfuserRecipe(InfuseRegistry.get("BIO"), 10, new ItemStack(Blocks.STONEBRICK, 1, 0), - new ItemStack(Blocks.STONEBRICK, 1, 1)); - RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("BIO"), 10, new ItemStack(Blocks.SAND), - new ItemStack(Blocks.DIRT)); - RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("BIO"), 10, new ItemStack(Blocks.DIRT), - new ItemStack(Blocks.DIRT, 1, 2)); - RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("DIAMOND"), 10, - new ItemStack(MekanismItems.EnrichedAlloy), new ItemStack(MekanismItems.ReinforcedAlloy)); - RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("OBSIDIAN"), 10, - new ItemStack(MekanismItems.ReinforcedAlloy), new ItemStack(MekanismItems.AtomicAlloy)); + RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("CARBON"), 10, new ItemStack(Items.IRON_INGOT), new ItemStack(MekanismItems.EnrichedIron)); + RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("CARBON"), 10, new ItemStack(MekanismItems.EnrichedIron), new ItemStack(MekanismItems.OtherDust, 1, 1)); + RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("REDSTONE"), 10, new ItemStack(Items.IRON_INGOT), new ItemStack(MekanismItems.EnrichedAlloy)); + RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("FUNGI"), 10, new ItemStack(Blocks.DIRT), new ItemStack(Blocks.MYCELIUM)); + RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("BIO"), 10, new ItemStack(Blocks.COBBLESTONE), new ItemStack(Blocks.MOSSY_COBBLESTONE)); + RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("BIO"), 10, new ItemStack(Blocks.STONEBRICK, 1, 0), new ItemStack(Blocks.STONEBRICK, 1, 1)); + RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("BIO"), 10, new ItemStack(Blocks.SAND), new ItemStack(Blocks.DIRT)); + RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("BIO"), 10, new ItemStack(Blocks.DIRT), new ItemStack(Blocks.DIRT, 1, 2)); + RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("DIAMOND"), 10, new ItemStack(MekanismItems.EnrichedAlloy), new ItemStack(MekanismItems.ReinforcedAlloy)); + RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("OBSIDIAN"), 10, new ItemStack(MekanismItems.ReinforcedAlloy), new ItemStack(MekanismItems.AtomicAlloy)); } //Chemical Infuser Recipes if (MekanismConfig.current().general.machinesManager.isEnabled(MachineType.CHEMICAL_INFUSER)) { - RecipeHandler.addChemicalInfuserRecipe(new GasStack(MekanismFluids.Oxygen, 1), - new GasStack(MekanismFluids.SulfurDioxide, 2), new GasStack(MekanismFluids.SulfurTrioxide, 2)); - RecipeHandler.addChemicalInfuserRecipe(new GasStack(MekanismFluids.SulfurTrioxide, 1), - new GasStack(MekanismFluids.Water, 1), new GasStack(MekanismFluids.SulfuricAcid, 1)); - RecipeHandler.addChemicalInfuserRecipe(new GasStack(MekanismFluids.Hydrogen, 1), - new GasStack(MekanismFluids.Chlorine, 1), new GasStack(MekanismFluids.HydrogenChloride, 1)); - RecipeHandler.addChemicalInfuserRecipe(new GasStack(MekanismFluids.Deuterium, 1), - new GasStack(MekanismFluids.Tritium, 1), new GasStack(MekanismFluids.FusionFuel, 2)); + RecipeHandler.addChemicalInfuserRecipe(new GasStack(MekanismFluids.Oxygen, 1), new GasStack(MekanismFluids.SulfurDioxide, 2), new GasStack(MekanismFluids.SulfurTrioxide, 2)); + RecipeHandler.addChemicalInfuserRecipe(new GasStack(MekanismFluids.SulfurTrioxide, 1), new GasStack(MekanismFluids.Water, 1), new GasStack(MekanismFluids.SulfuricAcid, 1)); + RecipeHandler.addChemicalInfuserRecipe(new GasStack(MekanismFluids.Hydrogen, 1), new GasStack(MekanismFluids.Chlorine, 1), new GasStack(MekanismFluids.HydrogenChloride, 1)); + RecipeHandler.addChemicalInfuserRecipe(new GasStack(MekanismFluids.Deuterium, 1), new GasStack(MekanismFluids.Tritium, 1), new GasStack(MekanismFluids.FusionFuel, 2)); } //Electrolytic Separator Recipes if (MekanismConfig.current().general.machinesManager.isEnabled(MachineType.ELECTROLYTIC_SEPARATOR)) { - RecipeHandler.addElectrolyticSeparatorRecipe(FluidRegistry.getFluidStack("water", 2), - 2 * MekanismConfig.current().general.FROM_H2.val(), + RecipeHandler.addElectrolyticSeparatorRecipe(FluidRegistry.getFluidStack("water", 2), 2 * MekanismConfig.current().general.FROM_H2.val(), new GasStack(MekanismFluids.Hydrogen, 2), new GasStack(MekanismFluids.Oxygen, 1)); - RecipeHandler.addElectrolyticSeparatorRecipe(FluidRegistry.getFluidStack("brine", 10), - 2 * MekanismConfig.current().general.FROM_H2.val(), + RecipeHandler.addElectrolyticSeparatorRecipe(FluidRegistry.getFluidStack("brine", 10), 2 * MekanismConfig.current().general.FROM_H2.val(), new GasStack(MekanismFluids.Sodium, 1), new GasStack(MekanismFluids.Chlorine, 1)); - RecipeHandler.addElectrolyticSeparatorRecipe(FluidRegistry.getFluidStack("heavywater", 2), - MekanismConfig.current().usage.heavyWaterElectrolysis.val(), - new GasStack(MekanismFluids.Deuterium, 2), - new GasStack(MekanismFluids.Oxygen, 1)); + RecipeHandler.addElectrolyticSeparatorRecipe(FluidRegistry.getFluidStack("heavywater", 2), MekanismConfig.current().usage.heavyWaterElectrolysis.val(), + new GasStack(MekanismFluids.Deuterium, 2), new GasStack(MekanismFluids.Oxygen, 1)); } //Thermal Evaporation Plant Recipes - RecipeHandler.addThermalEvaporationRecipe(FluidRegistry.getFluidStack("water", 10), - FluidRegistry.getFluidStack("brine", 1)); - RecipeHandler.addThermalEvaporationRecipe(FluidRegistry.getFluidStack("brine", 10), - FluidRegistry.getFluidStack("liquidlithium", 1)); + RecipeHandler.addThermalEvaporationRecipe(FluidRegistry.getFluidStack("water", 10), FluidRegistry.getFluidStack("brine", 1)); + RecipeHandler.addThermalEvaporationRecipe(FluidRegistry.getFluidStack("brine", 10), FluidRegistry.getFluidStack("liquidlithium", 1)); //Chemical Crystallizer Recipes if (MekanismConfig.current().general.machinesManager.isEnabled(MachineType.CHEMICAL_CRYSTALLIZER)) { - RecipeHandler.addChemicalCrystallizerRecipe(new GasStack(MekanismFluids.Lithium, 100), - new ItemStack(MekanismItems.OtherDust, 1, 4)); - RecipeHandler.addChemicalCrystallizerRecipe(new GasStack(MekanismFluids.Brine, 15), - new ItemStack(MekanismItems.Salt)); + RecipeHandler.addChemicalCrystallizerRecipe(new GasStack(MekanismFluids.Lithium, 100), new ItemStack(MekanismItems.OtherDust, 1, 4)); + RecipeHandler.addChemicalCrystallizerRecipe(new GasStack(MekanismFluids.Brine, 15), new ItemStack(MekanismItems.Salt)); } //T4 Processing Recipes for (Gas gas : GasRegistry.getRegisteredGasses()) { if (gas instanceof OreGas && !((OreGas) gas).isClean()) { OreGas oreGas = (OreGas) gas; - if (MekanismConfig.current().general.machinesManager.isEnabled(MachineType.CHEMICAL_WASHER)) { - RecipeHandler - .addChemicalWasherRecipe(new GasStack(oreGas, 1), new GasStack(oreGas.getCleanGas(), 1)); + RecipeHandler.addChemicalWasherRecipe(new GasStack(oreGas, 1), new GasStack(oreGas.getCleanGas(), 1)); } //do the crystallizer only if it's one of ours! Resource gasResource = Resource.getFromName(oreGas.getName()); - if (gasResource != null && MekanismConfig.current().general.machinesManager - .isEnabled(MachineType.CHEMICAL_CRYSTALLIZER)) { - RecipeHandler.addChemicalCrystallizerRecipe(new GasStack(oreGas.getCleanGas(), 200), - new ItemStack(MekanismItems.Crystal, 1, gasResource.ordinal())); + if (gasResource != null && MekanismConfig.current().general.machinesManager.isEnabled(MachineType.CHEMICAL_CRYSTALLIZER)) { + RecipeHandler.addChemicalCrystallizerRecipe(new GasStack(oreGas.getCleanGas(), 200), new ItemStack(MekanismItems.Crystal, 1, gasResource.ordinal())); } } } //Pressurized Reaction Chamber Recipes if (MekanismConfig.current().general.machinesManager.isEnabled(MachineType.PRESSURIZED_REACTION_CHAMBER)) { - RecipeHandler.addPRCRecipe( - new ItemStack(MekanismItems.BioFuel, 2), new FluidStack(FluidRegistry.WATER, 10), - new GasStack(MekanismFluids.Hydrogen, 100), - new ItemStack(MekanismItems.Substrate), new GasStack(MekanismFluids.Ethene, 100), - 0, - 100 - ); - RecipeHandler.addPRCRecipe( - new ItemStack(MekanismItems.Substrate), new FluidStack(MekanismFluids.Ethene.getFluid(), 50), - new GasStack(MekanismFluids.Oxygen, 10), - new ItemStack(MekanismItems.Polyethene), new GasStack(MekanismFluids.Oxygen, 5), - 1000, - 60 - ); - RecipeHandler.addPRCRecipe( - new ItemStack(MekanismItems.Substrate), new FluidStack(FluidRegistry.WATER, 200), - new GasStack(MekanismFluids.Ethene, 100), - new ItemStack(MekanismItems.Substrate, 8), new GasStack(MekanismFluids.Oxygen, 10), - 200, - 400 - ); + RecipeHandler.addPRCRecipe(new ItemStack(MekanismItems.BioFuel, 2), new FluidStack(FluidRegistry.WATER, 10), new GasStack(MekanismFluids.Hydrogen, 100), + new ItemStack(MekanismItems.Substrate), new GasStack(MekanismFluids.Ethene, 100), 0, 100); + RecipeHandler.addPRCRecipe(new ItemStack(MekanismItems.Substrate), new FluidStack(MekanismFluids.Ethene.getFluid(), 50), + new GasStack(MekanismFluids.Oxygen, 10), new ItemStack(MekanismItems.Polyethene), new GasStack(MekanismFluids.Oxygen, 5), 1000, 60); + RecipeHandler.addPRCRecipe(new ItemStack(MekanismItems.Substrate), new FluidStack(FluidRegistry.WATER, 200), new GasStack(MekanismFluids.Ethene, 100), + new ItemStack(MekanismItems.Substrate, 8), new GasStack(MekanismFluids.Oxygen, 10), 200, 400); } //Solar Neutron Activator Recipes if (MekanismConfig.current().general.machinesManager.isEnabled(MachineType.SOLAR_NEUTRON_ACTIVATOR)) { - RecipeHandler.addSolarNeutronRecipe(new GasStack(MekanismFluids.Lithium, 1), - new GasStack(MekanismFluids.Tritium, 1)); + RecipeHandler.addSolarNeutronRecipe(new GasStack(MekanismFluids.Lithium, 1), new GasStack(MekanismFluids.Tritium, 1)); } //Infuse objects - InfuseRegistry.registerInfuseObject(new ItemStack(MekanismItems.BioFuel), - new InfuseObject(InfuseRegistry.get("BIO"), 5)); - InfuseRegistry.registerInfuseObject(new ItemStack(Items.COAL, 1, 0), - new InfuseObject(InfuseRegistry.get("CARBON"), 10)); - InfuseRegistry.registerInfuseObject(new ItemStack(Items.COAL, 1, 1), - new InfuseObject(InfuseRegistry.get("CARBON"), 20)); - InfuseRegistry.registerInfuseObject(new ItemStack(Blocks.COAL_BLOCK, 1, 0), - new InfuseObject(InfuseRegistry.get("CARBON"), 90)); - InfuseRegistry.registerInfuseObject(new ItemStack(MekanismBlocks.BasicBlock, 1, 3), - new InfuseObject(InfuseRegistry.get("CARBON"), 180)); - InfuseRegistry.registerInfuseObject(new ItemStack(MekanismItems.CompressedCarbon), - new InfuseObject(InfuseRegistry.get("CARBON"), 80)); - InfuseRegistry.registerInfuseObject(new ItemStack(Items.REDSTONE), - new InfuseObject(InfuseRegistry.get("REDSTONE"), 10)); - InfuseRegistry.registerInfuseObject(new ItemStack(Blocks.REDSTONE_BLOCK), - new InfuseObject(InfuseRegistry.get("REDSTONE"), 90)); - InfuseRegistry.registerInfuseObject(new ItemStack(MekanismItems.CompressedRedstone), - new InfuseObject(InfuseRegistry.get("REDSTONE"), 80)); - InfuseRegistry.registerInfuseObject(new ItemStack(Blocks.RED_MUSHROOM), - new InfuseObject(InfuseRegistry.get("FUNGI"), 10)); - InfuseRegistry.registerInfuseObject(new ItemStack(Blocks.BROWN_MUSHROOM), - new InfuseObject(InfuseRegistry.get("FUNGI"), 10)); - InfuseRegistry.registerInfuseObject(new ItemStack(MekanismItems.CompressedDiamond), - new InfuseObject(InfuseRegistry.get("DIAMOND"), 80)); - InfuseRegistry.registerInfuseObject(new ItemStack(MekanismItems.CompressedObsidian), - new InfuseObject(InfuseRegistry.get("OBSIDIAN"), 80)); + InfuseRegistry.registerInfuseObject(new ItemStack(MekanismItems.BioFuel), new InfuseObject(InfuseRegistry.get("BIO"), 5)); + InfuseRegistry.registerInfuseObject(new ItemStack(Items.COAL, 1, 0), new InfuseObject(InfuseRegistry.get("CARBON"), 10)); + InfuseRegistry.registerInfuseObject(new ItemStack(Items.COAL, 1, 1), new InfuseObject(InfuseRegistry.get("CARBON"), 20)); + InfuseRegistry.registerInfuseObject(new ItemStack(Blocks.COAL_BLOCK, 1, 0), new InfuseObject(InfuseRegistry.get("CARBON"), 90)); + InfuseRegistry.registerInfuseObject(new ItemStack(MekanismBlocks.BasicBlock, 1, 3), new InfuseObject(InfuseRegistry.get("CARBON"), 180)); + InfuseRegistry.registerInfuseObject(new ItemStack(MekanismItems.CompressedCarbon), new InfuseObject(InfuseRegistry.get("CARBON"), 80)); + InfuseRegistry.registerInfuseObject(new ItemStack(Items.REDSTONE), new InfuseObject(InfuseRegistry.get("REDSTONE"), 10)); + InfuseRegistry.registerInfuseObject(new ItemStack(Blocks.REDSTONE_BLOCK), new InfuseObject(InfuseRegistry.get("REDSTONE"), 90)); + InfuseRegistry.registerInfuseObject(new ItemStack(MekanismItems.CompressedRedstone), new InfuseObject(InfuseRegistry.get("REDSTONE"), 80)); + InfuseRegistry.registerInfuseObject(new ItemStack(Blocks.RED_MUSHROOM), new InfuseObject(InfuseRegistry.get("FUNGI"), 10)); + InfuseRegistry.registerInfuseObject(new ItemStack(Blocks.BROWN_MUSHROOM), new InfuseObject(InfuseRegistry.get("FUNGI"), 10)); + InfuseRegistry.registerInfuseObject(new ItemStack(MekanismItems.CompressedDiamond), new InfuseObject(InfuseRegistry.get("DIAMOND"), 80)); + InfuseRegistry.registerInfuseObject(new ItemStack(MekanismItems.CompressedObsidian), new InfuseObject(InfuseRegistry.get("OBSIDIAN"), 80)); //Fuel Gases FuelHandler.addGas(MekanismFluids.Hydrogen, 1, MekanismConfig.current().general.FROM_H2.val()); @@ -676,8 +550,7 @@ public class Mekanism { */ public static void registerOreDict() { //Add specific items to ore dictionary for recipe usage in other mods. - OreDictionary.registerOre("universalCable", - MekanismUtils.getTransmitter(TransmitterType.UNIVERSAL_CABLE, BaseTier.BASIC, 1)); + OreDictionary.registerOre("universalCable", MekanismUtils.getTransmitter(TransmitterType.UNIVERSAL_CABLE, BaseTier.BASIC, 1)); OreDictionary.registerOre("battery", MekanismItems.EnergyTablet.getUnchargedItem()); OreDictionary.registerOre("pulpWood", MekanismItems.Sawdust); OreDictionary.registerOre("dustWood", MekanismItems.Sawdust); @@ -728,16 +601,11 @@ public class Mekanism { OreDictionary.registerOre("blockTin", new ItemStack(MekanismBlocks.BasicBlock, 1, 13)); for (Resource resource : Resource.values()) { - OreDictionary - .registerOre("dust" + resource.getName(), new ItemStack(MekanismItems.Dust, 1, resource.ordinal())); - OreDictionary.registerOre("dustDirty" + resource.getName(), - new ItemStack(MekanismItems.DirtyDust, 1, resource.ordinal())); - OreDictionary - .registerOre("clump" + resource.getName(), new ItemStack(MekanismItems.Clump, 1, resource.ordinal())); - OreDictionary - .registerOre("shard" + resource.getName(), new ItemStack(MekanismItems.Shard, 1, resource.ordinal())); - OreDictionary.registerOre("crystal" + resource.getName(), - new ItemStack(MekanismItems.Crystal, 1, resource.ordinal())); + OreDictionary.registerOre("dust" + resource.getName(), new ItemStack(MekanismItems.Dust, 1, resource.ordinal())); + OreDictionary.registerOre("dustDirty" + resource.getName(), new ItemStack(MekanismItems.DirtyDust, 1, resource.ordinal())); + OreDictionary.registerOre("clump" + resource.getName(), new ItemStack(MekanismItems.Clump, 1, resource.ordinal())); + OreDictionary.registerOre("shard" + resource.getName(), new ItemStack(MekanismItems.Shard, 1, resource.ordinal())); + OreDictionary.registerOre("crystal" + resource.getName(), new ItemStack(MekanismItems.Crystal, 1, resource.ordinal())); } OreDictionary.registerOre("oreOsmium", new ItemStack(MekanismBlocks.OreBlock, 1, 0)); @@ -917,24 +785,13 @@ public class Mekanism { Mekanism.proxy.preInit(); //Register infuses - InfuseRegistry.registerInfuseType( - new InfuseType("CARBON", new ResourceLocation("mekanism:blocks/infuse/Carbon")) - .setTranslationKey("carbon")); - InfuseRegistry.registerInfuseType( - new InfuseType("TIN", new ResourceLocation("mekanism:blocks/infuse/Tin")).setTranslationKey("tin")); - InfuseRegistry.registerInfuseType( - new InfuseType("DIAMOND", new ResourceLocation("mekanism:blocks/infuse/Diamond")) - .setTranslationKey("diamond")); - InfuseRegistry.registerInfuseType( - new InfuseType("REDSTONE", new ResourceLocation("mekanism:blocks/infuse/Redstone")) - .setTranslationKey("redstone")); - InfuseRegistry.registerInfuseType( - new InfuseType("FUNGI", new ResourceLocation("mekanism:blocks/infuse/Fungi")).setTranslationKey("fungi")); - InfuseRegistry.registerInfuseType( - new InfuseType("BIO", new ResourceLocation("mekanism:blocks/infuse/Bio")).setTranslationKey("bio")); - InfuseRegistry.registerInfuseType( - new InfuseType("OBSIDIAN", new ResourceLocation("mekanism:blocks/infuse/Obsidian")) - .setTranslationKey("obsidian")); + InfuseRegistry.registerInfuseType(new InfuseType("CARBON", new ResourceLocation("mekanism:blocks/infuse/Carbon")).setTranslationKey("carbon")); + InfuseRegistry.registerInfuseType(new InfuseType("TIN", new ResourceLocation("mekanism:blocks/infuse/Tin")).setTranslationKey("tin")); + InfuseRegistry.registerInfuseType(new InfuseType("DIAMOND", new ResourceLocation("mekanism:blocks/infuse/Diamond")).setTranslationKey("diamond")); + InfuseRegistry.registerInfuseType(new InfuseType("REDSTONE", new ResourceLocation("mekanism:blocks/infuse/Redstone")).setTranslationKey("redstone")); + InfuseRegistry.registerInfuseType(new InfuseType("FUNGI", new ResourceLocation("mekanism:blocks/infuse/Fungi")).setTranslationKey("fungi")); + InfuseRegistry.registerInfuseType(new InfuseType("BIO", new ResourceLocation("mekanism:blocks/infuse/Bio")).setTranslationKey("bio")); + InfuseRegistry.registerInfuseType(new InfuseType("OBSIDIAN", new ResourceLocation("mekanism:blocks/infuse/Obsidian")).setTranslationKey("obsidian")); Capabilities.registerCapabilities(); @@ -976,8 +833,7 @@ public class Mekanism { //Add baby skeleton spawner if (MekanismConfig.current().general.spawnBabySkeletons.val()) { for (Biome biome : BiomeProvider.allowedBiomes) { - if (biome.getSpawnableList(EnumCreatureType.MONSTER) != null - && biome.getSpawnableList(EnumCreatureType.MONSTER).size() > 0) { + if (biome.getSpawnableList(EnumCreatureType.MONSTER) != null && biome.getSpawnableList(EnumCreatureType.MONSTER).size() > 0) { EntityRegistry.addSpawn(EntityBabySkeleton.class, 40, 1, 3, EnumCreatureType.MONSTER, biome); } } @@ -1003,14 +859,12 @@ public class Mekanism { @EventHandler public void postInit(FMLPostInitializationEvent event) { - logger.info( - "Fake player readout: UUID = " + gameProfile.getId().toString() + ", name = " + gameProfile.getName()); + logger.info("Fake player readout: UUID = " + gameProfile.getId().toString() + ", name = " + gameProfile.getName()); // Add all furnace recipes to the energized smelter // Must happen after CraftTweaker for vanilla stuff has run. for (Map.Entry entry : FurnaceRecipes.instance().getSmeltingList().entrySet()) { - SmeltingRecipe recipe = new SmeltingRecipe(new ItemStackInput(entry.getKey()), - new ItemStackOutput(entry.getValue())); + SmeltingRecipe recipe = new SmeltingRecipe(new ItemStackInput(entry.getKey()), new ItemStackOutput(entry.getValue())); Recipe.ENERGIZED_SMELTER.put(recipe); } @@ -1024,8 +878,7 @@ public class Mekanism { @SubscribeEvent public void onEnergyTransferred(EnergyTransferEvent event) { try { - packetHandler.sendToReceivers(new TransmitterUpdateMessage(PacketType.ENERGY, - event.energyNetwork.firstTransmitter().coord(), event.power), + packetHandler.sendToReceivers(new TransmitterUpdateMessage(PacketType.ENERGY, event.energyNetwork.firstTransmitter().coord(), event.power), event.energyNetwork.getPacketRange()); } catch (Exception ignored) { } @@ -1034,9 +887,8 @@ public class Mekanism { @SubscribeEvent public void onGasTransferred(GasTransferEvent event) { try { - packetHandler.sendToReceivers( - new TransmitterUpdateMessage(PacketType.GAS, event.gasNetwork.firstTransmitter().coord(), - event.transferType, event.didTransfer), event.gasNetwork.getPacketRange()); + packetHandler.sendToReceivers(new TransmitterUpdateMessage(PacketType.GAS, event.gasNetwork.firstTransmitter().coord(), event.transferType, event.didTransfer), + event.gasNetwork.getPacketRange()); } catch (Exception ignored) { } } @@ -1044,8 +896,7 @@ public class Mekanism { @SubscribeEvent public void onLiquidTransferred(FluidTransferEvent event) { try { - packetHandler.sendToReceivers(new TransmitterUpdateMessage(PacketType.FLUID, - event.fluidNetwork.firstTransmitter().coord(), event.fluidType, event.didTransfer), + packetHandler.sendToReceivers(new TransmitterUpdateMessage(PacketType.FLUID, event.fluidNetwork.firstTransmitter().coord(), event.fluidType, event.didTransfer), event.fluidNetwork.getPacketRange()); } catch (Exception ignored) { } @@ -1054,9 +905,8 @@ public class Mekanism { @SubscribeEvent public void onTransmittersAddedEvent(TransmittersAddedEvent event) { try { - packetHandler.sendToReceivers( - new TransmitterUpdateMessage(PacketType.UPDATE, event.network.firstTransmitter().coord(), - event.newNetwork, event.newTransmitters), event.network.getPacketRange()); + packetHandler.sendToReceivers(new TransmitterUpdateMessage(PacketType.UPDATE, event.network.firstTransmitter().coord(), event.newNetwork, event.newTransmitters), + event.network.getPacketRange()); } catch (Exception ignored) { } } @@ -1143,13 +993,10 @@ public class Mekanism { if (!event.getWorld().isRemote) { if (MekanismConfig.current().general.enableWorldRegeneration.val()) { NBTTagCompound loadData = event.getData(); - - if (loadData.getInteger("MekanismWorldGen") == baseWorldGenVersion - && loadData.getInteger("MekanismUserWorldGen") == MekanismConfig - .current().general.userWorldGenVersion.val()) { + if (loadData.getInteger("MekanismWorldGen") == baseWorldGenVersion && + loadData.getInteger("MekanismUserWorldGen") == MekanismConfig.current().general.userWorldGenVersion.val()) { return; } - ChunkPos coordPair = event.getChunk().getPos(); worldTickHandler.addRegenChunk(event.getWorld().provider.getDimension(), coordPair); } @@ -1177,4 +1024,4 @@ public class Mekanism { MekFakePlayer.releaseInstance(event.getWorld()); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/MekanismBlocks.java b/src/main/java/mekanism/common/MekanismBlocks.java index 984a6279a..be3f61572 100644 --- a/src/main/java/mekanism/common/MekanismBlocks.java +++ b/src/main/java/mekanism/common/MekanismBlocks.java @@ -119,4 +119,4 @@ public class MekanismBlocks { public static Block init(Block block, String name) { return block.setTranslationKey(name).setRegistryName(new ResourceLocation(Mekanism.MODID, name)); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/MekanismFluids.java b/src/main/java/mekanism/common/MekanismFluids.java index ebf2b7673..6a546d587 100644 --- a/src/main/java/mekanism/common/MekanismFluids.java +++ b/src/main/java/mekanism/common/MekanismFluids.java @@ -19,8 +19,7 @@ public class MekanismFluids { public static final Gas SulfuricAcid = new Gas("sulfuricacid", 0x82802B); public static final Gas HydrogenChloride = new Gas("hydrogenchloride", 0xA8F1E9); - public static final Fluid HeavyWater = new Fluid("heavywater", - new ResourceLocation("mekanism:blocks/liquid/LiquidHeavyWater"), + public static final Fluid HeavyWater = new Fluid("heavywater", new ResourceLocation("mekanism:blocks/liquid/LiquidHeavyWater"), new ResourceLocation("mekanism:blocks/liquid/LiquidHeavyWater")); public static final Fluid Steam = new Fluid("steam", new ResourceLocation("mekanism:blocks/liquid/LiquidSteam"), new ResourceLocation("mekanism:blocks/liquid/LiquidSteam")).setGaseous(true); @@ -73,4 +72,4 @@ public class MekanismFluids { FluidRegistry.addBucketForFluid(Brine.getFluid()); FluidRegistry.addBucketForFluid(Lithium.getFluid()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/MekanismItems.java b/src/main/java/mekanism/common/MekanismItems.java index b7e04d5d4..bd0631b43 100644 --- a/src/main/java/mekanism/common/MekanismItems.java +++ b/src/main/java/mekanism/common/MekanismItems.java @@ -160,4 +160,4 @@ public class MekanismItems { public static Item init(Item item, String name) { return item.setTranslationKey(name).setRegistryName(new ResourceLocation(Mekanism.MODID, name)); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/MekanismSounds.java b/src/main/java/mekanism/common/MekanismSounds.java index 91498c163..ded5c0b52 100644 --- a/src/main/java/mekanism/common/MekanismSounds.java +++ b/src/main/java/mekanism/common/MekanismSounds.java @@ -34,4 +34,4 @@ public final class MekanismSounds { registry.register(event); return event; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/OreDictCache.java b/src/main/java/mekanism/common/OreDictCache.java index b6c5fd436..0d1985a15 100644 --- a/src/main/java/mekanism/common/OreDictCache.java +++ b/src/main/java/mekanism/common/OreDictCache.java @@ -19,24 +19,18 @@ public final class OreDictCache { if (check.isEmpty()) { return new ArrayList<>(); } - ItemInfo info = ItemInfo.get(check); List cached = cachedKeys.get(info); - if (cached != null) { return cached; } int[] idsFound = OreDictionary.getOreIDs(check); - List ret = new ArrayList<>(); - for (Integer id : idsFound) { ret.add(OreDictionary.getOreName(id)); } - cachedKeys.put(info, ret); - return ret; } @@ -46,12 +40,10 @@ public final class OreDictCache { } List keys = new ArrayList<>(); - for (String s : OreDictionary.getOreNames()) { if (s == null) { continue; } - if (oreName.equals(s) || oreName.equals("*")) { keys.add(s); } else if (oreName.endsWith("*") && !oreName.startsWith("*")) { @@ -70,19 +62,15 @@ public final class OreDictCache { } List stacks = new ArrayList<>(); - for (String key : keys) { for (ItemStack stack : OreDictionary.getOres(key)) { ItemStack toAdd = stack.copy(); - if (!stacks.contains(stack) && (!forceBlock || toAdd.getItem() instanceof ItemBlock)) { stacks.add(stack.copy()); } } } - oreDictStacks.put(oreName, stacks); - return stacks; } @@ -90,14 +78,11 @@ public final class OreDictCache { if (modIDStacks.get(modName) != null) { return modIDStacks.get(modName); } - List stacks = new ArrayList<>(); - for (String key : OreDictionary.getOreNames()) { for (ItemStack stack : OreDictionary.getOres(key)) { ItemStack toAdd = stack.copy(); String s = ItemRegistryUtils.getMod(toAdd); - if (!stacks.contains(stack) && toAdd.getItem() instanceof ItemBlock) { if (modName.equals(s) || modName.equals("*")) { stacks.add(stack.copy()); @@ -117,9 +102,7 @@ public final class OreDictCache { } } } - modIDStacks.put(modName, stacks); - return stacks; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/PacketHandler.java b/src/main/java/mekanism/common/PacketHandler.java index 8f22f81ad..8a6c8ddaf 100644 --- a/src/main/java/mekanism/common/PacketHandler.java +++ b/src/main/java/mekanism/common/PacketHandler.java @@ -94,7 +94,7 @@ public class PacketHandler { * Encodes an Object[] of data into a DataOutputStream. * * @param dataValues - an Object[] of data to encode - * @param output - the output stream to write to + * @param output - the output stream to write to */ public static void encode(Object[] dataValues, ByteBuf output) { try { @@ -134,14 +134,11 @@ public class PacketHandler { } else if (data instanceof NonNullList) { encode(((NonNullList) data).toArray(), output); } else { - throw new RuntimeException( - "Un-encodable data passed to encode(): " + data + ", full data: " + Arrays - .toString(dataValues)); + throw new RuntimeException("Un-encodable data passed to encode(): " + data + ", full data: " + Arrays.toString(dataValues)); } } } catch (Exception e) { - Mekanism.logger.error("Error while encoding packet data."); - e.printStackTrace(); + Mekanism.logger.error("Error while encoding packet data.", e); } } @@ -194,10 +191,8 @@ public class PacketHandler { netHandler.registerMessage(PacketTileEntity.class, TileEntityMessage.class, 5, Side.SERVER); netHandler.registerMessage(PacketPortalFX.class, PortalFXMessage.class, 6, Side.CLIENT); netHandler.registerMessage(PacketDataRequest.class, DataRequestMessage.class, 7, Side.SERVER); - netHandler - .registerMessage(PacketOredictionificatorGui.class, OredictionificatorGuiMessage.class, 8, Side.CLIENT); - netHandler - .registerMessage(PacketOredictionificatorGui.class, OredictionificatorGuiMessage.class, 8, Side.SERVER); + netHandler.registerMessage(PacketOredictionificatorGui.class, OredictionificatorGuiMessage.class, 8, Side.CLIENT); + netHandler.registerMessage(PacketOredictionificatorGui.class, OredictionificatorGuiMessage.class, 8, Side.SERVER); netHandler.registerMessage(PacketSecurityMode.class, SecurityModeMessage.class, 9, Side.SERVER); netHandler.registerMessage(PacketPortableTeleporter.class, PortableTeleporterMessage.class, 10, Side.CLIENT); netHandler.registerMessage(PacketPortableTeleporter.class, PortableTeleporterMessage.class, 10, Side.SERVER); @@ -227,17 +222,15 @@ public class PacketHandler { netHandler.registerMessage(PacketDropperUse.class, DropperUseMessage.class, 28, Side.SERVER); netHandler.registerMessage(PacketEntityMove.class, EntityMoveMessage.class, 29, Side.CLIENT); netHandler.registerMessage(PacketSecurityUpdate.class, SecurityUpdateMessage.class, 30, Side.CLIENT); - netHandler.registerMessage(PacketFreeRunnerData.class, PacketFreeRunnerData.FreeRunnerDataMessage.class, 31, - Side.CLIENT); - netHandler.registerMessage(PacketFreeRunnerData.class, PacketFreeRunnerData.FreeRunnerDataMessage.class, 31, - Side.SERVER); + netHandler.registerMessage(PacketFreeRunnerData.class, PacketFreeRunnerData.FreeRunnerDataMessage.class, 31, Side.CLIENT); + netHandler.registerMessage(PacketFreeRunnerData.class, PacketFreeRunnerData.FreeRunnerDataMessage.class, 31, Side.SERVER); } /** * Send this message to the specified player. * * @param message - the message to send - * @param player - the player to send it to + * @param player - the player to send it to */ public void sendTo(IMessage message, EntityPlayerMP player) { netHandler.sendTo(message, player); @@ -250,7 +243,6 @@ public class PacketHandler { */ public void sendToAll(IMessage message) { MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); - for (EntityPlayerMP player : server.getPlayerList().getPlayers()) { sendTo(message, player); } @@ -260,7 +252,7 @@ public class PacketHandler { * Send this message to everyone within a certain range of a point. * * @param message - the message to send - * @param point - the TargetPoint around which to send + * @param point - the TargetPoint around which to send */ public void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point) { netHandler.sendToAllAround(message, point); @@ -269,7 +261,7 @@ public class PacketHandler { /** * Send this message to everyone within the supplied dimension. * - * @param message - the message to send + * @param message - the message to send * @param dimensionId - the dimension id to target */ public void sendToDimension(IMessage message, int dimensionId) { @@ -289,12 +281,11 @@ public class PacketHandler { * Send this message to all players within a defined AABB cuboid. * * @param message - the message to send - * @param cuboid - the AABB cuboid to send the packet in - * @param dimId - the dimension the cuboid is in + * @param cuboid - the AABB cuboid to send the packet in + * @param dimId - the dimension the cuboid is in */ public void sendToCuboid(IMessage message, AxisAlignedBB cuboid, int dimId) { MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); - if (server != null && cuboid != null) { for (EntityPlayerMP player : server.getPlayerList().getPlayers()) { if (player.dimension == dimId && cuboid.contains(new Vec3d(player.posX, player.posY, player.posZ))) { @@ -306,7 +297,6 @@ public class PacketHandler { public void sendToReceivers(IMessage message, Range4D range) { MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); - if (server != null) { for (EntityPlayerMP player : server.getPlayerList().getPlayers()) { if (player.dimension == range.dimensionId && Range4D.getChunkRange(player).intersects(range)) { @@ -325,4 +315,4 @@ public class PacketHandler { dataStream.writeLong(uuid.getMostSignificantBits()); dataStream.writeLong(uuid.getLeastSignificantBits()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/PlayerState.java b/src/main/java/mekanism/common/PlayerState.java index 84ca5c7d9..835f90864 100644 --- a/src/main/java/mekanism/common/PlayerState.java +++ b/src/main/java/mekanism/common/PlayerState.java @@ -44,8 +44,7 @@ public class PlayerState { public void setJetpackState(UUID uuid, boolean isActive, boolean isLocal) { boolean alreadyActive = activeJetpacks.contains(uuid); - boolean changed = (alreadyActive != isActive); - + boolean changed = alreadyActive != isActive; if (alreadyActive && !isActive) { // On -> off activeJetpacks.remove(uuid); @@ -69,7 +68,7 @@ public class PlayerState { } public boolean isJetpackOn(EntityPlayer p) { - return activeJetpacks.contains(p.getName()); + return activeJetpacks.contains(p.getUniqueID()); } public Set getActiveJetpacks() { @@ -90,8 +89,7 @@ public class PlayerState { public void setGasmaskState(UUID uuid, boolean isActive, boolean isLocal) { boolean alreadyActive = activeGasmasks.contains(uuid); - boolean changed = (alreadyActive != isActive); - + boolean changed = alreadyActive != isActive; if (alreadyActive && !isActive) { activeGasmasks.remove(uuid); // On -> off } else if (!alreadyActive && isActive) { @@ -102,8 +100,7 @@ public class PlayerState { if (changed && world.isRemote) { // If the player is the "local" player, we need to tell the server the state has changed if (isLocal) { - Mekanism.packetHandler - .sendToServer(PacketScubaTankData.ScubaTankDataMessage.UPDATE(uuid, isActive)); + Mekanism.packetHandler.sendToServer(PacketScubaTankData.ScubaTankDataMessage.UPDATE(uuid, isActive)); } // Start a sound playing if the person is now using a gasmask @@ -135,8 +132,7 @@ public class PlayerState { public void setFlamethrowerState(UUID uuid, boolean isActive, boolean isLocal) { boolean alreadyActive = activeFlamethrowers.contains(uuid); - boolean changed = (alreadyActive != isActive); - + boolean changed = alreadyActive != isActive; if (alreadyActive && !isActive) { activeFlamethrowers.remove(uuid); // On -> off } else if (!alreadyActive && isActive) { @@ -147,8 +143,7 @@ public class PlayerState { if (changed && world.isRemote) { // If the player is the "local" player, we need to tell the server the state has changed if (isLocal) { - Mekanism.packetHandler.sendToServer(new FlamethrowerDataMessage(FlamethrowerPacket.UPDATE, null, - uuid, isActive)); + Mekanism.packetHandler.sendToServer(new FlamethrowerDataMessage(FlamethrowerPacket.UPDATE, null, uuid, isActive)); } // Start a sound playing if the person is now using a flamethrower @@ -162,4 +157,4 @@ public class PlayerState { return activeFlamethrowers.contains(p.getUniqueID()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/Resource.java b/src/main/java/mekanism/common/Resource.java index 68e578297..5358f36d9 100644 --- a/src/main/java/mekanism/common/Resource.java +++ b/src/main/java/mekanism/common/Resource.java @@ -20,16 +20,16 @@ public enum Resource { } public static Resource getFromName(String s) { + s = s.toLowerCase(Locale.ROOT); for (Resource r : values()) { - if (r.name.toLowerCase(Locale.ROOT).equals(s.toLowerCase(Locale.ROOT))) { + if (r.name.toLowerCase(Locale.ROOT).equals(s)) { return r; } } - return null; } public String getName() { return name; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/SideData.java b/src/main/java/mekanism/common/SideData.java index 34f94d5b1..5f2e034d0 100644 --- a/src/main/java/mekanism/common/SideData.java +++ b/src/main/java/mekanism/common/SideData.java @@ -55,34 +55,28 @@ public class SideData { } } } - return false; } public FluidTankInfo[] getFluidTankInfo(ITankManager manager) { Object[] tanks = manager.getTanks(); List infos = new ArrayList<>(); - if (tanks == null) { return infos.toArray(new FluidTankInfo[]{}); } - for (int slot : availableSlots) { if (slot <= tanks.length - 1 && tanks[slot] instanceof IFluidTank) { infos.add(((IFluidTank) tanks[slot]).getInfo()); } } - return infos.toArray(new FluidTankInfo[]{}); } public GasTank getGasTank(ITankManager manager) { Object[] tanks = manager.getTanks(); - if (tanks == null || tanks.length < 1 || !(tanks[0] instanceof GasTank)) { return null; } - return (GasTank) tanks[0]; } @@ -91,4 +85,4 @@ public class SideData { OUTPUT, OFF } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/Upgrade.java b/src/main/java/mekanism/common/Upgrade.java index 87ab7c729..b3a5a2c85 100644 --- a/src/main/java/mekanism/common/Upgrade.java +++ b/src/main/java/mekanism/common/Upgrade.java @@ -35,39 +35,31 @@ public enum Upgrade { public static Map buildMap(@Nullable NBTTagCompound nbtTags) { Map upgrades = new HashMap<>(); - if (nbtTags != null) { if (nbtTags.hasKey("upgrades")) { NBTTagList list = nbtTags.getTagList("upgrades", NBT.TAG_COMPOUND); - for (int tagCount = 0; tagCount < list.tagCount(); tagCount++) { NBTTagCompound compound = list.getCompoundTagAt(tagCount); - Upgrade upgrade = Upgrade.values()[compound.getInteger("type")]; upgrades.put(upgrade, compound.getInteger("amount")); } } } - return upgrades; } public static void saveMap(Map upgrades, NBTTagCompound nbtTags) { NBTTagList list = new NBTTagList(); - for (Map.Entry entry : upgrades.entrySet()) { list.appendTag(getTagFor(entry.getKey(), entry.getValue())); } - nbtTags.setTag("upgrades", list); } public static NBTTagCompound getTagFor(Upgrade upgrade, int amount) { NBTTagCompound compound = new NBTTagCompound(); - compound.setInteger("type", upgrade.ordinal()); compound.setInteger("amount", amount); - return compound; } @@ -106,13 +98,11 @@ public enum Upgrade { case ANCHOR: return new ItemStack(MekanismItems.AnchorUpgrade); } - return ItemStack.EMPTY; } public List getInfo(TileEntity tile) { List ret = new ArrayList<>(); - if (tile instanceof IUpgradeTile) { if (tile instanceof IUpgradeInfoHandler) { return ((IUpgradeInfoHandler) tile).getInfo(this); @@ -120,32 +110,24 @@ public enum Upgrade { ret = getMultScaledInfo((IUpgradeTile) tile); } } - return ret; } public List getMultScaledInfo(IUpgradeTile tile) { List ret = new ArrayList<>(); - if (canMultiply()) { - double effect = Math.pow(MekanismConfig.current().general.maxUpgradeMultiplier.val(), - (float) tile.getComponent().getUpgrades(this) / (float) getMax()); - + double effect = Math.pow(MekanismConfig.current().general.maxUpgradeMultiplier.val(), (float) tile.getComponent().getUpgrades(this) / (float) getMax()); ret.add(LangUtils.localize("gui.upgrades.effect") + ": " + (Math.round(effect * 100) / 100F) + "x"); } - return ret; } public List getExpScaledInfo(IUpgradeTile tile) { List ret = new ArrayList<>(); - if (canMultiply()) { double effect = Math.pow(2, (float) tile.getComponent().getUpgrades(this)); - ret.add(LangUtils.localize("gui.upgrades.effect") + ": " + effect + "x"); } - return ret; } @@ -153,4 +135,4 @@ public enum Upgrade { List getInfo(Upgrade upgrade); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/Version.java b/src/main/java/mekanism/common/Version.java index 8a3e19a81..369298991 100644 --- a/src/main/java/mekanism/common/Version.java +++ b/src/main/java/mekanism/common/Version.java @@ -39,15 +39,14 @@ public class Version { * Gets a version object from a string. * * @param s - string object + * * @return version if applicable, otherwise null */ 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()) { if (!Character.isDigit(c)) { @@ -57,11 +56,9 @@ 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]); } @@ -76,6 +73,7 @@ public class Version { /** * @param version Version to check against + * * @return 1: greater than, 0: equal to, -1: less than */ public byte comparedState(Version version) { @@ -86,31 +84,26 @@ public class Version { return -1; } else if (version.minor == minor) { return (byte) Integer.compare(build, version.build); - } else { - return 1; } - } else { return 1; } + return 1; } @Override public String toString() { if (major == 0 && minor == 0 && build == 0) { return ""; - } else { - return major + "." + minor + "." + build; } + return major + "." + minor + "." + build; } @Override public int hashCode() { int result = 1; - result = 31 * result + build; result = 31 * result + major; result = 31 * result + minor; - return result; } @@ -119,9 +112,7 @@ public class Version { if (obj == null || getClass() != obj.getClass()) { return false; } - Version other = (Version) obj; - return build == other.build && major == other.major && minor == other.minor; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/base/EnergyAcceptorWrapper.java b/src/main/java/mekanism/common/base/EnergyAcceptorWrapper.java index fcd5f3586..4d803f2b5 100644 --- a/src/main/java/mekanism/common/base/EnergyAcceptorWrapper.java +++ b/src/main/java/mekanism/common/base/EnergyAcceptorWrapper.java @@ -29,18 +29,14 @@ public abstract class EnergyAcceptorWrapper implements IStrictEnergyAcceptor { if (tileEntity == null || tileEntity.getWorld() == null) { return null; } - EnergyAcceptorWrapper wrapper = null; - if (CapabilityUtils.hasCapability(tileEntity, Capabilities.ENERGY_ACCEPTOR_CAPABILITY, side)) { wrapper = fromCapability(tileEntity, Capabilities.ENERGY_ACCEPTOR_CAPABILITY, side, MekanismAcceptor::new); - } else if (MekanismUtils.useForge() && CapabilityUtils - .hasCapability(tileEntity, CapabilityEnergy.ENERGY, side)) { + } else if (MekanismUtils.useForge() && CapabilityUtils.hasCapability(tileEntity, CapabilityEnergy.ENERGY, side)) { wrapper = fromCapability(tileEntity, CapabilityEnergy.ENERGY, side, ForgeAcceptor::new); } else if (MekanismUtils.useRF() && tileEntity instanceof IEnergyReceiver) { wrapper = new RFAcceptor((IEnergyReceiver) tileEntity); - } else if (MekanismUtils.useTesla() && CapabilityUtils - .hasCapability(tileEntity, Capabilities.TESLA_CONSUMER_CAPABILITY, side)) { + } else if (MekanismUtils.useTesla() && CapabilityUtils.hasCapability(tileEntity, Capabilities.TESLA_CONSUMER_CAPABILITY, side)) { wrapper = fromCapability(tileEntity, Capabilities.TESLA_CONSUMER_CAPABILITY, side, TeslaAcceptor::new); } else if (MekanismUtils.useIC2()) { IEnergyTile tile = EnergyNet.instance.getSubTile(tileEntity.getWorld(), tileEntity.getPos()); @@ -48,11 +44,9 @@ public abstract class EnergyAcceptorWrapper implements IStrictEnergyAcceptor { wrapper = new IC2Acceptor((IEnergySink) tile); } } - if (wrapper != null) { wrapper.coord = Coord4D.get(tileEntity); } - return wrapper; } @@ -65,8 +59,7 @@ public abstract class EnergyAcceptorWrapper implements IStrictEnergyAcceptor { if (acceptor != null) { return makeAcceptor.apply(acceptor); } else { - LOGGER.error("Tile {} @ {} told us it had {} cap but returned null", tileEntity, - tileEntity.getPos(), capability.getName()); + LOGGER.error("Tile {} @ {} told us it had {} cap but returned null", tileEntity, tileEntity.getPos(), capability.getName()); } return null; } @@ -145,7 +138,6 @@ public abstract class EnergyAcceptorWrapper implements IStrictEnergyAcceptor { return fromEU(toTransfer); } double rejects = acceptor.injectEnergy(side, toTransfer, 0); - return fromEU(toTransfer - rejects); } @@ -231,4 +223,4 @@ public abstract class EnergyAcceptorWrapper implements IStrictEnergyAcceptor { return forge * MekanismConfig.current().general.FROM_FORGE.val(); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/base/FluidHandlerWrapper.java b/src/main/java/mekanism/common/base/FluidHandlerWrapper.java index c8e8d919e..a9bf81b8c 100644 --- a/src/main/java/mekanism/common/base/FluidHandlerWrapper.java +++ b/src/main/java/mekanism/common/base/FluidHandlerWrapper.java @@ -20,8 +20,7 @@ public class FluidHandlerWrapper implements IFluidHandler { } private static IFluidTankProperties[] convertReadOnly(FluidTankInfo[] fluidTankInfos) { - return Arrays.stream(fluidTankInfos).map(t -> new FluidTankProperties(t.fluid, t.capacity, false, false)) - .toArray(IFluidTankProperties[]::new); + return Arrays.stream(fluidTankInfos).map(t -> new FluidTankProperties(t.fluid, t.capacity, false, false)).toArray(IFluidTankProperties[]::new); } @Override @@ -29,8 +28,7 @@ public class FluidHandlerWrapper implements IFluidHandler { if (side == null) { return convertReadOnly(wrapper.getAllTanks()); } - return wrapper.getTankInfo(side) != null ? FluidTankProperties.convert(wrapper.getTankInfo(side)) - : new IFluidTankProperties[]{}; + return wrapper.getTankInfo(side) != null ? FluidTankProperties.convert(wrapper.getTankInfo(side)) : new IFluidTankProperties[]{}; } @Override @@ -41,7 +39,6 @@ public class FluidHandlerWrapper implements IFluidHandler { if (wrapper.canFill(side, resource)) { return wrapper.fill(side, resource, doFill); } - return 0; } @@ -53,7 +50,6 @@ public class FluidHandlerWrapper implements IFluidHandler { if (wrapper.canDrain(side, resource)) { return wrapper.drain(side, resource, doDrain); } - return null; } @@ -65,7 +61,6 @@ public class FluidHandlerWrapper implements IFluidHandler { if (wrapper.canDrain(side, null)) { return wrapper.drain(side, maxDrain, doDrain); } - return null; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/base/FluidItemWrapper.java b/src/main/java/mekanism/common/base/FluidItemWrapper.java index 17f85c777..11610021c 100644 --- a/src/main/java/mekanism/common/base/FluidItemWrapper.java +++ b/src/main/java/mekanism/common/base/FluidItemWrapper.java @@ -13,8 +13,7 @@ public class FluidItemWrapper extends ItemCapability implements IFluidHandlerIte @Override public FluidTankProperties[] getTankProperties() { - return new FluidTankProperties[]{ - new FluidTankProperties(getItem().getFluid(getStack()), getItem().getCapacity(getStack()))}; + return new FluidTankProperties[]{new FluidTankProperties(getItem().getFluid(getStack()), getItem().getCapacity(getStack()))}; } @Override @@ -22,7 +21,6 @@ public class FluidItemWrapper extends ItemCapability implements IFluidHandlerIte if (getStack().getCount() != 1) { return 0; } - return getItem().fill(getStack(), resource, doFill); } @@ -31,15 +29,12 @@ public class FluidItemWrapper extends ItemCapability implements IFluidHandlerIte if (getStack().getCount() != 1 || resource == null) { return null; } - FluidStack canDrain = drain(resource.amount, false); - if (canDrain != null) { if (canDrain.isFluidEqual(resource)) { return drain(resource.amount, doDrain); } } - return null; } @@ -48,7 +43,6 @@ public class FluidItemWrapper extends ItemCapability implements IFluidHandlerIte if (getStack().getCount() != 1) { return null; } - return getItem().drain(getStack(), maxDrain, doDrain); } @@ -66,4 +60,4 @@ public class FluidItemWrapper extends ItemCapability implements IFluidHandlerIte public boolean canProcess(Capability cap) { return cap == CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/base/IActiveState.java b/src/main/java/mekanism/common/base/IActiveState.java index 1177e7bf1..b51f155ed 100644 --- a/src/main/java/mekanism/common/base/IActiveState.java +++ b/src/main/java/mekanism/common/base/IActiveState.java @@ -22,14 +22,14 @@ public interface IActiveState { void setActive(boolean active); /** - * Determine if a machine/generator was "recently" active, where "recently" is up to the interface - * implementor. This is useful for reducing rendering calls, esp. when the entity can oscillate between - * active/inactive states rapidly. + * Determine if a machine/generator was "recently" active, where "recently" is up to the interface implementor. This is useful for reducing rendering calls, esp. when + * the entity can oscillate between active/inactive states rapidly. * * The default implementation just returns current active state. - * */ - default boolean wasActiveRecently() { return getActive(); } + default boolean wasActiveRecently() { + return getActive(); + } /** * Whether or not this block has a visual effect when it is on it's active state. Used for rendering. @@ -39,4 +39,4 @@ public interface IActiveState { boolean renderUpdate(); boolean lightUpdate(); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/base/IAdvancedBoundingBlock.java b/src/main/java/mekanism/common/base/IAdvancedBoundingBlock.java index 112c4b4e3..aeea95661 100644 --- a/src/main/java/mekanism/common/base/IAdvancedBoundingBlock.java +++ b/src/main/java/mekanism/common/base/IAdvancedBoundingBlock.java @@ -22,13 +22,12 @@ import net.minecraftforge.fml.common.Optional.InterfaceList; @Interface(iface = "cofh.redstoneflux.api.IEnergyReceiver", modid = MekanismHooks.REDSTONEFLUX_MOD_ID), @Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = MekanismHooks.IC2_MOD_ID), }) -public interface IAdvancedBoundingBlock extends ICapabilityProvider, IBoundingBlock, ISidedInventory, IEnergySink, - IStrictEnergyAcceptor, IStrictEnergyStorage, IEnergyReceiver, IEnergyProvider, IComputerIntegration, - ISpecialConfigData, ISecurityTile, IOffsetCapability { +public interface IAdvancedBoundingBlock extends ICapabilityProvider, IBoundingBlock, ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IStrictEnergyStorage, + IEnergyReceiver, IEnergyProvider, IComputerIntegration, ISpecialConfigData, ISecurityTile, IOffsetCapability { boolean canBoundReceiveEnergy(BlockPos location, EnumFacing side); void onPower(); void onNoPower(); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/base/IBlockType.java b/src/main/java/mekanism/common/base/IBlockType.java index c2e22ed39..5ef7272f8 100644 --- a/src/main/java/mekanism/common/base/IBlockType.java +++ b/src/main/java/mekanism/common/base/IBlockType.java @@ -1,18 +1,8 @@ package mekanism.common.base; -//import java.util.Collection; - -//import mekanism.common.recipe.ShapedMekanismRecipe; - public interface IBlockType { String getBlockName(); -// public Collection getRecipes(); -// -// public void addRecipes(Collection recipes); -// -// public void addRecipe(ShapedMekanismRecipe recipe); - boolean isEnabled(); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/base/IBoundingBlock.java b/src/main/java/mekanism/common/base/IBoundingBlock.java index feebe32df..893c29297 100644 --- a/src/main/java/mekanism/common/base/IBoundingBlock.java +++ b/src/main/java/mekanism/common/base/IBoundingBlock.java @@ -1,8 +1,7 @@ package mekanism.common.base; /** - * Internal interface. A bounding block is not actually a 'bounding' block, it is really just a fake block that is used - * to mimic actual block bounds. + * Internal interface. A bounding block is not actually a 'bounding' block, it is really just a fake block that is used to mimic actual block bounds. * * @author AidanBrady */ @@ -17,4 +16,4 @@ public interface IBoundingBlock { * Called when any part of the structure is broken. */ void onBreak(); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/base/IElectricMachine.java b/src/main/java/mekanism/common/base/IElectricMachine.java index c691d1253..80c5cdf20 100644 --- a/src/main/java/mekanism/common/base/IElectricMachine.java +++ b/src/main/java/mekanism/common/base/IElectricMachine.java @@ -6,8 +6,7 @@ import mekanism.common.recipe.machines.MachineRecipe; import mekanism.common.recipe.outputs.MachineOutput; /** - * Internal interface containing methods that are shared by many core Mekanism machines. TODO: remove next minor MC - * version. + * Internal interface containing methods that are shared by many core Mekanism machines. TODO: remove next minor MC version. * * @author AidanBrady */ @@ -38,4 +37,4 @@ public interface IElectricMachine, OUTPUT exte RECIPE getRecipe(); INPUT getInput(); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/base/IEnergyWrapper.java b/src/main/java/mekanism/common/base/IEnergyWrapper.java index e98baf324..8a5a78fcf 100644 --- a/src/main/java/mekanism/common/base/IEnergyWrapper.java +++ b/src/main/java/mekanism/common/base/IEnergyWrapper.java @@ -22,12 +22,12 @@ import net.minecraftforge.fml.common.Optional.InterfaceList; @Interface(iface = "ic2.api.energy.tile.IEnergyEmitter", modid = MekanismHooks.IC2_MOD_ID), @Interface(iface = "ic2.api.tile.IEnergyStorage", modid = MekanismHooks.IC2_MOD_ID) }) -public interface IEnergyWrapper extends IStrictEnergyStorage, IEnergyReceiver, IEnergyProvider, IEnergySink, - IEnergySource, IEnergyStorage, IStrictEnergyAcceptor, IStrictEnergyOutputter, IInventory { +public interface IEnergyWrapper extends IStrictEnergyStorage, IEnergyReceiver, IEnergyProvider, IEnergySink, IEnergySource, IEnergyStorage, IStrictEnergyAcceptor, + IStrictEnergyOutputter, IInventory { boolean sideIsOutput(EnumFacing side); boolean sideIsConsumer(EnumFacing side); double getMaxOutput(); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/base/IFactory.java b/src/main/java/mekanism/common/base/IFactory.java index b23a1c3bb..98ad6107a 100644 --- a/src/main/java/mekanism/common/base/IFactory.java +++ b/src/main/java/mekanism/common/base/IFactory.java @@ -41,6 +41,7 @@ public interface IFactory { * Gets the recipe type this Smelting Factory currently has. * * @param itemStack - stack to check + * * @return RecipeType ordinal */ int getRecipeType(ItemStack itemStack); @@ -49,6 +50,7 @@ public interface IFactory { * Gets the recipe type this Factory currently has. * * @param itemStack - stack to check + * * @return RecipeType or null if it has invalid NBT */ @Nullable @@ -57,7 +59,7 @@ public interface IFactory { /** * Sets the recipe type of this Smelting Factory to a new value. * - * @param type - RecipeType ordinal + * @param type - RecipeType ordinal * @param itemStack - stack to set */ void setRecipeType(int type, ItemStack itemStack); @@ -70,22 +72,15 @@ public interface IFactory { } enum RecipeType implements IStringSerializable { - SMELTING("Smelting", "smelter", MachineType.ENERGIZED_SMELTER, MachineFuelType.BASIC, false, - Recipe.ENERGIZED_SMELTER), - ENRICHING("Enriching", "enrichment", MachineType.ENRICHMENT_CHAMBER, MachineFuelType.BASIC, false, - Recipe.ENRICHMENT_CHAMBER), + SMELTING("Smelting", "smelter", MachineType.ENERGIZED_SMELTER, MachineFuelType.BASIC, false, Recipe.ENERGIZED_SMELTER), + ENRICHING("Enriching", "enrichment", MachineType.ENRICHMENT_CHAMBER, MachineFuelType.BASIC, false, Recipe.ENRICHMENT_CHAMBER), CRUSHING("Crushing", "crusher", MachineType.CRUSHER, MachineFuelType.BASIC, false, Recipe.CRUSHER), - COMPRESSING("Compressing", "compressor", MachineType.OSMIUM_COMPRESSOR, MachineFuelType.ADVANCED, false, - Recipe.OSMIUM_COMPRESSOR), + COMPRESSING("Compressing", "compressor", MachineType.OSMIUM_COMPRESSOR, MachineFuelType.ADVANCED, false, Recipe.OSMIUM_COMPRESSOR), COMBINING("Combining", "combiner", MachineType.COMBINER, MachineFuelType.DOUBLE, false, Recipe.COMBINER), - PURIFYING("Purifying", "purifier", MachineType.PURIFICATION_CHAMBER, MachineFuelType.ADVANCED, true, - Recipe.PURIFICATION_CHAMBER), - INJECTING("Injecting", "injection", MachineType.CHEMICAL_INJECTION_CHAMBER, MachineFuelType.ADVANCED, true, - Recipe.CHEMICAL_INJECTION_CHAMBER), - INFUSING("Infusing", "metalinfuser", MachineType.METALLURGIC_INFUSER, MachineFuelType.BASIC, false, - Recipe.METALLURGIC_INFUSER), - SAWING("Sawing", "sawmill", MachineType.PRECISION_SAWMILL, MachineFuelType.CHANCE, false, - Recipe.PRECISION_SAWMILL); + PURIFYING("Purifying", "purifier", MachineType.PURIFICATION_CHAMBER, MachineFuelType.ADVANCED, true, Recipe.PURIFICATION_CHAMBER), + INJECTING("Injecting", "injection", MachineType.CHEMICAL_INJECTION_CHAMBER, MachineFuelType.ADVANCED, true, Recipe.CHEMICAL_INJECTION_CHAMBER), + INFUSING("Infusing", "metalinfuser", MachineType.METALLURGIC_INFUSER, MachineFuelType.BASIC, false, Recipe.METALLURGIC_INFUSER), + SAWING("Sawing", "sawmill", MachineType.PRECISION_SAWMILL, MachineFuelType.CHANCE, false, Recipe.PRECISION_SAWMILL); private String name; private SoundEvent sound; @@ -106,16 +101,13 @@ public interface IFactory { public static RecipeType getFromMachine(Block block, int meta) { RecipeType type = null; - for (RecipeType iterType : RecipeType.values()) { ItemStack machineStack = iterType.getStack(); - if (Block.getBlockFromItem(machineStack.getItem()) == block && machineStack.getItemDamage() == meta) { type = iterType; break; } } - return type; } @@ -160,8 +152,7 @@ public interface IFactory { } @Nullable - public MachineRecipe getAnyRecipe(ItemStack slotStack, ItemStack extraStack, Gas gasType, - InfuseStorage infuse) { + public MachineRecipe getAnyRecipe(ItemStack slotStack, ItemStack extraStack, Gas gasType, InfuseStorage infuse) { if (fuelType == MachineFuelType.ADVANCED) { return getRecipe(slotStack, gasType); } else if (fuelType == MachineFuelType.DOUBLE) { @@ -172,15 +163,13 @@ public interface IFactory { if (infuse.getType() != null) { return RecipeHandler.getMetallurgicInfuserRecipe(new InfusionInput(infuse, slotStack)); } else { - for (Entry entry : Recipe.METALLURGIC_INFUSER.get() - .entrySet()) { + for (Entry entry : Recipe.METALLURGIC_INFUSER.get().entrySet()) { if (entry.getKey().inputStack.isItemEqual(slotStack)) { return entry.getValue(); } } } } - return getRecipe(slotStack); } @@ -189,7 +178,6 @@ public interface IFactory { if (fuelType == MachineFuelType.ADVANCED) { return getTile().getItemGas(itemstack); } - return null; } @@ -197,7 +185,6 @@ public interface IFactory { if (fuelType == MachineFuelType.ADVANCED) { return getTile().BASE_SECONDARY_ENERGY_PER_TICK; } - return 0; } @@ -205,7 +192,6 @@ public interface IFactory { if (fuelType == MachineFuelType.ADVANCED) { return getTile().canReceiveGas(side, type); } - return false; } @@ -217,7 +203,6 @@ public interface IFactory { if (fuelType == MachineFuelType.ADVANCED) { return getTile().isValidGas(gas); } - return false; } @@ -225,18 +210,15 @@ public interface IFactory { if (itemStack.isEmpty()) { return false; } - for (Object obj : recipe.get().entrySet()) { if (((Map.Entry) obj).getKey() instanceof AdvancedMachineInput) { Map.Entry entry = (Map.Entry) obj; ItemStack stack = ((AdvancedMachineInput) entry.getKey()).itemStack; - if (StackUtils.equalsWildcard(stack, itemStack)) { return true; } } } - return false; } @@ -244,18 +226,15 @@ public interface IFactory { if (extraStack.isEmpty()) { return false; } - for (Object obj : recipe.get().entrySet()) { if (((Map.Entry) obj).getKey() instanceof DoubleMachineInput) { Map.Entry entry = (Map.Entry) obj; ItemStack stack = ((DoubleMachineInput) entry.getKey()).extraStack; - if (StackUtils.equalsWildcard(stack, extraStack)) { return true; } } } - return false; } @@ -264,7 +243,6 @@ public interface IFactory { MachineType type = MachineType.get(getStack()); cacheTile = (TileEntityAdvancedElectricMachine) type.create(); } - return cacheTile; } @@ -313,4 +291,4 @@ public interface IFactory { return type; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/base/IFluidContainerManager.java b/src/main/java/mekanism/common/base/IFluidContainerManager.java index f363645fd..5f890bc02 100644 --- a/src/main/java/mekanism/common/base/IFluidContainerManager.java +++ b/src/main/java/mekanism/common/base/IFluidContainerManager.java @@ -7,4 +7,4 @@ public interface IFluidContainerManager { ContainerEditMode getContainerEditMode(); void setContainerEditMode(ContainerEditMode mode); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/base/IFluidHandlerWrapper.java b/src/main/java/mekanism/common/base/IFluidHandlerWrapper.java index be126e2c3..b4abf86a7 100644 --- a/src/main/java/mekanism/common/base/IFluidHandlerWrapper.java +++ b/src/main/java/mekanism/common/base/IFluidHandlerWrapper.java @@ -20,4 +20,4 @@ public interface IFluidHandlerWrapper { FluidTankInfo[] getTankInfo(EnumFacing from); FluidTankInfo[] getAllTanks(); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/base/IFluidItemWrapper.java b/src/main/java/mekanism/common/base/IFluidItemWrapper.java index 08a8ab604..5eb4f6d73 100644 --- a/src/main/java/mekanism/common/base/IFluidItemWrapper.java +++ b/src/main/java/mekanism/common/base/IFluidItemWrapper.java @@ -12,4 +12,4 @@ public interface IFluidItemWrapper { int fill(ItemStack container, FluidStack resource, boolean doFill); FluidStack drain(ItemStack container, int maxDrain, boolean doDrain); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/base/IGuiProvider.java b/src/main/java/mekanism/common/base/IGuiProvider.java index c3b7629ea..037c78c02 100644 --- a/src/main/java/mekanism/common/base/IGuiProvider.java +++ b/src/main/java/mekanism/common/base/IGuiProvider.java @@ -10,10 +10,11 @@ public interface IGuiProvider { /** * Get the container for a GUI. Common. * - * @param ID - gui ID + * @param ID - gui ID * @param player - player that opened the GUI - * @param world - world the GUI was opened in - * @param pos - gui's position + * @param world - world the GUI was opened in + * @param pos - gui's position + * * @return the Container of the GUI */ Container getServerGui(int ID, EntityPlayer player, World world, BlockPos pos); @@ -21,11 +22,12 @@ public interface IGuiProvider { /** * Get the actual interface for a GUI. Client-only. * - * @param ID - gui ID + * @param ID - gui ID * @param player - player that opened the GUI - * @param world - world the GUI was opened in - * @param pos - gui's position + * @param world - world the GUI was opened in + * @param pos - gui's position + * * @return the GuiScreen of the GUI */ Object getClientGui(int ID, EntityPlayer player, World world, BlockPos pos); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/base/IItemNetwork.java b/src/main/java/mekanism/common/base/IItemNetwork.java index 0c73b547b..3c41c11cf 100644 --- a/src/main/java/mekanism/common/base/IItemNetwork.java +++ b/src/main/java/mekanism/common/base/IItemNetwork.java @@ -6,4 +6,4 @@ import net.minecraft.item.ItemStack; public interface IItemNetwork { void handlePacketData(ItemStack stack, ByteBuf dataStream); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/base/ILogisticalTransporter.java b/src/main/java/mekanism/common/base/ILogisticalTransporter.java index d5c13b470..3bd4e1fe9 100644 --- a/src/main/java/mekanism/common/base/ILogisticalTransporter.java +++ b/src/main/java/mekanism/common/base/ILogisticalTransporter.java @@ -16,8 +16,7 @@ public interface ILogisticalTransporter extends IGridTransmitter> { public abstract TYPE getTotalSent(); - public boolean shouldRecheck() { - return amountPerChanged && toSplitAmong > 0; - } - public static class IntegerSplitInfo extends SplitInfo { + private int amountToSplit; //AmountPer is the one that needs to be int or double private int amountPerTarget; @@ -62,6 +59,7 @@ public abstract class SplitInfo> { } public static class DoubleSplitInfo extends SplitInfo { + private double amountToSplit; private double amountPerTarget; private double sentSoFar; diff --git a/src/main/java/mekanism/common/base/target/Target.java b/src/main/java/mekanism/common/base/target/Target.java index edc409397..36d1106b0 100644 --- a/src/main/java/mekanism/common/base/target/Target.java +++ b/src/main/java/mekanism/common/base/target/Target.java @@ -11,8 +11,8 @@ import net.minecraft.util.EnumFacing; * Keeps track of a target for emitting from various networks. * * @param The Handler this target keeps track of. - * @param The type that is being transferred. - * @param Any extra information this target may need to keep track of. + * @param The type that is being transferred. + * @param Any extra information this target may need to keep track of. */ public abstract class Target, EXTRA> { @@ -36,10 +36,9 @@ public abstract class Target, EX } /** - * Sends the remaining amount to each handler we still have not settled on an amount for. We increment the amount - * sent in splitInfo as well as adjust the split as needed if one ends up accepting less than it originally wanted. - * (The most likely case this would change is with multi-blocks where it may return the same desire to all - * connections, but get satisfied by our first connection). + * Sends the remaining amount to each handler we still have not settled on an amount for. We increment the amount sent in splitInfo as well as adjust the split as + * needed if one ends up accepting less than it originally wanted. (The most likely case this would change is with multi-blocks where it may return the same desire to + * all connections, but get satisfied by our first connection). * * @param splitInfo Keeps track of the current amount sent and the default each one can get. */ @@ -53,10 +52,11 @@ public abstract class Target, EX /** * Gives the handler on the specified side the given amount. * - * @param side Side of handler to give. - * @param splitInfo Information about current overall split. The given split will be increased by the actual amount - * accepted, in case it is less than the offered amount. - * @param amount Amount to give. + * @param side Side of handler to give. + * @param splitInfo Information about current overall split. The given split will be increased by the actual amount accepted, in case it is less than the offered + * amount. + * @param amount Amount to give. + * * @implNote Must call {@link SplitInfo#send(Number)} with the amount actually accepted. */ protected abstract void acceptAmount(EnumFacing side, SplitInfo splitInfo, TYPE amount); @@ -65,18 +65,18 @@ public abstract class Target, EX * Simulate inserting into the handler. * * @param handler The handler (should correspond with the side we are simulating). - * @param side The side we are simulating - * @param extra All the information we are inserting. + * @param side The side we are simulating + * @param extra All the information we are inserting. + * * @return The amount it was actually willing to accept. */ protected abstract TYPE simulate(HANDLER handler, EnumFacing side, EXTRA extra); /** - * Calculates how much each handler can take of toSend. If the amount requested is less than the amount per - * handler/target in splitInfo it immediately sends the requested amount to the handler via {@link - * #acceptAmount(EnumFacing, SplitInfo, Number)} + * Calculates how much each handler can take of toSend. If the amount requested is less than the amount per handler/target in splitInfo it immediately sends the + * requested amount to the handler via {@link #acceptAmount(EnumFacing, SplitInfo, Number)} * - * @param toSend The total amount getting sent. + * @param toSend The total amount getting sent. * @param splitInfo Information about current overall split. */ public void sendPossible(EXTRA toSend, SplitInfo splitInfo) { @@ -93,8 +93,7 @@ public abstract class Target, EX } /** - * Rechecks to see if any of the needed amounts is able to fit under the new split and if so gives them the - * requested amount. + * Rechecks to see if any of the needed amounts is able to fit under the new split and if so gives them the requested amount. * * @param splitInfo The new split to (re)check. */ diff --git a/src/main/java/mekanism/common/block/BlockBasic.java b/src/main/java/mekanism/common/block/BlockBasic.java index 2dc31e4b4..d72669d42 100644 --- a/src/main/java/mekanism/common/block/BlockBasic.java +++ b/src/main/java/mekanism/common/block/BlockBasic.java @@ -73,12 +73,10 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; /** - * Block class for handling multiple metal block IDs. 0:0: Osmium Block 0:1: Bronze Block 0:2: Refined Obsidian 0:3: - * Charcoal Block 0:4: Refined Glowstone 0:5: Steel Block 0:6: Bin 0:7: Teleporter Frame 0:8: Steel Casing 0:9: Dynamic - * Tank 0:10: Structural Glass 0:11: Dynamic Valve 0:12: Copper Block 0:13: Tin Block 0:14: Thermal Evaporation - * Controller 0:15: Thermal Evaporation Valve 1:0: Thermal Evaporation Block 1:1: Induction Casing 1:2: Induction Port - * 1:3: Induction Cell 1:4: Induction Provider 1:5: Superheating Element 1:6: Pressure Disperser 1:7: Boiler Casing 1:8: - * Boiler Valve 1:9: Security Desk + * Block class for handling multiple metal block IDs. 0:0: Osmium Block 0:1: Bronze Block 0:2: Refined Obsidian 0:3: Charcoal Block 0:4: Refined Glowstone 0:5: Steel + * Block 0:6: Bin 0:7: Teleporter Frame 0:8: Steel Casing 0:9: Dynamic Tank 0:10: Structural Glass 0:11: Dynamic Valve 0:12: Copper Block 0:13: Tin Block 0:14: Thermal + * Evaporation Controller 0:15: Thermal Evaporation Valve 1:0: Thermal Evaporation Block 1:1: Induction Casing 1:2: Induction Port 1:3: Induction Cell 1:4: Induction + * Provider 1:5: Superheating Element 1:6: Pressure Disperser 1:7: Boiler Casing 1:8: Boiler Valve 1:9: Security Desk * * @author AidanBrady */ @@ -100,22 +98,18 @@ public abstract class BlockBasic extends BlockTileDrops { }; } - public static boolean manageInventory(EntityPlayer player, TileEntityDynamicTank tileEntity, EnumHand hand, - ItemStack itemStack) { + public static boolean manageInventory(EntityPlayer player, TileEntityDynamicTank tileEntity, EnumHand hand, ItemStack itemStack) { if (tileEntity.structure == null) { return false; } ItemStack copyStack = StackUtils.size(itemStack, 1); - if (FluidContainerUtils.isFluidContainer(itemStack)) { IFluidHandlerItem handler = FluidUtil.getFluidHandler(copyStack); - if (FluidUtil.getFluidContained(copyStack) == null) { if (tileEntity.structure.fluidStored != null) { int filled = handler.fill(tileEntity.structure.fluidStored, !player.capabilities.isCreativeMode); copyStack = handler.getContainer(); - if (filled > 0) { if (player.capabilities.isCreativeMode) { tileEntity.structure.fluidStored.amount -= filled; @@ -126,11 +120,9 @@ public abstract class BlockBasic extends BlockTileDrops { tileEntity.structure.fluidStored.amount -= filled; itemStack.shrink(1); } - if (tileEntity.structure.fluidStored.amount == 0) { tileEntity.structure.fluidStored = null; } - return true; } } @@ -138,12 +130,9 @@ public abstract class BlockBasic extends BlockTileDrops { FluidStack itemFluid = FluidUtil.getFluidContained(copyStack); int stored = tileEntity.structure.fluidStored != null ? tileEntity.structure.fluidStored.amount : 0; int needed = (tileEntity.structure.volume * TankUpdateProtocol.FLUID_PER_TANK) - stored; - - if (tileEntity.structure.fluidStored != null && !tileEntity.structure.fluidStored - .isFluidEqual(itemFluid)) { + if (tileEntity.structure.fluidStored != null && !tileEntity.structure.fluidStored.isFluidEqual(itemFluid)) { return false; } - boolean filled = false; FluidStack drained = handler.drain(needed, !player.capabilities.isCreativeMode); copyStack = handler.getContainer(); @@ -151,31 +140,23 @@ public abstract class BlockBasic extends BlockTileDrops { if (copyStack.getCount() == 0) { copyStack = ItemStack.EMPTY; } - if (drained != null) { if (player.capabilities.isCreativeMode) { filled = true; - } else { - if (!copyStack.isEmpty()) { - if (itemStack.getCount() == 1) { - player.setHeldItem(hand, copyStack); - filled = true; - } else { - if (player.inventory.addItemStackToInventory(copyStack)) { - itemStack.shrink(1); - - filled = true; - } - } - } else { + } else if (!copyStack.isEmpty()) { + if (itemStack.getCount() == 1) { + player.setHeldItem(hand, copyStack); + filled = true; + } else if (player.inventory.addItemStackToInventory(copyStack)) { itemStack.shrink(1); - - if (itemStack.getCount() == 0) { - player.setHeldItem(hand, ItemStack.EMPTY); - } - filled = true; } + } else { + itemStack.shrink(1); + if (itemStack.getCount() == 0) { + player.setHeldItem(hand, ItemStack.EMPTY); + } + filled = true; } if (filled) { @@ -184,13 +165,11 @@ public abstract class BlockBasic extends BlockTileDrops { } else { tileEntity.structure.fluidStored.amount += drained.amount; } - return true; } } } } - return false; } @@ -207,14 +186,12 @@ public abstract class BlockBasic extends BlockTileDrops { @Deprecated public IBlockState getStateFromMeta(int meta) { BlockStateBasic.BasicBlockType type = BlockStateBasic.BasicBlockType.get(getBasicBlock(), meta & 0xF); - return getDefaultState().withProperty(getTypeProperty(), type); } @Override public int getMetaFromState(IBlockState state) { - BlockStateBasic.BasicBlockType type = state.getValue(getTypeProperty()); - return type.meta; + return state.getValue(getTypeProperty()).meta; } @Nonnull @@ -222,45 +199,32 @@ public abstract class BlockBasic extends BlockTileDrops { @Deprecated public IBlockState getActualState(@Nonnull IBlockState state, IBlockAccess worldIn, BlockPos pos) { TileEntity tile = MekanismUtils.getTileEntitySafe(worldIn, pos); - if (tile instanceof TileEntityBasicBlock && ((TileEntityBasicBlock) tile).facing != null) { state = state.withProperty(BlockStateFacing.facingProperty, ((TileEntityBasicBlock) tile).facing); } - if (tile instanceof IActiveState) { state = state.withProperty(BlockStateBasic.activeProperty, ((IActiveState) tile).getActive()); } - if (tile instanceof TileEntityInductionCell) { - state = state - .withProperty(BlockStateBasic.tierProperty, ((TileEntityInductionCell) tile).tier.getBaseTier()); + state = state.withProperty(BlockStateBasic.tierProperty, ((TileEntityInductionCell) tile).tier.getBaseTier()); } - if (tile instanceof TileEntityInductionProvider) { - state = state - .withProperty(BlockStateBasic.tierProperty, ((TileEntityInductionProvider) tile).tier.getBaseTier()); + state = state.withProperty(BlockStateBasic.tierProperty, ((TileEntityInductionProvider) tile).tier.getBaseTier()); } - if (tile instanceof TileEntityBin) { state = state.withProperty(BlockStateBasic.tierProperty, ((TileEntityBin) tile).tier.getBaseTier()); } - if (tile instanceof TileEntityInductionPort) { state = state.withProperty(BlockStateBasic.activeProperty, ((TileEntityInductionPort) tile).mode); } - if (tile instanceof TileEntitySuperheatingElement) { TileEntitySuperheatingElement element = (TileEntitySuperheatingElement) tile; boolean active = false; - - if (element.multiblockUUID != null - && SynchronizedBoilerData.clientHotMap.get(element.multiblockUUID) != null) { + if (element.multiblockUUID != null && SynchronizedBoilerData.clientHotMap.get(element.multiblockUUID) != null) { active = SynchronizedBoilerData.clientHotMap.get(element.multiblockUUID); } - state = state.withProperty(BlockStateBasic.activeProperty, active); } - return state; } @@ -269,15 +233,12 @@ public abstract class BlockBasic extends BlockTileDrops { public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, BlockPos fromPos) { if (!world.isRemote) { TileEntity tileEntity = new Coord4D(pos, world).getTileEntity(world); - if (tileEntity instanceof IMultiblock) { ((IMultiblock) tileEntity).doUpdate(); } - if (tileEntity instanceof TileEntityBasicBlock) { ((TileEntityBasicBlock) tileEntity).onNeighborChange(neighborBlock); } - if (tileEntity instanceof IStructuralMultiblock) { ((IStructuralMultiblock) tileEntity).doUpdate(); } @@ -288,11 +249,9 @@ public abstract class BlockBasic extends BlockTileDrops { public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion) { IBlockState state = world.getBlockState(pos); BasicBlockType type = BasicBlockType.get(getBasicBlock(), state.getBlock().getMetaFromState(state)); - if (type == BasicBlockType.REFINED_OBSIDIAN) { return 4000F; } - return blockResistance; } @@ -316,7 +275,6 @@ public abstract class BlockBasic extends BlockTileDrops { list.add(stack); } } - break; default: list.add(new ItemStack(this, 1, type.meta)); @@ -326,10 +284,8 @@ public abstract class BlockBasic extends BlockTileDrops { } @Override - public boolean canCreatureSpawn(@Nonnull IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, - SpawnPlacementType type) { + public boolean canCreatureSpawn(@Nonnull IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, SpawnPlacementType type) { int meta = state.getBlock().getMetaFromState(state); - switch (getBasicBlock()) { case BASIC_BLOCK_1: switch (meta) { @@ -337,18 +293,14 @@ public abstract class BlockBasic extends BlockTileDrops { return false; case 9: case 11: - TileEntityDynamicTank tileEntity = (TileEntityDynamicTank) MekanismUtils - .getTileEntitySafe(world, pos); - + TileEntityDynamicTank tileEntity = (TileEntityDynamicTank) MekanismUtils.getTileEntitySafe(world, pos); if (tileEntity != null) { if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { if (tileEntity.structure != null) { return false; } - } else { - if (tileEntity.clientHasStructure) { - return false; - } + } else if (tileEntity.clientHasStructure) { + return false; } } default: @@ -360,18 +312,14 @@ public abstract class BlockBasic extends BlockTileDrops { case 2: case 7: case 8: - TileEntityMultiblock tileEntity = (TileEntityMultiblock) MekanismUtils - .getTileEntitySafe(world, pos); - + TileEntityMultiblock tileEntity = (TileEntityMultiblock) MekanismUtils.getTileEntitySafe(world, pos); if (tileEntity != null) { if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { if (tileEntity.structure != null) { return false; } - } else { - if (tileEntity.clientHasStructure) { - return false; - } + } else if (tileEntity.clientHasStructure) { + return false; } } default: @@ -385,7 +333,6 @@ public abstract class BlockBasic extends BlockTileDrops { @Override public void onBlockClicked(World world, BlockPos pos, EntityPlayer player) { BasicBlockType type = BasicBlockType.get(world.getBlockState(pos)); - if (!world.isRemote && type == BasicBlockType.BIN) { TileEntityBin bin = (TileEntityBin) world.getTileEntity(pos); RayTraceResult mop = MekanismUtils.rayTrace(world, player); @@ -398,17 +345,14 @@ public abstract class BlockBasic extends BlockTileDrops { } else { stack = bin.removeStack().copy(); } - if (!player.inventory.addItemStackToInventory(stack)) { BlockPos dropPos = pos.offset(bin.facing); - Entity item = new EntityItem(world, dropPos.getX() + .5f, dropPos.getY() + .3f, - dropPos.getZ() + .5f, stack); + Entity item = new EntityItem(world, dropPos.getX() + .5f, dropPos.getY() + .3f, dropPos.getZ() + .5f, stack); item.addVelocity(-item.motionX, -item.motionY, -item.motionZ); world.spawnEntity(item); } else { - world.playSound(null, pos.getX() + .5f, pos.getY() + .5f, pos.getZ() + .5f, - SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, - ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); + world.playSound(null, pos.getX() + .5f, pos.getY() + .5f, pos.getZ() + .5f, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, + 0.2F, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); } } } @@ -416,8 +360,7 @@ public abstract class BlockBasic extends BlockTileDrops { } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, - EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { BasicBlockType type = BasicBlockType.get(state); TileEntity tile = world.getTileEntity(pos); ItemStack stack = entityplayer.getHeldItem(hand); @@ -434,12 +377,10 @@ public abstract class BlockBasic extends BlockTileDrops { if (!world.isRemote) { entityplayer.openGui(Mekanism.instance, 33, world, pos.getX(), pos.getY(), pos.getZ()); } - return true; } } else if (tile instanceof TileEntitySecurityDesk) { UUID ownerUUID = ((TileEntitySecurityDesk) tile).ownerUUID; - if (!entityplayer.isSneaking()) { if (!world.isRemote) { if (ownerUUID == null || entityplayer.getUniqueID().equals(ownerUUID)) { @@ -448,35 +389,27 @@ public abstract class BlockBasic extends BlockTileDrops { SecurityUtils.displayNoAccess(entityplayer); } } - return true; } } else if (tile instanceof TileEntityBin) { TileEntityBin bin = (TileEntityBin) tile; - IMekWrench wrenchHandler; - if (!stack.isEmpty() && (wrenchHandler = Wrenches.getHandler(stack)) != null) { RayTraceResult raytrace = new RayTraceResult(new Vec3d(hitX, hitY, hitZ), side, pos); if (wrenchHandler.canUseWrench(entityplayer, hand, stack, raytrace)) { if (!world.isRemote) { wrenchHandler.wrenchUsed(entityplayer, hand, stack, raytrace); - if (entityplayer.isSneaking()) { MekanismUtils.dismantleBlock(this, state, world, pos); return true; } - int change = bin.facing.rotateY().ordinal(); - bin.setFacing((short) change); world.notifyNeighborsOfStateChange(pos, this, true); } - return true; } } - if (!world.isRemote) { if (bin.getItemCount() < bin.tier.getStorage()) { if (bin.addTicks == 0) { @@ -492,25 +425,21 @@ public abstract class BlockBasic extends BlockTileDrops { if (bin.getItemCount() == bin.tier.getStorage()) { break; } - if (!inv.get(i).isEmpty()) { ItemStack remain = bin.add(inv.get(i)); inv.set(i, remain); bin.addTicks = 5; } - ((EntityPlayerMP) entityplayer).sendContainerToPlayer(entityplayer.openContainer); } } } } - return true; } else if (tile instanceof IMultiblock) { if (world.isRemote) { return true; } - return ((IMultiblock) world.getTileEntity(pos)).onActivate(entityplayer, hand, stack); } else if (tile instanceof IStructuralMultiblock) { if (world.isRemote) { @@ -519,7 +448,6 @@ public abstract class BlockBasic extends BlockTileDrops { return ((IStructuralMultiblock) world.getTileEntity(pos)).onActivate(entityplayer, hand, stack); } - return false; } @@ -559,13 +487,11 @@ public abstract class BlockBasic extends BlockTileDrops { public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) { TileEntity tileEntity = MekanismUtils.getTileEntitySafe(world, pos); int metadata = state.getBlock().getMetaFromState(state); - if (tileEntity instanceof IActiveState) { if (((IActiveState) tileEntity).getActive() && ((IActiveState) tileEntity).lightUpdate()) { return 15; } } - if (getBasicBlock() == BasicBlock.BASIC_BLOCK_1) { switch (metadata) { case 2: @@ -578,12 +504,9 @@ public abstract class BlockBasic extends BlockTileDrops { } else if (getBasicBlock() == BasicBlock.BASIC_BLOCK_2) { if (metadata == 5 && tileEntity instanceof TileEntitySuperheatingElement) { TileEntitySuperheatingElement element = (TileEntitySuperheatingElement) tileEntity; - - if (element.multiblockUUID != null - && SynchronizedBoilerData.clientHotMap.get(element.multiblockUUID) != null) { + if (element.multiblockUUID != null && SynchronizedBoilerData.clientHotMap.get(element.multiblockUUID) != null) { return SynchronizedBoilerData.clientHotMap.get(element.multiblockUUID) ? 15 : 0; } - return 0; } } @@ -594,7 +517,6 @@ public abstract class BlockBasic extends BlockTileDrops { @Override public boolean hasTileEntity(IBlockState state) { BasicBlockType type = BasicBlockType.get(state); - return type != null && type.tileEntityClass != null; } @@ -603,19 +525,16 @@ public abstract class BlockBasic extends BlockTileDrops { if (BasicBlockType.get(state) == null) { return null; } - return BasicBlockType.get(state).create(); } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, - ItemStack stack) { + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { if (world.getTileEntity(pos) instanceof TileEntityBasicBlock) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock) world.getTileEntity(pos); int side = MathHelper.floor((placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; int height = Math.round(placer.rotationPitch); int change = 3; - if (tileEntity.canSetFacing(0) && tileEntity.canSetFacing(1)) { if (height >= 65) { change = 1; @@ -623,7 +542,6 @@ public abstract class BlockBasic extends BlockTileDrops { change = 0; } } - if (change != 0 && change != 1) { switch (side) { case 0: @@ -640,14 +558,12 @@ public abstract class BlockBasic extends BlockTileDrops { break; } } - tileEntity.setFacing((short) change); tileEntity.redstone = world.getRedstonePowerFromNeighbors(pos) > 0; if (tileEntity instanceof TileEntitySecurityDesk) { ((TileEntitySecurityDesk) tileEntity).ownerUUID = placer.getUniqueID(); } - if (tileEntity instanceof IBoundingBlock) { ((IBoundingBlock) tileEntity).onPlace(); } @@ -659,11 +575,9 @@ public abstract class BlockBasic extends BlockTileDrops { if (!world.isRemote && world.getTileEntity(pos) != null) { TileEntity tileEntity = world.getTileEntity(pos); - if (tileEntity instanceof IMultiblock) { ((IMultiblock) tileEntity).doUpdate(); } - if (tileEntity instanceof IStructuralMultiblock) { ((IStructuralMultiblock) tileEntity).doUpdate(); } @@ -673,11 +587,9 @@ public abstract class BlockBasic extends BlockTileDrops { @Override public void breakBlock(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state) { TileEntity tileEntity = world.getTileEntity(pos); - if (tileEntity instanceof IBoundingBlock) { ((IBoundingBlock) tileEntity).onBreak(); } - super.breakBlock(world, pos, state); } @@ -690,10 +602,8 @@ public abstract class BlockBasic extends BlockTileDrops { if (type == BasicBlockType.BIN) { TileEntityBin tileEntity = (TileEntityBin) world.getTileEntity(pos); InventoryBin inv = new InventoryBin(ret); - ((ITierItem) ret.getItem()).setBaseTier(ret, tileEntity.tier.getBaseTier()); inv.setItemCount(tileEntity.getItemCount()); - if (tileEntity.getItemCount() > 0) { inv.setItemType(tileEntity.itemType); } @@ -706,25 +616,20 @@ public abstract class BlockBasic extends BlockTileDrops { } TileEntity tileEntity = world.getTileEntity(pos); - if (tileEntity instanceof IStrictEnergyStorage) { IEnergizedItem energizedItem = (IEnergizedItem) ret.getItem(); energizedItem.setEnergy(ret, ((IStrictEnergyStorage) tileEntity).getEnergy()); } - return ret; } @Override @Deprecated @SideOnly(Side.CLIENT) - public boolean shouldSideBeRendered(IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, - EnumFacing side) { - if (BasicBlockType.get(state) == BasicBlockType.STRUCTURAL_GLASS - && BasicBlockType.get(world.getBlockState(pos.offset(side))) == BasicBlockType.STRUCTURAL_GLASS) { + public boolean shouldSideBeRendered(IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, EnumFacing side) { + if (BasicBlockType.get(state) == BasicBlockType.STRUCTURAL_GLASS && BasicBlockType.get(world.getBlockState(pos.offset(side))) == BasicBlockType.STRUCTURAL_GLASS) { return false; } - return super.shouldSideBeRendered(state, world, pos, side); } @@ -732,33 +637,27 @@ public abstract class BlockBasic extends BlockTileDrops { public EnumFacing[] getValidRotations(World world, @Nonnull BlockPos pos) { TileEntity tile = world.getTileEntity(pos); EnumFacing[] valid = new EnumFacing[6]; - if (tile instanceof TileEntityBasicBlock) { TileEntityBasicBlock basicTile = (TileEntityBasicBlock) tile; - for (EnumFacing dir : EnumFacing.VALUES) { if (basicTile.canSetFacing(dir.ordinal())) { valid[dir.ordinal()] = dir; } } } - return valid; } @Override public boolean rotateBlock(World world, @Nonnull BlockPos pos, @Nonnull EnumFacing axis) { TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileEntityBasicBlock) { TileEntityBasicBlock basicTile = (TileEntityBasicBlock) tile; - if (basicTile.canSetFacing(axis.ordinal())) { basicTile.setFacing((short) axis.ordinal()); return true; } } - return false; } diff --git a/src/main/java/mekanism/common/block/BlockBounding.java b/src/main/java/mekanism/common/block/BlockBounding.java index e6b184547..e08098008 100644 --- a/src/main/java/mekanism/common/block/BlockBounding.java +++ b/src/main/java/mekanism/common/block/BlockBounding.java @@ -72,8 +72,7 @@ public class BlockBounding extends Block { } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, - EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { BlockPos mainPos = getMainBlockPos(world, pos); if (mainPos == null) { return false; @@ -91,13 +90,11 @@ public class BlockBounding extends Block { } /** - * {@inheritDoc} Delegate to main {@link Block#getPickBlock(IBlockState, RayTraceResult, World, BlockPos, - * EntityPlayer)}. + * {@inheritDoc} Delegate to main {@link Block#getPickBlock(IBlockState, RayTraceResult, World, BlockPos, EntityPlayer)}. */ @Nonnull @Override - public ItemStack getPickBlock(@Nonnull IBlockState state, RayTraceResult target, @Nonnull World world, - @Nonnull BlockPos pos, EntityPlayer player) { + public ItemStack getPickBlock(@Nonnull IBlockState state, RayTraceResult target, @Nonnull World world, @Nonnull BlockPos pos, EntityPlayer player) { BlockPos mainPos = getMainBlockPos(world, pos); if (mainPos == null) { return ItemStack.EMPTY; @@ -107,16 +104,14 @@ public class BlockBounding extends Block { } /** - * {@inheritDoc} Keep tile entity in world until after {@link Block#getDrops(NonNullList, IBlockAccess, BlockPos, - * IBlockState, int)}. Used together with {@link Block#harvestBlock(World, EntityPlayer, BlockPos, IBlockState, - * TileEntity, ItemStack)}. + * {@inheritDoc} Keep tile entity in world until after {@link Block#getDrops(NonNullList, IBlockAccess, BlockPos, IBlockState, int)}. Used together with {@link + * Block#harvestBlock(World, EntityPlayer, BlockPos, IBlockState, TileEntity, ItemStack)}. * * @author Forge * @see BlockFlowerPot#removedByPlayer(IBlockState, World, BlockPos, EntityPlayer, boolean) */ @Override - public boolean removedByPlayer(@Nonnull IBlockState state, World world, @Nonnull BlockPos pos, - @Nonnull EntityPlayer player, boolean willHarvest) { + public boolean removedByPlayer(@Nonnull IBlockState state, World world, @Nonnull BlockPos pos, @Nonnull EntityPlayer player, boolean willHarvest) { if (willHarvest) { return true; } @@ -128,8 +123,7 @@ public class BlockBounding extends Block { * {@inheritDoc} Delegate to main {@link Block#getDrops(NonNullList, IBlockAccess, BlockPos, IBlockState, int)}. */ @Override - public void getDrops(@Nonnull NonNullList drops, IBlockAccess world, BlockPos pos, - @Nonnull IBlockState state, int fortune) { + public void getDrops(@Nonnull NonNullList drops, IBlockAccess world, BlockPos pos, @Nonnull IBlockState state, int fortune) { BlockPos mainPos = getMainBlockPos(world, pos); if (mainPos == null) { return; @@ -139,23 +133,21 @@ public class BlockBounding extends Block { } /** - * {@inheritDoc} Used together with {@link Block#removedByPlayer(IBlockState, World, BlockPos, EntityPlayer, - * boolean)}. + * {@inheritDoc} Used together with {@link Block#removedByPlayer(IBlockState, World, BlockPos, EntityPlayer, boolean)}. * * @author Forge * @see BlockFlowerPot#harvestBlock(World, EntityPlayer, BlockPos, IBlockState, TileEntity, ItemStack) */ @Override - public void harvestBlock(@Nonnull World world, EntityPlayer player, @Nonnull BlockPos pos, - @Nonnull IBlockState state, TileEntity te, ItemStack stack) { + public void harvestBlock(@Nonnull World world, EntityPlayer player, @Nonnull BlockPos pos, @Nonnull IBlockState state, TileEntity te, ItemStack stack) { super.harvestBlock(world, player, pos, state, te, stack); world.setBlockToAir(pos); } /** - * Returns that this "cannot" be silk touched. This is so that {@link Block#getSilkTouchDrop(IBlockState)} is not - * called, because only {@link Block#getDrops(NonNullList, IBlockAccess, BlockPos, IBlockState, int)} supports tile - * entities. Our blocks keep their inventory and other behave like they are being silk touched by default anyway. + * Returns that this "cannot" be silk touched. This is so that {@link Block#getSilkTouchDrop(IBlockState)} is not called, because only {@link + * Block#getDrops(NonNullList, IBlockAccess, BlockPos, IBlockState, int)} supports tile entities. Our blocks keep their inventory and other behave like they are being + * silk touched by default anyway. * * @return false */ @@ -167,8 +159,7 @@ public class BlockBounding extends Block { @Override @Deprecated - public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, - BlockPos neighborPos) { + public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, BlockPos neighborPos) { TileEntityBoundingBlock tileEntity = (TileEntityBoundingBlock) world.getTileEntity(pos); if (tileEntity != null) { tileEntity.onNeighborChange(state.getBlock()); @@ -182,8 +173,7 @@ public class BlockBounding extends Block { @Override @Deprecated - public float getPlayerRelativeBlockHardness(IBlockState state, @Nonnull EntityPlayer player, @Nonnull World world, - @Nonnull BlockPos pos) { + public float getPlayerRelativeBlockHardness(IBlockState state, @Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos) { BlockPos mainPos = getMainBlockPos(world, pos); if (mainPos == null) { return super.getPlayerRelativeBlockHardness(state, player, world, pos); diff --git a/src/main/java/mekanism/common/block/BlockCardboardBox.java b/src/main/java/mekanism/common/block/BlockCardboardBox.java index d61e030b9..67431be44 100644 --- a/src/main/java/mekanism/common/block/BlockCardboardBox.java +++ b/src/main/java/mekanism/common/block/BlockCardboardBox.java @@ -24,7 +24,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -64,45 +64,33 @@ public class BlockCardboardBox extends BlockMekanismContainer { } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, - EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (!world.isRemote && entityplayer.isSneaking()) { TileEntityCardboardBox tileEntity = (TileEntityCardboardBox) world.getTileEntity(pos); if (tileEntity.storedData != null) { BlockData data = tileEntity.storedData; - testingPlace = true; - if (!data.block.canPlaceBlockAt(world, pos)) { testingPlace = false; return true; } - testingPlace = false; - if (data.block != null) { - IBlockState newstate = data.block - .getStateForPlacement(world, pos, side, hitX, hitY, hitZ, data.meta, entityplayer, hand); + IBlockState newstate = data.block.getStateForPlacement(world, pos, side, hitX, hitY, hitZ, data.meta, entityplayer, hand); data.meta = newstate.getBlock().getMetaFromState(newstate); } - world.setBlockState(pos, data.block.getStateFromMeta(data.meta), 3); - if (data.tileTag != null && world.getTileEntity(pos) != null) { data.updateLocation(pos); world.getTileEntity(pos).readFromNBT(data.tileTag); } - if (data.block != null) { - data.block.onBlockPlacedBy(world, pos, data.block.getStateFromMeta(data.meta), entityplayer, - new ItemStack(data.block, 1, data.meta)); + data.block.onBlockPlacedBy(world, pos, data.block.getStateFromMeta(data.meta), entityplayer, new ItemStack(data.block, 1, data.meta)); } - spawnAsEntity(world, pos, new ItemStack(MekanismBlocks.CardboardBox)); } } - return entityplayer.isSneaking(); } @@ -122,27 +110,22 @@ public class BlockCardboardBox extends BlockMekanismContainer { @Override protected ItemStack getDropItem(@Nonnull IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos) { TileEntityCardboardBox tileEntity = (TileEntityCardboardBox) world.getTileEntity(pos); - Item item = Item.getItemFromBlock(state.getBlock()); ItemStack itemStack = new ItemStack(item, 1, state.getBlock().getMetaFromState(state)); - if (tileEntity.storedData != null) { ((ItemBlockCardboardBox) item).setBlockData(itemStack, tileEntity.storedData); } - return itemStack; } /** - * If the player is sneaking and the dest block is a cardboard box, ensure onBlockActivated is called, and that the - * item use is not. + * If the player is sneaking and the dest block is a cardboard box, ensure onBlockActivated is called, and that the item use is not. * * @param blockEvent event */ @SubscribeEvent - public void rightClickEvent(PlayerInteractEvent.RightClickBlock blockEvent) { - if (blockEvent.getEntityPlayer().isSneaking() - && blockEvent.getWorld().getBlockState(blockEvent.getPos()).getBlock() == this) { + public void rightClickEvent(RightClickBlock blockEvent) { + if (blockEvent.getEntityPlayer().isSneaking() && blockEvent.getWorld().getBlockState(blockEvent.getPos()).getBlock() == this) { blockEvent.setUseBlock(Event.Result.ALLOW); blockEvent.setUseItem(Event.Result.DENY); } @@ -165,14 +148,11 @@ public class BlockCardboardBox extends BlockMekanismContainer { public static BlockData read(NBTTagCompound nbtTags) { BlockData data = new BlockData(); - data.block = Block.getBlockById(nbtTags.getInteger("id")); data.meta = nbtTags.getInteger("meta"); - if (nbtTags.hasKey("tileTag")) { data.tileTag = nbtTags.getCompoundTag("tileTag"); } - return data; } @@ -187,12 +167,10 @@ public class BlockCardboardBox extends BlockMekanismContainer { public NBTTagCompound write(NBTTagCompound nbtTags) { nbtTags.setInteger("id", Block.getIdFromBlock(block)); nbtTags.setInteger("meta", meta); - if (tileTag != null) { nbtTags.setTag("tileTag", tileTag); } - return nbtTags; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/BlockEnergyCube.java b/src/main/java/mekanism/common/block/BlockEnergyCube.java index 6c9701fdb..cffa00e9f 100644 --- a/src/main/java/mekanism/common/block/BlockEnergyCube.java +++ b/src/main/java/mekanism/common/block/BlockEnergyCube.java @@ -42,8 +42,8 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; /** - * Block class for handling multiple energy cube block IDs. 0: Basic Energy Cube 1: Advanced Energy Cube 2: Elite Energy - * Cube 3: Ultimate Energy Cube 4: Creative Energy Cube + * Block class for handling multiple energy cube block IDs. 0: Basic Energy Cube 1: Advanced Energy Cube 2: Elite Energy Cube 3: Ultimate Energy Cube 4: Creative Energy + * Cube * * @author AidanBrady */ @@ -79,29 +79,23 @@ public class BlockEnergyCube extends BlockMekanismContainer { @Deprecated public IBlockState getActualState(@Nonnull IBlockState state, IBlockAccess worldIn, BlockPos pos) { TileEntity tile = MekanismUtils.getTileEntitySafe(worldIn, pos); - if (tile instanceof TileEntityEnergyCube) { TileEntityEnergyCube cube = (TileEntityEnergyCube) tile; - if (cube.facing != null) { state = state.withProperty(BlockStateFacing.facingProperty, cube.facing); } - if (cube.tier != null) { state = state.withProperty(BlockStateEnergyCube.typeProperty, cube.tier); } } - return state; } @Override @Deprecated - public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, - BlockPos neighborPos) { + public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, BlockPos neighborPos) { if (!world.isRemote) { TileEntity tileEntity = world.getTileEntity(pos); - if (tileEntity instanceof TileEntityBasicBlock) { ((TileEntityBasicBlock) tileEntity).onNeighborChange(neighborBlock); } @@ -109,8 +103,7 @@ public class BlockEnergyCube extends BlockMekanismContainer { } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, - ItemStack stack) { + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock) world.getTileEntity(pos); int side = MathHelper.floor((double) (placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; int height = Math.round(placer.rotationPitch); @@ -136,7 +129,6 @@ public class BlockEnergyCube extends BlockMekanismContainer { break; } } - tileEntity.setFacing((short) change); tileEntity.redstone = world.getRedstonePowerFromNeighbors(pos) > 0; } @@ -156,48 +148,38 @@ public class BlockEnergyCube extends BlockMekanismContainer { @Override @Deprecated - public float getPlayerRelativeBlockHardness(IBlockState state, @Nonnull EntityPlayer player, @Nonnull World world, - @Nonnull BlockPos pos) { + public float getPlayerRelativeBlockHardness(IBlockState state, @Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos) { TileEntity tile = world.getTileEntity(pos); - - return SecurityUtils.canAccess(player, tile) ? super.getPlayerRelativeBlockHardness(state, player, world, pos) - : 0.0F; + return SecurityUtils.canAccess(player, tile) ? super.getPlayerRelativeBlockHardness(state, player, world, pos) : 0.0F; } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, - EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (world.isRemote) { return true; } TileEntityEnergyCube tileEntity = (TileEntityEnergyCube) world.getTileEntity(pos); ItemStack stack = entityplayer.getHeldItem(hand); - if (!stack.isEmpty()) { IMekWrench wrenchHandler = Wrenches.getHandler(stack); if (wrenchHandler != null) { RayTraceResult raytrace = new RayTraceResult(new Vec3d(hitX, hitY, hitZ), side, pos); if (wrenchHandler.canUseWrench(entityplayer, hand, stack, raytrace)) { if (SecurityUtils.canAccess(entityplayer, tileEntity)) { - wrenchHandler.wrenchUsed(entityplayer, hand, stack, raytrace); - if (entityplayer.isSneaking()) { MekanismUtils.dismantleBlock(this, state, world, pos); return true; } - if (tileEntity != null) { int change = tileEntity.facing.rotateAround(side.getAxis()).ordinal(); - tileEntity.setFacing((short) change); world.notifyNeighborsOfStateChange(pos, this, true); } } else { SecurityUtils.displayNoAccess(entityplayer); } - return true; } } @@ -210,11 +192,9 @@ public class BlockEnergyCube extends BlockMekanismContainer { } else { SecurityUtils.displayNoAccess(entityplayer); } - return true; } } - return false; } @@ -245,7 +225,6 @@ public class BlockEnergyCube extends BlockMekanismContainer { if (!itemStack.hasTagCompound()) { itemStack.setTagCompound(new NBTTagCompound()); } - if (tileEntity != null) { ISecurityItem securityItem = (ISecurityItem) itemStack.getItem(); @@ -253,9 +232,7 @@ public class BlockEnergyCube extends BlockMekanismContainer { securityItem.setOwnerUUID(itemStack, ((ISecurityTile) tileEntity).getSecurity().getOwnerUUID()); securityItem.setSecurity(itemStack, ((ISecurityTile) tileEntity).getSecurity().getMode()); } - ISideConfiguration config = tileEntity; - config.getConfig().write(ItemDataUtils.getDataMap(itemStack)); config.getEjector().write(ItemDataUtils.getDataMap(itemStack)); } @@ -268,7 +245,6 @@ public class BlockEnergyCube extends BlockMekanismContainer { ISustainedInventory inventory = (ISustainedInventory) itemStack.getItem(); inventory.setInventory(tileEntity.getInventory(), itemStack); - return itemStack; } @@ -295,33 +271,27 @@ public class BlockEnergyCube extends BlockMekanismContainer { public EnumFacing[] getValidRotations(World world, @Nonnull BlockPos pos) { TileEntity tile = world.getTileEntity(pos); EnumFacing[] valid = new EnumFacing[6]; - if (tile instanceof TileEntityBasicBlock) { TileEntityBasicBlock basicTile = (TileEntityBasicBlock) tile; - for (EnumFacing dir : EnumFacing.VALUES) { if (basicTile.canSetFacing(dir.ordinal())) { valid[dir.ordinal()] = dir; } } } - return valid; } @Override public boolean rotateBlock(World world, @Nonnull BlockPos pos, @Nonnull EnumFacing axis) { TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileEntityBasicBlock) { TileEntityBasicBlock basicTile = (TileEntityBasicBlock) tile; - if (basicTile.canSetFacing(axis.ordinal())) { basicTile.setFacing((short) axis.ordinal()); return true; } } - return false; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/BlockGasTank.java b/src/main/java/mekanism/common/block/BlockGasTank.java index 4803fd309..1e2b0f636 100644 --- a/src/main/java/mekanism/common/block/BlockGasTank.java +++ b/src/main/java/mekanism/common/block/BlockGasTank.java @@ -72,30 +72,23 @@ public class BlockGasTank extends BlockMekanismContainer { @Deprecated public IBlockState getActualState(@Nonnull IBlockState state, IBlockAccess worldIn, BlockPos pos) { TileEntity tile = MekanismUtils.getTileEntitySafe(worldIn, pos); - if (tile instanceof TileEntityGasTank) { TileEntityGasTank tank = (TileEntityGasTank) tile; - if (tank.facing != null) { state = state.withProperty(BlockStateFacing.facingProperty, tank.facing); } - if (tank.tier != null) { state = state.withProperty(BlockStateGasTank.typeProperty, tank.tier); } } - return state; } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, - ItemStack stack) { + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock) world.getTileEntity(pos); - int side = MathHelper.floor((double) (placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; int change = 3; - switch (side) { case 0: change = 2; @@ -110,18 +103,15 @@ public class BlockGasTank extends BlockMekanismContainer { change = 4; break; } - tileEntity.setFacing((short) change); tileEntity.redstone = world.getRedstonePowerFromNeighbors(pos) > 0; } @Override @Deprecated - public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, - BlockPos neighborPos) { + public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, BlockPos neighborPos) { if (!world.isRemote) { TileEntity tileEntity = world.getTileEntity(pos); - if (tileEntity instanceof TileEntityBasicBlock) { ((TileEntityBasicBlock) tileEntity).onNeighborChange(neighborBlock); } @@ -130,24 +120,18 @@ public class BlockGasTank extends BlockMekanismContainer { @Override @Deprecated - public float getPlayerRelativeBlockHardness(IBlockState state, @Nonnull EntityPlayer player, @Nonnull World world, - @Nonnull BlockPos pos) { + public float getPlayerRelativeBlockHardness(IBlockState state, @Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos) { TileEntity tile = world.getTileEntity(pos); - - return SecurityUtils.canAccess(player, tile) ? super.getPlayerRelativeBlockHardness(state, player, world, pos) - : 0.0F; + return SecurityUtils.canAccess(player, tile) ? super.getPlayerRelativeBlockHardness(state, player, world, pos) : 0.0F; } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, - EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (world.isRemote) { return true; } - TileEntityGasTank tileEntity = (TileEntityGasTank) world.getTileEntity(pos); ItemStack stack = entityplayer.getHeldItem(hand); - if (!stack.isEmpty()) { IMekWrench wrenchHandler = Wrenches.getHandler(stack); if (wrenchHandler != null) { @@ -155,27 +139,22 @@ public class BlockGasTank extends BlockMekanismContainer { if (wrenchHandler.canUseWrench(entityplayer, hand, stack, raytrace)) { if (SecurityUtils.canAccess(entityplayer, tileEntity)) { wrenchHandler.wrenchUsed(entityplayer, hand, stack, raytrace); - if (entityplayer.isSneaking()) { MekanismUtils.dismantleBlock(this, state, world, pos); return true; } - if (tileEntity != null) { int change = tileEntity.facing.rotateY().ordinal(); - tileEntity.setFacing((short) change); world.notifyNeighborsOfStateChange(pos, this, true); } } else { SecurityUtils.displayNoAccess(entityplayer); } - return true; } } } - if (tileEntity != null) { if (!entityplayer.isSneaking()) { if (SecurityUtils.canAccess(entityplayer, tileEntity)) { @@ -183,11 +162,9 @@ public class BlockGasTank extends BlockMekanismContainer { } else { SecurityUtils.displayNoAccess(entityplayer); } - return true; } } - return false; } @@ -221,25 +198,19 @@ public class BlockGasTank extends BlockMekanismContainer { protected ItemStack getDropItem(@Nonnull IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos) { TileEntityGasTank tileEntity = (TileEntityGasTank) world.getTileEntity(pos); ItemStack itemStack = new ItemStack(MekanismBlocks.GasTank); - if (itemStack.hasTagCompound()) { itemStack.setTagCompound(new NBTTagCompound()); } - if (tileEntity != null) { ISecurityItem securityItem = (ISecurityItem) itemStack.getItem(); - if (securityItem.hasSecurity(itemStack)) { securityItem.setOwnerUUID(itemStack, ((ISecurityTile) tileEntity).getSecurity().getOwnerUUID()); securityItem.setSecurity(itemStack, ((ISecurityTile) tileEntity).getSecurity().getMode()); } - ISideConfiguration config = tileEntity; - config.getConfig().write(ItemDataUtils.getDataMap(itemStack)); config.getEjector().write(ItemDataUtils.getDataMap(itemStack)); } - ITierItem tierItem = (ITierItem) itemStack.getItem(); tierItem.setBaseTier(itemStack, tileEntity.tier.getBaseTier()); @@ -248,7 +219,6 @@ public class BlockGasTank extends BlockMekanismContainer { ISustainedInventory inventory = (ISustainedInventory) itemStack.getItem(); inventory.setInventory(tileEntity.getInventory(), itemStack); - return itemStack; } @@ -269,7 +239,6 @@ public class BlockGasTank extends BlockMekanismContainer { public EnumFacing[] getValidRotations(World world, @Nonnull BlockPos pos) { TileEntity tile = world.getTileEntity(pos); EnumFacing[] valid = new EnumFacing[6]; - if (tile instanceof TileEntityBasicBlock) { TileEntityBasicBlock basicTile = (TileEntityBasicBlock) tile; @@ -279,14 +248,12 @@ public class BlockGasTank extends BlockMekanismContainer { } } } - return valid; } @Override public boolean rotateBlock(World world, @Nonnull BlockPos pos, @Nonnull EnumFacing axis) { TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileEntityBasicBlock) { TileEntityBasicBlock basicTile = (TileEntityBasicBlock) tile; @@ -295,7 +262,6 @@ public class BlockGasTank extends BlockMekanismContainer { return true; } } - return false; } @@ -310,12 +276,4 @@ public class BlockGasTank extends BlockMekanismContainer { public boolean isFullCube(IBlockState state) { return false; } - - /* - @Override - public boolean isBlockSolid(IBlockAccess worldIn, BlockPos pos, EnumFacing side) - { - return false; - } - */ -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/BlockGlowPanel.java b/src/main/java/mekanism/common/block/BlockGlowPanel.java index 5d19aa7de..6825ed6af 100644 --- a/src/main/java/mekanism/common/block/BlockGlowPanel.java +++ b/src/main/java/mekanism/common/block/BlockGlowPanel.java @@ -37,11 +37,8 @@ public class BlockGlowPanel extends BlockTileDrops implements ITileEntityProvide static { AxisAlignedBB cuboid = new AxisAlignedBB(0.25, 0, 0.25, 0.75, 0.125, 0.75); Vec3d fromOrigin = new Vec3d(-0.5, -0.5, -0.5); - for (EnumFacing side : EnumFacing.VALUES) { - bounds[side.ordinal()] = MultipartUtils - .rotate(cuboid.offset(fromOrigin.x, fromOrigin.y, fromOrigin.z), side) - .offset(-fromOrigin.x, -fromOrigin.z, -fromOrigin.z); + bounds[side.ordinal()] = MultipartUtils.rotate(cuboid.offset(fromOrigin.x, fromOrigin.y, fromOrigin.z), side).offset(-fromOrigin.x, -fromOrigin.z, -fromOrigin.z); } } @@ -54,11 +51,9 @@ public class BlockGlowPanel extends BlockTileDrops implements ITileEntityProvide public static boolean canStay(IBlockAccess world, BlockPos pos) { boolean canStay = false; - if (Mekanism.hooks.MCMPLoaded) { canStay = MultipartMekanism.hasCenterSlot(world, pos); } - if (!canStay) { TileEntity tileEntity = world.getTileEntity(pos); if (tileEntity instanceof TileEntityGlowPanel) { @@ -67,7 +62,6 @@ public class BlockGlowPanel extends BlockTileDrops implements ITileEntityProvide canStay = glowPanel.getWorld().isSideSolid(adj.getPos(), glowPanel.side.getOpposite()); } } - return canStay; } @@ -82,7 +76,6 @@ public class BlockGlowPanel extends BlockTileDrops implements ITileEntityProvide glowPanel = (TileEntityGlowPanel) childEntity; } } - return glowPanel; } @@ -110,16 +103,12 @@ public class BlockGlowPanel extends BlockTileDrops implements ITileEntityProvide @Override public IBlockState getExtendedState(@Nonnull IBlockState state, IBlockAccess world, BlockPos pos) { TileEntityGlowPanel tileEntity = getTileEntityGlowPanel(world, pos); - if (tileEntity != null) { state = state.withProperty(BlockStateFacing.facingProperty, tileEntity.side); - if (state instanceof IExtendedBlockState) { - return ((IExtendedBlockState) state) - .withProperty(PropertyColor.INSTANCE, new PropertyColor(tileEntity.colour)); + return ((IExtendedBlockState) state).withProperty(PropertyColor.INSTANCE, new PropertyColor(tileEntity.colour)); } } - return state; } @@ -127,7 +116,6 @@ public class BlockGlowPanel extends BlockTileDrops implements ITileEntityProvide @Deprecated public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos neighbor) { TileEntityGlowPanel tileEntity = getTileEntityGlowPanel(world, pos); - if (tileEntity != null && !world.isRemote && !canStay(world, pos)) { dropBlockAsItem(world, pos, world.getBlockState(pos), 0); world.setBlockToAir(pos); @@ -139,11 +127,9 @@ public class BlockGlowPanel extends BlockTileDrops implements ITileEntityProvide @Deprecated public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { TileEntityGlowPanel tileEntity = getTileEntityGlowPanel(world, pos); - if (tileEntity != null) { return bounds[tileEntity.side.ordinal()]; } - return super.getBoundingBox(state, world, pos); } @@ -204,4 +190,4 @@ public class BlockGlowPanel extends BlockTileDrops implements ITileEntityProvide public boolean isFullBlock(IBlockState state) { return false; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java index a8339d892..56862a0c8 100644 --- a/src/main/java/mekanism/common/block/BlockMachine.java +++ b/src/main/java/mekanism/common/block/BlockMachine.java @@ -87,15 +87,12 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; /** - * Block class for handling multiple machine block IDs. 0:0: Enrichment Chamber 0:1: Osmium Compressor 0:2: Combiner - * 0:3: Crusher 0:4: Digital Miner 0:5: Basic Factory 0:6: Advanced Factory 0:7: Elite Factory 0:8: Metallurgic Infuser - * 0:9: Purification Chamber 0:10: Energized Smelter 0:11: Teleporter 0:12: Electric Pump 0:13: Electric Chest 0:14: - * Chargepad 0:15: Logistical Sorter 1:0: Rotary Condensentrator 1:1: Chemical Oxidizer 1:2: Chemical Infuser 1:3: - * Chemical Injection Chamber 1:4: Electrolytic Separator 1:5: Precision Sawmill 1:6: Chemical Dissolution Chamber 1:7: - * Chemical Washer 1:8: Chemical Crystallizer 1:9: Seismic Vibrator 1:10: Pressurized Reaction Chamber 1:11: Fluid Tank - * 1:12: Fluidic Plenisher 1:13: Laser 1:14: Laser Amplifier 1:15: Laser Tractor Beam 2:0: Quantum Entangloporter 2:1: - * Solar Neutron Activator 2:2: Ambient Accumulator 2:3: Oredictionificator 2:4: Resistive Heater 2:5: Formulaic - * Assemblicator 2:6: Fuelwood Heater + * Block class for handling multiple machine block IDs. 0:0: Enrichment Chamber 0:1: Osmium Compressor 0:2: Combiner 0:3: Crusher 0:4: Digital Miner 0:5: Basic Factory + * 0:6: Advanced Factory 0:7: Elite Factory 0:8: Metallurgic Infuser 0:9: Purification Chamber 0:10: Energized Smelter 0:11: Teleporter 0:12: Electric Pump 0:13: Electric + * Chest 0:14: Chargepad 0:15: Logistical Sorter 1:0: Rotary Condensentrator 1:1: Chemical Oxidizer 1:2: Chemical Infuser 1:3: Chemical Injection Chamber 1:4: + * Electrolytic Separator 1:5: Precision Sawmill 1:6: Chemical Dissolution Chamber 1:7: Chemical Washer 1:8: Chemical Crystallizer 1:9: Seismic Vibrator 1:10: Pressurized + * Reaction Chamber 1:11: Fluid Tank 1:12: Fluidic Plenisher 1:13: Laser 1:14: Laser Amplifier 1:15: Laser Tractor Beam 2:0: Quantum Entangloporter 2:1: Solar Neutron + * Activator 2:2: Ambient Accumulator 2:3: Oredictionificator 2:4: Resistive Heater 2:5: Formulaic Assemblicator 2:6: Fuelwood Heater * * @author AidanBrady */ @@ -104,8 +101,7 @@ public abstract class BlockMachine extends BlockMekanismContainer { private static final AxisAlignedBB CHARGEPAD_BOUNDS = new AxisAlignedBB(0.0F, 0.0F, 0.0F, 1.0F, 0.06F, 1.0F); private static final AxisAlignedBB TANK_BOUNDS = new AxisAlignedBB(0.125F, 0.0F, 0.125F, 0.875F, 1.0F, 0.875F); private static final AxisAlignedBB LASER_BOUNDS = new AxisAlignedBB(0.25F, 0.0F, 0.25F, 0.75F, 1.0F, 0.75F); - private static final AxisAlignedBB LOGISTICAL_SORTER_BOUNDS = new AxisAlignedBB(0.125F, 0.0F, 0.125F, 0.875F, 1.0F, - 0.875F); + private static final AxisAlignedBB LOGISTICAL_SORTER_BOUNDS = new AxisAlignedBB(0.125F, 0.0F, 0.125F, 0.875F, 1.0F, 0.875F); public BlockMachine() { super(Material.IRON); @@ -136,7 +132,6 @@ public abstract class BlockMachine extends BlockMekanismContainer { @Deprecated public IBlockState getStateFromMeta(int meta) { MachineType type = MachineType.get(getMachineBlock(), meta & 0xF); - return getDefaultState().withProperty(getTypeProperty(), type); } @@ -151,29 +146,23 @@ public abstract class BlockMachine extends BlockMekanismContainer { @Deprecated public IBlockState getActualState(@Nonnull IBlockState state, IBlockAccess worldIn, BlockPos pos) { TileEntity tile = MekanismUtils.getTileEntitySafe(worldIn, pos); - if (tile instanceof TileEntityBasicBlock && ((TileEntityBasicBlock) tile).facing != null) { state = state.withProperty(BlockStateFacing.facingProperty, ((TileEntityBasicBlock) tile).facing); } - if (tile instanceof IActiveState) { state = state.withProperty(BlockStateMachine.activeProperty, ((IActiveState) tile).getActive()); } - if (tile instanceof TileEntityFluidTank) { state = state.withProperty(BlockStateMachine.tierProperty, ((TileEntityFluidTank) tile).tier.getBaseTier()); } - if (tile instanceof TileEntityFactory) { state = state.withProperty(BlockStateMachine.recipeProperty, ((TileEntityFactory) tile).getRecipeType()); } - return state; } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, - ItemStack stack) { + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock) world.getTileEntity(pos); int side = MathHelper.floor((placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; int height = Math.round(placer.rotationPitch); @@ -213,11 +202,9 @@ public abstract class BlockMachine extends BlockMekanismContainer { if (tileEntity instanceof TileEntityLogisticalSorter) { TileEntityLogisticalSorter transporter = (TileEntityLogisticalSorter) tileEntity; - if (!transporter.hasInventory()) { for (EnumFacing dir : EnumFacing.VALUES) { TileEntity tile = Coord4D.get(transporter).offset(dir).getTileEntity(world); - if (InventoryUtils.isItemHandler(tile, dir)) { tileEntity.setFacing((short) dir.getOpposite().ordinal()); break; @@ -225,7 +212,6 @@ public abstract class BlockMachine extends BlockMekanismContainer { } } } - if (tileEntity instanceof IBoundingBlock) { ((IBoundingBlock) tileEntity).onPlace(); } @@ -234,11 +220,9 @@ public abstract class BlockMachine extends BlockMekanismContainer { @Override public void breakBlock(World world, @Nonnull BlockPos pos, @Nonnull IBlockState state) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock) world.getTileEntity(pos); - if (tileEntity instanceof IBoundingBlock) { ((IBoundingBlock) tileEntity).onBreak(); } - super.breakBlock(world, pos, state); } @@ -246,49 +230,36 @@ public abstract class BlockMachine extends BlockMekanismContainer { @SideOnly(Side.CLIENT) public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random random) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock) world.getTileEntity(pos); - if (tileEntity instanceof TileEntityFluidTank) { return; } - - if (MekanismUtils.isActive(world, pos) && ((IActiveState) tileEntity).renderUpdate() && MekanismConfig - .current().client.machineEffects.val()) { + if (MekanismUtils.isActive(world, pos) && ((IActiveState) tileEntity).renderUpdate() && MekanismConfig.current().client.machineEffects.val()) { float xRandom = (float) pos.getX() + 0.5F; float yRandom = (float) pos.getY() + 0.0F + random.nextFloat() * 6.0F / 16.0F; float zRandom = (float) pos.getZ() + 0.5F; float iRandom = 0.52F; float jRandom = random.nextFloat() * 0.6F - 0.3F; - EnumFacing side = tileEntity.facing; - if (tileEntity instanceof TileEntityMetallurgicInfuser) { side = side.getOpposite(); } switch (side) { case WEST: - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (xRandom - iRandom), yRandom, - (zRandom + jRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle(EnumParticleTypes.REDSTONE, (xRandom - iRandom), yRandom, (zRandom + jRandom), - 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, xRandom - iRandom, yRandom, zRandom + jRandom, 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.REDSTONE, xRandom - iRandom, yRandom, zRandom + jRandom, 0.0D, 0.0D, 0.0D); break; case EAST: - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (xRandom + iRandom), yRandom, - (zRandom + jRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle(EnumParticleTypes.REDSTONE, (xRandom + iRandom), yRandom, (zRandom + jRandom), - 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, xRandom + iRandom, yRandom, zRandom + jRandom, 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.REDSTONE, xRandom + iRandom, yRandom, zRandom + jRandom, 0.0D, 0.0D, 0.0D); break; case NORTH: - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (xRandom + jRandom), yRandom, - (zRandom - iRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle(EnumParticleTypes.REDSTONE, (xRandom + jRandom), yRandom, (zRandom - iRandom), - 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, xRandom + jRandom, yRandom, zRandom - iRandom, 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.REDSTONE, xRandom + jRandom, yRandom, zRandom - iRandom, 0.0D, 0.0D, 0.0D); break; case SOUTH: - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (xRandom + jRandom), yRandom, - (zRandom + iRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle(EnumParticleTypes.REDSTONE, (xRandom + jRandom), yRandom, (zRandom + iRandom), - 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, xRandom + jRandom, yRandom, zRandom + iRandom, 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.REDSTONE, xRandom + jRandom, yRandom, zRandom + iRandom, 0.0D, 0.0D, 0.0D); break; default: break; @@ -301,12 +272,11 @@ public abstract class BlockMachine extends BlockMekanismContainer { if (MekanismConfig.current().client.enableAmbientLighting.val()) { TileEntity tileEntity = MekanismUtils.getTileEntitySafe(world, pos); if (tileEntity instanceof IActiveState && - ((IActiveState) tileEntity).lightUpdate() && - ((IActiveState) tileEntity).wasActiveRecently()) { + ((IActiveState) tileEntity).lightUpdate() && + ((IActiveState) tileEntity).wasActiveRecently()) { return MekanismConfig.current().client.ambientLightingLevel.val(); } } - return 0; } @@ -330,17 +300,14 @@ public abstract class BlockMachine extends BlockMekanismContainer { list.add(stack); } } - break; case FLUID_TANK: ItemBlockMachine itemMachine = (ItemBlockMachine) Item.getItemFromBlock(this); - for (FluidTankTier tier : FluidTankTier.values()) { ItemStack stack = new ItemStack(this, 1, type.meta); itemMachine.setBaseTier(stack, tier.getBaseTier()); list.add(stack); } - break; default: list.add(new ItemStack(this, 1, type.meta)); @@ -350,16 +317,13 @@ public abstract class BlockMachine extends BlockMekanismContainer { } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, - EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (world.isRemote) { return true; } - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock) world.getTileEntity(pos); int metadata = state.getBlock().getMetaFromState(state); ItemStack stack = entityplayer.getHeldItem(hand); - if (!stack.isEmpty()) { IMekWrench wrenchHandler = Wrenches.getHandler(stack); if (wrenchHandler != null) { @@ -367,20 +331,16 @@ public abstract class BlockMachine extends BlockMekanismContainer { if (wrenchHandler.canUseWrench(entityplayer, hand, stack, raytrace)) { if (SecurityUtils.canAccess(entityplayer, tileEntity)) { wrenchHandler.wrenchUsed(entityplayer, hand, stack, raytrace); - if (entityplayer.isSneaking()) { MekanismUtils.dismantleBlock(this, state, world, pos); return true; } - if (tileEntity != null) { int change = tileEntity.facing.rotateY().ordinal(); - if (tileEntity instanceof TileEntityLogisticalSorter) { if (!((TileEntityLogisticalSorter) tileEntity).hasInventory()) { for (EnumFacing dir : EnumFacing.VALUES) { TileEntity tile = Coord4D.get(tileEntity).offset(dir).getTileEntity(world); - if (InventoryUtils.isItemHandler(tile, dir)) { change = dir.getOpposite().ordinal(); break; @@ -388,14 +348,12 @@ public abstract class BlockMachine extends BlockMekanismContainer { } } } - tileEntity.setFacing((short) change); world.notifyNeighborsOfStateChange(pos, this, true); } } else { SecurityUtils.displayNoAccess(entityplayer); } - return true; } } @@ -403,21 +361,17 @@ public abstract class BlockMachine extends BlockMekanismContainer { if (tileEntity != null) { MachineType type = MachineType.get(getMachineBlock(), metadata); - switch (type) { case PERSONAL_CHEST: if (!entityplayer.isSneaking() && !world.isSideSolid(pos.up(), EnumFacing.DOWN)) { TileEntityPersonalChest chest = (TileEntityPersonalChest) tileEntity; - if (SecurityUtils.canAccess(entityplayer, tileEntity)) { MekanismUtils.openPersonalChestGui((EntityPlayerMP) entityplayer, chest, null, true); } else { SecurityUtils.displayNoAccess(entityplayer); } - return true; } - break; case FLUID_TANK: if (!entityplayer.isSneaking()) { @@ -428,27 +382,21 @@ public abstract class BlockMachine extends BlockMekanismContainer { return true; } } else { - entityplayer.openGui(Mekanism.instance, type.guiId, world, pos.getX(), pos.getY(), - pos.getZ()); + entityplayer.openGui(Mekanism.instance, type.guiId, world, pos.getX(), pos.getY(), pos.getZ()); } } else { SecurityUtils.displayNoAccess(entityplayer); } - return true; } - break; case LOGISTICAL_SORTER: if (!entityplayer.isSneaking()) { if (SecurityUtils.canAccess(entityplayer, tileEntity)) { - LogisticalSorterGuiMessage - .openServerGui(SorterGuiPacket.SERVER, 0, world, (EntityPlayerMP) entityplayer, - Coord4D.get(tileEntity), -1); + LogisticalSorterGuiMessage.openServerGui(SorterGuiPacket.SERVER, 0, world, (EntityPlayerMP) entityplayer, Coord4D.get(tileEntity), -1); } else { SecurityUtils.displayNoAccess(entityplayer); } - return true; } @@ -456,30 +404,24 @@ public abstract class BlockMachine extends BlockMekanismContainer { default: if (!entityplayer.isSneaking() && type.guiId != -1) { if (SecurityUtils.canAccess(entityplayer, tileEntity)) { - entityplayer - .openGui(Mekanism.instance, type.guiId, world, pos.getX(), pos.getY(), pos.getZ()); + entityplayer.openGui(Mekanism.instance, type.guiId, world, pos.getX(), pos.getY(), pos.getZ()); } else { SecurityUtils.displayNoAccess(entityplayer); } - return true; } - break; } } - return false; } @Override public TileEntity createTileEntity(@Nonnull World world, @Nonnull IBlockState state) { int metadata = state.getBlock().getMetaFromState(state); - if (MachineType.get(getMachineBlock(), metadata) == null) { return null; } - return MachineType.get(getMachineBlock(), metadata).create(); } @@ -510,23 +452,18 @@ public abstract class BlockMachine extends BlockMekanismContainer { @Override @Deprecated - public float getPlayerRelativeBlockHardness(IBlockState state, @Nonnull EntityPlayer player, @Nonnull World world, - @Nonnull BlockPos pos) { + public float getPlayerRelativeBlockHardness(IBlockState state, @Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos) { TileEntity tile = world.getTileEntity(pos); - - return SecurityUtils.canAccess(player, tile) ? super.getPlayerRelativeBlockHardness(state, player, world, pos) - : 0.0F; + return SecurityUtils.canAccess(player, tile) ? super.getPlayerRelativeBlockHardness(state, player, world, pos) : 0.0F; } @Override public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion) { IBlockState state = world.getBlockState(pos); - if (MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state)) - != MachineType.PERSONAL_CHEST) { + if (MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state)) != MachineType.PERSONAL_CHEST) { return blockResistance; - } else { - return -1; } + return -1; } @Override @@ -539,36 +476,27 @@ public abstract class BlockMachine extends BlockMekanismContainer { @Deprecated public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos) { TileEntity tileEntity = world.getTileEntity(pos); - if (tileEntity instanceof TileEntityFluidTank) { return ((TileEntityFluidTank) tileEntity).getRedstoneLevel(); } - if (tileEntity instanceof TileEntityLaserAmplifier) { TileEntityLaserAmplifier amplifier = (TileEntityLaserAmplifier) tileEntity; - if (amplifier.outputMode == TileEntityLaserAmplifier.RedstoneOutput.ENERGY_CONTENTS) { return amplifier.getRedstoneLevel(); - } else { - return getWeakPower(state, world, pos, null); } + return getWeakPower(state, world, pos, null); } - return 0; } - private boolean manageInventory(EntityPlayer player, TileEntityFluidTank tileEntity, EnumHand hand, - ItemStack itemStack) { + private boolean manageInventory(EntityPlayer player, TileEntityFluidTank tileEntity, EnumHand hand, ItemStack itemStack) { ItemStack copyStack = StackUtils.size(itemStack.copy(), 1); - if (FluidContainerUtils.isFluidContainer(itemStack)) { IFluidHandlerItem handler = FluidUtil.getFluidHandler(copyStack); - if (FluidUtil.getFluidContained(copyStack) == null) { if (tileEntity.fluidTank.getFluid() != null) { int filled = handler.fill(tileEntity.fluidTank.getFluid(), !player.capabilities.isCreativeMode); copyStack = handler.getContainer(); - if (filled > 0) { if (itemStack.getCount() == 1) { player.setHeldItem(hand, copyStack); @@ -578,97 +506,74 @@ public abstract class BlockMachine extends BlockMekanismContainer { player.dropItem(copyStack, false, true); itemStack.shrink(1); } - if (tileEntity.tier != FluidTankTier.CREATIVE) { tileEntity.fluidTank.drain(filled, true); } - return true; } } } else { FluidStack itemFluid = FluidUtil.getFluidContained(copyStack); int needed = tileEntity.getCurrentNeeded(); - - if (tileEntity.fluidTank.getFluid() != null && !tileEntity.fluidTank.getFluid() - .isFluidEqual(itemFluid)) { + if (tileEntity.fluidTank.getFluid() != null && !tileEntity.fluidTank.getFluid().isFluidEqual(itemFluid)) { return false; } - boolean filled = false; FluidStack drained = handler.drain(needed, !player.capabilities.isCreativeMode); copyStack = handler.getContainer(); - if (copyStack.getCount() == 0) { copyStack = ItemStack.EMPTY; } - if (drained != null) { if (player.capabilities.isCreativeMode) { filled = true; - } else { - if (!copyStack.isEmpty()) { - if (itemStack.getCount() == 1) { - player.setHeldItem(hand, copyStack); - filled = true; - } else { - if (player.inventory.addItemStackToInventory(copyStack)) { - itemStack.shrink(1); - - filled = true; - } - } - } else { + } else if (!copyStack.isEmpty()) { + if (itemStack.getCount() == 1) { + player.setHeldItem(hand, copyStack); + filled = true; + } else if (player.inventory.addItemStackToInventory(copyStack)) { itemStack.shrink(1); - if (itemStack.getCount() == 0) { - player.setHeldItem(hand, ItemStack.EMPTY); - } - filled = true; } + } else { + itemStack.shrink(1); + if (itemStack.getCount() == 0) { + player.setHeldItem(hand, ItemStack.EMPTY); + } + filled = true; } if (filled) { int toFill = tileEntity.fluidTank.getCapacity() - tileEntity.fluidTank.getFluidAmount(); - if (tileEntity.tier != FluidTankTier.CREATIVE) { toFill = Math.min(toFill, drained.amount); } - tileEntity.fluidTank.fill(PipeUtils.copy(drained, toFill), true); - if (drained.amount - toFill > 0) { tileEntity.pushUp(PipeUtils.copy(itemFluid, drained.amount - toFill), true); } - return true; } } } } - return false; } @Override @Deprecated - public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, - BlockPos neighborPos) { + public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, BlockPos neighborPos) { if (!world.isRemote) { TileEntity tileEntity = world.getTileEntity(pos); - if (tileEntity instanceof TileEntityBasicBlock) { ((TileEntityBasicBlock) tileEntity).onNeighborChange(neighborBlock); } - if (tileEntity instanceof TileEntityLogisticalSorter) { TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter) tileEntity; - if (!sorter.hasInventory()) { for (EnumFacing dir : EnumFacing.VALUES) { TileEntity tile = Coord4D.get(tileEntity).offset(dir).getTileEntity(world); - if (InventoryUtils.isItemHandler(tile, dir)) { sorter.setFacing((short) dir.getOpposite().ordinal()); return; @@ -684,79 +589,61 @@ public abstract class BlockMachine extends BlockMekanismContainer { protected ItemStack getDropItem(@Nonnull IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock) world.getTileEntity(pos); ItemStack itemStack = new ItemStack(this, 1, state.getBlock().getMetaFromState(state)); - if (itemStack.getTagCompound() == null) { itemStack.setTagCompound(new NBTTagCompound()); } - if (tileEntity instanceof TileEntityFluidTank) { ITierItem tierItem = (ITierItem) itemStack.getItem(); tierItem.setBaseTier(itemStack, ((TileEntityFluidTank) tileEntity).tier.getBaseTier()); } - if (tileEntity instanceof ISecurityTile) { ISecurityItem securityItem = (ISecurityItem) itemStack.getItem(); - if (securityItem.hasSecurity(itemStack)) { securityItem.setOwnerUUID(itemStack, ((ISecurityTile) tileEntity).getSecurity().getOwnerUUID()); securityItem.setSecurity(itemStack, ((ISecurityTile) tileEntity).getSecurity().getMode()); } } - if (tileEntity instanceof IUpgradeTile) { ((IUpgradeTile) tileEntity).getComponent().write(ItemDataUtils.getDataMap(itemStack)); } - if (tileEntity instanceof ISideConfiguration) { ISideConfiguration config = (ISideConfiguration) tileEntity; - config.getConfig().write(ItemDataUtils.getDataMap(itemStack)); config.getEjector().write(ItemDataUtils.getDataMap(itemStack)); } - if (tileEntity instanceof ISustainedData) { ((ISustainedData) tileEntity).writeSustainedData(itemStack); } - if (tileEntity instanceof IRedstoneControl) { IRedstoneControl control = (IRedstoneControl) tileEntity; ItemDataUtils.setInt(itemStack, "controlType", control.getControlType().ordinal()); } - - if (tileEntity instanceof TileEntityContainerBlock - && ((TileEntityContainerBlock) tileEntity).inventory.size() > 0) { + if (tileEntity instanceof TileEntityContainerBlock && ((TileEntityContainerBlock) tileEntity).inventory.size() > 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); + ((ISustainedTank) itemStack.getItem()).setFluidStack(((ISustainedTank) tileEntity).getFluidStack(), itemStack); } } } - if (tileEntity instanceof TileEntityFactory) { IFactory factoryItem = (IFactory) itemStack.getItem(); factoryItem.setRecipeType(((TileEntityFactory) tileEntity).getRecipeType().ordinal(), itemStack); } - //this MUST be done after the factory info is saved, as it caps the energy to max, which is based on the recipe type if (tileEntity instanceof IStrictEnergyStorage) { IEnergizedItem energizedItem = (IEnergizedItem) itemStack.getItem(); energizedItem.setEnergy(itemStack, ((IStrictEnergyStorage) tileEntity).getEnergy()); } - if (tileEntity instanceof TileEntityQuantumEntangloporter) { InventoryFrequency frequency = ((TileEntityQuantumEntangloporter) tileEntity).frequency; - if (frequency != null) { ItemDataUtils.setCompound(itemStack, "entangleporter_frequency", frequency.getIdentity().serialize()); } } - return itemStack; } @@ -768,10 +655,8 @@ public abstract class BlockMachine extends BlockMekanismContainer { } MachineType type = state.getValue(getTypeProperty()); //If it is one of the types that block state won't have a color for - if (type == MachineType.FLUID_TANK) { - if (MekanismParticleHelper.addBlockHitEffects(world, target.getBlockPos(), target.sideHit, manager)) { - return true; - } + if (type == MachineType.FLUID_TANK && MekanismParticleHelper.addBlockHitEffects(world, target.getBlockPos(), target.sideHit, manager)) { + return true; } return super.addHitEffects(state, world, target, manager); } @@ -779,7 +664,6 @@ public abstract class BlockMachine extends BlockMekanismContainer { @Override public boolean canConnectRedstone(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { MachineType type = MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state)); - return type == MachineType.LASER_AMPLIFIER; } @@ -801,13 +685,11 @@ public abstract class BlockMachine extends BlockMekanismContainer { return TANK_BOUNDS; case LASER: if (tile instanceof TileEntityLaser) { - return MultipartUtils.rotate(LASER_BOUNDS.offset(-0.5, -0.5, -0.5), ((TileEntityLaser) tile).facing) - .offset(0.5, 0.5, 0.5); + return MultipartUtils.rotate(LASER_BOUNDS.offset(-0.5, -0.5, -0.5), ((TileEntityLaser) tile).facing).offset(0.5, 0.5, 0.5); } case LOGISTICAL_SORTER: if (tile instanceof TileEntityLogisticalSorter) { - return MultipartUtils.rotate(LOGISTICAL_SORTER_BOUNDS.offset(-0.5, -0.5, -0.5), - ((TileEntityLogisticalSorter) tile).facing).offset(0.5, 0.5, 0.5); + return MultipartUtils.rotate(LOGISTICAL_SORTER_BOUNDS.offset(-0.5, -0.5, -0.5), ((TileEntityLogisticalSorter) tile).facing).offset(0.5, 0.5, 0.5); } default: return super.getBoundingBox(state, world, pos); @@ -824,7 +706,6 @@ public abstract class BlockMachine extends BlockMekanismContainer { @Deprecated public boolean isSideSolid(IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, EnumFacing side) { MachineType type = MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state)); - switch (type) { case CHARGEPAD: case PERSONAL_CHEST: @@ -847,30 +728,25 @@ public abstract class BlockMachine extends BlockMekanismContainer { if (tile instanceof TileEntityBasicBlock) { TileEntityBasicBlock basicTile = (TileEntityBasicBlock) tile; - for (EnumFacing dir : EnumFacing.VALUES) { if (basicTile.canSetFacing(dir.ordinal())) { valid[dir.ordinal()] = dir; } } } - return valid; } @Override public boolean rotateBlock(World world, @Nonnull BlockPos pos, @Nonnull EnumFacing axis) { TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileEntityBasicBlock) { TileEntityBasicBlock basicTile = (TileEntityBasicBlock) tile; - if (basicTile.canSetFacing(axis.ordinal())) { basicTile.setFacing((short) axis.ordinal()); return true; } } - return false; } @@ -878,11 +754,9 @@ public abstract class BlockMachine extends BlockMekanismContainer { @Deprecated public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { TileEntity tile = MekanismUtils.getTileEntitySafe(world, pos); - if (tile instanceof TileEntityLaserAmplifier) { return ((TileEntityLaserAmplifier) tile).emittingRedstone ? 15 : 0; } - return 0; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/BlockMekanismContainer.java b/src/main/java/mekanism/common/block/BlockMekanismContainer.java index 647918b05..7d5a49286 100644 --- a/src/main/java/mekanism/common/block/BlockMekanismContainer.java +++ b/src/main/java/mekanism/common/block/BlockMekanismContainer.java @@ -25,23 +25,19 @@ public abstract class BlockMekanismContainer extends BlockContainer { } @Nonnull - protected abstract ItemStack getDropItem(@Nonnull IBlockState state, @Nonnull IBlockAccess world, - @Nonnull BlockPos pos); + protected abstract ItemStack getDropItem(@Nonnull IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos); /** - * {@inheritDoc} Used together with {@link Block#removedByPlayer(IBlockState, World, BlockPos, EntityPlayer, - * boolean)}. + * {@inheritDoc} Used together with {@link Block#removedByPlayer(IBlockState, World, BlockPos, EntityPlayer, boolean)}. *
- * This is like Vanilla's {@link BlockContainer#harvestBlock(World, EntityPlayer, BlockPos, IBlockState, TileEntity, - * ItemStack)} except that uses the custom {@link ItemStack} from {@link #getDropItem(IBlockState, IBlockAccess, - * BlockPos)} + * This is like Vanilla's {@link BlockContainer#harvestBlock(World, EntityPlayer, BlockPos, IBlockState, TileEntity, ItemStack)} except that uses the custom {@link + * ItemStack} from {@link #getDropItem(IBlockState, IBlockAccess, BlockPos)} * * @author Forge * @see BlockFlowerPot#harvestBlock(World, EntityPlayer, BlockPos, IBlockState, TileEntity, ItemStack) */ @Override - public void harvestBlock(@Nonnull World world, EntityPlayer player, @Nonnull BlockPos pos, - @Nonnull IBlockState state, TileEntity te, @Nonnull ItemStack stack) { + public void harvestBlock(@Nonnull World world, EntityPlayer player, @Nonnull BlockPos pos, @Nonnull IBlockState state, TileEntity te, @Nonnull ItemStack stack) { StatBase blockStats = StatList.getBlockStats(this); if (blockStats != null) { player.addStat(blockStats); @@ -59,9 +55,9 @@ public abstract class BlockMekanismContainer extends BlockContainer { } /** - * Returns that this "cannot" be silk touched. This is so that {@link Block#getSilkTouchDrop(IBlockState)} is not - * called, because only {@link Block#getDrops(NonNullList, IBlockAccess, BlockPos, IBlockState, int)} supports tile - * entities. Our blocks keep their inventory and other behave like they are being silk touched by default anyway. + * Returns that this "cannot" be silk touched. This is so that {@link Block#getSilkTouchDrop(IBlockState)} is not called, because only {@link + * Block#getDrops(NonNullList, IBlockAccess, BlockPos, IBlockState, int)} supports tile entities. Our blocks keep their inventory and other behave like they are being + * silk touched by default anyway. * * @return false */ @@ -72,29 +68,25 @@ public abstract class BlockMekanismContainer extends BlockContainer { } @Override - public void getDrops(@Nonnull NonNullList drops, IBlockAccess world, BlockPos pos, - @Nonnull IBlockState state, int fortune) { + public void getDrops(@Nonnull NonNullList drops, IBlockAccess world, BlockPos pos, @Nonnull IBlockState state, int fortune) { drops.add(getDropItem(state, world, pos)); } /** - * {@inheritDoc} Keep tile entity in world until after {@link Block#getDrops(NonNullList, IBlockAccess, BlockPos, - * IBlockState, int)}. Used together with {@link Block#harvestBlock(World, EntityPlayer, BlockPos, IBlockState, - * TileEntity, ItemStack)}. + * {@inheritDoc} Keep tile entity in world until after {@link Block#getDrops(NonNullList, IBlockAccess, BlockPos, IBlockState, int)}. Used together with {@link + * Block#harvestBlock(World, EntityPlayer, BlockPos, IBlockState, TileEntity, ItemStack)}. * * @author Forge * @see BlockFlowerPot#removedByPlayer(IBlockState, World, BlockPos, EntityPlayer, boolean) */ @Override - public boolean removedByPlayer(@Nonnull IBlockState state, World world, @Nonnull BlockPos pos, - @Nonnull EntityPlayer player, boolean willHarvest) { + public boolean removedByPlayer(@Nonnull IBlockState state, World world, @Nonnull BlockPos pos, @Nonnull EntityPlayer player, boolean willHarvest) { return willHarvest || super.removedByPlayer(state, world, pos, player, false); } @Nonnull @Override - public ItemStack getPickBlock(@Nonnull IBlockState state, RayTraceResult target, @Nonnull World world, - @Nonnull BlockPos pos, EntityPlayer player) { + public ItemStack getPickBlock(@Nonnull IBlockState state, RayTraceResult target, @Nonnull World world, @Nonnull BlockPos pos, EntityPlayer player) { return getDropItem(state, world, pos); } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/BlockObsidianTNT.java b/src/main/java/mekanism/common/block/BlockObsidianTNT.java index c7c53cbfd..36ff17820 100644 --- a/src/main/java/mekanism/common/block/BlockObsidianTNT.java +++ b/src/main/java/mekanism/common/block/BlockObsidianTNT.java @@ -28,14 +28,12 @@ public class BlockObsidianTNT extends Block { @Override public void breakBlock(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state) { super.breakBlock(world, pos, state); - world.removeTileEntity(pos); } @Override public void onBlockAdded(World world, BlockPos pos, IBlockState state) { super.onBlockAdded(world, pos, state); - if (world.getRedstonePowerFromNeighbors(pos) > 0) { explode(world, pos); world.setBlockToAir(pos); @@ -44,8 +42,7 @@ public class BlockObsidianTNT extends Block { @Override @Deprecated - public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, - BlockPos neighborPos) { + public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, BlockPos neighborPos) { if (world.getRedstonePowerFromNeighbors(pos) > 0) { explode(world, pos); world.setBlockToAir(pos); @@ -55,8 +52,7 @@ public class BlockObsidianTNT extends Block { @Override public void onExplosionDestroy(World world, @Nonnull BlockPos pos, @Nonnull Explosion explosion) { if (!world.isRemote) { - EntityObsidianTNT entity = new EntityObsidianTNT(world, pos.getX() + 0.5F, pos.getY() + 0.5F, - pos.getZ() + 0.5F); + EntityObsidianTNT entity = new EntityObsidianTNT(world, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F); entity.fuse = world.rand.nextInt(entity.fuse / 4) + entity.fuse / 8; world.spawnEntity(entity); } @@ -64,26 +60,21 @@ public class BlockObsidianTNT extends Block { public void explode(World world, BlockPos pos) { if (!world.isRemote) { - EntityObsidianTNT entity = new EntityObsidianTNT(world, pos.getX() + 0.5F, pos.getY() + 0.5F, - pos.getZ() + 0.5F); + EntityObsidianTNT entity = new EntityObsidianTNT(world, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F); world.spawnEntity(entity); entity.playSound(SoundEvents.ENTITY_TNT_PRIMED, 1.0F, 1.0F); } } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, - EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack stack = entityplayer.getHeldItem(hand); - if (!stack.isEmpty() && stack.getItem() == Items.FLINT_AND_STEEL) { explode(world, pos); world.setBlockToAir(pos); - return true; - } else { - return super.onBlockActivated(world, pos, state, entityplayer, hand, side, hitX, hitY, hitZ); } + return super.onBlockActivated(world, pos, state, entityplayer, hand, side, hitX, hitY, hitZ); } @Override @@ -101,11 +92,10 @@ public class BlockObsidianTNT extends Block { public void onEntityCollision(World world, BlockPos pos, IBlockState state, Entity entity) { if (entity instanceof EntityArrow && !world.isRemote) { EntityArrow entityarrow = (EntityArrow) entity; - if (entityarrow.isBurning()) { explode(world, pos); world.setBlockToAir(pos); } } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/BlockOre.java b/src/main/java/mekanism/common/block/BlockOre.java index d90ed6600..dfd9db90d 100644 --- a/src/main/java/mekanism/common/block/BlockOre.java +++ b/src/main/java/mekanism/common/block/BlockOre.java @@ -55,4 +55,4 @@ public class BlockOre extends Block { list.add(new ItemStack(this, 1, ore.ordinal())); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/BlockPlastic.java b/src/main/java/mekanism/common/block/BlockPlastic.java index 4ed9dd03c..d4475fa18 100644 --- a/src/main/java/mekanism/common/block/BlockPlastic.java +++ b/src/main/java/mekanism/common/block/BlockPlastic.java @@ -28,7 +28,6 @@ public class BlockPlastic extends Block { setHardness(type == PlasticBlockType.REINFORCED ? 50F : 5F); setResistance(type == PlasticBlockType.REINFORCED ? 2000F : 10F); setCreativeTab(Mekanism.tabMekanism); - if (type == PlasticBlockType.SLICK) { slipperiness = 0.98F; } @@ -79,7 +78,6 @@ public class BlockPlastic extends Block { if (type == PlasticBlockType.GLOW) { return 10; } - return 0; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/BlockPlasticFence.java b/src/main/java/mekanism/common/block/BlockPlasticFence.java index f156c2b5e..5662caec6 100644 --- a/src/main/java/mekanism/common/block/BlockPlasticFence.java +++ b/src/main/java/mekanism/common/block/BlockPlasticFence.java @@ -67,4 +67,4 @@ public class BlockPlasticFence extends BlockFence { return new ModelResourceLocation(baseLocation, properties); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/BlockSalt.java b/src/main/java/mekanism/common/block/BlockSalt.java index a0fcd5b23..408f1d3e9 100644 --- a/src/main/java/mekanism/common/block/BlockSalt.java +++ b/src/main/java/mekanism/common/block/BlockSalt.java @@ -29,4 +29,4 @@ public class BlockSalt extends Block { public int quantityDropped(Random random) { return 4; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/BlockTileDrops.java b/src/main/java/mekanism/common/block/BlockTileDrops.java index 06fdd6e6b..c322dcd0d 100644 --- a/src/main/java/mekanism/common/block/BlockTileDrops.java +++ b/src/main/java/mekanism/common/block/BlockTileDrops.java @@ -24,27 +24,24 @@ public abstract class BlockTileDrops extends Block { } @Nonnull - protected abstract ItemStack getDropItem(@Nonnull IBlockState state, @Nonnull IBlockAccess world, - @Nonnull BlockPos pos); + protected abstract ItemStack getDropItem(@Nonnull IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos); /** - * {@inheritDoc} Used together with {@link Block#removedByPlayer(IBlockState, World, BlockPos, EntityPlayer, - * boolean)}. + * {@inheritDoc} Used together with {@link Block#removedByPlayer(IBlockState, World, BlockPos, EntityPlayer, boolean)}. * * @author Forge * @see BlockFlowerPot#harvestBlock(World, EntityPlayer, BlockPos, IBlockState, TileEntity, ItemStack) */ @Override - public void harvestBlock(@Nonnull World world, EntityPlayer player, @Nonnull BlockPos pos, - @Nonnull IBlockState state, TileEntity te, ItemStack stack) { + public void harvestBlock(@Nonnull World world, EntityPlayer player, @Nonnull BlockPos pos, @Nonnull IBlockState state, TileEntity te, ItemStack stack) { super.harvestBlock(world, player, pos, state, te, stack); world.setBlockToAir(pos); } /** - * Returns that this "cannot" be silk touched. This is so that {@link Block#getSilkTouchDrop(IBlockState)} is not - * called, because only {@link Block#getDrops(NonNullList, IBlockAccess, BlockPos, IBlockState, int)} supports tile - * entities. Our blocks keep their inventory and other behave like they are being silk touched by default anyway. + * Returns that this "cannot" be silk touched. This is so that {@link Block#getSilkTouchDrop(IBlockState)} is not called, because only {@link + * Block#getDrops(NonNullList, IBlockAccess, BlockPos, IBlockState, int)} supports tile entities. Our blocks keep their inventory and other behave like they are being + * silk touched by default anyway. * * @return false */ @@ -55,29 +52,25 @@ public abstract class BlockTileDrops extends Block { } @Override - public void getDrops(@Nonnull NonNullList drops, IBlockAccess world, BlockPos pos, - @Nonnull IBlockState state, int fortune) { + public void getDrops(@Nonnull NonNullList drops, IBlockAccess world, BlockPos pos, @Nonnull IBlockState state, int fortune) { drops.add(getDropItem(state, world, pos)); } /** - * {@inheritDoc} Keep tile entity in world until after {@link Block#getDrops(NonNullList, IBlockAccess, BlockPos, - * IBlockState, int)}. Used together with {@link Block#harvestBlock(World, EntityPlayer, BlockPos, IBlockState, - * TileEntity, ItemStack)}. + * {@inheritDoc} Keep tile entity in world until after {@link Block#getDrops(NonNullList, IBlockAccess, BlockPos, IBlockState, int)}. Used together with {@link + * Block#harvestBlock(World, EntityPlayer, BlockPos, IBlockState, TileEntity, ItemStack)}. * * @author Forge * @see BlockFlowerPot#removedByPlayer(IBlockState, World, BlockPos, EntityPlayer, boolean) */ @Override - public boolean removedByPlayer(@Nonnull IBlockState state, World world, @Nonnull BlockPos pos, - @Nonnull EntityPlayer player, boolean willHarvest) { + public boolean removedByPlayer(@Nonnull IBlockState state, World world, @Nonnull BlockPos pos, @Nonnull EntityPlayer player, boolean willHarvest) { return willHarvest || super.removedByPlayer(state, world, pos, player, false); } @Nonnull @Override - public ItemStack getPickBlock(@Nonnull IBlockState state, RayTraceResult target, @Nonnull World world, - @Nonnull BlockPos pos, EntityPlayer player) { + public ItemStack getPickBlock(@Nonnull IBlockState state, RayTraceResult target, @Nonnull World world, @Nonnull BlockPos pos, EntityPlayer player) { return getDropItem(state, world, pos); } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/BlockTransmitter.java b/src/main/java/mekanism/common/block/BlockTransmitter.java index 697ebe7db..f0bed9174 100644 --- a/src/main/java/mekanism/common/block/BlockTransmitter.java +++ b/src/main/java/mekanism/common/block/BlockTransmitter.java @@ -99,7 +99,6 @@ public class BlockTransmitter extends BlockTileDrops implements ITileEntityProvi if (tile == null || tile.getTransmitterType().getSize() == Size.SMALL) { return smallDefault; } - return largeDefault; } @@ -107,17 +106,14 @@ public class BlockTransmitter extends BlockTileDrops implements ITileEntityProvi if (tile == null) { return; } - if (box == null) { throw new IllegalStateException("box should not be null"); } - if (tile.getTransmitterType().getSize() == Size.SMALL) { smallDefault = box; - return; + } else { + largeDefault = box; } - - largeDefault = box; } private static TileEntitySidedPipe getTileEntitySidedPipe(IBlockAccess world, BlockPos pos) { @@ -131,7 +127,6 @@ public class BlockTransmitter extends BlockTileDrops implements ITileEntityProvi sidedPipe = (TileEntitySidedPipe) childEntity; } } - return sidedPipe; } @@ -143,7 +138,6 @@ public class BlockTransmitter extends BlockTileDrops implements ITileEntityProvi if (tile != null) { state = state.withProperty(BlockStateTransmitter.tierProperty, tile.getBaseTier()); } - return state; } @@ -172,19 +166,13 @@ public class BlockTransmitter extends BlockTileDrops implements ITileEntityProvi @Override public IBlockState getExtendedState(@Nonnull IBlockState state, IBlockAccess w, BlockPos pos) { TileEntitySidedPipe tile = getTileEntitySidedPipe(w, pos); - if (tile != null) { return tile.getExtendedState(state); - } else { - ConnectionType[] typeArray = new ConnectionType[]{ConnectionType.NORMAL, ConnectionType.NORMAL, - ConnectionType.NORMAL, - ConnectionType.NORMAL, ConnectionType.NORMAL, ConnectionType.NORMAL}; - PropertyConnection connectionProp = new PropertyConnection((byte) 0, (byte) 0, typeArray, true); - - return ((IExtendedBlockState) state) - .withProperty(OBJProperty.INSTANCE, new OBJState(Collections.emptyList(), true)) - .withProperty(PropertyConnection.INSTANCE, connectionProp); } + ConnectionType[] typeArray = new ConnectionType[]{ConnectionType.NORMAL, ConnectionType.NORMAL, ConnectionType.NORMAL, + ConnectionType.NORMAL, ConnectionType.NORMAL, ConnectionType.NORMAL}; + PropertyConnection connectionProp = new PropertyConnection((byte) 0, (byte) 0, typeArray, true); + return ((IExtendedBlockState) state).withProperty(OBJProperty.INSTANCE, new OBJState(Collections.emptyList(), true)).withProperty(PropertyConnection.INSTANCE, connectionProp); } @Nonnull @@ -192,24 +180,19 @@ public class BlockTransmitter extends BlockTileDrops implements ITileEntityProvi @Deprecated public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { TileEntitySidedPipe tile = getTileEntitySidedPipe(world, pos); - if (tile != null && tile.getTransmitterType().getSize() == Size.SMALL) { return smallSides[6]; } - return largeSides[6]; } @Override @Deprecated - public void addCollisionBoxToList(IBlockState state, @Nonnull World world, @Nonnull BlockPos pos, - @Nonnull AxisAlignedBB entityBox, @Nonnull List collidingBoxes, @Nullable Entity entityIn, - boolean b) { + public void addCollisionBoxToList(IBlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull AxisAlignedBB entityBox, + @Nonnull List collidingBoxes, @Nullable Entity entityIn, boolean b) { TileEntitySidedPipe tile = getTileEntitySidedPipe(world, pos); - if (tile != null) { List boxes = tile.getCollisionBoxes(entityBox.offset(-pos.getX(), -pos.getY(), -pos.getZ())); - for (AxisAlignedBB box : boxes) { collidingBoxes.add(box.offset(pos)); } @@ -225,33 +208,25 @@ public class BlockTransmitter extends BlockTileDrops implements ITileEntityProvi @Override @Deprecated - public RayTraceResult collisionRayTrace(IBlockState blockState, @Nonnull World world, @Nonnull BlockPos pos, - @Nonnull Vec3d start, @Nonnull Vec3d end) { + public RayTraceResult collisionRayTrace(IBlockState blockState, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Vec3d start, @Nonnull Vec3d end) { TileEntitySidedPipe tile = getTileEntitySidedPipe(world, pos); - if (tile == null) { return null; } - List boxes = tile.getCollisionBoxes(); AdvancedRayTraceResult result = MultipartUtils.collisionRayTrace(pos, start, end, boxes); - if (result != null && result.valid()) { setDefaultForTile(tile, result.bounds); } - return result != null ? result.hit : null; } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, - EnumFacing facing, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); - if (stack.isEmpty()) { return false; } - IMekWrench wrenchHandler = Wrenches.getHandler(stack); if (wrenchHandler != null) { RayTraceResult raytrace = new RayTraceResult(new Vec3d(hitX, hitY, hitZ), facing, pos); @@ -259,11 +234,9 @@ public class BlockTransmitter extends BlockTileDrops implements ITileEntityProvi if (!world.isRemote) { MekanismUtils.dismantleBlock(this, state, world, pos); } - return true; } } - return false; } @@ -274,15 +247,12 @@ public class BlockTransmitter extends BlockTileDrops implements ITileEntityProvi TileEntitySidedPipe tileEntity = getTileEntitySidedPipe(world, pos); if (tileEntity != null) { itemStack = new ItemStack(MekanismBlocks.Transmitter, 1, tileEntity.getTransmitterType().ordinal()); - if (!itemStack.hasTagCompound()) { itemStack.setTagCompound(new NBTTagCompound()); } - ITierItem tierItem = (ITierItem) itemStack.getItem(); tierItem.setBaseTier(itemStack, tileEntity.getBaseTier()); } - return itemStack; } @@ -292,8 +262,7 @@ public class BlockTransmitter extends BlockTileDrops implements ITileEntityProvi if (!target.typeOfHit.equals(Type.BLOCK)) { return super.addHitEffects(state, world, target, manager); } - return MekanismParticleHelper.addBlockHitEffects(world, target.getBlockPos(), target.sideHit, manager) || - super.addHitEffects(state, world, target, manager); + return MekanismParticleHelper.addBlockHitEffects(world, target.getBlockPos(), target.sideHit, manager) || super.addHitEffects(state, world, target, manager); } @Override @@ -312,8 +281,7 @@ public class BlockTransmitter extends BlockTileDrops implements ITileEntityProvi } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, - ItemStack stack) { + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { TileEntitySidedPipe tile = getTileEntitySidedPipe(world, pos); if (tile != null) { tile.onAdded(); @@ -325,8 +293,7 @@ public class BlockTransmitter extends BlockTileDrops implements ITileEntityProvi public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos neighbor) { TileEntitySidedPipe tile = getTileEntitySidedPipe(world, pos); if (tile != null) { - EnumFacing side = EnumFacing.getFacingFromVector(neighbor.getX() - pos.getX(), neighbor.getY() - pos.getY(), - neighbor.getZ() - pos.getZ()); + EnumFacing side = EnumFacing.getFacingFromVector(neighbor.getX() - pos.getX(), neighbor.getY() - pos.getY(), neighbor.getZ() - pos.getZ()); tile.onNeighborBlockChange(side); } } @@ -335,8 +302,7 @@ public class BlockTransmitter extends BlockTileDrops implements ITileEntityProvi public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) { TileEntitySidedPipe tile = getTileEntitySidedPipe(world, pos); if (tile != null) { - EnumFacing side = EnumFacing.getFacingFromVector(neighbor.getX() - pos.getX(), neighbor.getY() - pos.getY(), - neighbor.getZ() - pos.getZ()); + EnumFacing side = EnumFacing.getFacingFromVector(neighbor.getX() - pos.getX(), neighbor.getY() - pos.getY(), neighbor.getZ() - pos.getZ()); tile.onNeighborTileChange(side); } } @@ -344,12 +310,9 @@ public class BlockTransmitter extends BlockTileDrops implements ITileEntityProvi @Override public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer) { TransmitterType type = state.getValue(BlockStateTransmitter.typeProperty); - - if (layer == BlockRenderLayer.TRANSLUCENT && (type == TransmitterType.LOGISTICAL_TRANSPORTER - || type == TransmitterType.DIVERSION_TRANSPORTER)) { + if (layer == BlockRenderLayer.TRANSLUCENT && (type == TransmitterType.LOGISTICAL_TRANSPORTER || type == TransmitterType.DIVERSION_TRANSPORTER)) { return true; } - return layer == BlockRenderLayer.CUTOUT; } @@ -387,7 +350,6 @@ public class BlockTransmitter extends BlockTileDrops implements ITileEntityProvi @Override public TileEntity createNewTileEntity(@Nonnull World worldIn, int meta) { TransmitterType type = TransmitterType.get(meta); - switch (type) { case UNIVERSAL_CABLE: return new TileEntityUniversalCable(); @@ -404,7 +366,6 @@ public class BlockTransmitter extends BlockTileDrops implements ITileEntityProvi case THERMODYNAMIC_CONDUCTOR: return new TileEntityThermodynamicConductor(); } - return null; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/property/PropertyColor.java b/src/main/java/mekanism/common/block/property/PropertyColor.java index cc1bb5609..888dbd8f1 100644 --- a/src/main/java/mekanism/common/block/property/PropertyColor.java +++ b/src/main/java/mekanism/common/block/property/PropertyColor.java @@ -35,4 +35,4 @@ public class PropertyColor implements IUnlistedProperty { public String valueToString(PropertyColor value) { return color.getName(); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/property/PropertyConnection.java b/src/main/java/mekanism/common/block/property/PropertyConnection.java index 505763a3e..8e802c276 100644 --- a/src/main/java/mekanism/common/block/property/PropertyConnection.java +++ b/src/main/java/mekanism/common/block/property/PropertyConnection.java @@ -40,7 +40,6 @@ public class PropertyConnection implements IUnlistedProperty @Override public String valueToString(PropertyConnection value) { - return value.connectionByte + "_" + value.transmitterConnections + "_" - + Arrays.toString(value.connectionTypes) + "_" + value.renderCenter; + return value.connectionByte + "_" + value.transmitterConnections + "_" + Arrays.toString(value.connectionTypes) + "_" + value.renderCenter; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/states/BlockStateBasic.java b/src/main/java/mekanism/common/block/states/BlockStateBasic.java index 067a8c152..fb32697b9 100644 --- a/src/main/java/mekanism/common/block/states/BlockStateBasic.java +++ b/src/main/java/mekanism/common/block/states/BlockStateBasic.java @@ -7,8 +7,8 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import mekanism.common.Mekanism; import mekanism.common.MekanismBlocks; -import mekanism.common.tier.BaseTier; import mekanism.common.block.BlockBasic; +import mekanism.common.tier.BaseTier; import mekanism.common.tile.TileEntityBin; import mekanism.common.tile.TileEntityBoilerCasing; import mekanism.common.tile.TileEntityBoilerValve; @@ -48,11 +48,9 @@ public class BlockStateBasic extends ExtendedBlockState { public static final PropertyEnum tierProperty = PropertyEnum.create("tier", BaseTier.class); public BlockStateBasic(BlockBasic block, PropertyEnum typeProperty) { - super(block, new IProperty[]{BlockStateFacing.facingProperty, typeProperty, activeProperty, tierProperty}, - new IUnlistedProperty[]{}); + super(block, new IProperty[]{BlockStateFacing.facingProperty, typeProperty, activeProperty, tierProperty}, new IUnlistedProperty[]{}); } - public enum BasicBlock { BASIC_BLOCK_1, BASIC_BLOCK_2; @@ -63,7 +61,6 @@ public class BlockStateBasic extends ExtendedBlockState { if (predicatedProperty == null) { predicatedProperty = PropertyEnum.create("type", BasicBlockType.class, new BasicBlockPredicate(this)); } - return predicatedProperty; } @@ -80,56 +77,32 @@ public class BlockStateBasic extends ExtendedBlockState { } public enum BasicBlockType implements IStringSerializable { - OSMIUM_BLOCK(BasicBlock.BASIC_BLOCK_1, 0, "OsmiumBlock", null, false, Predicates.alwaysFalse(), false, false, - true), - BRONZE_BLOCK(BasicBlock.BASIC_BLOCK_1, 1, "BronzeBlock", null, false, Predicates.alwaysFalse(), false, false, - true), - REFINED_OBSIDIAN(BasicBlock.BASIC_BLOCK_1, 2, "RefinedObsidian", null, false, Predicates.alwaysFalse(), false, - false, true), - COAL_BLOCK(BasicBlock.BASIC_BLOCK_1, 3, "CharcoalBlock", null, false, Predicates.alwaysFalse(), false, false, - false), - REFINED_GLOWSTONE(BasicBlock.BASIC_BLOCK_1, 4, "RefinedGlowstone", null, false, Predicates.alwaysFalse(), false, - false, true), - STEEL_BLOCK(BasicBlock.BASIC_BLOCK_1, 5, "SteelBlock", null, false, Predicates.alwaysFalse(), false, false, - true), + OSMIUM_BLOCK(BasicBlock.BASIC_BLOCK_1, 0, "OsmiumBlock", null, false, Predicates.alwaysFalse(), false, false, true), + BRONZE_BLOCK(BasicBlock.BASIC_BLOCK_1, 1, "BronzeBlock", null, false, Predicates.alwaysFalse(), false, false, true), + REFINED_OBSIDIAN(BasicBlock.BASIC_BLOCK_1, 2, "RefinedObsidian", null, false, Predicates.alwaysFalse(), false, false, true), + COAL_BLOCK(BasicBlock.BASIC_BLOCK_1, 3, "CharcoalBlock", null, false, Predicates.alwaysFalse(), false, false, false), + REFINED_GLOWSTONE(BasicBlock.BASIC_BLOCK_1, 4, "RefinedGlowstone", null, false, Predicates.alwaysFalse(), false, false, true), + STEEL_BLOCK(BasicBlock.BASIC_BLOCK_1, 5, "SteelBlock", null, false, Predicates.alwaysFalse(), false, false, true), BIN(BasicBlock.BASIC_BLOCK_1, 6, "Bin", TileEntityBin.class, true, Plane.HORIZONTAL, true, true, false, true), - TELEPORTER_FRAME(BasicBlock.BASIC_BLOCK_1, 7, "TeleporterFrame", null, true, Predicates.alwaysFalse(), false, - false, false), - STEEL_CASING(BasicBlock.BASIC_BLOCK_1, 8, "SteelCasing", null, true, Predicates.alwaysFalse(), false, false, - false), - DYNAMIC_TANK(BasicBlock.BASIC_BLOCK_1, 9, "DynamicTank", TileEntityDynamicTank.class, true, - Predicates.alwaysFalse(), false, false, false), - STRUCTURAL_GLASS(BasicBlock.BASIC_BLOCK_1, 10, "StructuralGlass", TileEntityStructuralGlass.class, true, - Predicates.alwaysFalse(), false, false, false), - DYNAMIC_VALVE(BasicBlock.BASIC_BLOCK_1, 11, "DynamicValve", TileEntityDynamicValve.class, true, - Predicates.alwaysFalse(), false, false, false), - COPPER_BLOCK(BasicBlock.BASIC_BLOCK_1, 12, "CopperBlock", null, false, Predicates.alwaysFalse(), false, false, - true), + TELEPORTER_FRAME(BasicBlock.BASIC_BLOCK_1, 7, "TeleporterFrame", null, true, Predicates.alwaysFalse(), false, false, false), + STEEL_CASING(BasicBlock.BASIC_BLOCK_1, 8, "SteelCasing", null, true, Predicates.alwaysFalse(), false, false, false), + DYNAMIC_TANK(BasicBlock.BASIC_BLOCK_1, 9, "DynamicTank", TileEntityDynamicTank.class, true, Predicates.alwaysFalse(), false, false, false), + STRUCTURAL_GLASS(BasicBlock.BASIC_BLOCK_1, 10, "StructuralGlass", TileEntityStructuralGlass.class, true, Predicates.alwaysFalse(), false, false, false), + DYNAMIC_VALVE(BasicBlock.BASIC_BLOCK_1, 11, "DynamicValve", TileEntityDynamicValve.class, true, Predicates.alwaysFalse(), false, false, false), + COPPER_BLOCK(BasicBlock.BASIC_BLOCK_1, 12, "CopperBlock", null, false, Predicates.alwaysFalse(), false, false, true), TIN_BLOCK(BasicBlock.BASIC_BLOCK_1, 13, "TinBlock", null, false, Predicates.alwaysFalse(), false, false, true), - THERMAL_EVAPORATION_CONTROLLER(BasicBlock.BASIC_BLOCK_1, 14, "ThermalEvaporationController", - TileEntityThermalEvaporationController.class, true, Plane.HORIZONTAL, true, false, false), - THERMAL_EVAPORATION_VALVE(BasicBlock.BASIC_BLOCK_1, 15, "ThermalEvaporationValve", - TileEntityThermalEvaporationValve.class, true, Predicates.alwaysFalse(), false, false, false), - THERMAL_EVAPORATION_BLOCK(BasicBlock.BASIC_BLOCK_2, 0, "ThermalEvaporationBlock", - TileEntityThermalEvaporationBlock.class, true, Predicates.alwaysFalse(), false, false, false), - INDUCTION_CASING(BasicBlock.BASIC_BLOCK_2, 1, "InductionCasing", TileEntityInductionCasing.class, true, - Predicates.alwaysFalse(), false, false, false), - INDUCTION_PORT(BasicBlock.BASIC_BLOCK_2, 2, "InductionPort", TileEntityInductionPort.class, true, - Predicates.alwaysFalse(), true, false, false), - INDUCTION_CELL(BasicBlock.BASIC_BLOCK_2, 3, "InductionCell", TileEntityInductionCell.class, true, - Predicates.alwaysFalse(), false, true, false), - INDUCTION_PROVIDER(BasicBlock.BASIC_BLOCK_2, 4, "InductionProvider", TileEntityInductionProvider.class, true, - Predicates.alwaysFalse(), false, true, false), - SUPERHEATING_ELEMENT(BasicBlock.BASIC_BLOCK_2, 5, "SuperheatingElement", TileEntitySuperheatingElement.class, - true, Predicates.alwaysFalse(), false, false, false), - PRESSURE_DISPERSER(BasicBlock.BASIC_BLOCK_2, 6, "PressureDisperser", TileEntityPressureDisperser.class, true, - Predicates.alwaysFalse(), false, false, false), - BOILER_CASING(BasicBlock.BASIC_BLOCK_2, 7, "BoilerCasing", TileEntityBoilerCasing.class, true, - Predicates.alwaysFalse(), false, false, false), - BOILER_VALVE(BasicBlock.BASIC_BLOCK_2, 8, "BoilerValve", TileEntityBoilerValve.class, true, - Predicates.alwaysFalse(), false, false, false), - SECURITY_DESK(BasicBlock.BASIC_BLOCK_2, 9, "SecurityDesk", TileEntitySecurityDesk.class, true, Plane.HORIZONTAL, - false, false, false); + THERMAL_EVAPORATION_CONTROLLER(BasicBlock.BASIC_BLOCK_1, 14, "ThermalEvaporationController", TileEntityThermalEvaporationController.class, true, Plane.HORIZONTAL, true, false, false), + THERMAL_EVAPORATION_VALVE(BasicBlock.BASIC_BLOCK_1, 15, "ThermalEvaporationValve", TileEntityThermalEvaporationValve.class, true, Predicates.alwaysFalse(), false, false, false), + THERMAL_EVAPORATION_BLOCK(BasicBlock.BASIC_BLOCK_2, 0, "ThermalEvaporationBlock", TileEntityThermalEvaporationBlock.class, true, Predicates.alwaysFalse(), false, false, false), + INDUCTION_CASING(BasicBlock.BASIC_BLOCK_2, 1, "InductionCasing", TileEntityInductionCasing.class, true, Predicates.alwaysFalse(), false, false, false), + INDUCTION_PORT(BasicBlock.BASIC_BLOCK_2, 2, "InductionPort", TileEntityInductionPort.class, true, Predicates.alwaysFalse(), true, false, false), + INDUCTION_CELL(BasicBlock.BASIC_BLOCK_2, 3, "InductionCell", TileEntityInductionCell.class, true, Predicates.alwaysFalse(), false, true, false), + INDUCTION_PROVIDER(BasicBlock.BASIC_BLOCK_2, 4, "InductionProvider", TileEntityInductionProvider.class, true, Predicates.alwaysFalse(), false, true, false), + SUPERHEATING_ELEMENT(BasicBlock.BASIC_BLOCK_2, 5, "SuperheatingElement", TileEntitySuperheatingElement.class, true, Predicates.alwaysFalse(), false, false, false), + PRESSURE_DISPERSER(BasicBlock.BASIC_BLOCK_2, 6, "PressureDisperser", TileEntityPressureDisperser.class, true, Predicates.alwaysFalse(), false, false, false), + BOILER_CASING(BasicBlock.BASIC_BLOCK_2, 7, "BoilerCasing", TileEntityBoilerCasing.class, true, Predicates.alwaysFalse(), false, false, false), + BOILER_VALVE(BasicBlock.BASIC_BLOCK_2, 8, "BoilerValve", TileEntityBoilerValve.class, true, Predicates.alwaysFalse(), false, false, false), + SECURITY_DESK(BasicBlock.BASIC_BLOCK_2, 9, "SecurityDesk", TileEntitySecurityDesk.class, true, Plane.HORIZONTAL, false, false, false); public BasicBlock blockType; public int meta; @@ -143,8 +116,8 @@ public class BlockStateBasic extends ExtendedBlockState { public boolean isBeaconBase; public boolean hasRedstoneOutput = false; - BasicBlockType(BasicBlock block, int metadata, String s, Class tileClass, boolean hasDesc, - Predicate facingAllowed, boolean activeState, boolean t, boolean beaconBase) { + BasicBlockType(BasicBlock block, int metadata, String s, Class tileClass, boolean hasDesc, Predicate facingAllowed, + boolean activeState, boolean t, boolean beaconBase) { blockType = block; meta = metadata; name = s; @@ -156,8 +129,8 @@ public class BlockStateBasic extends ExtendedBlockState { isBeaconBase = beaconBase; } - BasicBlockType(BasicBlock block, int metadata, String s, Class tileClass, boolean hasDesc, - Predicate facingAllowed, boolean activeState, boolean t, boolean beaconBase, boolean hasRedstoneOutput) { + BasicBlockType(BasicBlock block, int metadata, String s, Class tileClass, boolean hasDesc, Predicate facingAllowed, + boolean activeState, boolean t, boolean beaconBase, boolean hasRedstoneOutput) { blockType = block; meta = metadata; name = s; @@ -175,7 +148,6 @@ public class BlockStateBasic extends ExtendedBlockState { if (state.getBlock() instanceof BlockBasic) { return state.getValue(((BlockBasic) state.getBlock()).getTypeProperty()); } - return null; } @@ -189,7 +161,6 @@ public class BlockStateBasic extends ExtendedBlockState { if (block instanceof BlockBasic) { return get(((BlockBasic) block).getBasicBlock(), meta); } - return null; } @@ -198,20 +169,16 @@ public class BlockStateBasic extends ExtendedBlockState { int index = blockType.ordinal() << 4 | metadata; if (index < values().length) { BasicBlockType firstTry = values()[index]; - if (firstTry.blockType == blockType && firstTry.meta == metadata) { return firstTry; } } - for (BasicBlockType type : values()) { if (type.blockType == blockType && type.meta == metadata) { return type; } } - Mekanism.logger.error("Invalid BasicBlock. type: {}, meta: {}", blockType.ordinal(), metadata); - return null; } @@ -219,8 +186,7 @@ public class BlockStateBasic extends ExtendedBlockState { try { return tileEntityClass.newInstance(); } catch (Exception e) { - Mekanism.logger.error("Unable to indirectly create tile entity."); - e.printStackTrace(); + Mekanism.logger.error("Unable to indirectly create tile entity.", e); return null; } } @@ -299,21 +265,17 @@ public class BlockStateBasic extends ExtendedBlockState { if (type.tiers) { BaseTier tier = state.getValue(tierProperty); - if (tier == BaseTier.CREATIVE && type != BasicBlockType.BIN) { tier = BaseTier.ULTIMATE; } - nameOverride = type.getName() + "_" + tier.getName(); } if (builder.length() == 0) { builder.append("normal"); } - - ResourceLocation baseLocation = new ResourceLocation("mekanism", - nameOverride != null ? nameOverride : type.getName()); + ResourceLocation baseLocation = new ResourceLocation("mekanism", nameOverride != null ? nameOverride : type.getName()); return new ModelResourceLocation(baseLocation, builder.toString()); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/states/BlockStateBounding.java b/src/main/java/mekanism/common/block/states/BlockStateBounding.java index 6efb99fdb..2ce2a1c1f 100644 --- a/src/main/java/mekanism/common/block/states/BlockStateBounding.java +++ b/src/main/java/mekanism/common/block/states/BlockStateBounding.java @@ -11,4 +11,4 @@ public class BlockStateBounding extends BlockStateContainer { public BlockStateBounding(BlockBounding block) { super(block, advancedProperty); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/states/BlockStateCardboardBox.java b/src/main/java/mekanism/common/block/states/BlockStateCardboardBox.java index 8e9d7a90e..c26ba5262 100644 --- a/src/main/java/mekanism/common/block/states/BlockStateCardboardBox.java +++ b/src/main/java/mekanism/common/block/states/BlockStateCardboardBox.java @@ -23,9 +23,8 @@ public class BlockStateCardboardBox extends BlockStateContainer { @Override protected ModelResourceLocation getModelResourceLocation(@Nonnull IBlockState state) { String property = "storage=" + state.getValue(storageProperty); - ResourceLocation baseLocation = new ResourceLocation("mekanism", "CardboardBox"); return new ModelResourceLocation(baseLocation, property); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/states/BlockStateEnergyCube.java b/src/main/java/mekanism/common/block/states/BlockStateEnergyCube.java index 9942e4a1a..5d7537f86 100644 --- a/src/main/java/mekanism/common/block/states/BlockStateEnergyCube.java +++ b/src/main/java/mekanism/common/block/states/BlockStateEnergyCube.java @@ -9,10 +9,9 @@ import net.minecraft.block.properties.PropertyEnum; */ public class BlockStateEnergyCube extends BlockStateFacing { - public static final PropertyEnum typeProperty = PropertyEnum - .create("tier", EnergyCubeTier.class); + public static final PropertyEnum typeProperty = PropertyEnum.create("tier", EnergyCubeTier.class); public BlockStateEnergyCube(BlockEnergyCube block) { super(block, typeProperty); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/states/BlockStateFacing.java b/src/main/java/mekanism/common/block/states/BlockStateFacing.java index d43718159..a8f9758f0 100644 --- a/src/main/java/mekanism/common/block/states/BlockStateFacing.java +++ b/src/main/java/mekanism/common/block/states/BlockStateFacing.java @@ -1,7 +1,7 @@ package mekanism.common.block.states; -import mekanism.common.tier.BaseTier; import mekanism.common.base.IFactory.RecipeType; +import mekanism.common.tier.BaseTier; import net.minecraft.block.Block; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyDirection; @@ -12,8 +12,7 @@ public class BlockStateFacing extends BlockStateContainer { public static final PropertyDirection facingProperty = PropertyDirection.create("facing"); - public BlockStateFacing(Block block, PropertyEnum typeProperty, PropertyBool activeProperty, - PropertyEnum tierProperty, PropertyEnum recipeProperty) { + public BlockStateFacing(Block block, PropertyEnum typeProperty, PropertyBool activeProperty, PropertyEnum tierProperty, PropertyEnum recipeProperty) { super(block, facingProperty, typeProperty, activeProperty, tierProperty, recipeProperty); } @@ -28,4 +27,4 @@ public class BlockStateFacing extends BlockStateContainer { public BlockStateFacing(Block block) { super(block, facingProperty); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/states/BlockStateGasTank.java b/src/main/java/mekanism/common/block/states/BlockStateGasTank.java index 1029b780b..38222fed3 100644 --- a/src/main/java/mekanism/common/block/states/BlockStateGasTank.java +++ b/src/main/java/mekanism/common/block/states/BlockStateGasTank.java @@ -9,10 +9,9 @@ import net.minecraft.block.properties.PropertyEnum; */ public class BlockStateGasTank extends BlockStateFacing { - public static final PropertyEnum typeProperty = PropertyEnum - .create("tier", GasTankTier.class); + public static final PropertyEnum typeProperty = PropertyEnum.create("tier", GasTankTier.class); public BlockStateGasTank(BlockGasTank block) { super(block, typeProperty); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/states/BlockStateGlowPanel.java b/src/main/java/mekanism/common/block/states/BlockStateGlowPanel.java index ee0d6af33..89dba76f3 100644 --- a/src/main/java/mekanism/common/block/states/BlockStateGlowPanel.java +++ b/src/main/java/mekanism/common/block/states/BlockStateGlowPanel.java @@ -11,4 +11,4 @@ public class BlockStateGlowPanel extends ExtendedBlockState { public BlockStateGlowPanel(BlockGlowPanel block) { super(block, new IProperty[]{BlockStateFacing.facingProperty}, new IUnlistedProperty[]{PropertyColor.INSTANCE}); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/states/BlockStateMachine.java b/src/main/java/mekanism/common/block/states/BlockStateMachine.java index e04d2cdd6..129cb9296 100644 --- a/src/main/java/mekanism/common/block/states/BlockStateMachine.java +++ b/src/main/java/mekanism/common/block/states/BlockStateMachine.java @@ -9,11 +9,11 @@ import java.util.Locale; import javax.annotation.Nonnull; import mekanism.common.Mekanism; import mekanism.common.MekanismBlocks; -import mekanism.common.tier.BaseTier; import mekanism.common.base.IBlockType; import mekanism.common.base.IFactory.RecipeType; import mekanism.common.block.BlockMachine; import mekanism.common.config.MekanismConfig; +import mekanism.common.tier.BaseTier; import mekanism.common.tier.FactoryTier; import mekanism.common.tile.TileEntityAdvancedFactory; import mekanism.common.tile.TileEntityAmbientAccumulator; @@ -78,8 +78,7 @@ public class BlockStateMachine extends ExtendedBlockState { public static final PropertyEnum recipeProperty = PropertyEnum.create("recipe", RecipeType.class); public BlockStateMachine(BlockMachine block, PropertyEnum typeProperty) { - super(block, new IProperty[]{BlockStateFacing.facingProperty, typeProperty, activeProperty, tierProperty, - recipeProperty}, new IUnlistedProperty[]{}); + super(block, new IProperty[]{BlockStateFacing.facingProperty, typeProperty, activeProperty, tierProperty, recipeProperty}, new IUnlistedProperty[]{}); } public enum MachineBlock { @@ -93,7 +92,6 @@ public class BlockStateMachine extends ExtendedBlockState { if (machineTypeProperty == null) { machineTypeProperty = PropertyEnum.create("type", MachineType.class, new MachineBlockPredicate(this)); } - return machineTypeProperty; } @@ -112,84 +110,45 @@ public class BlockStateMachine extends ExtendedBlockState { } public enum MachineType implements IStringSerializable, IBlockType { - ENRICHMENT_CHAMBER(MachineBlock.MACHINE_BLOCK_1, 0, "EnrichmentChamber", 3, TileEntityEnrichmentChamber.class, - true, false, true, Plane.HORIZONTAL, true), - OSMIUM_COMPRESSOR(MachineBlock.MACHINE_BLOCK_1, 1, "OsmiumCompressor", 4, TileEntityOsmiumCompressor.class, - true, false, true, Plane.HORIZONTAL, true), - COMBINER(MachineBlock.MACHINE_BLOCK_1, 2, "Combiner", 5, TileEntityCombiner.class, true, false, true, - Plane.HORIZONTAL, true), - CRUSHER(MachineBlock.MACHINE_BLOCK_1, 3, "Crusher", 6, TileEntityCrusher.class, true, false, true, - Plane.HORIZONTAL, true), - DIGITAL_MINER(MachineBlock.MACHINE_BLOCK_1, 4, "DigitalMiner", 2, TileEntityDigitalMiner.class, true, true, - true, Plane.HORIZONTAL, true), - BASIC_FACTORY(MachineBlock.MACHINE_BLOCK_1, 5, "Factory", 11, TileEntityFactory.class, true, false, true, - Plane.HORIZONTAL, true, FactoryTier.BASIC), - ADVANCED_FACTORY(MachineBlock.MACHINE_BLOCK_1, 6, "Factory", 11, TileEntityAdvancedFactory.class, true, false, - true, Plane.HORIZONTAL, true, FactoryTier.ADVANCED), - ELITE_FACTORY(MachineBlock.MACHINE_BLOCK_1, 7, "Factory", 11, TileEntityEliteFactory.class, true, false, true, - Plane.HORIZONTAL, true, FactoryTier.ELITE), - METALLURGIC_INFUSER(MachineBlock.MACHINE_BLOCK_1, 8, "MetallurgicInfuser", 12, - TileEntityMetallurgicInfuser.class, true, true, true, Plane.HORIZONTAL, false), - PURIFICATION_CHAMBER(MachineBlock.MACHINE_BLOCK_1, 9, "PurificationChamber", 15, - TileEntityPurificationChamber.class, true, false, true, Plane.HORIZONTAL, true), - ENERGIZED_SMELTER(MachineBlock.MACHINE_BLOCK_1, 10, "EnergizedSmelter", 16, TileEntityEnergizedSmelter.class, - true, false, true, Plane.HORIZONTAL, true), - TELEPORTER(MachineBlock.MACHINE_BLOCK_1, 11, "Teleporter", 13, TileEntityTeleporter.class, true, false, false, - Predicates.alwaysFalse(), false), - ELECTRIC_PUMP(MachineBlock.MACHINE_BLOCK_1, 12, "ElectricPump", 17, TileEntityElectricPump.class, true, true, - false, Plane.HORIZONTAL, false), - PERSONAL_CHEST(MachineBlock.MACHINE_BLOCK_1, 13, "PersonalChest", -1, TileEntityPersonalChest.class, true, true, - false, Plane.HORIZONTAL, false), - CHARGEPAD(MachineBlock.MACHINE_BLOCK_1, 14, "Chargepad", -1, TileEntityChargepad.class, true, true, false, - Plane.HORIZONTAL, false), - LOGISTICAL_SORTER(MachineBlock.MACHINE_BLOCK_1, 15, "LogisticalSorter", 59, TileEntityLogisticalSorter.class, - false, true, false, Predicates.alwaysTrue(), true), - ROTARY_CONDENSENTRATOR(MachineBlock.MACHINE_BLOCK_2, 0, "RotaryCondensentrator", 7, - TileEntityRotaryCondensentrator.class, true, true, false, Plane.HORIZONTAL, false), - CHEMICAL_OXIDIZER(MachineBlock.MACHINE_BLOCK_2, 1, "ChemicalOxidizer", 29, TileEntityChemicalOxidizer.class, - true, true, true, Plane.HORIZONTAL, true), - CHEMICAL_INFUSER(MachineBlock.MACHINE_BLOCK_2, 2, "ChemicalInfuser", 30, TileEntityChemicalInfuser.class, true, - true, false, Plane.HORIZONTAL, true), - CHEMICAL_INJECTION_CHAMBER(MachineBlock.MACHINE_BLOCK_2, 3, "ChemicalInjectionChamber", 31, - TileEntityChemicalInjectionChamber.class, true, false, true, Plane.HORIZONTAL, true), - ELECTROLYTIC_SEPARATOR(MachineBlock.MACHINE_BLOCK_2, 4, "ElectrolyticSeparator", 32, - TileEntityElectrolyticSeparator.class, true, true, false, Plane.HORIZONTAL, true), - PRECISION_SAWMILL(MachineBlock.MACHINE_BLOCK_2, 5, "PrecisionSawmill", 34, TileEntityPrecisionSawmill.class, - true, false, true, Plane.HORIZONTAL, true), - CHEMICAL_DISSOLUTION_CHAMBER(MachineBlock.MACHINE_BLOCK_2, 6, "ChemicalDissolutionChamber", 35, - TileEntityChemicalDissolutionChamber.class, true, true, true, Plane.HORIZONTAL, true), - CHEMICAL_WASHER(MachineBlock.MACHINE_BLOCK_2, 7, "ChemicalWasher", 36, TileEntityChemicalWasher.class, true, - true, false, Plane.HORIZONTAL, true), - CHEMICAL_CRYSTALLIZER(MachineBlock.MACHINE_BLOCK_2, 8, "ChemicalCrystallizer", 37, - TileEntityChemicalCrystallizer.class, true, true, true, Plane.HORIZONTAL, true), - SEISMIC_VIBRATOR(MachineBlock.MACHINE_BLOCK_2, 9, "SeismicVibrator", 39, TileEntitySeismicVibrator.class, true, - true, false, Plane.HORIZONTAL, true), - PRESSURIZED_REACTION_CHAMBER(MachineBlock.MACHINE_BLOCK_2, 10, "PressurizedReactionChamber", 40, - TileEntityPRC.class, true, true, false, Plane.HORIZONTAL, true), - FLUID_TANK(MachineBlock.MACHINE_BLOCK_2, 11, "FluidTank", 41, TileEntityFluidTank.class, false, true, false, - Predicates.alwaysFalse(), true), - FLUIDIC_PLENISHER(MachineBlock.MACHINE_BLOCK_2, 12, "FluidicPlenisher", 42, TileEntityFluidicPlenisher.class, - true, true, false, Plane.HORIZONTAL, true), - LASER(MachineBlock.MACHINE_BLOCK_2, 13, "Laser", -1, TileEntityLaser.class, true, true, false, - Predicates.alwaysTrue(), false), - LASER_AMPLIFIER(MachineBlock.MACHINE_BLOCK_2, 14, "LaserAmplifier", 44, TileEntityLaserAmplifier.class, false, - true, false, Predicates.alwaysTrue(), true), - LASER_TRACTOR_BEAM(MachineBlock.MACHINE_BLOCK_2, 15, "LaserTractorBeam", 45, TileEntityLaserTractorBeam.class, - false, true, false, Predicates.alwaysTrue(), true), - QUANTUM_ENTANGLOPORTER(MachineBlock.MACHINE_BLOCK_3, 0, "QuantumEntangloporter", 46, - TileEntityQuantumEntangloporter.class, true, false, false, Predicates.alwaysTrue(), false), - SOLAR_NEUTRON_ACTIVATOR(MachineBlock.MACHINE_BLOCK_3, 1, "SolarNeutronActivator", 47, - TileEntitySolarNeutronActivator.class, false, true, false, Plane.HORIZONTAL, true), - AMBIENT_ACCUMULATOR(MachineBlock.MACHINE_BLOCK_3, 2, "AmbientAccumulator", 48, - TileEntityAmbientAccumulator.class, true, false, false, Predicates.alwaysFalse(), true), - OREDICTIONIFICATOR(MachineBlock.MACHINE_BLOCK_3, 3, "Oredictionificator", 52, - TileEntityOredictionificator.class, false, false, false, Plane.HORIZONTAL, true), - RESISTIVE_HEATER(MachineBlock.MACHINE_BLOCK_3, 4, "ResistiveHeater", 53, TileEntityResistiveHeater.class, true, - false, false, Plane.HORIZONTAL, true), - FORMULAIC_ASSEMBLICATOR(MachineBlock.MACHINE_BLOCK_3, 5, "FormulaicAssemblicator", 56, - TileEntityFormulaicAssemblicator.class, true, false, true, Plane.HORIZONTAL, true), - FUELWOOD_HEATER(MachineBlock.MACHINE_BLOCK_3, 6, "FuelwoodHeater", 58, TileEntityFuelwoodHeater.class, false, - false, false, Plane.HORIZONTAL, true); + ENRICHMENT_CHAMBER(MachineBlock.MACHINE_BLOCK_1, 0, "EnrichmentChamber", 3, TileEntityEnrichmentChamber.class, true, false, true, Plane.HORIZONTAL, true), + OSMIUM_COMPRESSOR(MachineBlock.MACHINE_BLOCK_1, 1, "OsmiumCompressor", 4, TileEntityOsmiumCompressor.class, true, false, true, Plane.HORIZONTAL, true), + COMBINER(MachineBlock.MACHINE_BLOCK_1, 2, "Combiner", 5, TileEntityCombiner.class, true, false, true, Plane.HORIZONTAL, true), + CRUSHER(MachineBlock.MACHINE_BLOCK_1, 3, "Crusher", 6, TileEntityCrusher.class, true, false, true, Plane.HORIZONTAL, true), + DIGITAL_MINER(MachineBlock.MACHINE_BLOCK_1, 4, "DigitalMiner", 2, TileEntityDigitalMiner.class, true, true, true, Plane.HORIZONTAL, true), + BASIC_FACTORY(MachineBlock.MACHINE_BLOCK_1, 5, "Factory", 11, TileEntityFactory.class, true, false, true, Plane.HORIZONTAL, true, FactoryTier.BASIC), + ADVANCED_FACTORY(MachineBlock.MACHINE_BLOCK_1, 6, "Factory", 11, TileEntityAdvancedFactory.class, true, false, true, Plane.HORIZONTAL, true, FactoryTier.ADVANCED), + ELITE_FACTORY(MachineBlock.MACHINE_BLOCK_1, 7, "Factory", 11, TileEntityEliteFactory.class, true, false, true, Plane.HORIZONTAL, true, FactoryTier.ELITE), + METALLURGIC_INFUSER(MachineBlock.MACHINE_BLOCK_1, 8, "MetallurgicInfuser", 12, TileEntityMetallurgicInfuser.class, true, true, true, Plane.HORIZONTAL, false), + PURIFICATION_CHAMBER(MachineBlock.MACHINE_BLOCK_1, 9, "PurificationChamber", 15, TileEntityPurificationChamber.class, true, false, true, Plane.HORIZONTAL, true), + ENERGIZED_SMELTER(MachineBlock.MACHINE_BLOCK_1, 10, "EnergizedSmelter", 16, TileEntityEnergizedSmelter.class, true, false, true, Plane.HORIZONTAL, true), + TELEPORTER(MachineBlock.MACHINE_BLOCK_1, 11, "Teleporter", 13, TileEntityTeleporter.class, true, false, false, Predicates.alwaysFalse(), false), + ELECTRIC_PUMP(MachineBlock.MACHINE_BLOCK_1, 12, "ElectricPump", 17, TileEntityElectricPump.class, true, true, false, Plane.HORIZONTAL, false), + PERSONAL_CHEST(MachineBlock.MACHINE_BLOCK_1, 13, "PersonalChest", -1, TileEntityPersonalChest.class, true, true, false, Plane.HORIZONTAL, false), + CHARGEPAD(MachineBlock.MACHINE_BLOCK_1, 14, "Chargepad", -1, TileEntityChargepad.class, true, true, false, Plane.HORIZONTAL, false), + LOGISTICAL_SORTER(MachineBlock.MACHINE_BLOCK_1, 15, "LogisticalSorter", 59, TileEntityLogisticalSorter.class, false, true, false, Predicates.alwaysTrue(), true), + ROTARY_CONDENSENTRATOR(MachineBlock.MACHINE_BLOCK_2, 0, "RotaryCondensentrator", 7, TileEntityRotaryCondensentrator.class, true, true, false, Plane.HORIZONTAL, false), + CHEMICAL_OXIDIZER(MachineBlock.MACHINE_BLOCK_2, 1, "ChemicalOxidizer", 29, TileEntityChemicalOxidizer.class, true, true, true, Plane.HORIZONTAL, true), + CHEMICAL_INFUSER(MachineBlock.MACHINE_BLOCK_2, 2, "ChemicalInfuser", 30, TileEntityChemicalInfuser.class, true, true, false, Plane.HORIZONTAL, true), + CHEMICAL_INJECTION_CHAMBER(MachineBlock.MACHINE_BLOCK_2, 3, "ChemicalInjectionChamber", 31, TileEntityChemicalInjectionChamber.class, true, false, true, Plane.HORIZONTAL, true), + ELECTROLYTIC_SEPARATOR(MachineBlock.MACHINE_BLOCK_2, 4, "ElectrolyticSeparator", 32, TileEntityElectrolyticSeparator.class, true, true, false, Plane.HORIZONTAL, true), + PRECISION_SAWMILL(MachineBlock.MACHINE_BLOCK_2, 5, "PrecisionSawmill", 34, TileEntityPrecisionSawmill.class, true, false, true, Plane.HORIZONTAL, true), + CHEMICAL_DISSOLUTION_CHAMBER(MachineBlock.MACHINE_BLOCK_2, 6, "ChemicalDissolutionChamber", 35, TileEntityChemicalDissolutionChamber.class, true, true, true, Plane.HORIZONTAL, true), + CHEMICAL_WASHER(MachineBlock.MACHINE_BLOCK_2, 7, "ChemicalWasher", 36, TileEntityChemicalWasher.class, true, true, false, Plane.HORIZONTAL, true), + CHEMICAL_CRYSTALLIZER(MachineBlock.MACHINE_BLOCK_2, 8, "ChemicalCrystallizer", 37, TileEntityChemicalCrystallizer.class, true, true, true, Plane.HORIZONTAL, true), + SEISMIC_VIBRATOR(MachineBlock.MACHINE_BLOCK_2, 9, "SeismicVibrator", 39, TileEntitySeismicVibrator.class, true, true, false, Plane.HORIZONTAL, true), + PRESSURIZED_REACTION_CHAMBER(MachineBlock.MACHINE_BLOCK_2, 10, "PressurizedReactionChamber", 40, TileEntityPRC.class, true, true, false, Plane.HORIZONTAL, true), + FLUID_TANK(MachineBlock.MACHINE_BLOCK_2, 11, "FluidTank", 41, TileEntityFluidTank.class, false, true, false, Predicates.alwaysFalse(), true), + FLUIDIC_PLENISHER(MachineBlock.MACHINE_BLOCK_2, 12, "FluidicPlenisher", 42, TileEntityFluidicPlenisher.class, true, true, false, Plane.HORIZONTAL, true), + LASER(MachineBlock.MACHINE_BLOCK_2, 13, "Laser", -1, TileEntityLaser.class, true, true, false, Predicates.alwaysTrue(), false), + LASER_AMPLIFIER(MachineBlock.MACHINE_BLOCK_2, 14, "LaserAmplifier", 44, TileEntityLaserAmplifier.class, false, true, false, Predicates.alwaysTrue(), true), + LASER_TRACTOR_BEAM(MachineBlock.MACHINE_BLOCK_2, 15, "LaserTractorBeam", 45, TileEntityLaserTractorBeam.class, false, true, false, Predicates.alwaysTrue(), true), + QUANTUM_ENTANGLOPORTER(MachineBlock.MACHINE_BLOCK_3, 0, "QuantumEntangloporter", 46, TileEntityQuantumEntangloporter.class, true, false, false, Predicates.alwaysTrue(), false), + SOLAR_NEUTRON_ACTIVATOR(MachineBlock.MACHINE_BLOCK_3, 1, "SolarNeutronActivator", 47, TileEntitySolarNeutronActivator.class, false, true, false, Plane.HORIZONTAL, true), + AMBIENT_ACCUMULATOR(MachineBlock.MACHINE_BLOCK_3, 2, "AmbientAccumulator", 48, TileEntityAmbientAccumulator.class, true, false, false, Predicates.alwaysFalse(), true), + OREDICTIONIFICATOR(MachineBlock.MACHINE_BLOCK_3, 3, "Oredictionificator", 52, TileEntityOredictionificator.class, false, false, false, Plane.HORIZONTAL, true), + RESISTIVE_HEATER(MachineBlock.MACHINE_BLOCK_3, 4, "ResistiveHeater", 53, TileEntityResistiveHeater.class, true, false, false, Plane.HORIZONTAL, true), + FORMULAIC_ASSEMBLICATOR(MachineBlock.MACHINE_BLOCK_3, 5, "FormulaicAssemblicator", 56, TileEntityFormulaicAssemblicator.class, true, false, true, Plane.HORIZONTAL, true), + FUELWOOD_HEATER(MachineBlock.MACHINE_BLOCK_3, 6, "FuelwoodHeater", 58, TileEntityFuelwoodHeater.class, false, false, false, Plane.HORIZONTAL, true); public MachineBlock typeBlock; public int meta; @@ -203,14 +162,13 @@ public class BlockStateMachine extends ExtendedBlockState { public boolean activable; public FactoryTier factoryTier; - MachineType(MachineBlock block, int i, String s, int j, Class tileClass, boolean electric, - boolean model, boolean upgrades, Predicate predicate, boolean hasActiveTexture) { + MachineType(MachineBlock block, int i, String s, int j, Class tileClass, boolean electric, boolean model, boolean upgrades, + Predicate predicate, boolean hasActiveTexture) { this(block, i, s, j, tileClass, electric, model, upgrades, predicate, hasActiveTexture, null); } - MachineType(MachineBlock block, int i, String s, int j, Class tileClass, boolean electric, - boolean model, boolean upgrades, Predicate predicate, boolean hasActiveTexture, - FactoryTier factoryTier) { + MachineType(MachineBlock block, int i, String s, int j, Class tileClass, boolean electric, boolean model, boolean upgrades, + Predicate predicate, boolean hasActiveTexture, FactoryTier factoryTier) { typeBlock = block; meta = i; blockName = s; @@ -238,7 +196,6 @@ public class BlockStateMachine extends ExtendedBlockState { if (block instanceof BlockMachine) { return get(((BlockMachine) block).getMachineBlock(), meta); } - return null; } @@ -248,7 +205,6 @@ public class BlockStateMachine extends ExtendedBlockState { return type; } } - return null; } @@ -275,8 +231,7 @@ public class BlockStateMachine extends ExtendedBlockState { try { return tileEntityClass.newInstance(); } catch (Exception e) { - Mekanism.logger.error("Unable to indirectly create tile entity."); - e.printStackTrace(); + Mekanism.logger.error("Unable to indirectly create tile entity.", e); return null; } } @@ -355,7 +310,7 @@ public class BlockStateMachine extends ExtendedBlockState { return 0; } } - + private double getConfigStorage() { switch (this) { case ENRICHMENT_CHAMBER: @@ -484,35 +439,27 @@ public class BlockStateMachine extends ExtendedBlockState { if (type.hasRotations()) { EnumFacing facing = state.getValue(BlockStateFacing.facingProperty); - if (!type.canRotateTo(facing)) { facing = EnumFacing.NORTH; } - if (builder.length() > 0) { builder.append(","); } - builder.append(BlockStateFacing.facingProperty.getName()); builder.append("="); builder.append(facing.getName()); } - if (type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY - || type == MachineType.ELITE_FACTORY) { + if (type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY || type == MachineType.ELITE_FACTORY) { RecipeType recipe = state.getValue(recipeProperty); - nameOverride = type.getName() + "_" + recipe.getName(); } if (builder.length() == 0) { builder.append("normal"); } - - ResourceLocation baseLocation = new ResourceLocation("mekanism", - nameOverride != null ? nameOverride : type.getName()); - + ResourceLocation baseLocation = new ResourceLocation("mekanism", nameOverride != null ? nameOverride : type.getName()); return new ModelResourceLocation(baseLocation, builder.toString()); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/states/BlockStateOre.java b/src/main/java/mekanism/common/block/states/BlockStateOre.java index f4fd8fb40..038f5c604 100644 --- a/src/main/java/mekanism/common/block/states/BlockStateOre.java +++ b/src/main/java/mekanism/common/block/states/BlockStateOre.java @@ -27,4 +27,4 @@ public class BlockStateOre extends BlockStateContainer { return name().toLowerCase(Locale.ROOT); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/states/BlockStatePlastic.java b/src/main/java/mekanism/common/block/states/BlockStatePlastic.java index dd17107ef..9b86665f2 100644 --- a/src/main/java/mekanism/common/block/states/BlockStatePlastic.java +++ b/src/main/java/mekanism/common/block/states/BlockStatePlastic.java @@ -40,9 +40,8 @@ public class BlockStatePlastic extends BlockStateContainer { protected ModelResourceLocation getModelResourceLocation(@Nonnull IBlockState state) { PlasticBlockType type = ((BlockPlastic) state.getBlock()).type; String property = "type=" + type.getName(); - ResourceLocation baseLocation = new ResourceLocation("mekanism", "plastic_block"); return new ModelResourceLocation(baseLocation, property); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/states/BlockStateTransmitter.java b/src/main/java/mekanism/common/block/states/BlockStateTransmitter.java index 5f7a6a863..a390a29bb 100644 --- a/src/main/java/mekanism/common/block/states/BlockStateTransmitter.java +++ b/src/main/java/mekanism/common/block/states/BlockStateTransmitter.java @@ -3,10 +3,10 @@ package mekanism.common.block.states; import java.util.Locale; import javax.annotation.Nonnull; import mekanism.api.transmitters.TransmissionType; -import mekanism.common.tier.BaseTier; import mekanism.common.block.BlockTransmitter; import mekanism.common.block.property.PropertyColor; import mekanism.common.block.property.PropertyConnection; +import mekanism.common.tier.BaseTier; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.IBlockState; @@ -24,8 +24,7 @@ public class BlockStateTransmitter extends ExtendedBlockState { public static final PropertyEnum tierProperty = PropertyEnum.create("tier", BaseTier.class); public BlockStateTransmitter(BlockTransmitter block) { - super(block, new IProperty[]{typeProperty, tierProperty}, - new IUnlistedProperty[]{OBJProperty.INSTANCE, PropertyColor.INSTANCE, PropertyConnection.INSTANCE}); + super(block, new IProperty[]{typeProperty, tierProperty}, new IUnlistedProperty[]{OBJProperty.INSTANCE, PropertyColor.INSTANCE, PropertyConnection.INSTANCE}); } public enum TransmitterType implements IStringSerializable { @@ -104,22 +103,16 @@ public class BlockStateTransmitter extends ExtendedBlockState { if (type.tiers) { BaseTier tier = state.getValue(tierProperty); - if (tier == BaseTier.CREATIVE) { tier = BaseTier.ULTIMATE; } - nameOverride = type.getName() + "_" + tier.getName(); } - if (builder.length() == 0) { builder.append("normal"); } - - ResourceLocation baseLocation = new ResourceLocation("mekanism", - nameOverride != null ? nameOverride : type.getName()); - + ResourceLocation baseLocation = new ResourceLocation("mekanism", nameOverride != null ? nameOverride : type.getName()); return new ModelResourceLocation(baseLocation, builder.toString()); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/capabilities/CapabilityWrapperManager.java b/src/main/java/mekanism/common/capabilities/CapabilityWrapperManager.java index ee65dc4aa..f18ec52fa 100644 --- a/src/main/java/mekanism/common/capabilities/CapabilityWrapperManager.java +++ b/src/main/java/mekanism/common/capabilities/CapabilityWrapperManager.java @@ -28,4 +28,4 @@ public class CapabilityWrapperManager { return wrappers.get(facing); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/capabilities/DefaultAlloyInteraction.java b/src/main/java/mekanism/common/capabilities/DefaultAlloyInteraction.java index 6dbad3496..e35f20f74 100644 --- a/src/main/java/mekanism/common/capabilities/DefaultAlloyInteraction.java +++ b/src/main/java/mekanism/common/capabilities/DefaultAlloyInteraction.java @@ -16,4 +16,4 @@ public class DefaultAlloyInteraction implements IAlloyInteraction { @Override public void onAlloyInteraction(EntityPlayer player, EnumHand hand, ItemStack stack, int tierOrdinal) { } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/capabilities/DefaultBlockableConnection.java b/src/main/java/mekanism/common/capabilities/DefaultBlockableConnection.java index c11bc93d1..93cc2c600 100644 --- a/src/main/java/mekanism/common/capabilities/DefaultBlockableConnection.java +++ b/src/main/java/mekanism/common/capabilities/DefaultBlockableConnection.java @@ -8,8 +8,7 @@ import net.minecraftforge.common.capabilities.CapabilityManager; public class DefaultBlockableConnection implements IBlockableConnection { public static void register() { - CapabilityManager.INSTANCE - .register(IBlockableConnection.class, new NullStorage<>(), DefaultBlockableConnection::new); + CapabilityManager.INSTANCE.register(IBlockableConnection.class, new NullStorage<>(), DefaultBlockableConnection::new); } @Override @@ -21,4 +20,4 @@ public class DefaultBlockableConnection implements IBlockableConnection { public boolean canConnect(EnumFacing side) { return false; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/capabilities/DefaultCableOutputter.java b/src/main/java/mekanism/common/capabilities/DefaultCableOutputter.java index 362cff1b9..069b1ed33 100644 --- a/src/main/java/mekanism/common/capabilities/DefaultCableOutputter.java +++ b/src/main/java/mekanism/common/capabilities/DefaultCableOutputter.java @@ -11,8 +11,7 @@ import net.minecraftforge.common.capabilities.CapabilityManager; public class DefaultCableOutputter implements IStrictEnergyOutputter { public static void register() { - CapabilityManager.INSTANCE - .register(IStrictEnergyOutputter.class, new NullStorage<>(), DefaultCableOutputter::new); + CapabilityManager.INSTANCE.register(IStrictEnergyOutputter.class, new NullStorage<>(), DefaultCableOutputter::new); } @Override @@ -24,4 +23,4 @@ public class DefaultCableOutputter implements IStrictEnergyOutputter { public boolean canOutputEnergy(EnumFacing side) { return true; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/capabilities/DefaultConfigCardAccess.java b/src/main/java/mekanism/common/capabilities/DefaultConfigCardAccess.java index adf9cfde6..e8a449d52 100644 --- a/src/main/java/mekanism/common/capabilities/DefaultConfigCardAccess.java +++ b/src/main/java/mekanism/common/capabilities/DefaultConfigCardAccess.java @@ -9,4 +9,4 @@ public class DefaultConfigCardAccess implements IConfigCardAccess { public static void register() { CapabilityManager.INSTANCE.register(IConfigCardAccess.class, new NullStorage<>(), DefaultConfigCardAccess::new); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/capabilities/DefaultConfigurable.java b/src/main/java/mekanism/common/capabilities/DefaultConfigurable.java index 99ace14ce..6902e0db7 100644 --- a/src/main/java/mekanism/common/capabilities/DefaultConfigurable.java +++ b/src/main/java/mekanism/common/capabilities/DefaultConfigurable.java @@ -25,4 +25,4 @@ public class DefaultConfigurable implements IConfigurable { public EnumActionResult onRightClick(EntityPlayer player, EnumFacing side) { return EnumActionResult.PASS; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/capabilities/DefaultEvaporationSolar.java b/src/main/java/mekanism/common/capabilities/DefaultEvaporationSolar.java index 46c5746a7..55f48ed16 100644 --- a/src/main/java/mekanism/common/capabilities/DefaultEvaporationSolar.java +++ b/src/main/java/mekanism/common/capabilities/DefaultEvaporationSolar.java @@ -14,4 +14,4 @@ public class DefaultEvaporationSolar implements IEvaporationSolar { public boolean canSeeSun() { return false; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/capabilities/DefaultGasHandler.java b/src/main/java/mekanism/common/capabilities/DefaultGasHandler.java index 8fc1e381c..7f9da2eb5 100644 --- a/src/main/java/mekanism/common/capabilities/DefaultGasHandler.java +++ b/src/main/java/mekanism/common/capabilities/DefaultGasHandler.java @@ -40,4 +40,4 @@ public class DefaultGasHandler implements IGasHandler { public GasTankInfo[] getTankInfo() { return IGasHandler.NONE; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/capabilities/DefaultGridTransmitter.java b/src/main/java/mekanism/common/capabilities/DefaultGridTransmitter.java index 4185f213f..f1623ee16 100644 --- a/src/main/java/mekanism/common/capabilities/DefaultGridTransmitter.java +++ b/src/main/java/mekanism/common/capabilities/DefaultGridTransmitter.java @@ -31,7 +31,6 @@ public class DefaultGridTransmitter, B @Override public void setTransmitterNetwork(N network) { - } @Override @@ -101,7 +100,6 @@ public class DefaultGridTransmitter, B @Override public void setOrphan(boolean orphaned) { - } @Override @@ -121,12 +119,10 @@ public class DefaultGridTransmitter, B @Override public void takeShare() { - } @Override public void updateShare() { - } @Override @@ -147,4 +143,4 @@ public class DefaultGridTransmitter, B public boolean isCompatibleWith(IGridTransmitter other) { return false; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/capabilities/DefaultHeatTransfer.java b/src/main/java/mekanism/common/capabilities/DefaultHeatTransfer.java index 2b683d0fe..e111f78f8 100644 --- a/src/main/java/mekanism/common/capabilities/DefaultHeatTransfer.java +++ b/src/main/java/mekanism/common/capabilities/DefaultHeatTransfer.java @@ -28,7 +28,6 @@ public class DefaultHeatTransfer implements IHeatTransfer { @Override public void transferHeatTo(double heat) { - } @Override @@ -50,4 +49,4 @@ public class DefaultHeatTransfer implements IHeatTransfer { public IHeatTransfer getAdjacent(EnumFacing side) { return null; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/capabilities/DefaultLaserReceptor.java b/src/main/java/mekanism/common/capabilities/DefaultLaserReceptor.java index b5fb76778..67d6ac94d 100644 --- a/src/main/java/mekanism/common/capabilities/DefaultLaserReceptor.java +++ b/src/main/java/mekanism/common/capabilities/DefaultLaserReceptor.java @@ -13,11 +13,10 @@ public class DefaultLaserReceptor implements ILaserReceptor { @Override public void receiveLaserEnergy(double energy, EnumFacing side) { - } @Override public boolean canLasersDig() { return false; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/capabilities/DefaultLogisticalTransporter.java b/src/main/java/mekanism/common/capabilities/DefaultLogisticalTransporter.java index 159b51959..c9a0e8567 100644 --- a/src/main/java/mekanism/common/capabilities/DefaultLogisticalTransporter.java +++ b/src/main/java/mekanism/common/capabilities/DefaultLogisticalTransporter.java @@ -23,8 +23,7 @@ import net.minecraftforge.common.capabilities.CapabilityManager; public class DefaultLogisticalTransporter implements ILogisticalTransporter { public static void register() { - CapabilityManager.INSTANCE - .register(ILogisticalTransporter.class, new NullStorage<>(), DefaultLogisticalTransporter::new); + CapabilityManager.INSTANCE.register(ILogisticalTransporter.class, new NullStorage<>(), DefaultLogisticalTransporter::new); } @Override @@ -33,14 +32,12 @@ public class DefaultLogisticalTransporter implements ILogisticalTransporter { } @Override - public TransitResponse insertRR(TileEntityLogisticalSorter outputter, TransitRequest request, EnumColor color, - boolean doEmit, int min) { + public TransitResponse insertRR(TileEntityLogisticalSorter outputter, TransitRequest request, EnumColor color, boolean doEmit, int min) { return TransitResponse.EMPTY; } @Override public void entityEntering(TransporterStack stack, int progress) { - } @Override @@ -50,7 +47,6 @@ public class DefaultLogisticalTransporter implements ILogisticalTransporter { @Override public void setColor(EnumColor c) { - } @Override @@ -90,7 +86,6 @@ public class DefaultLogisticalTransporter implements ILogisticalTransporter { @Override public void setTransmitterNetwork(InventoryNetwork network) { - } @Override @@ -160,7 +155,6 @@ public class DefaultLogisticalTransporter implements ILogisticalTransporter { @Override public void setOrphan(boolean orphaned) { - } @Override @@ -180,12 +174,10 @@ public class DefaultLogisticalTransporter implements ILogisticalTransporter { @Override public void takeShare() { - } @Override public void updateShare() { - } @Override @@ -206,4 +198,4 @@ public class DefaultLogisticalTransporter implements ILogisticalTransporter { public boolean isCompatibleWith(IGridTransmitter other) { return false; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/capabilities/DefaultSpecialConfigData.java b/src/main/java/mekanism/common/capabilities/DefaultSpecialConfigData.java index 765c0f9d7..1e0cca93e 100644 --- a/src/main/java/mekanism/common/capabilities/DefaultSpecialConfigData.java +++ b/src/main/java/mekanism/common/capabilities/DefaultSpecialConfigData.java @@ -8,8 +8,7 @@ import net.minecraftforge.common.capabilities.CapabilityManager; public class DefaultSpecialConfigData extends DefaultConfigCardAccess implements ISpecialConfigData { public static void register() { - CapabilityManager.INSTANCE - .register(ISpecialConfigData.class, new NullStorage<>(), DefaultSpecialConfigData::new); + CapabilityManager.INSTANCE.register(ISpecialConfigData.class, new NullStorage<>(), DefaultSpecialConfigData::new); } @Override @@ -19,11 +18,10 @@ public class DefaultSpecialConfigData extends DefaultConfigCardAccess implements @Override public void setConfigurationData(NBTTagCompound nbtTags) { - } @Override public String getDataType() { return null; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/capabilities/DefaultStorageHelper.java b/src/main/java/mekanism/common/capabilities/DefaultStorageHelper.java index 9037a039f..2e62111f8 100644 --- a/src/main/java/mekanism/common/capabilities/DefaultStorageHelper.java +++ b/src/main/java/mekanism/common/capabilities/DefaultStorageHelper.java @@ -26,7 +26,6 @@ public class DefaultStorageHelper { public void readNBT(Capability capability, T instance, EnumFacing side, NBTBase nbt) { if (instance instanceof INBTSerializable) { Class nbtClass = ((INBTSerializable) instance).serializeNBT().getClass(); - if (nbtClass.isInstance(nbt)) { ((INBTSerializable) instance).deserializeNBT(nbtClass.cast(nbt)); } @@ -45,4 +44,4 @@ public class DefaultStorageHelper { public void readNBT(Capability capability, T instance, EnumFacing side, NBTBase nbt) { } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/capabilities/DefaultStrictEnergyAcceptor.java b/src/main/java/mekanism/common/capabilities/DefaultStrictEnergyAcceptor.java index 0c7e24448..dddb4849b 100644 --- a/src/main/java/mekanism/common/capabilities/DefaultStrictEnergyAcceptor.java +++ b/src/main/java/mekanism/common/capabilities/DefaultStrictEnergyAcceptor.java @@ -11,8 +11,7 @@ import net.minecraftforge.common.capabilities.CapabilityManager; public class DefaultStrictEnergyAcceptor implements IStrictEnergyAcceptor { public static void register() { - CapabilityManager.INSTANCE - .register(IStrictEnergyAcceptor.class, new DefaultStorage<>(), DefaultStrictEnergyAcceptor::new); + CapabilityManager.INSTANCE.register(IStrictEnergyAcceptor.class, new DefaultStorage<>(), DefaultStrictEnergyAcceptor::new); } @Override @@ -24,4 +23,4 @@ public class DefaultStrictEnergyAcceptor implements IStrictEnergyAcceptor { public boolean canReceiveEnergy(EnumFacing side) { return true; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/capabilities/DefaultStrictEnergyStorage.java b/src/main/java/mekanism/common/capabilities/DefaultStrictEnergyStorage.java index 6d6148b1b..c08468ada 100644 --- a/src/main/java/mekanism/common/capabilities/DefaultStrictEnergyStorage.java +++ b/src/main/java/mekanism/common/capabilities/DefaultStrictEnergyStorage.java @@ -23,8 +23,7 @@ public class DefaultStrictEnergyStorage implements IStrictEnergyStorage, INBTSer } public static void register() { - CapabilityManager.INSTANCE - .register(IStrictEnergyStorage.class, new DefaultStorage<>(), DefaultStrictEnergyStorage::new); + CapabilityManager.INSTANCE.register(IStrictEnergyStorage.class, new DefaultStorage<>(), DefaultStrictEnergyStorage::new); } @Override @@ -55,4 +54,4 @@ public class DefaultStrictEnergyStorage implements IStrictEnergyStorage, INBTSer setEnergy(nbt.getDouble("energyStored")); maxEnergy = nbt.getDouble("maxEnergy"); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/capabilities/DefaultTileNetwork.java b/src/main/java/mekanism/common/capabilities/DefaultTileNetwork.java index 1d4754b7c..14e154ea2 100644 --- a/src/main/java/mekanism/common/capabilities/DefaultTileNetwork.java +++ b/src/main/java/mekanism/common/capabilities/DefaultTileNetwork.java @@ -1,8 +1,8 @@ package mekanism.common.capabilities; import io.netty.buffer.ByteBuf; -import mekanism.common.base.ITileNetwork; import mekanism.api.TileNetworkList; +import mekanism.common.base.ITileNetwork; import mekanism.common.capabilities.DefaultStorageHelper.NullStorage; import net.minecraftforge.common.capabilities.CapabilityManager; @@ -20,4 +20,4 @@ public class DefaultTileNetwork implements ITileNetwork { public TileNetworkList getNetworkedData(TileNetworkList data) { return data; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/capabilities/DefaultTubeConnection.java b/src/main/java/mekanism/common/capabilities/DefaultTubeConnection.java index f6a743d0e..f662d2aba 100644 --- a/src/main/java/mekanism/common/capabilities/DefaultTubeConnection.java +++ b/src/main/java/mekanism/common/capabilities/DefaultTubeConnection.java @@ -16,4 +16,4 @@ public class DefaultTubeConnection implements ITubeConnection { public boolean canTubeConnect(EnumFacing side) { return false; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/capabilities/IOffsetCapability.java b/src/main/java/mekanism/common/capabilities/IOffsetCapability.java index c885eb487..2cc7e11f1 100644 --- a/src/main/java/mekanism/common/capabilities/IOffsetCapability.java +++ b/src/main/java/mekanism/common/capabilities/IOffsetCapability.java @@ -7,23 +7,22 @@ import net.minecraft.util.math.Vec3i; import net.minecraftforge.common.capabilities.Capability; /** - * Allows for handling capabilities at an offset to the actual implementer. This allows Tile Entities such as the - * Digital Miner to via the advanced bounding blocks be able to return a partial true for hasCapability for a given - * side. Example: Instead of the entire back side having access to the ItemHandler capability, only the eject slot on - * the back has access. + * Allows for handling capabilities at an offset to the actual implementer. This allows Tile Entities such as the Digital Miner to via the advanced bounding blocks be + * able to return a partial true for hasCapability for a given side. Example: Instead of the entire back side having access to the ItemHandler capability, only the eject + * slot on the back has access. */ public interface IOffsetCapability extends IToggleableCapability { /** - * Determines if this object has support for the capability in question on the specific side, with a given offset. - * The return value of this MIGHT change during runtime if this object gains or loses support for a capability. It - * is not required to call this function before calling {@link #getCapability(Capability, EnumFacing)}. + * Determines if this object has support for the capability in question on the specific side, with a given offset. The return value of this MIGHT change during + * runtime if this object gains or loses support for a capability. It is not required to call this function before calling {@link #getCapability(Capability, + * EnumFacing)}. * * @param capability The capability to check - * @param side The Side to check from: CAN BE NULL. Null is defined to represent 'internal' or 'self' - * @param offset An offset position to figure out what block is actually the one that is being checked. - * @return True if this object supports the capability. If true, then {@link #getCapability(Capability, EnumFacing)} - * must not return null. + * @param side The Side to check from: CAN BE NULL. Null is defined to represent 'internal' or 'self' + * @param offset An offset position to figure out what block is actually the one that is being checked. + * + * @return True if this object supports the capability. If true, then {@link #getCapability(Capability, EnumFacing)} must not return null. */ boolean hasOffsetCapability(@Nonnull Capability capability, @Nullable EnumFacing side, @Nonnull Vec3i offset); @@ -37,27 +36,27 @@ public interface IOffsetCapability extends IToggleableCapability { * * * @param capability The capability to check - * @param side The Side to check from, - * CAN BE NULL. Null is defined to represent 'internal' or 'self' - * @param offset An offset position to figure out what block is actually the one that is being checked. - * @return The requested capability. Must NOT be null when {@link #hasCapability(Capability, - * EnumFacing)} would return true. + * @param side The Side to check from, + * CAN BE NULL. Null is defined to represent 'internal' or 'self' + * @param offset An offset position to figure out what block is actually the one that is being checked. + * + * @return The requested capability. Must NOT be null when {@link #hasCapability(Capability, EnumFacing)} would return true. */ @Nullable T getOffsetCapability(@Nonnull Capability capability, @Nullable EnumFacing side, @Nonnull Vec3i offset); /** - * Checks if a given capability is disabled for this provider on the given side and offset. If false is returned it - * makes makes no guarantees that the capability is provided. + * Checks if a given capability is disabled for this provider on the given side and offset. If false is returned it makes makes no guarantees that the capability is + * provided. * * @param capability The capability to check - * @param side The Side to check from: CAN BE NULL. Null is defined to represent 'internal' or 'self' - * @param offset An offset position to figure out what block is actually the one that is being checked. - * @return True if this given capability is disabled for the given side and offset. If true, then {@link - * #hasOffsetCapability(Capability, EnumFacing, Vec3i)} should return false. + * @param side The Side to check from: CAN BE NULL. Null is defined to represent 'internal' or 'self' + * @param offset An offset position to figure out what block is actually the one that is being checked. + * + * @return True if this given capability is disabled for the given side and offset. If true, then {@link #hasOffsetCapability(Capability, EnumFacing, Vec3i)} should + * return false. */ - default boolean isOffsetCapabilityDisabled(@Nonnull Capability capability, @Nullable EnumFacing side, - @Nonnull Vec3i offset) { + default boolean isOffsetCapabilityDisabled(@Nonnull Capability capability, @Nullable EnumFacing side, @Nonnull Vec3i offset) { return false; } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/capabilities/IToggleableCapability.java b/src/main/java/mekanism/common/capabilities/IToggleableCapability.java index 500ea04e1..bae7158ee 100644 --- a/src/main/java/mekanism/common/capabilities/IToggleableCapability.java +++ b/src/main/java/mekanism/common/capabilities/IToggleableCapability.java @@ -7,19 +7,18 @@ import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.ICapabilityProvider; /** - * A capability provider that allows for easier toggling of capabilities in subclasses where everything else may be the - * same but the capability may not always be enabled. + * A capability provider that allows for easier toggling of capabilities in subclasses where everything else may be the same but the capability may not always be + * enabled. */ public interface IToggleableCapability extends ICapabilityProvider { /** - * Checks if a given capability is disabled for this provider on the given side. If false is returned it makes makes - * no guarantees that the capability is provided. + * Checks if a given capability is disabled for this provider on the given side. If false is returned it makes makes no guarantees that the capability is provided. * * @param capability The capability to check - * @param side The Side to check from: CAN BE NULL. Null is defined to represent 'internal' or 'self' - * @return True if this given capability is disabled for the given side. If true, then {@link - * #hasCapability(Capability, EnumFacing)} should return false. + * @param side The Side to check from: CAN BE NULL. Null is defined to represent 'internal' or 'self' + * + * @return True if this given capability is disabled for the given side. If true, then {@link #hasCapability(Capability, EnumFacing)} should return false. */ default boolean isCapabilityDisabled(@Nonnull Capability capability, @Nullable EnumFacing side) { return false; diff --git a/src/main/java/mekanism/common/capabilities/ItemCapabilityWrapper.java b/src/main/java/mekanism/common/capabilities/ItemCapabilityWrapper.java index e98f85654..527da91d7 100644 --- a/src/main/java/mekanism/common/capabilities/ItemCapabilityWrapper.java +++ b/src/main/java/mekanism/common/capabilities/ItemCapabilityWrapper.java @@ -15,7 +15,6 @@ public class ItemCapabilityWrapper implements ICapabilityProvider { public ItemCapabilityWrapper(ItemStack stack, ItemCapability... caps) { itemStack = stack; - for (ItemCapability c : caps) { c.wrapper = this; capabilities.add(c); @@ -29,7 +28,6 @@ public class ItemCapabilityWrapper implements ICapabilityProvider { return true; } } - return false; } @@ -40,7 +38,6 @@ public class ItemCapabilityWrapper implements ICapabilityProvider { return (T) cap; } } - return null; } @@ -54,4 +51,4 @@ public class ItemCapabilityWrapper implements ICapabilityProvider { return wrapper.itemStack; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/chunkloading/ChunkManager.java b/src/main/java/mekanism/common/chunkloading/ChunkManager.java index 24154f15f..535780e00 100644 --- a/src/main/java/mekanism/common/chunkloading/ChunkManager.java +++ b/src/main/java/mekanism/common/chunkloading/ChunkManager.java @@ -2,6 +2,7 @@ package mekanism.common.chunkloading; import com.google.common.collect.ListMultimap; import java.util.List; +import mekanism.common.tile.component.TileComponentChunkLoader; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -17,12 +18,11 @@ public class ChunkManager implements LoadingCallback, PlayerOrderedLoadingCallba int x = ticket.getModData().getInteger("x"); int y = ticket.getModData().getInteger("y"); int z = ticket.getModData().getInteger("z"); - TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z)); - if (tileEntity instanceof IChunkLoader) { - ((IChunkLoader) tileEntity).getChunkLoader().refreshChunkSet(); - ((IChunkLoader) tileEntity).getChunkLoader().forceChunks(ticket); + TileComponentChunkLoader chunkLoader = ((IChunkLoader) tileEntity).getChunkLoader(); + chunkLoader.refreshChunkSet(); + chunkLoader.forceChunks(ticket); } } } @@ -31,4 +31,4 @@ public class ChunkManager implements LoadingCallback, PlayerOrderedLoadingCallba public ListMultimap playerTicketsLoaded(ListMultimap tickets, World world) { return tickets; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/chunkloading/IChunkLoader.java b/src/main/java/mekanism/common/chunkloading/IChunkLoader.java index 977bb2a40..3a734395a 100644 --- a/src/main/java/mekanism/common/chunkloading/IChunkLoader.java +++ b/src/main/java/mekanism/common/chunkloading/IChunkLoader.java @@ -9,4 +9,4 @@ public interface IChunkLoader { TileComponentChunkLoader getChunkLoader(); Set getChunkSet(); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/command/CommandChunk.java b/src/main/java/mekanism/common/command/CommandChunk.java index 2f731fe2d..7f49f7eaf 100644 --- a/src/main/java/mekanism/common/command/CommandChunk.java +++ b/src/main/java/mekanism/common/command/CommandChunk.java @@ -2,9 +2,9 @@ package mekanism.common.command; import java.util.HashSet; import java.util.Set; +import javax.annotation.Nonnull; import mekanism.common.command.CommandMek.Cmd; import net.minecraft.command.CommandBase; -import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; import net.minecraft.server.MinecraftServer; import net.minecraft.util.math.ChunkPos; @@ -24,17 +24,18 @@ public class CommandChunk extends CommandTreeBase { addSubcommand(new Cmd("unwatch", "cmd.mek.chunk.unwatch", this::removeWatcher)); addSubcommand(new Cmd("clear", "cmd.mek.chunk.clear", this::clearWatchers)); addSubcommand(new Cmd("flush", "cmd.mek.chunk.flush", this::flushChunks)); - MinecraftForge.EVENT_BUS.register(this); } + @Nonnull @Override public String getName() { return "chunk"; } + @Nonnull @Override - public String getUsage(ICommandSender sender) { + public String getUsage(@Nonnull ICommandSender sender) { return "cmd.mek.chunk.usage"; } @@ -52,42 +53,43 @@ public class CommandChunk extends CommandTreeBase { if (event.getWorld().isRemote) { return; } - ChunkPos pos = event.getChunk().getPos(); long key = ChunkPos.asLong(pos.x, pos.z); if (chunkWatchers.contains(key)) { String msg = String.format("%s chunk %d, %d", direction, pos.x, pos.z); - event.getWorld().getMinecraftServer().getPlayerList().sendMessage(new TextComponentString(msg)); + MinecraftServer server = event.getWorld().getMinecraftServer(); + if (server != null) { + server.getPlayerList().sendMessage(new TextComponentString(msg)); + } } } - public void addWatcher(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { + public void addWatcher(MinecraftServer server, ICommandSender sender, String[] args) { ChunkPos cpos = new ChunkPos(sender.getPosition()); chunkWatchers.add(ChunkPos.asLong(cpos.x, cpos.z)); CommandBase.notifyCommandListener(sender, this, "cmd.mek.chunk.watch", cpos.x, cpos.z); } - public void removeWatcher(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { + public void removeWatcher(MinecraftServer server, ICommandSender sender, String[] args) { ChunkPos cpos = new ChunkPos(sender.getPosition()); chunkWatchers.remove(ChunkPos.asLong(cpos.x, cpos.z)); CommandBase.notifyCommandListener(sender, this, "cmd.mek.chunk.unwatch", cpos.x, cpos.z); } - public void clearWatchers(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { + public void clearWatchers(MinecraftServer server, ICommandSender sender, String[] args) { int count = chunkWatchers.size(); chunkWatchers.clear(); CommandBase.notifyCommandListener(sender, this, "cmd.mek.chunk.clear", count); } - public void flushChunks(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { + public void flushChunks(MinecraftServer server, ICommandSender sender, String[] args) { if (sender.getEntityWorld().isRemote) { return; } - - ChunkProviderServer sp = (ChunkProviderServer)sender.getEntityWorld().getChunkProvider(); + ChunkProviderServer sp = (ChunkProviderServer) sender.getEntityWorld().getChunkProvider(); int startCount = sp.getLoadedChunkCount(); sp.queueUnloadAll(); sp.tick(); notifyCommandListener(sender, this, "cmd.mek.chunk.flush", startCount - sp.getLoadedChunkCount()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/command/CommandMek.java b/src/main/java/mekanism/common/command/CommandMek.java index df473a84c..1a6d3585f 100644 --- a/src/main/java/mekanism/common/command/CommandMek.java +++ b/src/main/java/mekanism/common/command/CommandMek.java @@ -5,6 +5,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Stack; import java.util.UUID; +import javax.annotation.Nonnull; import mekanism.api.MekanismAPI; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.command.CommandBase; @@ -38,23 +39,25 @@ public class CommandMek extends CommandTreeBase { event.registerServerCommand(new Cmd("mtpop", "cmd.mek.tpop", cmd::teleportPop)); } + @Nonnull @Override public String getName() { return "mek"; } + @Nonnull @Override - public String getUsage(ICommandSender sender) { + public String getUsage(@Nonnull ICommandSender sender) { return "cmd.mek.usage"; } - public void toggleDebug(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { + public void toggleDebug(MinecraftServer server, ICommandSender sender, String[] args) { MekanismAPI.debug = !MekanismAPI.debug; CommandBase.notifyCommandListener(sender, this, "cmd.mek.debug", MekanismAPI.debug); } - public void setupTestRules(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { + public void setupTestRules(MinecraftServer server, ICommandSender sender, String[] args) { GameRules rules = server.getEntityWorld().getGameRules(); rules.setOrCreateGameRule("doMobSpawning", "false"); rules.setOrCreateGameRule("doDaylightCycle", "false"); @@ -77,7 +80,7 @@ public class CommandMek extends CommandTreeBase { // Save the current location on the stack UUID player = sender.getCommandSenderEntity().getUniqueID(); - Stack playerLocations = tpStack.getOrDefault(player, new Stack()); + Stack playerLocations = tpStack.getOrDefault(player, new Stack<>()); playerLocations.push(sender.getPosition()); tpStack.put(player, playerLocations); @@ -86,18 +89,17 @@ public class CommandMek extends CommandTreeBase { notifyCommandListener(sender, this, "cmd.mek.tp", args[0], args[1], args[2]); } - public void teleportPop(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { + public void teleportPop(MinecraftServer server, ICommandSender sender, String[] args) { UUID player = sender.getCommandSenderEntity().getUniqueID(); // Get stack of locations for the user; if there's at least one entry, pop it off // and send the user back there - Stack playerLocations = tpStack.getOrDefault(player, new Stack()); + Stack playerLocations = tpStack.getOrDefault(player, new Stack<>()); if (!playerLocations.isEmpty()) { BlockPos lastPos = playerLocations.pop(); tpStack.put(player, playerLocations); teleport(sender.getCommandSenderEntity(), lastPos.getX(), lastPos.getY(), lastPos.getZ()); - notifyCommandListener(sender, this, "cmd.mek.tpop", - lastPos.getX(), lastPos.getY(), lastPos.getZ(), playerLocations.size()); + notifyCommandListener(sender, this, "cmd.mek.tpop", lastPos.getX(), lastPos.getY(), lastPos.getZ(), playerLocations.size()); } else { notifyCommandListener(sender, this, "cmd.mek.tpop.empty.stack"); } @@ -105,10 +107,10 @@ public class CommandMek extends CommandTreeBase { private void teleport(Entity player, double x, double y, double z) { if (player instanceof EntityPlayerMP) { - EntityPlayerMP mp = (EntityPlayerMP)player; + EntityPlayerMP mp = (EntityPlayerMP) player; mp.connection.setPlayerLocation(x, y, z, mp.rotationYaw, mp.rotationPitch); } else { - EntityPlayerSP sp = (EntityPlayerSP)player; + EntityPlayerSP sp = (EntityPlayerSP) player; sp.setLocationAndAngles(x, y, z, sp.rotationYaw, sp.rotationPitch); } } @@ -126,23 +128,26 @@ public class CommandMek extends CommandTreeBase { this.ex = ex; } + @Nonnull @Override public String getName() { return name; } + @Nonnull @Override - public String getUsage(ICommandSender sender) { + public String getUsage(@Nonnull ICommandSender sender) { return usage + ".usage"; } @Override - public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { + public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, @Nonnull String[] args) throws CommandException { ex.execute(server, sender, args); } } interface CmdExecute { + void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/config/ClientConfig.java b/src/main/java/mekanism/common/config/ClientConfig.java index 64f7a2727..baa2663d5 100644 --- a/src/main/java/mekanism/common/config/ClientConfig.java +++ b/src/main/java/mekanism/common/config/ClientConfig.java @@ -34,16 +34,14 @@ public class ClientConfig extends BaseConfig { public final BooleanOption opaqueTransmitters = new BooleanOption(this, "client", "OpaqueTransmitterRender", false, "If true, don't render Cables/Pipes/Tubes as transparent and don't render their contents."); - public final BooleanOption allowConfiguratorModeScroll = new BooleanOption(this, "client", "ConfiguratorModeScroll", - true, "Allow sneak+scroll to change Configurator modes."); + public final BooleanOption allowConfiguratorModeScroll = new BooleanOption(this, "client", "ConfiguratorModeScroll", true, + "Allow sneak+scroll to change Configurator modes."); - public final BooleanOption enableMultiblockFormationParticles = new BooleanOption(this, "client", - "MultiblockFormParticles", - true, + public final BooleanOption enableMultiblockFormationParticles = new BooleanOption(this, "client", "MultiblockFormParticles", true, "Set to false to prevent particle spam when loading multiblocks (notification message will display instead)."); - public final BooleanOption alignHUDLeft = new BooleanOption(this, "client", "AlignHUDLeft", - true, "Align HUD with left (if true) or right (if false)"); + public final BooleanOption alignHUDLeft = new BooleanOption(this, "client", "AlignHUDLeft", true, + "Align HUD with left (if true) or right (if false)"); @Override public void write(ByteBuf config) { diff --git a/src/main/java/mekanism/common/config/GeneralConfig.java b/src/main/java/mekanism/common/config/GeneralConfig.java index 0feeb03a4..97137d1e5 100644 --- a/src/main/java/mekanism/common/config/GeneralConfig.java +++ b/src/main/java/mekanism/common/config/GeneralConfig.java @@ -24,14 +24,14 @@ public class GeneralConfig extends BaseConfig { public final BooleanOption dynamicTankEasterEgg = new BooleanOption(this, "general", "DynamicTankEasterEgg", false, "Audible sparkles."); - public final BooleanOption voiceServerEnabled = new BooleanOption(this, "general", "WalkieTalkieServerEnabled", - false, "Enables the voice server for Walkie Talkies."); + public final BooleanOption voiceServerEnabled = new BooleanOption(this, "general", "WalkieTalkieServerEnabled", false, + "Enables the voice server for Walkie Talkies."); public final BooleanOption cardboardSpawners = new BooleanOption(this, "general", "AllowSpawnerBoxPickup", true, "Allows vanilla spawners to be moved with a Cardboard Box."); - public final BooleanOption enableWorldRegeneration = new BooleanOption(this, "general", "EnableWorldRegeneration", - false, "Allows chunks to retrogen Mekanism ore blocks."); + public final BooleanOption enableWorldRegeneration = new BooleanOption(this, "general", "EnableWorldRegeneration", false, + "Allows chunks to retrogen Mekanism ore blocks."); public final BooleanOption spawnBabySkeletons = new BooleanOption(this, "general", "SpawnBabySkeletons", true, "Enable the spawning of baby skeletons. Think baby zombies but skeletons."); @@ -113,8 +113,7 @@ public class GeneralConfig extends BaseConfig { //If this is less than 1, upgrades make machines worse. If less than 0, I don't even know. public final IntOption maxUpgradeMultiplier = new IntOption(this, "general", "UpgradeModifier", 10, - "Base factor for working out machine performance with upgrades - UpgradeModifier * (UpgradesInstalled/UpgradesPossible).", - 1, Integer.MAX_VALUE); + "Base factor for working out machine performance with upgrades - UpgradeModifier * (UpgradesInstalled/UpgradesPossible).", 1, Integer.MAX_VALUE); public final IntOption minerSilkMultiplier = new IntOption(this, "general", "MinerSilkMultiplier", 6, "Energy multiplier for using silk touch mode with the Digital Miner."); @@ -122,8 +121,8 @@ public class GeneralConfig extends BaseConfig { public final BooleanOption prefilledGasTanks = new BooleanOption(this, "general", "PrefilledGasTanks", true, "Add filled creative gas tanks to creative/JEI."); - public final DoubleOption armoredJetpackDamageRatio = new DoubleOption(this, "general", "ArmoredJetpackDamageRatio", - 0.8, "Damage absorb ratio of the Armored Jetpack."); + public final DoubleOption armoredJetpackDamageRatio = new DoubleOption(this, "general", "ArmoredJetpackDamageRatio", 0.8, + "Damage absorb ratio of the Armored Jetpack."); public final IntOption armoredJetpackDamageMax = new IntOption(this, "general", "ArmoredJepackDamageMax", 115, "Max damage the Armored Jetpack can absorb."); @@ -131,8 +130,8 @@ public class GeneralConfig extends BaseConfig { public final BooleanOption aestheticWorldDamage = new BooleanOption(this, "general", "AestheticWorldDamage", true, "If enabled, lasers can break blocks and the flamethrower starts fires."); - public final BooleanOption opsBypassRestrictions = new BooleanOption(this, "general", "OpsBypassRestrictions", - false, "Ops can bypass the block security restrictions if enabled."); + public final BooleanOption opsBypassRestrictions = new BooleanOption(this, "general", "OpsBypassRestrictions", false, + "Ops can bypass the block security restrictions if enabled."); public final IntOption maxJetpackGas = new IntOption(this, "general", "MaxJetpackGas", 24000, "Jetpack Gas Tank capacity in mB."); @@ -152,14 +151,14 @@ public class GeneralConfig extends BaseConfig { public final IntOption maxPlenisherNodes = new IntOption(this, "general", "MaxPlenisherNodes", 4000, "Fluidic Plenisher stops after this many blocks."); - public final DoubleOption evaporationHeatDissipation = new DoubleOption(this, "general", - "EvaporationHeatDissipation", 0.02D, "Thermal Evaporation Tower heat loss per tick."); + public final DoubleOption evaporationHeatDissipation = new DoubleOption(this, "general", "EvaporationHeatDissipation", 0.02D, + "Thermal Evaporation Tower heat loss per tick."); - public final DoubleOption evaporationTempMultiplier = new DoubleOption(this, "general", "EvaporationTempMultiplier", - 0.1D, "Temperature to amount produced ratio for Thermal Evaporation Tower."); + public final DoubleOption evaporationTempMultiplier = new DoubleOption(this, "general", "EvaporationTempMultiplier", 0.1D, + "Temperature to amount produced ratio for Thermal Evaporation Tower."); - public final DoubleOption evaporationSolarMultiplier = new DoubleOption(this, "general", - "EvaporationSolarMultiplier", 0.2D, "Heat to absorb per Solar Panel array of Thermal Evaporation Tower."); + public final DoubleOption evaporationSolarMultiplier = new DoubleOption(this, "general", "EvaporationSolarMultiplier", 0.2D, + "Heat to absorb per Solar Panel array of Thermal Evaporation Tower."); public final DoubleOption evaporationMaxTemp = new DoubleOption(this, "general", "EvaporationMaxTemp", 3000D, "Max Temperature of the Thermal Evaporation Tower."); @@ -170,14 +169,13 @@ public class GeneralConfig extends BaseConfig { public final DoubleOption maxEnergyPerSteam = new DoubleOption(this, "general", "MaxEnergyPerSteam", 100D, "Maximum Joules per mB of Steam. Also affects Thermoelectric Boiler."); - public final DoubleOption superheatingHeatTransfer = new DoubleOption(this, "general", "SuperheatingHeatTransfer", - 10000D, "Amount of heat each Boiler heating element produces."); + public final DoubleOption superheatingHeatTransfer = new DoubleOption(this, "general", "SuperheatingHeatTransfer", 10000D, + "Amount of heat each Boiler heating element produces."); public final DoubleOption heatPerFuelTick = new DoubleOption(this, "general", "HeatPerFuelTick", 4D, "Amount of heat produced per fuel tick of a fuel's burn time in the Fuelwood Heater."); - public final BooleanOption allowTransmitterAlloyUpgrade = new BooleanOption(this, "general", - "AllowTransmitterAlloyUpgrade", true, + public final BooleanOption allowTransmitterAlloyUpgrade = new BooleanOption(this, "general", "AllowTransmitterAlloyUpgrade", true, "Allow right clicking on Cables/Pipes/Tubes with alloys to upgrade the tier."); public final BooleanOption allowChunkloading = new BooleanOption(this, "general", "AllowChunkloading", true, @@ -189,8 +187,8 @@ public class GeneralConfig extends BaseConfig { public final IntOption portableTeleporterDelay = new IntOption(this, "general", "PortableTeleporterDelay", 0, "Delay in ticks before a player is teleported after clicking the Teleport button in the portable teleporter."); - public final DoubleOption quantumEntangloporterEnergyTransfer = new DoubleOption(this, "general", - "QuantumEntangloporterEnergyTransfer", 16000000D, "Maximum buffer of an Entangoloporter frequency."); + public final DoubleOption quantumEntangloporterEnergyTransfer = new DoubleOption(this, "general", "QuantumEntangloporterEnergyTransfer", 16000000D, + "Maximum buffer of an Entangoloporter frequency."); public final BooleanOption blacklistIC2 = new BooleanOption(this, "general", "BlacklistIC2Power", false, "Disables IC2 power integration. Requires world restart (server-side option in SMP)."); @@ -204,11 +202,11 @@ public class GeneralConfig extends BaseConfig { public final BooleanOption blacklistForge = new BooleanOption(this, "general", "BlacklistForgePower", false, "Disables Forge Energy (FE,IF,uF,CF) power integration. Requires world restart (server-side option in SMP)."); - public EnumOption energyUnit = new EnumOption<>(this, "general", "EnergyType", - EnergyType.RF, "Displayed energy type in Mekanism GUIs."); + public EnumOption energyUnit = new EnumOption<>(this, "general", "EnergyType", EnergyType.RF, + "Displayed energy type in Mekanism GUIs."); - public EnumOption tempUnit = new EnumOption<>(this, "general", "Temperature Units", - TempType.K, "Displayed temperature unit in Mekanism GUIs."); + public EnumOption tempUnit = new EnumOption<>(this, "general", "Temperature Units", TempType.K, + "Displayed temperature unit in Mekanism GUIs."); public final IntOption laserRange = new IntOption(this, "general", "LaserRange", 64, "How far (in blocks) a laser can travel."); @@ -220,20 +218,16 @@ public class GeneralConfig extends BaseConfig { "If machine is disabled in config, do we set its block to air if it is found in world?"); public final IntOption digitalMinerMaxRadius = new IntOption(this, "general", "digitalMinerMaxRadius", 32, - "Maximum radius in blocks that the Digital Miner can reach. " - + "(Increasing this may have negative effects on stability and/or performance. " - + "We strongly recommend you leave it at the default value.)", 1, Integer.MAX_VALUE); + "Maximum radius in blocks that the Digital Miner can reach. (Increasing this may have negative effects on stability and/or performance. " + + "We strongly recommend you leave it at the default value.)", 1, Integer.MAX_VALUE); public final DoubleOption sawdustChancePlank = new DoubleOption(this, "general", "SawdustChancePlank", 0.25D, - "Chance of producing sawdust per operation in the precision sawmill when turning planks into sticks.") - .setRequiresGameRestart(true); + "Chance of producing sawdust per operation in the precision sawmill when turning planks into sticks.").setRequiresGameRestart(true); public final DoubleOption sawdustChanceLog = new DoubleOption(this, "general", "SawdustChanceLog", 1D, - "Chance of producing sawdust per operation in the precision sawmill when turning logs into planks.") - .setRequiresGameRestart(true); + "Chance of producing sawdust per operation in the precision sawmill when turning logs into planks.").setRequiresGameRestart(true); - public final TypeConfigManager machinesManager = new TypeConfigManager<>(this, - "machines", MachineType.class, MachineType::getValidMachines, t -> t.blockName); + public final TypeConfigManager machinesManager = new TypeConfigManager<>(this, "machines", MachineType.class, MachineType::getValidMachines, t -> t.blockName); public final EnumMap tiers = TierConfig.create(this); } \ No newline at end of file diff --git a/src/main/java/mekanism/common/config/GeneratorsConfig.java b/src/main/java/mekanism/common/config/GeneratorsConfig.java index 1ff43c339..b0149772a 100644 --- a/src/main/java/mekanism/common/config/GeneratorsConfig.java +++ b/src/main/java/mekanism/common/config/GeneratorsConfig.java @@ -12,8 +12,7 @@ import net.minecraftforge.common.config.Configuration; */ public class GeneratorsConfig extends BaseConfig { - public final DoubleOption advancedSolarGeneration = new DoubleOption(this, "generation", "AdvancedSolarGeneration", - 300D, + public final DoubleOption advancedSolarGeneration = new DoubleOption(this, "generation", "AdvancedSolarGeneration", 300D, "Peak output for the Advanced Solar Generator. Note: It can go higher than this value in some extreme environments."); public final DoubleOption bioGeneration = new DoubleOption(this, "generation", "BioGeneration", 350D, @@ -37,8 +36,8 @@ public class GeneratorsConfig extends BaseConfig { public final DoubleOption turbineVentGasFlow = new DoubleOption(this, "generation", "TurbineVentGasFlow", 16000D, "The rate at which steam is vented into the turbine."); - public final DoubleOption turbineDisperserGasFlow = new DoubleOption(this, "generation", "TurbineDisperserGasFlow", - 640D, "The rate at which steam is dispersed into the turbine."); + public final DoubleOption turbineDisperserGasFlow = new DoubleOption(this, "generation", "TurbineDisperserGasFlow", 640D, + "The rate at which steam is dispersed into the turbine."); public final IntOption condenserRate = new IntOption(this, "generation", "TurbineCondenserFlowRate", 32000, "The rate at which steam is condensed in the turbine."); @@ -58,12 +57,10 @@ public class GeneratorsConfig extends BaseConfig { public final IntOption windGenerationMaxY = new IntOption(this, "generation", "WindGenerationMaxY", 255, "The maximum Y value that affects the Wind Generators Power generation."); - public final IntSetOption windGenerationDimBlacklist = new IntSetOption(this, "generation", - "WindGenerationDimBlacklist", new int[0], + public final IntSetOption windGenerationDimBlacklist = new IntSetOption(this, "generation", "WindGenerationDimBlacklist", new int[0], "The list of dimension ids that the Wind Generator will not generate power in."); - public TypeConfigManager generatorsManager = new TypeConfigManager<>(this, - "generators", BlockStateGenerator.GeneratorType.class, + public TypeConfigManager generatorsManager = new TypeConfigManager<>(this, "generators", BlockStateGenerator.GeneratorType.class, BlockStateGenerator.GeneratorType::getGeneratorsForConfig, t -> t.blockName); @Override diff --git a/src/main/java/mekanism/common/config/StorageConfig.java b/src/main/java/mekanism/common/config/StorageConfig.java index c27002923..bab1095fd 100644 --- a/src/main/java/mekanism/common/config/StorageConfig.java +++ b/src/main/java/mekanism/common/config/StorageConfig.java @@ -4,79 +4,78 @@ import mekanism.common.config.options.DoubleOption; public class StorageConfig extends BaseConfig { - public final DoubleOption enrichmentChamber = new DoubleOption(this, "storage", - "EnrichmentChamberStorage", 20000D, "Base energy storage (Joules)."); + public final DoubleOption enrichmentChamber = new DoubleOption(this, "storage", "EnrichmentChamberStorage", 20000D, + "Base energy storage (Joules)."); - public final DoubleOption osmiumCompressor = new DoubleOption(this, "storage", - "OsmiumCompressorStorage", 80000D, "Base energy storage (Joules)."); + public final DoubleOption osmiumCompressor = new DoubleOption(this, "storage", "OsmiumCompressorStorage", 80000D, + "Base energy storage (Joules)."); - public final DoubleOption combiner = new DoubleOption(this, "storage", - "CombinerStorage", 40000D, "Base energy storage (Joules)."); + public final DoubleOption combiner = new DoubleOption(this, "storage", "CombinerStorage", 40000D, + "Base energy storage (Joules)."); - public final DoubleOption crusher = new DoubleOption(this, "storage", - "CrusherStorage", 20000D, "Base energy storage (Joules)."); + public final DoubleOption crusher = new DoubleOption(this, "storage", "CrusherStorage", 20000D, + "Base energy storage (Joules)."); - public final DoubleOption metallurgicInfuser = new DoubleOption(this, "storage", - "MetallurgicInfuserStorage", 20000D, "Base energy storage (Joules)."); + public final DoubleOption metallurgicInfuser = new DoubleOption(this, "storage", "MetallurgicInfuserStorage", 20000D, + "Base energy storage (Joules)."); - public final DoubleOption purificationChamber = new DoubleOption(this, "storage", - "PurificationChamberStorage", 80000D, "Base energy storage (Joules)."); + public final DoubleOption purificationChamber = new DoubleOption(this, "storage", "PurificationChamberStorage", 80000D, + "Base energy storage (Joules)."); - public final DoubleOption energizedSmelter = new DoubleOption(this, "storage", - "EnergizedSmelterStorage", 20000D, "Base energy storage (Joules)."); + public final DoubleOption energizedSmelter = new DoubleOption(this, "storage", "EnergizedSmelterStorage", 20000D, + "Base energy storage (Joules)."); - public final DoubleOption digitalMiner = new DoubleOption(this, "storage", - "DigitalMinerStorage", 40000D, "Base energy storage (Joules)."); + public final DoubleOption digitalMiner = new DoubleOption(this, "storage", "DigitalMinerStorage", 40000D, + "Base energy storage (Joules)."); - public final DoubleOption electricPump = new DoubleOption(this, "storage", - "ElectricPumpStorage", 40000D, "Base energy storage (Joules)."); + public final DoubleOption electricPump = new DoubleOption(this, "storage", "ElectricPumpStorage", 40000D, + "Base energy storage (Joules)."); - public final DoubleOption chargePad = new DoubleOption(this, "storage", - "ChargePadStorage", 40000D, "Base energy storage (Joules)."); + public final DoubleOption chargePad = new DoubleOption(this, "storage", "ChargePadStorage", 40000D, + "Base energy storage (Joules)."); - public final DoubleOption rotaryCondensentrator = new DoubleOption(this, "storage", - "RotaryCondensentratorStorage", 20000D, "Base energy storage (Joules)."); + public final DoubleOption rotaryCondensentrator = new DoubleOption(this, "storage", "RotaryCondensentratorStorage", 20000D, + "Base energy storage (Joules)."); - public final DoubleOption oxidationChamber = new DoubleOption(this, "storage", - "OxidationChamberStorage", 80000D, "Base energy storage (Joules)."); + public final DoubleOption oxidationChamber = new DoubleOption(this, "storage", "OxidationChamberStorage", 80000D, + "Base energy storage (Joules)."); - public final DoubleOption chemicalInfuser = new DoubleOption(this, "storage", - "ChemicalInfuserStorage", 80000D, "Base energy storage (Joules)."); + public final DoubleOption chemicalInfuser = new DoubleOption(this, "storage", "ChemicalInfuserStorage", 80000D, + "Base energy storage (Joules)."); - public final DoubleOption chemicalInjectionChamber = new DoubleOption(this, "storage", - "ChemicalInjectionChamberStorage", 160000D, "Base energy storage (Joules)."); + public final DoubleOption chemicalInjectionChamber = new DoubleOption(this, "storage", "ChemicalInjectionChamberStorage", 160000D, + "Base energy storage (Joules)."); - public final DoubleOption electrolyticSeparator = new DoubleOption(this, "storage", - "ElectrolyticSeparatorStorage", 160000D, "Base energy storage (Joules)."); + public final DoubleOption electrolyticSeparator = new DoubleOption(this, "storage", "ElectrolyticSeparatorStorage", 160000D, + "Base energy storage (Joules)."); - public final DoubleOption precisionSawmill = new DoubleOption(this, "storage", - "PrecisionSawmillStorage", 20000D, "Base energy storage (Joules)."); + public final DoubleOption precisionSawmill = new DoubleOption(this, "storage", "PrecisionSawmillStorage", 20000D, + "Base energy storage (Joules)."); - public final DoubleOption chemicalDissolutionChamber = new DoubleOption(this, "storage", - "ChemicalDissolutionChamberStorage", 160000D, "Base energy storage (Joules)."); + public final DoubleOption chemicalDissolutionChamber = new DoubleOption(this, "storage", "ChemicalDissolutionChamberStorage", 160000D, + "Base energy storage (Joules)."); - public final DoubleOption chemicalWasher = new DoubleOption(this, "storage", - "ChemicalWasherStorage", 80000D, "Base energy storage (Joules)."); + public final DoubleOption chemicalWasher = new DoubleOption(this, "storage", "ChemicalWasherStorage", 80000D, + "Base energy storage (Joules)."); - public final DoubleOption chemicalCrystallizer = new DoubleOption(this, "storage", - "ChemicalCrystallizerStorage", 160000D, "Base energy storage (Joules)."); + public final DoubleOption chemicalCrystallizer = new DoubleOption(this, "storage", "ChemicalCrystallizerStorage", 160000D, + "Base energy storage (Joules)."); - public final DoubleOption seismicVibrator = new DoubleOption(this, "storage", - "SeismicVibratorStorage", 20000D, "Base energy storage (Joules)."); + public final DoubleOption seismicVibrator = new DoubleOption(this, "storage", "SeismicVibratorStorage", 20000D, + "Base energy storage (Joules)."); - public final DoubleOption pressurizedReactionBase = new DoubleOption(this, "storage", - "PressurizedReactionBaseStorage", 2000D, "Base energy storage (Joules)."); + public final DoubleOption pressurizedReactionBase = new DoubleOption(this, "storage", "PressurizedReactionBaseStorage", 2000D, + "Base energy storage (Joules)."); - public final DoubleOption fluidicPlenisher = new DoubleOption(this, "storage", - "FluidicPlenisherStorage", 40000D, "Base energy storage (Joules)."); + public final DoubleOption fluidicPlenisher = new DoubleOption(this, "storage", "FluidicPlenisherStorage", 40000D, + "Base energy storage (Joules)."); - public final DoubleOption laser = new DoubleOption(this, "storage", - "LaserStorage", 2000000D, "Base energy storage (Joules)."); + public final DoubleOption laser = new DoubleOption(this, "storage", "LaserStorage", 2000000D, + "Base energy storage (Joules)."); - public final DoubleOption formulaicAssemblicator = new DoubleOption(this, "storage", - "FormulaicAssemblicatorStorage", 40000D, "Base energy storage (Joules)."); + public final DoubleOption formulaicAssemblicator = new DoubleOption(this, "storage", "FormulaicAssemblicatorStorage", 40000D, + "Base energy storage (Joules)."); - public final DoubleOption teleporter = new DoubleOption(this, "storage", - "TeleporterStorage", 5000000D, "Base energy storage (Joules)."); - -} + public final DoubleOption teleporter = new DoubleOption(this, "storage", "TeleporterStorage", 5000000D, + "Base energy storage (Joules)."); +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/config/TierConfig.java b/src/main/java/mekanism/common/config/TierConfig.java index 719086a87..2538dbfdc 100644 --- a/src/main/java/mekanism/common/config/TierConfig.java +++ b/src/main/java/mekanism/common/config/TierConfig.java @@ -23,11 +23,9 @@ public class TierConfig { public static EnumMap create(BaseConfig baseConfig) { EnumMap map = new EnumMap<>(BaseTier.class); - for (BaseTier baseTier : BaseTier.values()) { map.put(baseTier, new TierConfig(baseConfig, baseTier)); } - return map; } @@ -53,66 +51,45 @@ public class TierConfig { private TierConfig(BaseConfig baseConfig, BaseTier tier) { String name = tier.getSimpleName(); - EnergyCubeMaxEnergy = new DoubleOption(baseConfig, "tier", name + "EnergyCubeMaxEnergy", - EnergyCubeTier.values()[tier.ordinal()].getBaseMaxEnergy(), + EnergyCubeMaxEnergy = new DoubleOption(baseConfig, "tier", name + "EnergyCubeMaxEnergy", EnergyCubeTier.values()[tier.ordinal()].getBaseMaxEnergy(), "Maximum number of Joules a " + name + " energy cube can store."); - EnergyCubeOutput = new DoubleOption(baseConfig, "tier", name + "EnergyCubeOutput", - EnergyCubeTier.values()[tier.ordinal()].getBaseOutput(), + EnergyCubeOutput = new DoubleOption(baseConfig, "tier", name + "EnergyCubeOutput", EnergyCubeTier.values()[tier.ordinal()].getBaseOutput(), "Output rate in Joules of a " + name + " energy cube."); - FluidTankStorage = new IntOption(baseConfig, "tier", name + "FluidTankStorage", - FluidTankTier.values()[tier.ordinal()].getBaseStorage(), + FluidTankStorage = new IntOption(baseConfig, "tier", name + "FluidTankStorage", FluidTankTier.values()[tier.ordinal()].getBaseStorage(), "Storage size of " + name + " gas tank in mB."); - FluidTankOutput = new IntOption(baseConfig, "tier", name + "FluidTankOutput", - FluidTankTier.values()[tier.ordinal()].getBaseOutput(), + FluidTankOutput = new IntOption(baseConfig, "tier", name + "FluidTankOutput", FluidTankTier.values()[tier.ordinal()].getBaseOutput(), "Output rate of " + name + " gas tank in mB."); - GasTankStorage = new IntOption(baseConfig, "tier", name + "GasTankStorage", - GasTankTier.values()[tier.ordinal()].getBaseStorage(), + GasTankStorage = new IntOption(baseConfig, "tier", name + "GasTankStorage", GasTankTier.values()[tier.ordinal()].getBaseStorage(), "Storage size of " + name + " gas tank in mB."); - GasTankOutput = new IntOption(baseConfig, "tier", name + "GasTankOutput", - GasTankTier.values()[tier.ordinal()].getBaseOutput(), "Output rate of " + name + " gas tank in mB."); - BinStorage = new IntOption(baseConfig, "tier", name + "BinStorage", - BinTier.values()[tier.ordinal()].getBaseStorage(), + GasTankOutput = new IntOption(baseConfig, "tier", name + "GasTankOutput", GasTankTier.values()[tier.ordinal()].getBaseOutput(), + "Output rate of " + name + " gas tank in mB."); + BinStorage = new IntOption(baseConfig, "tier", name + "BinStorage", BinTier.values()[tier.ordinal()].getBaseStorage(), "The number of items a " + name + " bin can store."); if (tier != BaseTier.CREATIVE) { - InductionCellMaxEnergy = new DoubleOption(baseConfig, "tier", name + "InductionCellMaxEnergy", - InductionCellTier.values()[tier.ordinal()].getBaseMaxEnergy(), + InductionCellMaxEnergy = new DoubleOption(baseConfig, "tier", name + "InductionCellMaxEnergy", InductionCellTier.values()[tier.ordinal()].getBaseMaxEnergy(), "Maximum number of Joules a " + name + " induction cell can store."); - InductionProviderOutput = new DoubleOption(baseConfig, "tier", name + "InductionProviderOutput", - InductionProviderTier.values()[tier.ordinal()].getBaseOutput(), + InductionProviderOutput = new DoubleOption(baseConfig, "tier", name + "InductionProviderOutput", InductionProviderTier.values()[tier.ordinal()].getBaseOutput(), "Maximum number of Joules a " + name + " induction provider can output or accept."); - CableCapacity = new IntOption(baseConfig, "tier", name + "CableCapacity", - CableTier.values()[tier.ordinal()].getBaseCapacity(), + CableCapacity = new IntOption(baseConfig, "tier", name + "CableCapacity", CableTier.values()[tier.ordinal()].getBaseCapacity(), "Internal buffer in Joules of each " + name + " universal cable."); - PipeCapacity = new IntOption(baseConfig, "tier", name + "PipeCapacity", - PipeTier.values()[tier.ordinal()].getBaseCapacity(), + PipeCapacity = new IntOption(baseConfig, "tier", name + "PipeCapacity", PipeTier.values()[tier.ordinal()].getBaseCapacity(), "Capacity of " + name + " mechanical pipe in mB."); - PipePullAmount = new IntOption(baseConfig, "tier", name + "PipePullAmount", - PipeTier.values()[tier.ordinal()].getBasePull(), + PipePullAmount = new IntOption(baseConfig, "tier", name + "PipePullAmount", PipeTier.values()[tier.ordinal()].getBasePull(), "Pump rate of " + name + " mechanical pipe in mB/t."); - TubeCapacity = new IntOption(baseConfig, "tier", name + "TubeCapacity", - TubeTier.values()[tier.ordinal()].getBaseCapacity(), + TubeCapacity = new IntOption(baseConfig, "tier", name + "TubeCapacity", TubeTier.values()[tier.ordinal()].getBaseCapacity(), "Capacity of " + name + " pressurized tube in mB."); - TubePullAmount = new IntOption(baseConfig, "tier", name + "TubePullAmount", - TubeTier.values()[tier.ordinal()].getBasePull(), + TubePullAmount = new IntOption(baseConfig, "tier", name + "TubePullAmount", TubeTier.values()[tier.ordinal()].getBasePull(), "Pump rate of " + name + " pressurized tube in mB/t."); - TransporterPullAmount = new IntOption(baseConfig, "tier", name + "TransporterPullAmount", - TransporterTier.values()[tier.ordinal()].getBasePull(), + TransporterPullAmount = new IntOption(baseConfig, "tier", name + "TransporterPullAmount", TransporterTier.values()[tier.ordinal()].getBasePull(), "Item throughput rate of " + name + " logistical transporter in items/s."); - TransporterSpeed = new IntOption(baseConfig, "tier", name + "TransporterSpeed", - TransporterTier.values()[tier.ordinal()].getBaseSpeed(), + TransporterSpeed = new IntOption(baseConfig, "tier", name + "TransporterSpeed", TransporterTier.values()[tier.ordinal()].getBaseSpeed(), "Five times travel speed of " + name + " logistical transporter."); - ConductorInverseConduction = new DoubleOption(baseConfig, "tier", - name + "ConductorInverseConduction", - ConductorTier.values()[tier.ordinal()].getBaseConduction(), + ConductorInverseConduction = new DoubleOption(baseConfig, "tier", name + "ConductorInverseConduction", ConductorTier.values()[tier.ordinal()].getBaseConduction(), "Conduction value of " + name + " thermodynamic conductor."); - ConductorHeatCapacity = new DoubleOption(baseConfig, "tier", name + "ConductorHeatCapacity", - ConductorTier.values()[tier.ordinal()].getBaseHeatCapacity(), + ConductorHeatCapacity = new DoubleOption(baseConfig, "tier", name + "ConductorHeatCapacity", ConductorTier.values()[tier.ordinal()].getBaseHeatCapacity(), "Heat capacity of " + name + " thermodynamic conductor."); - ConductorConductionInsulation = new DoubleOption(baseConfig, "tier", - name + "ConductorConductionInsulation", - ConductorTier.values()[tier.ordinal()].getBaseConductionInsulation(), + ConductorConductionInsulation = new DoubleOption(baseConfig, "tier", name + "ConductorConductionInsulation", ConductorTier.values()[tier.ordinal()].getBaseConductionInsulation(), "Insulation value of " + name + " thermodynamic conductor."); - } else { InductionCellMaxEnergy = null; InductionProviderOutput = null; diff --git a/src/main/java/mekanism/common/config/ToolsConfig.java b/src/main/java/mekanism/common/config/ToolsConfig.java index 3094da34d..7b54011b2 100644 --- a/src/main/java/mekanism/common/config/ToolsConfig.java +++ b/src/main/java/mekanism/common/config/ToolsConfig.java @@ -45,27 +45,18 @@ public class ToolsConfig extends BaseConfig { public final IntOption enchantability; public final FloatOption toughness; - private ArmorBalance(BaseConfig owner, String toolKey, int durabilityDefault, int feetProtectionDefault, - int legsProtectionDefault, int chestProtectionDefault, int headProtectionDefault, - int enchantabilityDefault, float toughnessDefault) { + private ArmorBalance(BaseConfig owner, String toolKey, int durabilityDefault, int feetProtectionDefault, int legsProtectionDefault, int chestProtectionDefault, + int headProtectionDefault, int enchantabilityDefault, float toughnessDefault) { final String category = "tools.armor-balance." + toolKey; final String protectionCategory = category + ".protection"; - this.durability = new IntOption(owner, category, "durability", durabilityDefault, - "Base durability of " + toolKey + " armor."); + this.durability = new IntOption(owner, category, "durability", durabilityDefault, "Base durability of " + toolKey + " armor."); String protectionComment = "Protection value of " + toolKey; - this.feetProtection = new IntOption(owner, protectionCategory, "feet", feetProtectionDefault, - protectionComment + " boots."); - this.legsProtection = new IntOption(owner, protectionCategory, "legs", legsProtectionDefault, - protectionComment + " leggings."); - this.chestProtection = new IntOption(owner, protectionCategory, "chest", chestProtectionDefault, - protectionComment + " chestplates."); - this.headProtection = new IntOption(owner, protectionCategory, "head", headProtectionDefault, - protectionComment + " helmets."); - this.enchantability = new IntOption(owner, category, "enchantability", enchantabilityDefault, - "Natural enchantability factor of " + toolKey + " armor."); - this.toughness = new FloatOption(owner, category, "toughness", toughnessDefault, - "Base armor toughness value of " + toolKey + " armor."); - + this.feetProtection = new IntOption(owner, protectionCategory, "feet", feetProtectionDefault, protectionComment + " boots."); + this.legsProtection = new IntOption(owner, protectionCategory, "legs", legsProtectionDefault, protectionComment + " leggings."); + this.chestProtection = new IntOption(owner, protectionCategory, "chest", chestProtectionDefault, protectionComment + " chestplates."); + this.headProtection = new IntOption(owner, protectionCategory, "head", headProtectionDefault, protectionComment + " helmets."); + this.enchantability = new IntOption(owner, category, "enchantability", enchantabilityDefault, "Natural enchantability factor of " + toolKey + " armor."); + this.toughness = new FloatOption(owner, category, "toughness", toughnessDefault, "Base armor toughness value of " + toolKey + " armor."); this.durability.setRequiresGameRestart(true); this.feetProtection.setRequiresGameRestart(true); this.legsProtection.setRequiresGameRestart(true); @@ -87,26 +78,18 @@ public class ToolsConfig extends BaseConfig { public final FloatOption axeAttackDamage; public final FloatOption axeAttackSpeed; - private ToolBalance(BaseConfig owner, String toolKey, String variant, int harvestLevelDefault, - int maxUsesDefault, float efficiencyDefault, int damageDefault, int enchantabilityDefault, - float axeAttackDamageDefault, float axeAttackSpeedDefault) { + private ToolBalance(BaseConfig owner, String toolKey, String variant, int harvestLevelDefault, int maxUsesDefault, float efficiencyDefault, int damageDefault, + int enchantabilityDefault, float axeAttackDamageDefault, float axeAttackSpeedDefault) { final String category = "tools.tool-balance." + toolKey + "." + variant; - this.harvestLevel = new IntOption(owner, category, "harvestLevel", harvestLevelDefault, - "Harvest level of " + toolKey + " tools."); - this.maxUses = new IntOption(owner, category, "maxUses", maxUsesDefault, - "Maximum durability of " + toolKey + " tools."); - this.efficiency = new FloatOption(owner, category, "efficiency", efficiencyDefault, - "Base speed of " + toolKey + "."); - this.damage = new IntOption(owner, category, "damage", damageDefault, - "Base attack damage of " + toolKey + "."); - this.enchantability = new IntOption(owner, category, "enchantability", enchantabilityDefault, - "Natural enchantability factor of " + toolKey + "."); + this.harvestLevel = new IntOption(owner, category, "harvestLevel", harvestLevelDefault, "Harvest level of " + toolKey + " tools."); + this.maxUses = new IntOption(owner, category, "maxUses", maxUsesDefault, "Maximum durability of " + toolKey + " tools."); + this.efficiency = new FloatOption(owner, category, "efficiency", efficiencyDefault, "Base speed of " + toolKey + "."); + this.damage = new IntOption(owner, category, "damage", damageDefault, "Base attack damage of " + toolKey + "."); + this.enchantability = new IntOption(owner, category, "enchantability", enchantabilityDefault, "Natural enchantability factor of " + toolKey + "."); if (variant.equals("regular")) { - this.axeAttackDamage = new FloatOption(owner, category, "axeAttackDamage", axeAttackDamageDefault, - "Base attack damage of a " + toolKey + " axe."); - this.axeAttackSpeed = new FloatOption(owner, category, "axeAttackSpeed", axeAttackSpeedDefault, - "Base attack speed of a " + toolKey + " axe."); + this.axeAttackDamage = new FloatOption(owner, category, "axeAttackDamage", axeAttackDamageDefault, "Base attack damage of a " + toolKey + " axe."); + this.axeAttackSpeed = new FloatOption(owner, category, "axeAttackSpeed", axeAttackSpeedDefault, "Base attack speed of a " + toolKey + " axe."); } else { this.axeAttackDamage = new FloatOption(NULL_OWNER, "", ""); this.axeAttackSpeed = new FloatOption(NULL_OWNER, "", ""); @@ -121,10 +104,9 @@ public class ToolsConfig extends BaseConfig { this.axeAttackSpeed.setRequiresGameRestart(true); } - public ToolBalance(BaseConfig owner, String toolKey, String variant, int harvestLevelDefault, - int maxUsesDefault, float efficiencyDefault, int damageDefault, int enchantabilityDefault) { - this(owner, toolKey, variant, harvestLevelDefault, maxUsesDefault, efficiencyDefault, damageDefault, - enchantabilityDefault, 0, 0); + public ToolBalance(BaseConfig owner, String toolKey, String variant, int harvestLevelDefault, int maxUsesDefault, float efficiencyDefault, int damageDefault, + int enchantabilityDefault) { + this(owner, toolKey, variant, harvestLevelDefault, maxUsesDefault, efficiencyDefault, damageDefault, enchantabilityDefault, 0, 0); if (!variant.equals("paxel")) { throw new IllegalStateException("Wrong constructor, only paxel can use this"); } diff --git a/src/main/java/mekanism/common/config/TypeConfigManager.java b/src/main/java/mekanism/common/config/TypeConfigManager.java index cf3e6526c..8e90357d9 100644 --- a/src/main/java/mekanism/common/config/TypeConfigManager.java +++ b/src/main/java/mekanism/common/config/TypeConfigManager.java @@ -18,8 +18,7 @@ public class TypeConfigManager> extends Option> validValuesSupplier; private Function nameSupplier; - TypeConfigManager(BaseConfig owner, String category, Class enumClazz, Supplier> validValuesSupplier, - Function nameSupplier) { + TypeConfigManager(BaseConfig owner, String category, Class enumClazz, Supplier> validValuesSupplier, Function nameSupplier) { super(owner, category, "", null);//key unused this.validValuesSupplier = validValuesSupplier; this.nameSupplier = nameSupplier; @@ -42,6 +41,7 @@ public class TypeConfigManager> extends Option> extends Option { private boolean value; private final boolean defaultValue; - public BooleanOption(BaseConfig owner, String category, String key, boolean defaultValue, - @Nullable String comment) { + public BooleanOption(BaseConfig owner, String category, String key, boolean defaultValue, @Nullable String comment) { super(owner, category, key, comment); this.defaultValue = defaultValue; this.value = defaultValue; @@ -39,14 +38,11 @@ public class BooleanOption extends Option { this.value = value; } - @SuppressWarnings("Duplicates")//types are different @Override public void load(Configuration config) { Property prop = config.get(this.category, this.key, this.defaultValue, this.comment); - prop.setRequiresMcRestart(this.requiresGameRestart); prop.setRequiresWorldRestart(this.requiresWorldRestart); - this.value = prop.getBoolean(); } diff --git a/src/main/java/mekanism/common/config/options/DoubleOption.java b/src/main/java/mekanism/common/config/options/DoubleOption.java index 6ad5dfb77..06aa17042 100644 --- a/src/main/java/mekanism/common/config/options/DoubleOption.java +++ b/src/main/java/mekanism/common/config/options/DoubleOption.java @@ -33,8 +33,7 @@ public class DoubleOption extends Option { this(owner, category, key, 0, null); } - public DoubleOption(BaseConfig owner, String category, String key, double defaultValue, @Nullable String comment, - double min, double max) { + public DoubleOption(BaseConfig owner, String category, String key, double defaultValue, @Nullable String comment, double min, double max) { this(owner, category, key, defaultValue, comment); this.hasRange = true; this.min = min; @@ -53,16 +52,13 @@ public class DoubleOption extends Option { @Override public void load(Configuration config) { Property prop; - if (hasRange) { prop = config.get(this.category, this.key, this.defaultValue, this.comment, this.min, this.max); } else { prop = config.get(this.category, this.key, this.defaultValue, this.comment); } - prop.setRequiresMcRestart(this.requiresGameRestart); prop.setRequiresWorldRestart(this.requiresWorldRestart); - this.value = prop.getDouble(); } diff --git a/src/main/java/mekanism/common/config/options/EnumOption.java b/src/main/java/mekanism/common/config/options/EnumOption.java index 7564141be..12df6a359 100644 --- a/src/main/java/mekanism/common/config/options/EnumOption.java +++ b/src/main/java/mekanism/common/config/options/EnumOption.java @@ -43,10 +43,8 @@ public class EnumOption> extends Option> { @Override public void load(Configuration config) { final Property prop = config.get(this.category, this.key, this.defaultValue.name(), this.comment); - prop.setRequiresMcRestart(this.requiresGameRestart); prop.setRequiresWorldRestart(this.requiresWorldRestart); - this.value = Enum.valueOf(this.enumClass, prop.getString()); } diff --git a/src/main/java/mekanism/common/config/options/FloatOption.java b/src/main/java/mekanism/common/config/options/FloatOption.java index 4ea4e5b00..a3f9a9757 100644 --- a/src/main/java/mekanism/common/config/options/FloatOption.java +++ b/src/main/java/mekanism/common/config/options/FloatOption.java @@ -33,8 +33,7 @@ public class FloatOption extends Option { this(owner, category, key, 0, null); } - public FloatOption(BaseConfig owner, String category, String key, float defaultValue, @Nullable String comment, - float min, float max) { + public FloatOption(BaseConfig owner, String category, String key, float defaultValue, @Nullable String comment, float min, float max) { this(owner, category, key, defaultValue, comment); this.hasRange = true; this.min = min; @@ -53,16 +52,13 @@ public class FloatOption extends Option { @Override public void load(Configuration config) { Property prop; - if (hasRange) { prop = config.get(this.category, this.key, this.defaultValue, this.comment, this.min, this.max); } else { prop = config.get(this.category, this.key, this.defaultValue, this.comment); } - prop.setRequiresMcRestart(this.requiresGameRestart); prop.setRequiresWorldRestart(this.requiresWorldRestart); - this.value = (float) prop.getDouble(); } diff --git a/src/main/java/mekanism/common/config/options/IntListOption.java b/src/main/java/mekanism/common/config/options/IntListOption.java index 72d0a8981..d12bf8f2b 100644 --- a/src/main/java/mekanism/common/config/options/IntListOption.java +++ b/src/main/java/mekanism/common/config/options/IntListOption.java @@ -33,8 +33,7 @@ public class IntListOption extends Option { this(owner, category, key, new int[0], null); } - public IntListOption(BaseConfig owner, String category, String key, int[] defaultValue, @Nullable String comment, - int min, int max) { + public IntListOption(BaseConfig owner, String category, String key, int[] defaultValue, @Nullable String comment, int min, int max) { this(owner, category, key, defaultValue, comment); this.hasRange = true; this.min = min; @@ -53,16 +52,13 @@ public class IntListOption extends Option { @Override public void load(Configuration config) { Property prop; - if (hasRange) { prop = config.get(this.category, this.key, this.defaultValue, this.comment, this.min, this.max); } else { prop = config.get(this.category, this.key, this.defaultValue, this.comment); } - prop.setRequiresMcRestart(this.requiresGameRestart); prop.setRequiresWorldRestart(this.requiresWorldRestart); - this.value = prop.getIntList(); } diff --git a/src/main/java/mekanism/common/config/options/IntOption.java b/src/main/java/mekanism/common/config/options/IntOption.java index 67a083fa7..4363685dc 100644 --- a/src/main/java/mekanism/common/config/options/IntOption.java +++ b/src/main/java/mekanism/common/config/options/IntOption.java @@ -33,8 +33,7 @@ public class IntOption extends Option { this(owner, category, key, 0, null); } - public IntOption(BaseConfig owner, String category, String key, int defaultValue, @Nullable String comment, int min, - int max) { + public IntOption(BaseConfig owner, String category, String key, int defaultValue, @Nullable String comment, int min, int max) { this(owner, category, key, defaultValue, comment); this.hasRange = true; this.min = min; @@ -53,16 +52,13 @@ public class IntOption extends Option { @Override public void load(Configuration config) { Property prop; - if (hasRange) { prop = config.get(this.category, this.key, this.defaultValue, this.comment, this.min, this.max); } else { prop = config.get(this.category, this.key, this.defaultValue, this.comment); } - prop.setRequiresMcRestart(this.requiresGameRestart); prop.setRequiresWorldRestart(this.requiresWorldRestart); - this.value = prop.getInt(); } diff --git a/src/main/java/mekanism/common/config/options/IntSetOption.java b/src/main/java/mekanism/common/config/options/IntSetOption.java index f8a0f2014..c9c498918 100644 --- a/src/main/java/mekanism/common/config/options/IntSetOption.java +++ b/src/main/java/mekanism/common/config/options/IntSetOption.java @@ -38,8 +38,7 @@ public class IntSetOption extends Option { this(owner, category, key, new int[0], null); } - public IntSetOption(BaseConfig owner, String category, String key, int[] defaultValue, @Nullable String comment, - int min, int max) { + public IntSetOption(BaseConfig owner, String category, String key, int[] defaultValue, @Nullable String comment, int min, int max) { this(owner, category, key, defaultValue, comment); this.hasRange = true; this.min = min; @@ -58,16 +57,13 @@ public class IntSetOption extends Option { @Override public void load(Configuration config) { Property prop; - if (hasRange) { prop = config.get(this.category, this.key, this.defaultValue, this.comment, this.min, this.max); } else { prop = config.get(this.category, this.key, this.defaultValue, this.comment); } - prop.setRequiresMcRestart(this.requiresGameRestart); prop.setRequiresWorldRestart(this.requiresWorldRestart); - this.value.clear(); for (int i : prop.getIntList()) { this.value.add(i); diff --git a/src/main/java/mekanism/common/config/options/Option.java b/src/main/java/mekanism/common/config/options/Option.java index 8912517f3..249202e91 100644 --- a/src/main/java/mekanism/common/config/options/Option.java +++ b/src/main/java/mekanism/common/config/options/Option.java @@ -33,8 +33,7 @@ public abstract class Option { } /** - * Loads this option from the config file NB: saving back is handled by the config system / GUIs, load will be - * re-called + * Loads this option from the config file NB: saving back is handled by the config system / GUIs, load will be re-called * * @param config where to load from */ diff --git a/src/main/java/mekanism/common/content/assemblicator/RecipeFormula.java b/src/main/java/mekanism/common/content/assemblicator/RecipeFormula.java index baa2ef631..cf1f36213 100644 --- a/src/main/java/mekanism/common/content/assemblicator/RecipeFormula.java +++ b/src/main/java/mekanism/common/content/assemblicator/RecipeFormula.java @@ -25,9 +25,7 @@ public class RecipeFormula { for (int i = 0; i < 9; i++) { input.set(i, StackUtils.size(inv.get(start + i), 1)); } - resetToRecipe(); - recipe = RecipeUtils.getRecipeFromGrid(dummy, world); } @@ -41,44 +39,35 @@ public class RecipeFormula { for (int i = 0; i < 9; i++) { dummy.setInventorySlotContents(i, newInput.get(start + i)); } - return recipe.matches(dummy, world); } public boolean isIngredientInPos(World world, ItemStack stack, int i) { resetToRecipe(); dummy.setInventorySlotContents(i, stack); - return recipe.matches(dummy, world); } public boolean isIngredient(World world, ItemStack stack) { for (int i = 0; i < 9; i++) { dummy.setInventorySlotContents(i, stack); - if (recipe.matches(dummy, world)) { return true; } - dummy.setInventorySlotContents(i, input.get(i)); } - return false; } public List getIngredientIndices(World world, ItemStack stack) { List ret = new ArrayList<>(); - for (int i = 0; i < 9; i++) { dummy.setInventorySlotContents(i, stack); - if (recipe.matches(dummy, world)) { ret.add(i); } - dummy.setInventorySlotContents(i, input.get(i)); } - return ret; } @@ -93,4 +82,4 @@ public class RecipeFormula { public boolean isFormulaEqual(World world, RecipeFormula formula) { return formula.getRecipe(world) == getRecipe(world); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/boiler/BoilerCache.java b/src/main/java/mekanism/common/content/boiler/BoilerCache.java index afc02aa25..529eca0de 100644 --- a/src/main/java/mekanism/common/content/boiler/BoilerCache.java +++ b/src/main/java/mekanism/common/content/boiler/BoilerCache.java @@ -8,7 +8,6 @@ public class BoilerCache extends MultiblockCache { public FluidStack water; public FluidStack steam; - public double temperature; @Override @@ -30,11 +29,9 @@ public class BoilerCache extends MultiblockCache { if (nbtTags.hasKey("cachedWater")) { water = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("cachedWater")); } - if (nbtTags.hasKey("cachedSteam")) { steam = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("cachedSteam")); } - temperature = nbtTags.getDouble("temperature"); } @@ -43,11 +40,9 @@ public class BoilerCache extends MultiblockCache { if (water != null) { nbtTags.setTag("cachedWater", water.writeToNBT(new NBTTagCompound())); } - if (steam != null) { nbtTags.setTag("cachedSteam", steam.writeToNBT(new NBTTagCompound())); } - nbtTags.setDouble("temperature", temperature); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/boiler/BoilerSteamTank.java b/src/main/java/mekanism/common/content/boiler/BoilerSteamTank.java index c1e15b645..337e7f44e 100644 --- a/src/main/java/mekanism/common/content/boiler/BoilerSteamTank.java +++ b/src/main/java/mekanism/common/content/boiler/BoilerSteamTank.java @@ -21,7 +21,6 @@ public class BoilerSteamTank extends BoilerTank { @Override public int getCapacity() { - return steamBoiler.structure != null ? steamBoiler.structure.steamVolume * BoilerUpdateProtocol.STEAM_PER_TANK - : 0; + return steamBoiler.structure != null ? steamBoiler.structure.steamVolume * BoilerUpdateProtocol.STEAM_PER_TANK : 0; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/boiler/BoilerTank.java b/src/main/java/mekanism/common/content/boiler/BoilerTank.java index 3faecd8be..aca02f6f6 100644 --- a/src/main/java/mekanism/common/content/boiler/BoilerTank.java +++ b/src/main/java/mekanism/common/content/boiler/BoilerTank.java @@ -24,32 +24,26 @@ public abstract class BoilerTank implements IFluidTank { if (resource == null || resource.getFluid() == null) { return 0; } - if (getFluid() == null || getFluid().getFluid() == null) { if (resource.amount <= getCapacity()) { if (doFill) { setFluid(resource.copy()); } - if (resource.amount > 0 && doFill) { MekanismUtils.saveChunk(steamBoiler); updateValveData(); } - return resource.amount; - } else { - if (doFill) { - setFluid(resource.copy()); - getFluid().amount = getCapacity(); - } - - if (getCapacity() > 0 && doFill) { - MekanismUtils.saveChunk(steamBoiler); - updateValveData(); - } - - return getCapacity(); } + if (doFill) { + setFluid(resource.copy()); + getFluid().amount = getCapacity(); + } + if (getCapacity() > 0 && doFill) { + MekanismUtils.saveChunk(steamBoiler); + updateValveData(); + } + return getCapacity(); } if (!getFluid().isFluidEqual(resource)) { @@ -57,32 +51,27 @@ public abstract class BoilerTank implements IFluidTank { } int space = getCapacity() - getFluid().amount; - if (resource.amount <= space) { if (doFill) { getFluid().amount += resource.amount; } - if (resource.amount > 0 && doFill) { MekanismUtils.saveChunk(steamBoiler); updateValveData(); } - return resource.amount; - } else { - if (doFill) { - getFluid().amount = getCapacity(); - } - - if (space > 0 && doFill) { - MekanismUtils.saveChunk(steamBoiler); - updateValveData(); - } - - return space; } - } + if (doFill) { + getFluid().amount = getCapacity(); + } + if (space > 0 && doFill) { + MekanismUtils.saveChunk(steamBoiler); + updateValveData(); + } + + return space; + } return 0; } @@ -102,35 +91,26 @@ public abstract class BoilerTank implements IFluidTank { if (getFluid() == null || getFluid().getFluid() == null) { return null; } - if (getFluid().amount <= 0) { return null; } - int used = maxDrain; - if (getFluid().amount < used) { used = getFluid().amount; } - if (doDrain) { getFluid().amount -= used; } - FluidStack drained = new FluidStack(getFluid(), used); - if (getFluid().amount <= 0) { setFluid(null); } - if (drained.amount > 0 && doDrain) { MekanismUtils.saveChunk(steamBoiler); steamBoiler.sendPacketToRenderer(); } - return drained; } - return null; } @@ -139,7 +119,6 @@ public abstract class BoilerTank implements IFluidTank { if (steamBoiler.structure != null) { return getFluid().amount; } - return 0; } @@ -147,4 +126,4 @@ public abstract class BoilerTank implements IFluidTank { public FluidTankInfo getInfo() { return new FluidTankInfo(this); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/boiler/BoilerUpdateProtocol.java b/src/main/java/mekanism/common/content/boiler/BoilerUpdateProtocol.java index af6af7377..89b528d49 100644 --- a/src/main/java/mekanism/common/content/boiler/BoilerUpdateProtocol.java +++ b/src/main/java/mekanism/common/content/boiler/BoilerUpdateProtocol.java @@ -29,8 +29,7 @@ public class BoilerUpdateProtocol extends UpdateProtocol @Override protected boolean isValidFrame(int x, int y, int z) { - return BasicBlockType.get(pointer.getWorld().getBlockState(new BlockPos(x, y, z))) - == BasicBlockType.BOILER_CASING; + return BasicBlockType.get(pointer.getWorld().getBlockState(new BlockPos(x, y, z))) == BasicBlockType.BOILER_CASING; } @Override @@ -38,10 +37,7 @@ public class BoilerUpdateProtocol extends UpdateProtocol if (super.isValidInnerNode(x, y, z)) { return true; } - - TileEntity tile = new Coord4D(x, y, z, pointer.getWorld().provider.getDimension()) - .getTileEntity(pointer.getWorld()); - + TileEntity tile = new Coord4D(x, y, z, pointer.getWorld().provider.getDimension()).getTileEntity(pointer.getWorld()); return tile instanceof TileEntityPressureDisperser || tile instanceof TileEntitySuperheatingElement; } @@ -50,10 +46,8 @@ public class BoilerUpdateProtocol extends UpdateProtocol if (structure.volHeight >= 3) { Set dispersers = new HashSet<>(); Set elements = new HashSet<>(); - for (Coord4D coord : innerNodes) { TileEntity tile = coord.getTileEntity(pointer.getWorld()); - if (tile instanceof TileEntityPressureDisperser) { dispersers.add(coord); } else if (tile instanceof TileEntitySuperheatingElement) { @@ -63,27 +57,22 @@ public class BoilerUpdateProtocol extends UpdateProtocol } int prevDispersers = dispersers.size(); - //Ensure at least one disperser exists if (dispersers.size() == 0) { return false; } - //Find a single disperser contained within this multiblock final Coord4D initDisperser = dispersers.iterator().next(); //Ensure that a full horizontal plane of dispersers exist, surrounding the found disperser - Coord4D pos = new Coord4D(structure.renderLocation.x, initDisperser.y, structure.renderLocation.z, - pointer.getWorld().provider.getDimension()); + Coord4D pos = new Coord4D(structure.renderLocation.x, initDisperser.y, structure.renderLocation.z, pointer.getWorld().provider.getDimension()); for (int x = 1; x < structure.volLength - 1; x++) { for (int z = 1; z < structure.volWidth - 1; z++) { Coord4D coord4D = pos.translate(x, 0, z); TileEntity tile = coord4D.getTileEntity(pointer.getWorld()); - if (!(tile instanceof TileEntityPressureDisperser)) { return false; } - dispersers.remove(coord4D); } } @@ -135,9 +124,9 @@ public class BoilerUpdateProtocol extends UpdateProtocol @Override public final boolean isValid(Coord4D coord) { return coord.y >= renderLocation.y - 1 && coord.y < initDisperser.y && - coord.x >= renderLocation.x && coord.x < renderLocation.x + volLength && - coord.z >= renderLocation.z && coord.z < renderLocation.z + volWidth && - (coord.isAirBlock(pointer.getWorld()) || isViableNode(coord.getPos())); + coord.x >= renderLocation.x && coord.x < renderLocation.x + volLength && + coord.z >= renderLocation.z && coord.z < renderLocation.z + volWidth && + (coord.isAirBlock(pointer.getWorld()) || isViableNode(coord.getPos())); } }).calculate(initAir); @@ -146,11 +135,10 @@ public class BoilerUpdateProtocol extends UpdateProtocol return false; } - int steamHeight = (structure.renderLocation.y + structure.volHeight - 2) - initDisperser.y; + int steamHeight = structure.renderLocation.y + structure.volHeight - 2 - initDisperser.y; structure.steamVolume = structure.volWidth * structure.volLength * steamHeight; - structure.upperRenderLocation = new Coord4D(structure.renderLocation.x, initDisperser.y + 1, - structure.renderLocation.z, pointer.getWorld().provider.getDimension()); + structure.upperRenderLocation = new Coord4D(structure.renderLocation.x, initDisperser.y + 1, structure.renderLocation.z, pointer.getWorld().provider.getDimension()); return true; } @@ -178,49 +166,41 @@ public class BoilerUpdateProtocol extends UpdateProtocol MultiblockCache merge) { if (((BoilerCache) cache).water == null) { ((BoilerCache) cache).water = ((BoilerCache) merge).water; - } else if (((BoilerCache) merge).water != null && ((BoilerCache) cache).water - .isFluidEqual(((BoilerCache) merge).water)) { + } else if (((BoilerCache) merge).water != null && ((BoilerCache) cache).water.isFluidEqual(((BoilerCache) merge).water)) { ((BoilerCache) cache).water.amount += ((BoilerCache) merge).water.amount; } if (((BoilerCache) cache).steam == null) { ((BoilerCache) cache).steam = ((BoilerCache) merge).steam; - } else if (((BoilerCache) merge).steam != null && ((BoilerCache) cache).steam - .isFluidEqual(((BoilerCache) merge).steam)) { + } else if (((BoilerCache) merge).steam != null && ((BoilerCache) cache).steam.isFluidEqual(((BoilerCache) merge).steam)) { ((BoilerCache) cache).steam.amount += ((BoilerCache) merge).steam.amount; } - ((BoilerCache) cache).temperature = Math - .max(((BoilerCache) cache).temperature, ((BoilerCache) merge).temperature); + ((BoilerCache) cache).temperature = Math.max(((BoilerCache) cache).temperature, ((BoilerCache) merge).temperature); } @Override protected void onFormed() { super.onFormed(); - if ((structureFound).waterStored != null) { - (structureFound).waterStored.amount = Math - .min((structureFound).waterStored.amount, structureFound.waterVolume * WATER_PER_TANK); + if (structureFound.waterStored != null) { + structureFound.waterStored.amount = Math.min(structureFound.waterStored.amount, structureFound.waterVolume * WATER_PER_TANK); } - if ((structureFound).steamStored != null) { - (structureFound).steamStored.amount = Math - .min((structureFound).steamStored.amount, structureFound.steamVolume * STEAM_PER_TANK); + if (structureFound.steamStored != null) { + structureFound.steamStored.amount = Math.min(structureFound.steamStored.amount, structureFound.steamVolume * STEAM_PER_TANK); } } @Override - protected void onStructureCreated(SynchronizedBoilerData structure, int origX, int origY, int origZ, int xmin, - int xmax, int ymin, int ymax, int zmin, int zmax) { + protected void onStructureCreated(SynchronizedBoilerData structure, int origX, int origY, int origZ, int xmin, int xmax, int ymin, int ymax, int zmin, int zmax) { for (Coord4D obj : structure.locations) { if (obj.getTileEntity(pointer.getWorld()) instanceof TileEntityBoilerValve) { ValveData data = new ValveData(); data.location = obj; - data.side = getSide(obj, origX + xmin, origX + xmax, origY + ymin, origY + ymax, origZ + zmin, - origZ + zmax); - + data.side = getSide(obj, origX + xmin, origX + xmax, origY + ymin, origY + ymax, origZ + zmin, origZ + zmax); structure.valves.add(data); } } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/boiler/BoilerWaterTank.java b/src/main/java/mekanism/common/content/boiler/BoilerWaterTank.java index 2a4fe29b5..9133a90a5 100644 --- a/src/main/java/mekanism/common/content/boiler/BoilerWaterTank.java +++ b/src/main/java/mekanism/common/content/boiler/BoilerWaterTank.java @@ -21,7 +21,6 @@ public class BoilerWaterTank extends BoilerTank { @Override public int getCapacity() { - return steamBoiler.structure != null ? steamBoiler.structure.waterVolume * BoilerUpdateProtocol.WATER_PER_TANK - : 0; + return steamBoiler.structure != null ? steamBoiler.structure.waterVolume * BoilerUpdateProtocol.WATER_PER_TANK : 0; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/boiler/SynchronizedBoilerData.java b/src/main/java/mekanism/common/content/boiler/SynchronizedBoilerData.java index 9d77456cb..e465d7c88 100644 --- a/src/main/java/mekanism/common/content/boiler/SynchronizedBoilerData.java +++ b/src/main/java/mekanism/common/content/boiler/SynchronizedBoilerData.java @@ -21,8 +21,7 @@ public class SynchronizedBoilerData extends SynchronizedData= 0 && slotID < 1) { + if (slotID == 0) { inventory.set(slotID, new ItemStack(tagCompound)); } } - temperature = nbtTags.getDouble("temperature"); } @Override public void write(TileNetworkList data) { super.write(data); - data.add(storedEnergy); - if (storedFluid.getFluid() != null) { data.add(true); data.add(FluidRegistry.getFluidName(storedFluid.getFluid())); @@ -118,7 +102,6 @@ public class InventoryFrequency extends Frequency { } else { data.add(false); } - if (storedGas.getGas() != null) { data.add(true); data.add(storedGas.getGasType().getID()); @@ -126,32 +109,25 @@ public class InventoryFrequency extends Frequency { } else { data.add(false); } - data.add(temperature); } @Override protected void read(ByteBuf dataStream) { super.read(dataStream); - storedFluid = new FluidTank(FluidTankTier.ULTIMATE.getOutput()); storedGas = new GasTank(GasTankTier.ULTIMATE.getOutput()); - storedEnergy = dataStream.readDouble(); - if (dataStream.readBoolean()) { - storedFluid.setFluid( - new FluidStack(FluidRegistry.getFluid(PacketHandler.readString(dataStream)), dataStream.readInt())); + storedFluid.setFluid(new FluidStack(FluidRegistry.getFluid(PacketHandler.readString(dataStream)), dataStream.readInt())); } else { storedFluid.setFluid(null); } - if (dataStream.readBoolean()) { storedGas.setGas(new GasStack(dataStream.readInt(), dataStream.readInt())); } else { storedGas.setGas(null); } - temperature = dataStream.readDouble(); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/filter/IFilter.java b/src/main/java/mekanism/common/content/filter/IFilter.java index c40b13949..46601af00 100644 --- a/src/main/java/mekanism/common/content/filter/IFilter.java +++ b/src/main/java/mekanism/common/content/filter/IFilter.java @@ -1,5 +1,4 @@ package mekanism.common.content.filter; public interface IFilter { - } \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/filter/IItemStackFilter.java b/src/main/java/mekanism/common/content/filter/IItemStackFilter.java index 0afe09b74..39cae1135 100644 --- a/src/main/java/mekanism/common/content/filter/IItemStackFilter.java +++ b/src/main/java/mekanism/common/content/filter/IItemStackFilter.java @@ -1,5 +1,4 @@ package mekanism.common.content.filter; public interface IItemStackFilter { - } \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/filter/IMaterialFilter.java b/src/main/java/mekanism/common/content/filter/IMaterialFilter.java index 55b7608c4..6e49fbb12 100644 --- a/src/main/java/mekanism/common/content/filter/IMaterialFilter.java +++ b/src/main/java/mekanism/common/content/filter/IMaterialFilter.java @@ -3,6 +3,7 @@ package mekanism.common.content.filter; import net.minecraft.item.ItemStack; public interface IMaterialFilter { + ItemStack getMaterialItem(); void setMaterialItem(ItemStack stack); diff --git a/src/main/java/mekanism/common/content/filter/IModIDFilter.java b/src/main/java/mekanism/common/content/filter/IModIDFilter.java index d9e40f687..928347aab 100644 --- a/src/main/java/mekanism/common/content/filter/IModIDFilter.java +++ b/src/main/java/mekanism/common/content/filter/IModIDFilter.java @@ -1,6 +1,7 @@ package mekanism.common.content.filter; public interface IModIDFilter { + void setModID(String id); String getModID(); diff --git a/src/main/java/mekanism/common/content/filter/IOreDictFilter.java b/src/main/java/mekanism/common/content/filter/IOreDictFilter.java index edd476bc1..e10afe7ff 100644 --- a/src/main/java/mekanism/common/content/filter/IOreDictFilter.java +++ b/src/main/java/mekanism/common/content/filter/IOreDictFilter.java @@ -1,6 +1,7 @@ package mekanism.common.content.filter; public interface IOreDictFilter { + void setOreDictName(String name); String getOreDictName(); diff --git a/src/main/java/mekanism/common/content/matrix/MatrixCache.java b/src/main/java/mekanism/common/content/matrix/MatrixCache.java index d4310bd47..cfbdd0f0b 100644 --- a/src/main/java/mekanism/common/content/matrix/MatrixCache.java +++ b/src/main/java/mekanism/common/content/matrix/MatrixCache.java @@ -25,11 +25,9 @@ public class MatrixCache extends MultiblockCache { public void load(NBTTagCompound nbtTags) { NBTTagList tagList = nbtTags.getTagList("Items", NBT.TAG_COMPOUND); inventory = NonNullList.withSize(2, ItemStack.EMPTY); - for (int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(tagCount); byte slotID = tagCompound.getByte("Slot"); - if (slotID >= 0 && slotID < 2) { inventory.set(slotID, new ItemStack(tagCompound)); } @@ -39,7 +37,6 @@ public class MatrixCache extends MultiblockCache { @Override public void save(NBTTagCompound nbtTags) { NBTTagList tagList = new NBTTagList(); - for (int slotCount = 0; slotCount < 2; slotCount++) { if (!inventory.get(slotCount).isEmpty()) { NBTTagCompound tagCompound = new NBTTagCompound(); @@ -48,7 +45,6 @@ public class MatrixCache extends MultiblockCache { tagList.appendTag(tagCompound); } } - nbtTags.setTag("Items", tagList); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/matrix/MatrixUpdateProtocol.java b/src/main/java/mekanism/common/content/matrix/MatrixUpdateProtocol.java index d3559d0c8..83e5ae7bf 100644 --- a/src/main/java/mekanism/common/content/matrix/MatrixUpdateProtocol.java +++ b/src/main/java/mekanism/common/content/matrix/MatrixUpdateProtocol.java @@ -30,13 +30,10 @@ public class MatrixUpdateProtocol extends UpdateProtocol @Override public boolean isValidInnerNode(int x, int y, int z) { - TileEntity tile = new Coord4D(x, y, z, pointer.getWorld().provider.getDimension()) - .getTileEntity(pointer.getWorld()); - + TileEntity tile = new Coord4D(x, y, z, pointer.getWorld().provider.getDimension()).getTileEntity(pointer.getWorld()); if (tile instanceof TileEntityInductionCell || tile instanceof TileEntityInductionProvider) { return true; } - return isAir(x, y, z); } @@ -58,13 +55,10 @@ public class MatrixUpdateProtocol extends UpdateProtocol @Override protected void mergeCaches(List rejectedItems, MultiblockCache cache, MultiblockCache merge) { - List rejects = StackUtils - .getMergeRejects(((MatrixCache) cache).inventory, ((MatrixCache) merge).inventory); - + List rejects = StackUtils.getMergeRejects(((MatrixCache) cache).inventory, ((MatrixCache) merge).inventory); if (!rejects.isEmpty()) { rejectedItems.addAll(rejects); } - StackUtils.merge(((MatrixCache) cache).inventory, ((MatrixCache) merge).inventory); } @@ -72,7 +66,6 @@ public class MatrixUpdateProtocol extends UpdateProtocol protected boolean canForm(SynchronizedMatrixData structure) { for (Coord4D coord : innerNodes) { TileEntity tile = coord.getTileEntity(pointer.getWorld()); - if (tile instanceof TileEntityInductionCell) { structure.cells.add(coord); structure.storageCap += ((TileEntityInductionCell) tile).tier.getMaxEnergy(); @@ -81,7 +74,6 @@ public class MatrixUpdateProtocol extends UpdateProtocol structure.transferCap += ((TileEntityInductionProvider) tile).tier.getOutput(); } } - return true; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/miner/MItemStackFilter.java b/src/main/java/mekanism/common/content/miner/MItemStackFilter.java index 744a6beb9..5bbddc852 100644 --- a/src/main/java/mekanism/common/content/miner/MItemStackFilter.java +++ b/src/main/java/mekanism/common/content/miner/MItemStackFilter.java @@ -25,30 +25,24 @@ public class MItemStackFilter extends MinerFilter implements IItemStackFilter { if (itemStack.isEmpty()) { return false; } - if (itemStack.getItem() == itemType.getItem() && fuzzy) { return true; } - return itemType.isItemEqual(itemStack); } @Override public NBTTagCompound write(NBTTagCompound nbtTags) { super.write(nbtTags); - nbtTags.setInteger("type", 0); - nbtTags.setBoolean("fuzzy", fuzzy); itemType.writeToNBT(nbtTags); - return nbtTags; } @Override protected void read(NBTTagCompound nbtTags) { super.read(nbtTags); - fuzzy = nbtTags.getBoolean("fuzzy"); itemType = new ItemStack(nbtTags); } @@ -56,11 +50,8 @@ public class MItemStackFilter extends MinerFilter implements IItemStackFilter { @Override public void write(TileNetworkList data) { data.add(0); - super.write(data); - data.add(fuzzy); - data.add(MekanismUtils.getID(itemType)); data.add(itemType.getCount()); data.add(itemType.getItemDamage()); @@ -69,9 +60,7 @@ public class MItemStackFilter extends MinerFilter implements IItemStackFilter { @Override protected void read(ByteBuf dataStream) { super.read(dataStream); - fuzzy = dataStream.readBoolean(); - itemType = new ItemStack(Item.getItemById(dataStream.readInt()), dataStream.readInt(), dataStream.readInt()); } @@ -86,8 +75,7 @@ public class MItemStackFilter extends MinerFilter implements IItemStackFilter { @Override public boolean equals(Object filter) { - return super.equals(filter) && filter instanceof MItemStackFilter && ((MItemStackFilter) filter).itemType - .isItemEqual(itemType); + return super.equals(filter) && filter instanceof MItemStackFilter && ((MItemStackFilter) filter).itemType.isItemEqual(itemType); } @Override @@ -97,7 +85,6 @@ public class MItemStackFilter extends MinerFilter implements IItemStackFilter { filter.requireStack = requireStack; filter.fuzzy = fuzzy; filter.itemType = itemType.copy(); - return filter; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/miner/MMaterialFilter.java b/src/main/java/mekanism/common/content/miner/MMaterialFilter.java index 54d2415fe..5f23348a8 100644 --- a/src/main/java/mekanism/common/content/miner/MMaterialFilter.java +++ b/src/main/java/mekanism/common/content/miner/MMaterialFilter.java @@ -17,8 +17,7 @@ public class MMaterialFilter extends MinerFilter implements IMaterialFilter { private ItemStack materialItem = ItemStack.EMPTY; public Material getMaterial() { - return Block.getBlockFromItem(materialItem.getItem()).getStateFromMeta(materialItem.getItemDamage()) - .getMaterial(); + return Block.getBlockFromItem(materialItem.getItem()).getStateFromMeta(materialItem.getItemDamage()).getMaterial(); } @Override @@ -26,33 +25,27 @@ public class MMaterialFilter extends MinerFilter implements IMaterialFilter { if (itemStack.isEmpty() || !(itemStack.getItem() instanceof ItemBlock)) { return false; } - return new MaterialFinder(getMaterial()).modifies(itemStack); } @Override public NBTTagCompound write(NBTTagCompound nbtTags) { super.write(nbtTags); - nbtTags.setInteger("type", 2); materialItem.writeToNBT(nbtTags); - return nbtTags; } @Override protected void read(NBTTagCompound nbtTags) { super.read(nbtTags); - materialItem = new ItemStack(nbtTags); } @Override public void write(TileNetworkList data) { data.add(2); - super.write(data); - data.add(MekanismUtils.getID(materialItem)); data.add(materialItem.getCount()); data.add(materialItem.getItemDamage()); @@ -61,9 +54,7 @@ public class MMaterialFilter extends MinerFilter implements IMaterialFilter { @Override protected void read(ByteBuf dataStream) { super.read(dataStream); - - materialItem = new ItemStack(Item.getItemById(dataStream.readInt()), dataStream.readInt(), - dataStream.readInt()); + materialItem = new ItemStack(Item.getItemById(dataStream.readInt()), dataStream.readInt(), dataStream.readInt()); } @Override @@ -77,8 +68,7 @@ public class MMaterialFilter extends MinerFilter implements IMaterialFilter { @Override public boolean equals(Object filter) { - return super.equals(filter) && filter instanceof MMaterialFilter && ((MMaterialFilter) filter).materialItem - .isItemEqual(materialItem); + return super.equals(filter) && filter instanceof MMaterialFilter && ((MMaterialFilter) filter).materialItem.isItemEqual(materialItem); } @Override @@ -87,7 +77,6 @@ public class MMaterialFilter extends MinerFilter implements IMaterialFilter { filter.replaceStack = replaceStack; filter.requireStack = requireStack; filter.materialItem = materialItem; - return filter; } @@ -100,4 +89,4 @@ public class MMaterialFilter extends MinerFilter implements IMaterialFilter { public void setMaterialItem(ItemStack stack) { materialItem = stack; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/miner/MModIDFilter.java b/src/main/java/mekanism/common/content/miner/MModIDFilter.java index 75b5721fd..9c087b81c 100644 --- a/src/main/java/mekanism/common/content/miner/MModIDFilter.java +++ b/src/main/java/mekanism/common/content/miner/MModIDFilter.java @@ -1,8 +1,8 @@ package mekanism.common.content.miner; import io.netty.buffer.ByteBuf; -import mekanism.common.PacketHandler; import mekanism.api.TileNetworkList; +import mekanism.common.PacketHandler; import mekanism.common.content.filter.IModIDFilter; import mekanism.common.content.transporter.Finder.ModIDFinder; import net.minecraft.item.ItemBlock; @@ -18,40 +18,33 @@ public class MModIDFilter extends MinerFilter implements IModIDFilter { if (itemStack.isEmpty() || !(itemStack.getItem() instanceof ItemBlock)) { return false; } - return new ModIDFinder(modID).modifies(itemStack); } @Override public NBTTagCompound write(NBTTagCompound nbtTags) { super.write(nbtTags); - nbtTags.setInteger("type", 3); nbtTags.setString("modID", modID); - return nbtTags; } @Override protected void read(NBTTagCompound nbtTags) { super.read(nbtTags); - modID = nbtTags.getString("modID"); } @Override public void write(TileNetworkList data) { data.add(3); - super.write(data); - data.add(modID); } @Override protected void read(ByteBuf dataStream) { super.read(dataStream); - modID = PacketHandler.readString(dataStream); } @@ -73,7 +66,6 @@ public class MModIDFilter extends MinerFilter implements IModIDFilter { filter.replaceStack = replaceStack; filter.requireStack = requireStack; filter.modID = modID; - return filter; } @@ -86,4 +78,4 @@ public class MModIDFilter extends MinerFilter implements IModIDFilter { public String getModID() { return modID; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/miner/MOreDictFilter.java b/src/main/java/mekanism/common/content/miner/MOreDictFilter.java index 1cb3959dc..8e6703d0e 100644 --- a/src/main/java/mekanism/common/content/miner/MOreDictFilter.java +++ b/src/main/java/mekanism/common/content/miner/MOreDictFilter.java @@ -1,8 +1,8 @@ package mekanism.common.content.miner; import io.netty.buffer.ByteBuf; -import mekanism.common.PacketHandler; import mekanism.api.TileNetworkList; +import mekanism.common.PacketHandler; import mekanism.common.content.filter.IOreDictFilter; import mekanism.common.content.transporter.Finder.OreDictFinder; import net.minecraft.item.ItemBlock; @@ -18,40 +18,33 @@ public class MOreDictFilter extends MinerFilter implements IOreDictFilter { if (itemStack.isEmpty() || !(itemStack.getItem() instanceof ItemBlock)) { return false; } - return new OreDictFinder(oreDictName).modifies(itemStack); } @Override public NBTTagCompound write(NBTTagCompound nbtTags) { super.write(nbtTags); - nbtTags.setInteger("type", 1); nbtTags.setString("oreDictName", oreDictName); - return nbtTags; } @Override protected void read(NBTTagCompound nbtTags) { super.read(nbtTags); - oreDictName = nbtTags.getString("oreDictName"); } @Override public void write(TileNetworkList data) { data.add(1); - super.write(data); - data.add(oreDictName); } @Override protected void read(ByteBuf dataStream) { super.read(dataStream); - oreDictName = PacketHandler.readString(dataStream); } @@ -64,8 +57,7 @@ public class MOreDictFilter extends MinerFilter implements IOreDictFilter { @Override public boolean equals(Object filter) { - return super.equals(filter) && filter instanceof MOreDictFilter && ((MOreDictFilter) filter).oreDictName - .equals(oreDictName); + return super.equals(filter) && filter instanceof MOreDictFilter && ((MOreDictFilter) filter).oreDictName.equals(oreDictName); } @Override @@ -74,7 +66,6 @@ public class MOreDictFilter extends MinerFilter implements IOreDictFilter { filter.replaceStack = replaceStack; filter.requireStack = requireStack; filter.oreDictName = oreDictName; - return filter; } diff --git a/src/main/java/mekanism/common/content/miner/MinerFilter.java b/src/main/java/mekanism/common/content/miner/MinerFilter.java index e12259cab..786d3bd77 100644 --- a/src/main/java/mekanism/common/content/miner/MinerFilter.java +++ b/src/main/java/mekanism/common/content/miner/MinerFilter.java @@ -16,9 +16,7 @@ public abstract class MinerFilter implements IFilter { public static MinerFilter readFromNBT(NBTTagCompound nbtTags) { int type = nbtTags.getInteger("type"); - MinerFilter filter = null; - if (type == 0) { filter = new MItemStackFilter(); } else if (type == 1) { @@ -28,17 +26,13 @@ public abstract class MinerFilter implements IFilter { } else if (type == 3) { filter = new MModIDFilter(); } - filter.read(nbtTags); - return filter; } public static MinerFilter readFromPacket(ByteBuf dataStream) { int type = dataStream.readInt(); - MinerFilter filter = null; - if (type == 0) { filter = new MItemStackFilter(); } else if (type == 1) { @@ -48,9 +42,7 @@ public abstract class MinerFilter implements IFilter { } else if (type == 3) { filter = new MModIDFilter(); } - filter.read(dataStream); - return filter; } @@ -58,17 +50,14 @@ public abstract class MinerFilter implements IFilter { public NBTTagCompound write(NBTTagCompound nbtTags) { nbtTags.setBoolean("requireStack", requireStack); - if (!replaceStack.isEmpty()) { nbtTags.setTag("replaceStack", replaceStack.writeToNBT(new NBTTagCompound())); } - return nbtTags; } protected void read(NBTTagCompound nbtTags) { requireStack = nbtTags.getBoolean("requireStack"); - if (nbtTags.hasKey("replaceStack")) { replaceStack = new ItemStack(nbtTags.getCompoundTag("replaceStack")); } @@ -76,7 +65,6 @@ public abstract class MinerFilter implements IFilter { public void write(TileNetworkList data) { data.add(requireStack); - if (!replaceStack.isEmpty()) { data.add(true); data.add(MekanismUtils.getID(replaceStack)); @@ -88,7 +76,6 @@ public abstract class MinerFilter implements IFilter { protected void read(ByteBuf dataStream) { requireStack = dataStream.readBoolean(); - if (dataStream.readBoolean()) { replaceStack = new ItemStack(Item.getItemById(dataStream.readInt()), 1, dataStream.readInt()); } else { @@ -100,4 +87,4 @@ public abstract class MinerFilter implements IFilter { public boolean equals(Object filter) { return filter instanceof MinerFilter; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/miner/ThreadMinerSearch.java b/src/main/java/mekanism/common/content/miner/ThreadMinerSearch.java index e999bbd59..594ced314 100644 --- a/src/main/java/mekanism/common/content/miner/ThreadMinerSearch.java +++ b/src/main/java/mekanism/common/content/miner/ThreadMinerSearch.java @@ -35,12 +35,10 @@ public class ThreadMinerSearch extends Thread { @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(); @@ -71,34 +69,28 @@ public class ThreadMinerSearch extends Thread { info.block = state.getBlock(); info.meta = state.getBlock().getMetaFromState(state); - if (info.block == null || info.block instanceof BlockLiquid || info.block instanceof IFluidBlock - || info.block.isAir(state, world, testPos)) { + if (info.block == null || info.block instanceof BlockLiquid || info.block instanceof IFluidBlock || info.block.isAir(state, world, testPos)) { //Skip air and liquids continue; } if (state.getBlockHardness(world, testPos) >= 0) { MinerFilter filterFound = null; - if (acceptedItems.containsKey(info)) { filterFound = acceptedItems.get(info); } else { ItemStack stack = new ItemStack(info.block, 1, info.meta); - if (tileEntity.isReplaceStack(stack)) { continue; } - for (MinerFilter filter : tileEntity.filters) { if (filter.canFilter(stack)) { filterFound = filter; break; } } - acceptedItems.put(info, filterFound); } - if (tileEntity.inverse == (filterFound == null)) { set(i, new Coord4D(x, y, z, world.provider.getDimension())); replaceMap.put(i, filterFound); @@ -115,9 +107,7 @@ public class ThreadMinerSearch extends Thread { public void set(int i, Coord4D location) { Chunk3D chunk = new Chunk3D(location); - oresToMine.computeIfAbsent(chunk, k -> new BitSet()); - oresToMine.get(chunk).set(i); } @@ -137,4 +127,4 @@ public class ThreadMinerSearch extends Thread { desc = s; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/tank/DynamicFluidTank.java b/src/main/java/mekanism/common/content/tank/DynamicFluidTank.java index dc02876fe..cc71971f0 100644 --- a/src/main/java/mekanism/common/content/tank/DynamicFluidTank.java +++ b/src/main/java/mekanism/common/content/tank/DynamicFluidTank.java @@ -32,64 +32,50 @@ public class DynamicFluidTank implements IFluidTank { if (resource == null || resource.getFluid() == null) { return 0; } - - if (dynamicTank.structure.fluidStored != null && !dynamicTank.structure.fluidStored - .isFluidEqual(resource)) { + if (dynamicTank.structure.fluidStored != null && !dynamicTank.structure.fluidStored.isFluidEqual(resource)) { return 0; } - if (dynamicTank.structure.fluidStored == null || dynamicTank.structure.fluidStored.getFluid() == null) { if (resource.amount <= getCapacity()) { if (doFill) { dynamicTank.structure.fluidStored = resource.copy(); - if (resource.amount > 0) { MekanismUtils.saveChunk(dynamicTank); updateValveData(); } } - return resource.amount; - } else { - if (doFill) { - dynamicTank.structure.fluidStored = resource.copy(); - dynamicTank.structure.fluidStored.amount = getCapacity(); - - if (getCapacity() > 0) { - MekanismUtils.saveChunk(dynamicTank); - updateValveData(); - } + } else if (doFill) { + dynamicTank.structure.fluidStored = resource.copy(); + dynamicTank.structure.fluidStored.amount = getCapacity(); + if (getCapacity() > 0) { + MekanismUtils.saveChunk(dynamicTank); + updateValveData(); } - - return getCapacity(); } + return getCapacity(); + } else if (resource.amount <= getNeeded()) { if (doFill) { dynamicTank.structure.fluidStored.amount += resource.amount; - if (resource.amount > 0) { MekanismUtils.saveChunk(dynamicTank); updateValveData(); } } - return resource.amount; } else { int prevNeeded = getNeeded(); - if (doFill) { dynamicTank.structure.fluidStored.amount = getCapacity(); - if (prevNeeded > 0) { MekanismUtils.saveChunk(dynamicTank); updateValveData(); } } - return prevNeeded; } } - return 0; } @@ -109,35 +95,27 @@ public class DynamicFluidTank implements IFluidTank { if (dynamicTank.structure.fluidStored == null || dynamicTank.structure.fluidStored.getFluid() == null) { 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.getFluid(), 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; } @@ -150,7 +128,6 @@ public class DynamicFluidTank implements IFluidTank { if (dynamicTank.structure != null) { return dynamicTank.structure.fluidStored.amount; } - return 0; } @@ -158,4 +135,4 @@ public class DynamicFluidTank implements IFluidTank { public FluidTankInfo getInfo() { return new FluidTankInfo(this); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/tank/SynchronizedTankData.java b/src/main/java/mekanism/common/content/tank/SynchronizedTankData.java index 100fb8532..a0b5af8fa 100644 --- a/src/main/java/mekanism/common/content/tank/SynchronizedTankData.java +++ b/src/main/java/mekanism/common/content/tank/SynchronizedTankData.java @@ -30,16 +30,13 @@ public class SynchronizedTankData extends SynchronizedData if ((fluidStored == null && prevFluid != null) || (fluidStored != null && prevFluid == null)) { return true; } - if (fluidStored != null) { int totalStage = (volHeight - 2) * (TankUpdateProtocol.FLUID_PER_TANK / 100); - int currentStage = (int) ((fluidStored.amount / (float) (volume * TankUpdateProtocol.FLUID_PER_TANK)) - * totalStage); + int currentStage = (int) ((fluidStored.amount / (float) (volume * TankUpdateProtocol.FLUID_PER_TANK)) * totalStage); boolean stageChanged = currentStage != prevFluidStage; prevFluidStage = currentStage; return (fluidStored.getFluid() != prevFluid.getFluid()) || stageChanged; } - return false; } @@ -70,8 +67,7 @@ public class SynchronizedTankData extends SynchronizedData @Override public boolean equals(Object obj) { - return obj instanceof ValveData && ((ValveData) obj).side == side && ((ValveData) obj).location - .equals(location); + return obj instanceof ValveData && ((ValveData) obj).side == side && ((ValveData) obj).location.equals(location); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/tank/TankCache.java b/src/main/java/mekanism/common/content/tank/TankCache.java index 675297fac..18e599142 100644 --- a/src/main/java/mekanism/common/content/tank/TankCache.java +++ b/src/main/java/mekanism/common/content/tank/TankCache.java @@ -34,19 +34,16 @@ public class TankCache extends MultiblockCache { @Override public void load(NBTTagCompound nbtTags) { editMode = ContainerEditMode.values()[nbtTags.getInteger("editMode")]; - NBTTagList tagList = nbtTags.getTagList("Items", NBT.TAG_COMPOUND); inventory = NonNullList.withSize(2, ItemStack.EMPTY); for (int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(tagCount); byte slotID = tagCompound.getByte("Slot"); - if (slotID >= 0 && slotID < 2) { inventory.set(slotID, new ItemStack(tagCompound)); } } - if (nbtTags.hasKey("cachedFluid")) { fluid = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("cachedFluid")); } @@ -55,9 +52,7 @@ public class TankCache extends MultiblockCache { @Override public void save(NBTTagCompound nbtTags) { nbtTags.setInteger("editMode", editMode.ordinal()); - NBTTagList tagList = new NBTTagList(); - for (int slotCount = 0; slotCount < 2; slotCount++) { if (!inventory.get(slotCount).isEmpty()) { NBTTagCompound tagCompound = new NBTTagCompound(); @@ -66,11 +61,9 @@ public class TankCache extends MultiblockCache { tagList.appendTag(tagCompound); } } - nbtTags.setTag("Items", tagList); - if (fluid != null) { nbtTags.setTag("cachedFluid", fluid.writeToNBT(new NBTTagCompound())); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/tank/TankUpdateProtocol.java b/src/main/java/mekanism/common/content/tank/TankUpdateProtocol.java index 42ba988d0..4795c82c5 100644 --- a/src/main/java/mekanism/common/content/tank/TankUpdateProtocol.java +++ b/src/main/java/mekanism/common/content/tank/TankUpdateProtocol.java @@ -28,8 +28,7 @@ public class TankUpdateProtocol extends UpdateProtocol { @Override protected boolean isValidFrame(int x, int y, int z) { IBlockState state = pointer.getWorld().getBlockState(new BlockPos(x, y, z)); - return state.getBlock() == MekanismBlocks.BasicBlock - && state.getValue(((BlockBasic) state.getBlock()).getTypeProperty()) == BasicBlockType.DYNAMIC_TANK; + return state.getBlock() == MekanismBlocks.BasicBlock && state.getValue(((BlockBasic) state.getBlock()).getTypeProperty()) == BasicBlockType.DYNAMIC_TANK; } @Override @@ -52,45 +51,35 @@ public class TankUpdateProtocol extends UpdateProtocol { MultiblockCache merge) { if (((TankCache) cache).fluid == null) { ((TankCache) cache).fluid = ((TankCache) merge).fluid; - } else if (((TankCache) merge).fluid != null && ((TankCache) cache).fluid - .isFluidEqual(((TankCache) merge).fluid)) { + } else if (((TankCache) merge).fluid != null && ((TankCache) cache).fluid.isFluidEqual(((TankCache) merge).fluid)) { ((TankCache) cache).fluid.amount += ((TankCache) merge).fluid.amount; } ((TankCache) cache).editMode = ((TankCache) merge).editMode; - - List rejects = StackUtils - .getMergeRejects(((TankCache) cache).inventory, ((TankCache) merge).inventory); - + List rejects = StackUtils.getMergeRejects(((TankCache) cache).inventory, ((TankCache) merge).inventory); if (!rejects.isEmpty()) { rejectedItems.addAll(rejects); } - StackUtils.merge(((TankCache) cache).inventory, ((TankCache) merge).inventory); } @Override protected void onFormed() { super.onFormed(); - if (structureFound.fluidStored != null) { - structureFound.fluidStored.amount = Math - .min(structureFound.fluidStored.amount, structureFound.volume * FLUID_PER_TANK); + structureFound.fluidStored.amount = Math.min(structureFound.fluidStored.amount, structureFound.volume * FLUID_PER_TANK); } } @Override - protected void onStructureCreated(SynchronizedTankData structure, int origX, int origY, int origZ, int xmin, - int xmax, int ymin, int ymax, int zmin, int zmax) { + protected void onStructureCreated(SynchronizedTankData structure, int origX, int origY, int origZ, int xmin, int xmax, int ymin, int ymax, int zmin, int zmax) { for (Coord4D obj : structure.locations) { if (obj.getTileEntity(pointer.getWorld()) instanceof TileEntityDynamicValve) { ValveData data = new ValveData(); data.location = obj; - data.side = getSide(obj, origX + xmin, origX + xmax, origY + ymin, origY + ymax, origZ + zmin, - origZ + zmax); - + data.side = getSide(obj, origX + xmin, origX + xmax, origY + ymin, origY + ymax, origZ + zmin, origZ + zmax); structure.valves.add(data); } } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/transporter/Finder.java b/src/main/java/mekanism/common/content/transporter/Finder.java index ec0a72ff5..9d556605a 100644 --- a/src/main/java/mekanism/common/content/transporter/Finder.java +++ b/src/main/java/mekanism/common/content/transporter/Finder.java @@ -36,7 +36,6 @@ public abstract class Finder { if (oreKeys.isEmpty()) { return false; } - for (String oreKey : oreKeys) { if (oreDictName.equals(oreKey) || oreDictName.equals("*")) { return true; @@ -54,7 +53,6 @@ public abstract class Finder { } } } - return false; } } @@ -69,8 +67,7 @@ public abstract class Finder { @Override public boolean modifies(ItemStack stack) { - return itemType.getHasSubtypes() ? StackUtils.equalsWildcard(itemType, stack) - : itemType.getItem() == stack.getItem(); + return itemType.getHasSubtypes() ? StackUtils.equalsWildcard(itemType, stack) : itemType.getItem() == stack.getItem(); } } @@ -87,9 +84,7 @@ public abstract class Finder { if (stack.isEmpty() || !(stack.getItem() instanceof ItemBlock)) { return false; } - - return Block.getBlockFromItem(stack.getItem()).getStateFromMeta(stack.getItemDamage()).getMaterial() - == materialType; + return Block.getBlockFromItem(stack.getItem()).getStateFromMeta(stack.getItemDamage()).getMaterial() == materialType; } } @@ -106,9 +101,7 @@ public abstract class Finder { if (stack.isEmpty()) { return false; } - String id = ItemRegistryUtils.getMod(stack); - if (modID.equals(id) || modID.equals("*")) { return true; } else if (modID.endsWith("*") && !modID.startsWith("*")) { @@ -118,8 +111,7 @@ public abstract class Finder { } else if (modID.startsWith("*") && modID.endsWith("*")) { return id.contains(modID.substring(1, modID.length() - 1)); } - return false; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/transporter/HashedItem.java b/src/main/java/mekanism/common/content/transporter/HashedItem.java index 11302d4c8..3edb464e2 100644 --- a/src/main/java/mekanism/common/content/transporter/HashedItem.java +++ b/src/main/java/mekanism/common/content/transporter/HashedItem.java @@ -4,13 +4,12 @@ import mekanism.common.util.InventoryUtils; import net.minecraft.item.ItemStack; /** - * A wrapper of an ItemStack which tests equality and hashes based on item type, damage and NBT - * data, ignoring stack size. - * - * @author aidancbrady + * A wrapper of an ItemStack which tests equality and hashes based on item type, damage and NBT data, ignoring stack size. * + * @author aidancbrady */ public class HashedItem { + private final ItemStack itemStack; private final int hashCode; @@ -25,12 +24,13 @@ public class HashedItem { @Override public boolean equals(Object obj) { - if(obj == this) return true; + if (obj == this) { + return true; + } if (obj instanceof HashedItem) { HashedItem other = (HashedItem) obj; return InventoryUtils.areItemsStackable(itemStack, other.itemStack); } - return false; } @@ -42,8 +42,9 @@ public class HashedItem { private int initHashCode() { int code = 1; code = 31 * code + itemStack.getItem().hashCode(); - if (itemStack.hasTagCompound()) + if (itemStack.hasTagCompound()) { code = 31 * code + itemStack.getTagCompound().hashCode(); + } code = 31 * code + itemStack.getItemDamage(); return code; } diff --git a/src/main/java/mekanism/common/content/transporter/InvStack.java b/src/main/java/mekanism/common/content/transporter/InvStack.java index fd952b0b8..353564eb9 100644 --- a/src/main/java/mekanism/common/content/transporter/InvStack.java +++ b/src/main/java/mekanism/common/content/transporter/InvStack.java @@ -2,6 +2,7 @@ package mekanism.common.content.transporter; import java.util.HashMap; import java.util.Map; +import java.util.Map.Entry; import mekanism.common.Mekanism; import mekanism.common.util.InventoryUtils; import mekanism.common.util.StackUtils; @@ -11,13 +12,10 @@ import net.minecraft.util.EnumFacing; import net.minecraftforge.items.IItemHandler; /** - * An InvStack attaches to an inventory and tracks a specific homogenous item in a variable amount - * of slots. An InvStack can either track the entirety of these slots or portions of their contents. - * Utility methods in this class allow for the strategic removal of clustered items from - * inventories. - * - * @author aidancbrady + * An InvStack attaches to an inventory and tracks a specific homogenous item in a variable amount of slots. An InvStack can either track the entirety of these slots or + * portions of their contents. Utility methods in this class allow for the strategic removal of clustered items from inventories. * + * @author aidancbrady */ public final class InvStack { @@ -28,9 +26,8 @@ public final class InvStack { private final EnumFacing side; /** - * A map associating the slot IDs in consideration to the amount of items in those slots we care - * about. Note that the associated item counts may not be the full count of items in the actual - * inventory slots. + * A map associating the slot IDs in consideration to the amount of items in those slots we care about. Note that the associated item counts may not be the full count + * of items in the actual inventory slots. */ private Map itemMap = new HashMap<>(); @@ -53,67 +50,58 @@ public final class InvStack { tileEntity = inv; side = facing; itemMap = idMap; - - for (Map.Entry entry : idMap.entrySet()) { + for (Entry entry : idMap.entrySet()) { appendStack(entry.getKey(), StackUtils.size(stack, entry.getValue())); } } /** * Gets an ItemStack of the defined type and total item count tracked by this InvStack. - * + * * @return the total ItemStack contents of this InvStack */ public ItemStack getStack() { if (itemType == null || itemCount == 0) { return ItemStack.EMPTY; } - return StackUtils.size(itemType.getStack(), itemCount); } /** * Appends a slot ID and specified ItemStack count to the tracked map of this InvStack. - * - * @param id - slot ID of items to track + * + * @param id - slot ID of items to track * @param stack - an ItemStack representing the count of items to track in the given slot ID */ public void appendStack(int id, ItemStack stack) { if (itemType == null) { itemType = new HashedItem(stack); } - itemMap.put(id, stack.getCount()); itemCount += stack.getCount(); } /** * Removes a specified amount of items from the parent inventory. - * + * * @param amount - the amount of items to remove */ public void use(int amount) { if (!InventoryUtils.assertItemHandler("InvStack", tileEntity, side)) { return; } - IItemHandler handler = InventoryUtils.getItemHandler(tileEntity, side); - - for (Map.Entry entry : itemMap.entrySet()) { + for (Entry entry : itemMap.entrySet()) { int toUse = Math.min(amount, entry.getValue()); ItemStack ret = handler.extractItem(entry.getKey(), toUse, false); boolean stackable = InventoryUtils.areItemsStackable(itemType.getStack(), ret); - if (!stackable || ret.getCount() != toUse) { // be loud if an InvStack's prediction doesn't line up - Mekanism.logger.warn("An inventory's returned content " + (!stackable ? "type" : "count") - + " does not line up with InvStack's prediction."); - + Mekanism.logger.warn("An inventory's returned content " + (!stackable ? "type" : "count") + " does not line up with InvStack's prediction."); Mekanism.logger.warn("InvStack item: " + itemType.getStack() + ", ret: " + ret); Mekanism.logger.warn("Tile: " + tileEntity + " " + tileEntity.getPos()); } amount -= toUse; - if (amount == 0) { return; } @@ -132,4 +120,4 @@ public final class InvStack { map.put(slotID, stack.getCount()); return map; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/transporter/PathfinderCache.java b/src/main/java/mekanism/common/content/transporter/PathfinderCache.java index a6574a05f..d0df7a958 100644 --- a/src/main/java/mekanism/common/content/transporter/PathfinderCache.java +++ b/src/main/java/mekanism/common/content/transporter/PathfinderCache.java @@ -17,17 +17,13 @@ public class PathfinderCache { public static List getCache(Coord4D start, Coord4D end, EnumSet sides) { List ret = null; - for (EnumFacing side : sides) { PathData data = new PathData(start, end, side); - List test = cachedPaths.get(data); - if (ret == null || (test != null && test.size() < ret.size())) { ret = test; } } - return ret; } @@ -44,17 +40,13 @@ public class PathfinderCache { public PathData(Coord4D s, Coord4D e, EnumFacing es) { startTransporter = s; - end = e; endSide = es; } @Override public boolean equals(Object obj) { - return obj instanceof PathData && - ((PathData) obj).startTransporter.equals(startTransporter) && - ((PathData) obj).end.equals(end) && - ((PathData) obj).endSide.equals(endSide); + return obj instanceof PathData && ((PathData) obj).startTransporter.equals(startTransporter) && ((PathData) obj).end.equals(end) && ((PathData) obj).endSide.equals(endSide); } @Override @@ -66,4 +58,4 @@ public class PathfinderCache { return code; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/transporter/StackSearcher.java b/src/main/java/mekanism/common/content/transporter/StackSearcher.java index cffe210cc..21e916a33 100644 --- a/src/main/java/mekanism/common/content/transporter/StackSearcher.java +++ b/src/main/java/mekanism/common/content/transporter/StackSearcher.java @@ -16,7 +16,6 @@ public class StackSearcher { public StackSearcher(TileEntity tile, EnumFacing direction) { tileEntity = tile; side = direction; - if (InventoryUtils.isItemHandler(tile, direction.getOpposite())) { slotCount = InventoryUtils.getItemHandler(tile, direction.getOpposite()).getSlots(); } @@ -26,35 +25,26 @@ public class StackSearcher { if (!InventoryUtils.assertItemHandler("StackSearcher", tileEntity, side.getOpposite())) { return null; } - IItemHandler inventory = InventoryUtils.getItemHandler(tileEntity, side.getOpposite()); - for (slotCount = slotCount - 1; slotCount >= 0; slotCount--) { ItemStack stack = inventory.extractItem(slotCount, amount, true); - if (!stack.isEmpty() && id.modifies(stack)) { return new InvStack(tileEntity, slotCount, stack, side.getOpposite()); } } - return null; } public InvStack takeDefinedItem(ItemStack type, int min, int max) { InvStack ret = new InvStack(tileEntity, side.getOpposite()); - if (!InventoryUtils.assertItemHandler("StackSearcher", tileEntity, side.getOpposite())) { return null; } - IItemHandler inventory = InventoryUtils.getItemHandler(tileEntity, side.getOpposite()); - for (slotCount = slotCount - 1; slotCount >= 0; slotCount--) { ItemStack stack = inventory.extractItem(slotCount, max, true); - if (!stack.isEmpty() && StackUtils.equalsWildcardWithNBT(stack, type)) { int current = !ret.getStack().isEmpty() ? ret.getStack().getCount() : 0; - if (current + stack.getCount() <= max) { ret.appendStack(slotCount, stack.copy()); } else { @@ -62,7 +52,6 @@ public class StackSearcher { copy.setCount(max - current); ret.appendStack(slotCount, copy); } - if (!ret.getStack().isEmpty() && ret.getStack().getCount() == max) { return ret; } @@ -72,11 +61,10 @@ public class StackSearcher { if (!ret.getStack().isEmpty() && ret.getStack().getCount() >= min) { return ret; } - return null; } public int getSlotCount() { return slotCount; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/transporter/TItemStackFilter.java b/src/main/java/mekanism/common/content/transporter/TItemStackFilter.java index b7c8ae5ae..76ef4675a 100644 --- a/src/main/java/mekanism/common/content/transporter/TItemStackFilter.java +++ b/src/main/java/mekanism/common/content/transporter/TItemStackFilter.java @@ -22,17 +22,16 @@ public class TItemStackFilter extends TransporterFilter implements IItemStackFil @Override public boolean canFilter(ItemStack itemStack, boolean strict) { return super.canFilter(itemStack, strict) && - !(strict && sizeMode && (max == 0 || itemStack.getCount() < min)) && - ItemHandlerHelper.canItemStacksStackRelaxed(itemType, itemStack); + !(strict && sizeMode && (max == 0 || itemStack.getCount() < min)) && + ItemHandlerHelper.canItemStacksStackRelaxed(itemType, itemStack); } @Override public InvStack getStackFromInventory(StackSearcher searcher, boolean singleItem) { if (sizeMode && !singleItem) { return searcher.takeDefinedItem(itemType, min, max); - } else { - return super.getStackFromInventory(searcher, singleItem); } + return super.getStackFromInventory(searcher, singleItem); } public Finder getFinder() { @@ -42,7 +41,6 @@ public class TItemStackFilter extends TransporterFilter implements IItemStackFil @Override public void write(NBTTagCompound nbtTags) { super.write(nbtTags); - nbtTags.setInteger("type", 0); nbtTags.setBoolean("sizeMode", sizeMode); nbtTags.setInteger("min", min); @@ -53,11 +51,9 @@ public class TItemStackFilter extends TransporterFilter implements IItemStackFil @Override protected void read(NBTTagCompound nbtTags) { super.read(nbtTags); - sizeMode = nbtTags.getBoolean("sizeMode"); min = nbtTags.getInteger("min"); max = nbtTags.getInteger("max"); - itemType = new ItemStack(nbtTags); } @@ -79,11 +75,9 @@ public class TItemStackFilter extends TransporterFilter implements IItemStackFil @Override protected void read(ByteBuf dataStream) { super.read(dataStream); - sizeMode = dataStream.readBoolean(); min = dataStream.readInt(); max = dataStream.readInt(); - itemType = new ItemStack(Item.getItemById(dataStream.readInt()), dataStream.readInt(), dataStream.readInt()); } @@ -102,10 +96,8 @@ public class TItemStackFilter extends TransporterFilter implements IItemStackFil @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; + 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 @@ -117,7 +109,6 @@ public class TItemStackFilter extends TransporterFilter implements IItemStackFil filter.sizeMode = sizeMode; filter.min = min; filter.max = max; - return filter; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/transporter/TMaterialFilter.java b/src/main/java/mekanism/common/content/transporter/TMaterialFilter.java index ba299be0c..f4d9a0cbd 100644 --- a/src/main/java/mekanism/common/content/transporter/TMaterialFilter.java +++ b/src/main/java/mekanism/common/content/transporter/TMaterialFilter.java @@ -24,8 +24,8 @@ public class TMaterialFilter extends TransporterFilter implements IMaterialFilte @Override public boolean canFilter(ItemStack itemStack, boolean strict) { return super.canFilter(itemStack, strict) && - (itemStack.getItem() instanceof ItemBlock) && - new MaterialFinder(getMaterial()).modifies(itemStack); + (itemStack.getItem() instanceof ItemBlock) && + new MaterialFinder(getMaterial()).modifies(itemStack); } @Override @@ -36,7 +36,6 @@ public class TMaterialFilter extends TransporterFilter implements IMaterialFilte @Override public void write(NBTTagCompound nbtTags) { super.write(nbtTags); - nbtTags.setInteger("type", 2); materialItem.writeToNBT(nbtTags); } @@ -44,7 +43,6 @@ public class TMaterialFilter extends TransporterFilter implements IMaterialFilte @Override protected void read(NBTTagCompound nbtTags) { super.read(nbtTags); - materialItem = new ItemStack(nbtTags); } @@ -53,7 +51,6 @@ public class TMaterialFilter extends TransporterFilter implements IMaterialFilte data.add(2); super.write(data); - data.add(MekanismUtils.getID(materialItem)); data.add(materialItem.getCount()); data.add(materialItem.getItemDamage()); @@ -62,9 +59,7 @@ public class TMaterialFilter extends TransporterFilter implements IMaterialFilte @Override protected void read(ByteBuf dataStream) { super.read(dataStream); - - materialItem = new ItemStack(Item.getItemById(dataStream.readInt()), dataStream.readInt(), - dataStream.readInt()); + materialItem = new ItemStack(Item.getItemById(dataStream.readInt()), dataStream.readInt(), dataStream.readInt()); } @Override @@ -78,8 +73,7 @@ public class TMaterialFilter extends TransporterFilter implements IMaterialFilte @Override public boolean equals(Object filter) { - return super.equals(filter) && filter instanceof TMaterialFilter && ((TMaterialFilter) filter).materialItem - .isItemEqual(materialItem); + return super.equals(filter) && filter instanceof TMaterialFilter && ((TMaterialFilter) filter).materialItem.isItemEqual(materialItem); } @Override @@ -88,7 +82,6 @@ public class TMaterialFilter extends TransporterFilter implements IMaterialFilte filter.allowDefault = allowDefault; filter.color = color; filter.materialItem = materialItem; - return filter; } @@ -101,4 +94,4 @@ public class TMaterialFilter extends TransporterFilter implements IMaterialFilte public void setMaterialItem(ItemStack stack) { materialItem = stack; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/transporter/TModIDFilter.java b/src/main/java/mekanism/common/content/transporter/TModIDFilter.java index ef54b85e6..884d3f7f1 100644 --- a/src/main/java/mekanism/common/content/transporter/TModIDFilter.java +++ b/src/main/java/mekanism/common/content/transporter/TModIDFilter.java @@ -1,8 +1,8 @@ package mekanism.common.content.transporter; import io.netty.buffer.ByteBuf; -import mekanism.common.PacketHandler; import mekanism.api.TileNetworkList; +import mekanism.common.PacketHandler; import mekanism.common.content.filter.IModIDFilter; import mekanism.common.content.transporter.Finder.ModIDFinder; import net.minecraft.item.ItemStack; @@ -14,8 +14,7 @@ public class TModIDFilter extends TransporterFilter implements IModIDFilter { @Override public boolean canFilter(ItemStack itemStack, boolean strict) { - return super.canFilter(itemStack, strict) && - new ModIDFinder(modID).modifies(itemStack); + return super.canFilter(itemStack, strict) && new ModIDFinder(modID).modifies(itemStack); } @Override @@ -26,7 +25,6 @@ public class TModIDFilter extends TransporterFilter implements IModIDFilter { @Override public void write(NBTTagCompound nbtTags) { super.write(nbtTags); - nbtTags.setInteger("type", 3); nbtTags.setString("modID", modID); } @@ -34,23 +32,19 @@ public class TModIDFilter extends TransporterFilter implements IModIDFilter { @Override protected void read(NBTTagCompound nbtTags) { super.read(nbtTags); - modID = nbtTags.getString("modID"); } @Override public void write(TileNetworkList data) { data.add(3); - super.write(data); - data.add(modID); } @Override protected void read(ByteBuf dataStream) { super.read(dataStream); - modID = PacketHandler.readString(dataStream); } @@ -73,7 +67,6 @@ public class TModIDFilter extends TransporterFilter implements IModIDFilter { filter.allowDefault = allowDefault; filter.color = color; filter.modID = modID; - return filter; } @@ -86,4 +79,4 @@ public class TModIDFilter extends TransporterFilter implements IModIDFilter { public String getModID() { return modID; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/transporter/TOreDictFilter.java b/src/main/java/mekanism/common/content/transporter/TOreDictFilter.java index 4c80d3f4b..f1125cf66 100644 --- a/src/main/java/mekanism/common/content/transporter/TOreDictFilter.java +++ b/src/main/java/mekanism/common/content/transporter/TOreDictFilter.java @@ -1,8 +1,8 @@ package mekanism.common.content.transporter; import io.netty.buffer.ByteBuf; -import mekanism.common.PacketHandler; import mekanism.api.TileNetworkList; +import mekanism.common.PacketHandler; import mekanism.common.content.filter.IOreDictFilter; import mekanism.common.content.transporter.Finder.OreDictFinder; import net.minecraft.item.ItemStack; @@ -14,8 +14,7 @@ public class TOreDictFilter extends TransporterFilter implements IOreDictFilter @Override public boolean canFilter(ItemStack itemStack, boolean strict) { - return super.canFilter(itemStack, strict) && - new OreDictFinder(oreDictName).modifies(itemStack); + return super.canFilter(itemStack, strict) && new OreDictFinder(oreDictName).modifies(itemStack); } @Override @@ -26,7 +25,6 @@ public class TOreDictFilter extends TransporterFilter implements IOreDictFilter @Override public void write(NBTTagCompound nbtTags) { super.write(nbtTags); - nbtTags.setInteger("type", 1); nbtTags.setString("oreDictName", oreDictName); } @@ -34,23 +32,19 @@ public class TOreDictFilter extends TransporterFilter implements IOreDictFilter @Override protected void read(NBTTagCompound nbtTags) { super.read(nbtTags); - oreDictName = nbtTags.getString("oreDictName"); } @Override public void write(TileNetworkList data) { data.add(1); - super.write(data); - data.add(oreDictName); } @Override protected void read(ByteBuf dataStream) { super.read(dataStream); - oreDictName = PacketHandler.readString(dataStream); } @@ -64,8 +58,7 @@ public class TOreDictFilter extends TransporterFilter implements IOreDictFilter @Override public boolean equals(Object filter) { - return super.equals(filter) && filter instanceof TOreDictFilter && ((TOreDictFilter) filter).oreDictName - .equals(oreDictName); + return super.equals(filter) && filter instanceof TOreDictFilter && ((TOreDictFilter) filter).oreDictName.equals(oreDictName); } @Override @@ -74,7 +67,6 @@ public class TOreDictFilter extends TransporterFilter implements IOreDictFilter filter.allowDefault = allowDefault; filter.color = color; filter.oreDictName = oreDictName; - return filter; } @@ -87,4 +79,4 @@ public class TOreDictFilter extends TransporterFilter implements IOreDictFilter public String getOreDictName() { return oreDictName; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/transporter/TransitRequest.java b/src/main/java/mekanism/common/content/transporter/TransitRequest.java index a6d39322b..9113a3d05 100644 --- a/src/main/java/mekanism/common/content/transporter/TransitRequest.java +++ b/src/main/java/mekanism/common/content/transporter/TransitRequest.java @@ -2,7 +2,6 @@ package mekanism.common.content.transporter; import java.util.HashMap; import java.util.Map; -import org.apache.commons.lang3.tuple.Pair; import mekanism.common.content.transporter.Finder.FirstFinder; import mekanism.common.util.InventoryUtils; import mekanism.common.util.StackUtils; @@ -10,12 +9,12 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraftforge.items.IItemHandler; +import org.apache.commons.lang3.tuple.Pair; public class TransitRequest { /** - * Complicated map- associates item types with both total available item count and slot IDs and - * available item amounts for each slot. + * Complicated map- associates item types with both total available item count and slot IDs and available item amounts for each slot. */ private Map>> itemMap = new HashMap<>(); @@ -34,11 +33,9 @@ public class TransitRequest { } /** - * Creates a TransitRequest based on a full inspection of an entire specified inventory from a given - * side. The algorithm will use the specified Finder to ensure the resulting map will only capture - * desired items. The amount of each item type present in the resulting item type will cap at the - * given 'amount' parameter. - * + * Creates a TransitRequest based on a full inspection of an entire specified inventory from a given side. The algorithm will use the specified Finder to ensure the + * resulting map will only capture desired items. The amount of each item type present in the resulting item type will cap at the given 'amount' parameter. + * * @param side - the side from an adjacent connected inventory, *not* the inventory itself. */ public static TransitRequest buildInventoryMap(TileEntity tile, EnumFacing side, int amount, Finder finder) { @@ -60,8 +57,9 @@ public class TransitRequest { HashedItem hashed = new HashedItem(stack); int currentCount = itemCountMap.getOrDefault(hashed, -1); int toUse = currentCount != -1 ? Math.min(stack.getCount(), amount - currentCount) : stack.getCount(); - if (toUse == 0) + if (toUse == 0) { continue; // continue if we don't need anymore of this item type + } ret.addItem(StackUtils.size(stack, toUse), i); if (currentCount != -1) { @@ -107,17 +105,14 @@ public class TransitRequest { return true; } } - return false; } /** - * A TransitResponse contains information regarding the partial ItemStacks which were allowed entry - * into a destination inventory. Note that a TransitResponse should only contain a single item type, - * although it may be spread out across multiple slots. - * - * @author aidancbrady + * A TransitResponse contains information regarding the partial ItemStacks which were allowed entry into a destination inventory. Note that a TransitResponse should + * only contain a single item type, although it may be spread out across multiple slots. * + * @author aidancbrady */ public static class TransitResponse { @@ -127,7 +122,8 @@ public class TransitRequest { private Map idMap = new HashMap<>(); private ItemStack toSend = ItemStack.EMPTY; - private TransitResponse() {} + private TransitResponse() { + } public TransitResponse(ItemStack i, Map slots) { toSend = i; @@ -138,8 +134,9 @@ public class TransitRequest { int toUse = Math.min(amount, entry.getValue()); idMap.put(entry.getKey(), toUse); amount -= toUse; - if (amount == 0) + if (amount == 0) { break; + } } } @@ -159,4 +156,4 @@ public class TransitRequest { return new InvStack(tile, toSend, idMap, side); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/transporter/TransporterFilter.java b/src/main/java/mekanism/common/content/transporter/TransporterFilter.java index 9398b02f0..f2498ca69 100644 --- a/src/main/java/mekanism/common/content/transporter/TransporterFilter.java +++ b/src/main/java/mekanism/common/content/transporter/TransporterFilter.java @@ -22,9 +22,7 @@ public abstract class TransporterFilter implements IFilter { public static TransporterFilter readFromNBT(NBTTagCompound nbtTags) { int type = nbtTags.getInteger("type"); - TransporterFilter filter = null; - if (type == 0) { filter = new TItemStackFilter(); } else if (type == 1) { @@ -34,17 +32,13 @@ public abstract class TransporterFilter implements IFilter { } else if (type == 3) { filter = new TModIDFilter(); } - filter.read(nbtTags); - return filter; } public static TransporterFilter readFromPacket(ByteBuf dataStream) { int type = dataStream.readInt(); - TransporterFilter filter = null; - if (type == 0) { filter = new TItemStackFilter(); } else if (type == 1) { @@ -54,9 +48,7 @@ public abstract class TransporterFilter implements IFilter { } else if (type == 3) { filter = new TModIDFilter(); } - filter.read(dataStream); - return filter; } @@ -72,7 +64,6 @@ public abstract class TransporterFilter implements IFilter { public void write(NBTTagCompound nbtTags) { nbtTags.setBoolean("allowDefault", allowDefault); - if (color != null) { nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color)); } @@ -80,7 +71,6 @@ public abstract class TransporterFilter implements IFilter { protected void read(NBTTagCompound nbtTags) { allowDefault = nbtTags.getBoolean("allowDefault"); - if (nbtTags.hasKey("color")) { color = TransporterUtils.colors.get(nbtTags.getInteger("color")); } @@ -88,7 +78,6 @@ public abstract class TransporterFilter implements IFilter { public void write(TileNetworkList data) { data.add(allowDefault); - if (color != null) { data.add(TransporterUtils.colors.indexOf(color)); } else { @@ -98,9 +87,7 @@ public abstract class TransporterFilter implements IFilter { protected void read(ByteBuf dataStream) { allowDefault = dataStream.readBoolean(); - int c = dataStream.readInt(); - if (c != -1) { color = TransporterUtils.colors.get(c); } else { @@ -119,4 +106,4 @@ public abstract class TransporterFilter implements IFilter { public boolean equals(Object filter) { return filter instanceof TransporterFilter && ((TransporterFilter) filter).color == color; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/transporter/TransporterManager.java b/src/main/java/mekanism/common/content/transporter/TransporterManager.java index 0928b2edb..cbb66dbf8 100644 --- a/src/main/java/mekanism/common/content/transporter/TransporterManager.java +++ b/src/main/java/mekanism/common/content/transporter/TransporterManager.java @@ -6,7 +6,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import org.apache.commons.lang3.tuple.Pair; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.common.Mekanism; @@ -21,6 +20,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.NonNullList; import net.minecraftforge.items.IItemHandler; +import org.apache.commons.lang3.tuple.Pair; public class TransporterManager { @@ -33,7 +33,6 @@ public class TransporterManager { public static void add(TransporterStack stack) { Set set = new HashSet<>(); set.add(stack); - if (flowingStacks.get(stack.getDest()) == null) { flowingStacks.put(stack.getDest(), set); } else { @@ -49,7 +48,6 @@ public class TransporterManager { public static List getStacksToDest(Coord4D dest) { List ret = new ArrayList<>(); - if (flowingStacks.containsKey(dest)) { for (TransporterStack stack : flowingStacks.get(dest)) { if (stack != null && stack.pathType != Path.NONE && stack.hasPath()) { @@ -59,7 +57,6 @@ public class TransporterManager { } } } - return ret; } @@ -120,7 +117,6 @@ public class TransporterManager { stack.setCount(0); } } - return stack; } @@ -132,24 +128,20 @@ public class TransporterManager { if (returned.isEmpty() || returned.getCount() == 0) { return stack; } - return StackUtils.size(stack, stack.getCount() - returned.getCount()); } /** * @return TransitResponse of expected items to use */ - public static TransitResponse getPredictedInsert(TileEntity tileEntity, EnumColor color, TransitRequest request, - EnumFacing side) { + public static TransitResponse getPredictedInsert(TileEntity tileEntity, EnumColor color, TransitRequest request, EnumFacing side) { // If the TE in question implements the mekanism interface, check that the color matches and bail // fast if it doesn't if (tileEntity instanceof ISideConfiguration) { ISideConfiguration config = (ISideConfiguration) tileEntity; EnumFacing tileSide = config.getOrientation(); - EnumColor configColor = config.getEjector() - .getInputColor(MekanismUtils.getBaseOrientation(side, tileSide).getOpposite()); - + EnumColor configColor = config.getEjector().getInputColor(MekanismUtils.getBaseOrientation(side, tileSide).getOpposite()); if (config.getEjector().hasStrictInput() && configColor != null && configColor != color) { return TransitResponse.EMPTY; } @@ -167,7 +159,6 @@ public class TransporterManager { Mekanism.logger.error("Failed to predict insert; not an IItemHandler: {}", tileEntity); return TransitResponse.EMPTY; } - InventoryCopy invCopy = new InventoryCopy(handler); // For each of the in-flight stacks, simulate their insert into the tile entity. Note that the invCopy @@ -197,7 +188,6 @@ public class TransporterManager { toSend.setCount(toSend.getCount() - leftovers.getCount()); return new TransitResponse(toSend, requestEntry.getValue().getRight()); } - return TransitResponse.EMPTY; } @@ -212,4 +202,4 @@ public class TransporterManager { } } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/transporter/TransporterPathfinder.java b/src/main/java/mekanism/common/content/transporter/TransporterPathfinder.java index 7ed09ea17..d02b74471 100644 --- a/src/main/java/mekanism/common/content/transporter/TransporterPathfinder.java +++ b/src/main/java/mekanism/common/content/transporter/TransporterPathfinder.java @@ -9,7 +9,6 @@ import java.util.List; import java.util.Map; import java.util.Set; import javax.annotation.Nonnull; -import org.apache.commons.lang3.tuple.Pair; import mekanism.api.Coord4D; import mekanism.common.base.ILogisticalTransporter; import mekanism.common.capabilities.Capabilities; @@ -25,18 +24,16 @@ import mekanism.common.util.InventoryUtils; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; +import org.apache.commons.lang3.tuple.Pair; public final class TransporterPathfinder { - public static List getPaths(ILogisticalTransporter start, TransporterStack stack, - TransitRequest request, int min) { + public static List getPaths(ILogisticalTransporter start, TransporterStack stack, TransitRequest request, int min) { List paths = new ArrayList<>(); InventoryNetwork network = start.getTransmitterNetwork(); - if (network == null) { return paths; } - List acceptors = network.calculateAcceptors(request, stack); for (AcceptorData entry : acceptors) { @@ -46,76 +43,57 @@ public final class TransporterPathfinder { return InventoryUtils.canInsert(tile, stack.color, entry.response.getStack(), dir, false); } }; - Destination d = getPath(checker, entry.sides, start, entry.location, stack, entry.response, min); - if (d != null) { paths.add(d); } } - Collections.sort(paths); - return paths; } public static boolean checkPath(World world, List path, TransporterStack stack) { for (int i = path.size() - 1; i > 0; i--) { TileEntity tile = path.get(i).getTileEntity(world); - if (!CapabilityUtils.hasCapability(tile, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, null)) { return false; } - - ILogisticalTransporter transporter = CapabilityUtils - .getCapability(tile, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, null); - + ILogisticalTransporter transporter = CapabilityUtils.getCapability(tile, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, null); if (transporter == null || (transporter.getColor() != null && transporter.getColor() != stack.color)) { return false; } } - return true; } - public static Destination getPath(DestChecker checker, EnumSet sides, ILogisticalTransporter start, - Coord4D dest, TransporterStack stack, TransitResponse response, int min) { + public static Destination getPath(DestChecker checker, EnumSet sides, ILogisticalTransporter start, Coord4D dest, TransporterStack stack, + TransitResponse response, int min) { if (response.getStack().getCount() >= min) { List test = PathfinderCache.getCache(start.coord(), dest, sides); - if (test != null && checkPath(start.world(), test, stack)) { return new Destination(test, false, response, 0).calculateScore(start.world()); } Pathfinder p = new Pathfinder(checker, start.world(), dest, start.coord(), stack); - if (p.getPath().size() >= 2) { PathfinderCache.cachedPaths.put(new PathData(start.coord(), dest, p.side), p.getPath()); - return new Destination(p.getPath(), false, response, p.finalScore); } } - return null; } - public static Destination getNewBasePath(ILogisticalTransporter start, TransporterStack stack, - TransitRequest request, int min) { + public static Destination getNewBasePath(ILogisticalTransporter start, TransporterStack stack, TransitRequest request, int min) { List paths = getPaths(start, stack, request, min); - if (paths.isEmpty()) { return null; } - return paths.get(0); } - public static Destination getNewRRPath(ILogisticalTransporter start, TransporterStack stack, TransitRequest request, - TileEntityLogisticalSorter outputter, int min) { + public static Destination getNewRRPath(ILogisticalTransporter start, TransporterStack stack, TransitRequest request, TileEntityLogisticalSorter outputter, int min) { List paths = getPaths(start, stack, request, min); - Map destPaths = new HashMap<>(); - for (Destination d : paths) { if (destPaths.get(d.path.get(0)) == null || destPaths.get(d.path.get(0)).path.size() < d.path.size()) { destPaths.put(d.path.get(0), d); @@ -123,15 +101,11 @@ public final class TransporterPathfinder { } List dests = new ArrayList<>(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) { @@ -146,7 +120,6 @@ public final class TransporterPathfinder { if (closest == null) { return null; } - return closest; } @@ -158,10 +131,8 @@ public final class TransporterPathfinder { return InventoryUtils.canInsert(tile, stack.color, stack.itemStack, side, true); } }; - Pathfinder p = new Pathfinder(checker, start.world(), stack.homeLocation, start.coord(), stack); List path = p.getPath(); - if (path.size() >= 2) { return Pair.of(path, Path.HOME); } else { @@ -171,11 +142,9 @@ public final class TransporterPathfinder { IdlePath d = new IdlePath(start.world(), start.coord(), stack); Destination dest = d.find(); - if (dest == null) { return null; } - return Pair.of(dest.path, dest.pathType); } @@ -196,46 +165,35 @@ public final class TransporterPathfinder { public Destination find() { ArrayList ret = new ArrayList<>(); ret.add(start); - if (transportStack.idleDir == null) { EnumFacing newSide = findSide(); - if (newSide == null) { return null; } - transportStack.idleDir = newSide; loopSide(ret, newSide); - return new Destination(ret, true, null, 0).setPathType(Path.NONE); } else { TileEntity tile = start.offset(transportStack.idleDir).getTileEntity(worldObj); - if (transportStack.canInsertToTransporter(tile, transportStack.idleDir)) { loopSide(ret, transportStack.idleDir); - return new Destination(ret, true, null, 0).setPathType(Path.NONE); } else { TransitRequest request = TransitRequest.getFromTransport(transportStack); - Destination newPath = TransporterPathfinder.getNewBasePath(CapabilityUtils - .getCapability(start.getTileEntity(worldObj), Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, - null), transportStack, request, 0); + Destination newPath = TransporterPathfinder.getNewBasePath(CapabilityUtils.getCapability(start.getTileEntity(worldObj), + Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, null), transportStack, request, 0); if (newPath != null && newPath.response != null) { transportStack.idleDir = null; newPath.setPathType(Path.DEST); - return newPath; } else { EnumFacing newSide = findSide(); - if (newSide == null) { return null; } - transportStack.idleDir = newSide; loopSide(ret, newSide); - return new Destination(ret, true, null, 0).setPathType(Path.NONE); } } @@ -244,16 +202,13 @@ public final class TransporterPathfinder { private void loopSide(List list, EnumFacing side) { int count = 1; - while (true) { Coord4D coord = start.offset(side, count); - - if (transportStack.canInsertToTransporter(coord.getTileEntity(worldObj), side)) { - list.add(coord); - count++; - } else { + if (!transportStack.canInsertToTransporter(coord.getTileEntity(worldObj), side)) { break; } + list.add(coord); + count++; } } @@ -261,7 +216,6 @@ public final class TransporterPathfinder { if (transportStack.idleDir == null) { for (EnumFacing side : EnumFacing.VALUES) { TileEntity tile = start.offset(side).getTileEntity(worldObj); - if (transportStack.canInsertToTransporter(tile, side)) { return side; } @@ -269,19 +223,15 @@ public final class TransporterPathfinder { } else { for (EnumFacing side : EnumSet.complementOf(EnumSet.of(transportStack.idleDir.getOpposite()))) { TileEntity tile = start.offset(side).getTileEntity(worldObj); - if (transportStack.canInsertToTransporter(tile, side)) { return side; } } - TileEntity tile = start.offset(transportStack.idleDir.getOpposite()).getTileEntity(worldObj); - if (transportStack.canInsertToTransporter(tile, transportStack.idleDir.getOpposite())) { return transportStack.idleDir.getOpposite(); } } - return null; } } @@ -295,11 +245,9 @@ public final class TransporterPathfinder { public Destination(List list, boolean inv, TransitResponse ret, double gScore) { path = new ArrayList<>(list); - if (inv) { Collections.reverse(path); } - response = ret; score = gScore; } @@ -311,16 +259,12 @@ public final class TransporterPathfinder { public Destination calculateScore(World world) { score = 0; - for (Coord4D location : path) { TileEntity tile = location.getTileEntity(world); - if (CapabilityUtils.hasCapability(tile, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, null)) { - score += CapabilityUtils.getCapability(tile, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, null) - .getCost(); + score += CapabilityUtils.getCapability(tile, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, null).getCost(); } } - return this; } @@ -342,9 +286,8 @@ public final class TransporterPathfinder { return -1; } else if (score > dest.score) { return 1; - } else { - return path.size() - dest.path.size(); } + return path.size() - dest.path.size(); } } @@ -372,8 +315,7 @@ public final class TransporterPathfinder { 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; @@ -404,14 +346,11 @@ public final class TransporterPathfinder { for (EnumFacing direction : EnumFacing.VALUES) { Coord4D neighbor = start.offset(direction); - - if (!transportStack.canInsertToTransporter(neighbor.getTileEntity(worldObj), direction) && ( - !neighbor.equals(finalNode) || !destChecker - .isValid(transportStack, direction, neighbor.getTileEntity(worldObj)))) { + if (!transportStack.canInsertToTransporter(neighbor.getTileEntity(worldObj), direction) && + (!neighbor.equals(finalNode) || !destChecker.isValid(transportStack, direction, neighbor.getTileEntity(worldObj)))) { blockCount++; } } - if (blockCount >= 6) { return false; } @@ -420,18 +359,15 @@ public final class TransporterPathfinder { ArrayList directionsToCheck = new ArrayList<>(); Coord4D[] neighbors = new Coord4D[EnumFacing.VALUES.length]; TileEntity[] neighborEntities = new TileEntity[neighbors.length]; - while (!openSet.isEmpty()) { Coord4D currentNode = null; double lowestFScore = 0; - for (Coord4D node : openSet) { if (currentNode == null || fScore.get(node) < lowestFScore) { currentNode = node; lowestFScore = fScore.get(node); } } - if (currentNode == null || start.distanceTo(currentNode) > maxSearchDistance) { break; } @@ -442,9 +378,7 @@ public final class TransporterPathfinder { TileEntity currentNodeTile = currentNode.getTileEntity(worldObj); ILogisticalTransporter currentNodeTransporter = null; if (currentNodeTile.hasCapability(Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, null)) { - currentNodeTransporter = - CapabilityUtils - .getCapability(currentNodeTile, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, null); + currentNodeTransporter = CapabilityUtils.getCapability(currentNodeTile, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, null); } directionsToCheck.clear(); @@ -453,21 +387,17 @@ public final class TransporterPathfinder { neighbors[direction.ordinal()] = neighbor; TileEntity neighborEntity = neighbor.getTileEntity(worldObj); neighborEntities[direction.ordinal()] = neighborEntity; - if ((currentNodeTransporter == null || currentNodeTransporter.canEmitTo(neighborEntity, direction)) || - (neighbor.equals(finalNode) && destChecker - .isValid(transportStack, direction, neighborEntities[direction.ordinal()]))) { + if (currentNodeTransporter == null || currentNodeTransporter.canEmitTo(neighborEntity, direction) || + (neighbor.equals(finalNode) && destChecker.isValid(transportStack, direction, neighborEntities[direction.ordinal()]))) { directionsToCheck.add(direction); } } for (EnumFacing direction : directionsToCheck) { Coord4D neighbor = neighbors[direction.ordinal()]; - if (transportStack.canInsertToTransporter(neighborEntities[direction.ordinal()], direction)) { TileEntity tile = neighborEntities[direction.ordinal()]; - double tentativeG = gScore.get(currentNode) + CapabilityUtils - .getCapability(tile, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, - direction.getOpposite()).getCost(); + double tentativeG = gScore.get(currentNode) + CapabilityUtils.getCapability(tile, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, direction.getOpposite()).getCost(); if (closedSet.contains(neighbor)) { if (tentativeG >= gScore.get(neighbor)) { @@ -481,29 +411,23 @@ public final class TransporterPathfinder { fScore.put(neighbor, gScore.get(neighbor) + getEstimate(neighbor, finalNode)); openSet.add(neighbor); } - } else if (neighbor.equals(finalNode) && destChecker - .isValid(transportStack, direction, neighborEntities[direction.ordinal()])) { + } else if (neighbor.equals(finalNode) && destChecker.isValid(transportStack, direction, neighborEntities[direction.ordinal()])) { side = direction; results = reconstructPath(navMap, currentNode); return true; } } } - return false; } private ArrayList reconstructPath(HashMap naviMap, Coord4D currentNode) { ArrayList path = new ArrayList<>(); - path.add(currentNode); - if (naviMap.containsKey(currentNode)) { path.addAll(reconstructPath(naviMap, naviMap.get(currentNode))); } - finalScore = gScore.get(currentNode) + currentNode.distanceTo(finalNode); - return path; } @@ -511,7 +435,6 @@ public final class TransporterPathfinder { ArrayList path = new ArrayList<>(); path.add(finalNode); path.addAll(results); - return path; } @@ -526,4 +449,4 @@ public final class TransporterPathfinder { } } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/transporter/TransporterStack.java b/src/main/java/mekanism/common/content/transporter/TransporterStack.java index 213395ce4..b93cad02f 100644 --- a/src/main/java/mekanism/common/content/transporter/TransporterStack.java +++ b/src/main/java/mekanism/common/content/transporter/TransporterStack.java @@ -5,9 +5,9 @@ import java.util.ArrayList; import java.util.List; import mekanism.api.Coord4D; import mekanism.api.EnumColor; +import mekanism.api.TileNetworkList; import mekanism.common.PacketHandler; import mekanism.common.base.ILogisticalTransporter; -import mekanism.api.TileNetworkList; import mekanism.common.capabilities.Capabilities; import mekanism.common.content.transporter.TransitRequest.TransitResponse; import mekanism.common.content.transporter.TransporterPathfinder.Destination; @@ -41,14 +41,12 @@ public class TransporterStack { public static TransporterStack readFromNBT(NBTTagCompound nbtTags) { TransporterStack stack = new TransporterStack(); stack.read(nbtTags); - return stack; } public static TransporterStack readFromPacket(ByteBuf dataStream) { TransporterStack stack = new TransporterStack(); stack.read(dataStream); - return stack; } @@ -71,13 +69,11 @@ public class TransporterStack { } getPrev(transporter).write(data); - data.add(itemStack); } public void read(ByteBuf dataStream) { int c = dataStream.readInt(); - if (c != -1) { color = TransporterUtils.colors.get(c); } else { @@ -91,9 +87,7 @@ public class TransporterStack { if (dataStream.readBoolean()) { clientNext = Coord4D.read(dataStream); } - clientPrev = Coord4D.read(dataStream); - itemStack = PacketHandler.readStack(dataStream); } @@ -108,11 +102,9 @@ public class TransporterStack { if (idleDir != null) { nbtTags.setInteger("idleDir", idleDir.ordinal()); } - if (homeLocation != null) { nbtTags.setTag("homeLocation", homeLocation.write(new NBTTagCompound())); } - nbtTags.setInteger("pathType", pathType.ordinal()); itemStack.writeToNBT(nbtTags); } @@ -128,11 +120,9 @@ public class TransporterStack { if (nbtTags.hasKey("idleDir")) { idleDir = EnumFacing.values()[nbtTags.getInteger("idleDir")]; } - if (nbtTags.hasKey("homeLocation")) { homeLocation = Coord4D.read(nbtTags.getCompoundTag("homeLocation")); } - pathType = Path.values()[nbtTags.getInteger("pathType")]; itemStack = new ItemStack(nbtTags); } @@ -142,10 +132,8 @@ public class TransporterStack { if (pathType != Path.NONE) { TransporterManager.remove(this); } - pathToTarget = path; pathType = type; - if (pathType != Path.NONE) { TransporterManager.add(this); } @@ -161,49 +149,37 @@ public class TransporterStack { public TransitResponse recalculatePath(TransitRequest request, ILogisticalTransporter transporter, int min) { Destination newPath = TransporterPathfinder.getNewBasePath(transporter, this, request, min); - if (newPath == null) { return TransitResponse.EMPTY; } - idleDir = null; setPath(newPath.path, Path.DEST); initiatedPath = true; - return newPath.response; } - public TransitResponse recalculateRRPath(TransitRequest request, TileEntityLogisticalSorter outputter, - ILogisticalTransporter transporter, int min) { + public TransitResponse recalculateRRPath(TransitRequest request, TileEntityLogisticalSorter outputter, ILogisticalTransporter transporter, int min) { Destination newPath = TransporterPathfinder.getNewRRPath(transporter, this, request, outputter, min); - if (newPath == null) { return TransitResponse.EMPTY; } - idleDir = null; setPath(newPath.path, Path.DEST); initiatedPath = true; - return newPath.response; } public boolean calculateIdle(ILogisticalTransporter transporter) { Pair, Path> newPath = TransporterPathfinder.getIdlePath(transporter, this); - if (newPath == null) { return false; } - if (newPath.getRight() == Path.HOME) { idleDir = null; } - setPath(newPath.getLeft(), newPath.getRight()); - originalLocation = transporter.coord(); initiatedPath = true; - return true; } @@ -214,29 +190,23 @@ public class TransporterStack { public Coord4D getNext(ILogisticalTransporter transporter) { if (!transporter.world().isRemote) { int index = pathToTarget.indexOf(transporter.coord()) - 1; - if (index < 0) { return null; } - return pathToTarget.get(index); - } else { - return clientNext; } + return clientNext; } public Coord4D getPrev(ILogisticalTransporter transporter) { if (!transporter.world().isRemote) { int index = pathToTarget.indexOf(transporter.coord()) + 1; - if (index < pathToTarget.size()) { return pathToTarget.get(index); - } else { - return originalLocation; } - } else { - return clientPrev; + return originalLocation; } + return clientPrev; } public EnumFacing getSide(ILogisticalTransporter transporter) { @@ -248,29 +218,21 @@ public class TransporterStack { if (getNext(transporter) != null) { return getNext(transporter).sideDifference(transporter.coord()); } - } else { - if (getNext(transporter) != null) { - return getNext(transporter).sideDifference(transporter.coord()); - } + } else if (getNext(transporter) != null) { + return getNext(transporter).sideDifference(transporter.coord()); } return EnumFacing.DOWN; } public boolean canInsertToTransporter(TileEntity tileEntity, EnumFacing from) { - if (!(CapabilityUtils - .hasCapability(tileEntity, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, from.getOpposite()))) { + if (!CapabilityUtils.hasCapability(tileEntity, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, from.getOpposite())) { return false; } - - ILogisticalTransporter transporter = CapabilityUtils - .getCapability(tileEntity, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, from.getOpposite()); - - if (!CapabilityUtils.getCapability(tileEntity, Capabilities.BLOCKABLE_CONNECTION_CAPABILITY, from.getOpposite()) - .canConnectMutual(from.getOpposite())) { + ILogisticalTransporter transporter = CapabilityUtils.getCapability(tileEntity, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, from.getOpposite()); + if (!CapabilityUtils.getCapability(tileEntity, Capabilities.BLOCKABLE_CONNECTION_CAPABILITY, from.getOpposite()).canConnectMutual(from.getOpposite())) { return false; } - return transporter.getColor() == color || transporter.getColor() == null; } @@ -278,7 +240,6 @@ public class TransporterStack { if (!transporter.canConnectMutual(side)) { return false; } - return transporter.getColor() == color || transporter.getColor() == null; } @@ -287,6 +248,8 @@ public class TransporterStack { } public enum Path { - DEST, HOME, NONE + DEST, + HOME, + NONE } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/entity/EntityBabySkeleton.java b/src/main/java/mekanism/common/entity/EntityBabySkeleton.java index 4dcc2b94c..e64609d7c 100644 --- a/src/main/java/mekanism/common/entity/EntityBabySkeleton.java +++ b/src/main/java/mekanism/common/entity/EntityBabySkeleton.java @@ -14,15 +14,12 @@ import net.minecraft.world.World; public class EntityBabySkeleton extends EntitySkeleton { private static final UUID babySpeedBoostUUID = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836"); - private static final AttributeModifier babySpeedBoostModifier = new AttributeModifier(babySpeedBoostUUID, - "Baby speed boost", 0.5D, 1); + private static final AttributeModifier babySpeedBoostModifier = new AttributeModifier(babySpeedBoostUUID, "Baby speed boost", 0.5D, 1); - private static final DataParameter IS_CHILD = EntityDataManager - .createKey(EntityBabySkeleton.class, DataSerializers.BOOLEAN); + private static final DataParameter IS_CHILD = EntityDataManager.createKey(EntityBabySkeleton.class, DataSerializers.BOOLEAN); public EntityBabySkeleton(World world) { super(world); - dataManager.register(IS_CHILD, false); setChild(true); } @@ -34,16 +31,13 @@ public class EntityBabySkeleton extends EntitySkeleton { public void setChild(boolean child) { dataManager.set(IS_CHILD, child); - if (world != null && !world.isRemote) { IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED); iattributeinstance.removeModifier(babySpeedBoostModifier); - if (child) { iattributeinstance.applyModifier(babySpeedBoostModifier); } } - updateChildSize(child); } @@ -52,7 +46,6 @@ public class EntityBabySkeleton extends EntitySkeleton { if (isChild()) { experienceValue = (int) ((float) experienceValue * 2.5F); } - return super.getExperiencePoints(p_70693_1_); } @@ -68,4 +61,4 @@ public class EntityBabySkeleton extends EntitySkeleton { public float getEyeHeight() { return this.height * 0.85F; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/entity/EntityBalloon.java b/src/main/java/mekanism/common/entity/EntityBalloon.java index 262428899..5eb399113 100644 --- a/src/main/java/mekanism/common/entity/EntityBalloon.java +++ b/src/main/java/mekanism/common/entity/EntityBalloon.java @@ -27,16 +27,11 @@ import net.minecraftforge.fml.relauncher.SideOnly; public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData { - private static final DataParameter IS_LATCHED = EntityDataManager - .createKey(EntityBalloon.class, DataSerializers.BYTE); - private static final DataParameter LATCHED_X = EntityDataManager - .createKey(EntityBalloon.class, DataSerializers.VARINT); - private static final DataParameter LATCHED_Y = EntityDataManager - .createKey(EntityBalloon.class, DataSerializers.VARINT); - private static final DataParameter LATCHED_Z = EntityDataManager - .createKey(EntityBalloon.class, DataSerializers.VARINT); - private static final DataParameter LATCHED_ID = EntityDataManager - .createKey(EntityBalloon.class, DataSerializers.VARINT); + private static final DataParameter IS_LATCHED = EntityDataManager.createKey(EntityBalloon.class, DataSerializers.BYTE); + private static final DataParameter LATCHED_X = EntityDataManager.createKey(EntityBalloon.class, DataSerializers.VARINT); + private static final DataParameter LATCHED_Y = EntityDataManager.createKey(EntityBalloon.class, DataSerializers.VARINT); + private static final DataParameter LATCHED_Z = EntityDataManager.createKey(EntityBalloon.class, DataSerializers.VARINT); + private static final DataParameter LATCHED_ID = EntityDataManager.createKey(EntityBalloon.class, DataSerializers.VARINT); public EnumColor color = EnumColor.DARK_BLUE; public Coord4D latched; public EntityLivingBase latchedEntity; @@ -62,19 +57,16 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData 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.world); - latchedEntity = entity; setPosition(latchedEntity.posX, latchedEntity.posY + latchedEntity.height + 1.7F, latchedEntity.posZ); @@ -83,14 +75,12 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData prevPosZ = posZ; color = c; - dataManager.set(IS_LATCHED, (byte) 2); dataManager.set(LATCHED_ID, entity.getEntityId()); } public EntityBalloon(World world, Coord4D obj, EnumColor c) { this(world); - latched = obj; setPosition(latched.x + 0.5F, latched.y + 1.9F, latched.z + 0.5F); @@ -99,7 +89,6 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData prevPosZ = posZ; color = c; - dataManager.set(IS_LATCHED, (byte) 1); dataManager.set(LATCHED_X, latched != null ? latched.x : 0); /* Latched X */ dataManager.set(LATCHED_Y, latched != null ? latched.y : 0); /* Latched Y */ @@ -119,12 +108,10 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData if (world.isRemote) { if (dataManager.get(IS_LATCHED) == 1) { - latched = new Coord4D(dataManager.get(LATCHED_X), dataManager.get(LATCHED_Y), - dataManager.get(LATCHED_Z), world.provider.getDimension()); + latched = new Coord4D(dataManager.get(LATCHED_X), dataManager.get(LATCHED_Y), dataManager.get(LATCHED_Z), world.provider.getDimension()); } else { latched = null; } - if (dataManager.get(IS_LATCHED) == 2) { latchedEntity = (EntityLivingBase) world.getEntityByID(dataManager.get(LATCHED_ID)); } else { @@ -136,7 +123,6 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData cachedEntityUUID = null; hasCachedEntity = false; } - if (ticksExisted == 1) { byte isLatched; if (latched != null) { @@ -146,7 +132,6 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData } else { isLatched = (byte) 0; } - dataManager.set(IS_LATCHED, isLatched); dataManager.set(LATCHED_X, latched != null ? latched.x : 0); dataManager.set(LATCHED_Y, latched != null ? latched.y : 0); @@ -156,16 +141,12 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData } if (!world.isRemote) { - if (latched != null && (latched.exists(world) && latched.isAirBlock(world))) { + if (latched != null && latched.exists(world) && latched.isAirBlock(world)) { latched = null; - dataManager.set(IS_LATCHED, (byte) 0); } - - if (latchedEntity != null && (latchedEntity.getHealth() <= 0 || latchedEntity.isDead - || !world.loadedEntityList.contains(latchedEntity))) { + if (latchedEntity != null && (latchedEntity.getHealth() <= 0 || latchedEntity.isDead || !world.loadedEntityList.contains(latchedEntity))) { latchedEntity = null; - dataManager.set(IS_LATCHED, (byte) 0); } } @@ -182,7 +163,6 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData motionX *= 0.7; motionZ *= 0.7; } - if (motionY == 0) { motionY = 0.04; } @@ -192,7 +172,6 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData 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) { @@ -200,7 +179,6 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData } else { latchedEntity.motionY = 0; } - setPosition(latchedEntity.posX, latchedEntity.posY + getAddedHeight(), latchedEntity.posZ); } } @@ -211,13 +189,11 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData private int getFloor(EntityLivingBase entity) { BlockPos pos = new BlockPos(entity); - for (BlockPos posi = pos; posi.getY() > 0; posi = posi.down()) { if (posi.getY() < 256 && !world.isAirBlock(posi)) { return posi.getY() + 1 + (entity instanceof EntityPlayer ? 1 : 0); } } - return -1; } @@ -225,7 +201,6 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData for (Object obj : world.loadedEntityList) { if (obj instanceof EntityLivingBase) { EntityLivingBase entity = (EntityLivingBase) obj; - if (entity.getUniqueID().equals(cachedEntityUUID)) { latchedEntity = entity; } @@ -235,7 +210,6 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData private void pop() { playSound(MekanismSounds.POP, 1, 1); - if (world.isRemote) { for (int i = 0; i < 10; i++) { try { @@ -244,18 +218,15 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData } } } - setDead(); } @SideOnly(Side.CLIENT) private void doParticle() { - Pos3D pos = new Pos3D(posX + (rand.nextFloat() * .6 - 0.3), posY + (rand.nextFloat() * .6 - 0.3), - posZ + (rand.nextFloat() * .6 - 0.3)); + Pos3D pos = new Pos3D(posX + (rand.nextFloat() * .6 - 0.3), posY + (rand.nextFloat() * .6 - 0.3), posZ + (rand.nextFloat() * .6 - 0.3)); Particle fx = new ParticleRedstone.Factory().createParticle(0, world, pos.x, pos.y, pos.z, 0, 0, 0); fx.setRBGColorF(color.getColor(0), color.getColor(1), color.getColor(2)); - Minecraft.getMinecraft().effectRenderer.addEffect(fx); } @@ -281,11 +252,9 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData @Override protected void readEntityFromNBT(@Nonnull NBTTagCompound nbtTags) { color = EnumColor.values()[nbtTags.getInteger("color")]; - if (nbtTags.hasKey("latched")) { latched = Coord4D.read(nbtTags.getCompoundTag("latched")); } - if (nbtTags.hasKey("idMost")) { hasCachedEntity = true; cachedEntityUUID = new UUID(nbtTags.getLong("idMost"), nbtTags.getLong("idLeast")); @@ -295,11 +264,9 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData @Override protected void writeEntityToNBT(@Nonnull NBTTagCompound nbtTags) { nbtTags.setInteger("color", color.ordinal()); - if (latched != null) { nbtTags.setTag("latched", latched.write(new NBTTagCompound())); } - if (latchedEntity != null) { nbtTags.setLong("idMost", latchedEntity.getUniqueID().getMostSignificantBits()); nbtTags.setLong("idLeast", latchedEntity.getUniqueID().getLeastSignificantBits()); @@ -319,10 +286,8 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData data.writeDouble(posZ); data.writeInt(color.ordinal()); - if (latched != null) { data.writeByte((byte) 1); - latched.write(data); } else if (latchedEntity != null) { data.writeByte((byte) 2); @@ -335,11 +300,8 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData @Override public void readSpawnData(ByteBuf data) { setPosition(data.readDouble(), data.readDouble(), data.readDouble()); - color = EnumColor.values()[data.readInt()]; - byte type = data.readByte(); - if (type == 1) { latched = Coord4D.read(data); } else if (type == 2) { @@ -352,7 +314,6 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData @Override public void setDead() { super.setDead(); - if (latchedEntity != null) { latchedEntity.isAirBorne = false; } @@ -374,12 +335,10 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData return false; } else { markVelocityChanged(); - if (dmgSource != DamageSource.MAGIC && dmgSource != DamageSource.DROWN && dmgSource != DamageSource.FALL) { pop(); return true; } - return false; } } @@ -387,12 +346,11 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData public boolean isLatched() { if (!world.isRemote) { return latched != null || latchedEntity != null; - } else { - return dataManager.get(IS_LATCHED) > 0; } + return dataManager.get(IS_LATCHED) > 0; } public boolean isLatchedToEntity() { return dataManager.get(IS_LATCHED) == 2 && latchedEntity != null; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/entity/EntityFlame.java b/src/main/java/mekanism/common/entity/EntityFlame.java index 6c500ebb3..13d4e0c66 100644 --- a/src/main/java/mekanism/common/entity/EntityFlame.java +++ b/src/main/java/mekanism/common/entity/EntityFlame.java @@ -40,13 +40,11 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData { public EntityFlame(World world) { super(world); - setSize(0.5F, 0.5F); } public EntityFlame(EntityPlayer player) { this(player.world); - Pos3D playerPos = new Pos3D(player).translate(0, 1.6, 0); Pos3D flameVec = new Pos3D(1, 1, 1); @@ -64,13 +62,11 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData { motionZ = motion.z; owner = player; - mode = ((ItemFlamethrower) player.inventory.getCurrentItem().getItem()) - .getMode(player.inventory.getCurrentItem()); + mode = ((ItemFlamethrower) player.inventory.getCurrentItem().getItem()).getMode(player.inventory.getCurrentItem()); } public void setHeading(Pos3D motion) { float d = MathHelper.sqrt((motion.x * motion.x) + (motion.z * motion.z)); - prevRotationYaw = rotationYaw = (float) (Math.atan2(motion.x, motion.z) * 180.0D / Math.PI); prevRotationPitch = rotationPitch = (float) (Math.atan2(motion.y, d) * 180.0D / Math.PI); } @@ -80,7 +76,6 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData { if (isDead) { return; } - ticksExisted++; prevPosX = posX; @@ -97,10 +92,8 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData { setPosition(posX, posY, posZ); calculateVector(); - if (ticksExisted > LIFESPAN) { setDead(); - return; } } @@ -110,27 +103,22 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData { RayTraceResult mop = world.rayTraceBlocks(localVec, motionVec, true, false, false); localVec = new Vec3d(posX, posY, posZ); motionVec = new Vec3d(posX + motionX, posY + motionY, posZ + motionZ); - if (mop != null) { motionVec = new Vec3d(mop.hitVec.x, mop.hitVec.y, mop.hitVec.z); } Entity entity = null; - List list = world.getEntitiesWithinAABBExcludingEntity(this, - getEntityBoundingBox().expand(motionX, motionY, motionZ).grow(1.0D, 1.0D, 1.0D)); + List list = world.getEntitiesWithinAABBExcludingEntity(this, getEntityBoundingBox().expand(motionX, motionY, motionZ).grow(1.0D, 1.0D, 1.0D)); double entityDist = 0.0D; - int i; for (Entity entity1 : list) { if ((entity1 instanceof EntityItem || entity1.canBeCollidedWith()) && entity1 != owner) { float boundsScale = 0.3F; - AxisAlignedBB newBounds = entity1.getEntityBoundingBox() - .expand((double) boundsScale, (double) boundsScale, (double) boundsScale); + AxisAlignedBB newBounds = entity1.getEntityBoundingBox().expand((double) boundsScale, (double) boundsScale, (double) boundsScale); RayTraceResult RayTraceResult1 = newBounds.calculateIntercept(localVec, motionVec); if (RayTraceResult1 != null) { double dist = localVec.distanceTo(RayTraceResult1.hitVec); - if (dist < entityDist || entityDist == 0) { entity = entity1; entityDist = dist; @@ -145,9 +133,7 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData { if (mop != null && mop.entityHit instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer) mop.entityHit; - - if (entityplayer.capabilities.disableDamage || owner instanceof EntityPlayer && !((EntityPlayer) owner) - .canAttackPlayer(entityplayer)) { + if (entityplayer.capabilities.disableDamage || owner instanceof EntityPlayer && !((EntityPlayer) owner).canAttackPlayer(entityplayer)) { mop = null; } } @@ -165,14 +151,11 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData { } } else if (mop.typeOfHit == Type.BLOCK) { IBlockState state = world.getBlockState(mop.getBlockPos()); - Block block = state.getBlock(); - boolean fluid = MekanismUtils.isFluid(world, new Coord4D(mop, world)) || MekanismUtils - .isDeadFluid(world, new Coord4D(mop, world)); + boolean fluid = MekanismUtils.isFluid(world, new Coord4D(mop, world)) || MekanismUtils.isDeadFluid(world, new Coord4D(mop, world)); Coord4D sideCoord = new Coord4D(mop.getBlockPos().offset(mop.sideHit), world); - if (MekanismConfig.current().general.aestheticWorldDamage.val() && !fluid && ( - sideCoord.isAirBlock(world) || sideCoord.isReplaceable(world))) { + if (MekanismConfig.current().general.aestheticWorldDamage.val() && !fluid && (sideCoord.isAirBlock(world) || sideCoord.isReplaceable(world))) { if (mode != ItemFlamethrower.FlamethrowerMode.COMBAT && !smeltBlock(new Coord4D(mop, world))) { if (mode == ItemFlamethrower.FlamethrowerMode.INFERNO && !world.isRemote) { world.setBlockState(sideCoord.getPos(), Blocks.FIRE.getDefaultState()); @@ -185,54 +168,41 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData { playSound(SoundEvents.BLOCK_FIRE_EXTINGUISH, 1.0F, 1.0F); } } - setDead(); } } private boolean smeltItem(EntityItem item) { ItemStack result = FurnaceRecipes.instance().getSmeltingResult(item.getItem()); - if (!result.isEmpty()) { item.setItem(StackUtils.size(result, item.getItem().getCount())); item.ticksExisted = 0; - spawnParticlesAt(new Pos3D(item)); playSound(SoundEvents.BLOCK_FIRE_EXTINGUISH, 1.0F, 1.0F); - return true; } - return false; } private boolean smeltBlock(Coord4D block) { ItemStack stack = block.getStack(world); - if (stack.isEmpty()) { return false; } - ItemStack result; - try { result = FurnaceRecipes.instance().getSmeltingResult(block.getStack(world)); } catch (Exception e) { return false; } - if (!result.isEmpty()) { if (!world.isRemote) { IBlockState state = block.getBlockState(world); - Block b = state.getBlock(); Block newBlock = Block.getBlockFromItem(result.getItem()); - if (newBlock != Blocks.AIR) { - world.setBlockState(block.getPos(), - Block.getBlockFromItem(result.getItem()).getStateFromMeta(result.getItemDamage()), 3); + world.setBlockState(block.getPos(), Block.getBlockFromItem(result.getItem()).getStateFromMeta(result.getItemDamage()), 3); } else { world.setBlockToAir(block.getPos()); - EntityItem item = new EntityItem(world, block.x + 0.5, block.y + 0.5, block.z + 0.5, result.copy()); item.motionX = 0; item.motionY = 0; @@ -242,12 +212,9 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData { world.playEvent(WorldEvents.BREAK_BLOCK_EFFECTS, block.getPos(), Block.getStateId(state)); } - spawnParticlesAt(new Pos3D(block).translate(0.5, 0.5, 0.5)); - return true; } - return false; } @@ -259,15 +226,14 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData { private DamageSource getFlamethrowerDamage() { if (owner == null) { return DamageSource.causeThrownDamage(this, this); - } else { - return DamageSource.causeThrownDamage(this, owner); } + return DamageSource.causeThrownDamage(this, owner); } private void spawnParticlesAt(Pos3D pos) { for (int i = 0; i < 10; i++) { - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.x + (rand.nextFloat() - 0.5), - pos.y + (rand.nextFloat() - 0.5), pos.z + (rand.nextFloat() - 0.5), 0, 0, 0); + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.x + (rand.nextFloat() - 0.5), pos.y + (rand.nextFloat() - 0.5), + pos.z + (rand.nextFloat() - 0.5), 0, 0, 0); } } @@ -294,4 +260,4 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData { public void readSpawnData(ByteBuf dataStream) { mode = ItemFlamethrower.FlamethrowerMode.values()[dataStream.readInt()]; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/entity/EntityObsidianTNT.java b/src/main/java/mekanism/common/entity/EntityObsidianTNT.java index 12ca83b1b..54facd100 100644 --- a/src/main/java/mekanism/common/entity/EntityObsidianTNT.java +++ b/src/main/java/mekanism/common/entity/EntityObsidianTNT.java @@ -29,14 +29,12 @@ public class EntityObsidianTNT extends Entity { 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; + motionX = -Math.sin(randPi) * 0.02F; motionY = 0.2; - motionZ = -(Math.cos(randPi)) * 0.02F; + motionZ = -Math.cos(randPi) * 0.02F; fuse = MekanismConfig.current().general.obsidianTNTDelay.val(); @@ -101,8 +99,7 @@ public class EntityObsidianTNT extends Entity { } private void explode() { - world.createExplosion(null, posX, posY, posZ, MekanismConfig.current().general.obsidianTNTBlastRadius.val(), - true); + world.createExplosion(null, posX, posY, posZ, MekanismConfig.current().general.obsidianTNTBlastRadius.val(), true); hasExploded = true; } @@ -115,4 +112,4 @@ public class EntityObsidianTNT extends Entity { protected void readEntityFromNBT(@Nonnull NBTTagCompound nbtTags) { fuse = nbtTags.getByte("Fuse"); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/entity/EntityRobit.java b/src/main/java/mekanism/common/entity/EntityRobit.java index c86b35b88..e5c9a9ae3 100644 --- a/src/main/java/mekanism/common/entity/EntityRobit.java +++ b/src/main/java/mekanism/common/entity/EntityRobit.java @@ -63,16 +63,11 @@ import net.minecraftforge.items.ItemHandlerHelper; @Interface(iface = "micdoodle8.mods.galacticraft.api.entity.IEntityBreathable", modid = MekanismHooks.GALACTICRAFT_MOD_ID) public class EntityRobit extends EntityCreature implements IInventory, ISustainedInventory, IEntityBreathable { - private static final DataParameter ELECTRICITY = EntityDataManager - .createKey(EntityRobit.class, DataSerializers.FLOAT); - private static final DataParameter OWNER_UUID = EntityDataManager - .createKey(EntityRobit.class, DataSerializers.STRING); - private static final DataParameter OWNER_NAME = EntityDataManager - .createKey(EntityRobit.class, DataSerializers.STRING); - private static final DataParameter FOLLOW = EntityDataManager - .createKey(EntityRobit.class, DataSerializers.BOOLEAN); - private static final DataParameter DROP_PICKUP = EntityDataManager - .createKey(EntityRobit.class, DataSerializers.BOOLEAN); + private static final DataParameter ELECTRICITY = EntityDataManager.createKey(EntityRobit.class, DataSerializers.FLOAT); + private static final DataParameter OWNER_UUID = EntityDataManager.createKey(EntityRobit.class, DataSerializers.STRING); + private static final DataParameter OWNER_NAME = EntityDataManager.createKey(EntityRobit.class, DataSerializers.STRING); + private static final DataParameter FOLLOW = EntityDataManager.createKey(EntityRobit.class, DataSerializers.BOOLEAN); + private static final DataParameter DROP_PICKUP = EntityDataManager.createKey(EntityRobit.class, DataSerializers.BOOLEAN); public double MAX_ELECTRICITY = 100000; public Coord4D homeLocation; public NonNullList inventory = NonNullList.withSize(31, ItemStack.EMPTY); @@ -83,25 +78,19 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine public EntityRobit(World world) { super(world); - setSize(0.5F, 0.5F); - getNavigator().setCanSwim(false); - 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; prevPosY = y; prevPosZ = z; @@ -116,7 +105,6 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); - getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.3); getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(1); } @@ -129,7 +117,6 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine @Override protected void entityInit() { super.entityInit(); - dataManager.register(ELECTRICITY, 0F); dataManager.register(OWNER_UUID, ""); dataManager.register(OWNER_NAME, ""); @@ -138,15 +125,13 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine } public double getRoundedTravelEnergy() { - return new BigDecimal(getDistance(prevPosX, prevPosY, prevPosZ) * 1.5).setScale(2, RoundingMode.HALF_EVEN) - .doubleValue(); + return new BigDecimal(getDistance(prevPosX, prevPosY, prevPosZ) * 1.5).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); } @Override public void onEntityUpdate() { if (!world.isRemote) { - if (getFollowing() && getOwner() != null && getDistanceSq(getOwner()) > 4 && !getNavigator().noPath() - && getEnergy() > 0) { + if (getFollowing() && getOwner() != null && getDistanceSq(getOwner()) > 4 && !getNavigator().noPath() && getEnergy() > 0) { setEnergy(getEnergy() - getRoundedTravelEnergy()); } } @@ -157,17 +142,13 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine if (getDropPickup()) { collectItems(); } - if (homeLocation == null) { setDead(); - return; } if (ticksExisted % 20 == 0) { - World serverWorld = FMLCommonHandler.instance().getMinecraftServerInstance() - .getWorld(homeLocation.dimensionId); - + World serverWorld = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(homeLocation.dimensionId); if (homeLocation.exists(serverWorld)) { if (!(homeLocation.getTileEntity(serverWorld) instanceof TileEntityChargepad)) { drop(); @@ -185,44 +166,28 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine if (!stack.isEmpty() && getEnergy() < MAX_ELECTRICITY) { if (stack.getItem() instanceof IEnergizedItem) { setEnergy(getEnergy() + EnergizedItemManager.discharge(stack, MAX_ELECTRICITY - getEnergy())); - } else if (MekanismUtils.useTesla() && stack - .hasCapability(Capabilities.TESLA_PRODUCER_CAPABILITY, null)) { + } else if (MekanismUtils.useTesla() && stack.hasCapability(Capabilities.TESLA_PRODUCER_CAPABILITY, null)) { ITeslaProducer producer = stack.getCapability(Capabilities.TESLA_PRODUCER_CAPABILITY, null); - - long needed = Math - .round((MAX_ELECTRICITY - getEnergy()) * MekanismConfig.current().general.TO_TESLA.val()); - setEnergy( - getEnergy() + producer.takePower(needed, false) * MekanismConfig.current().general.FROM_TESLA - .val()); + long needed = Math.round((MAX_ELECTRICITY - getEnergy()) * MekanismConfig.current().general.TO_TESLA.val()); + setEnergy(getEnergy() + producer.takePower(needed, false) * MekanismConfig.current().general.FROM_TESLA.val()); } else if (MekanismUtils.useForge() && stack.hasCapability(CapabilityEnergy.ENERGY, null)) { IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null); - if (storage.canExtract()) { - int needed = MekanismUtils.clampToInt( - (MAX_ELECTRICITY - getEnergy()) * MekanismConfig.current().general.TO_FORGE.val()); - setEnergy(getEnergy() + storage.extractEnergy(needed, false) * MekanismConfig - .current().general.FROM_FORGE.val()); + int needed = MekanismUtils.clampToInt((MAX_ELECTRICITY - getEnergy()) * MekanismConfig.current().general.TO_FORGE.val()); + setEnergy(getEnergy() + storage.extractEnergy(needed, false) * MekanismConfig.current().general.FROM_FORGE.val()); } } else if (MekanismUtils.useRF() && stack.getItem() instanceof IEnergyContainerItem) { IEnergyContainerItem item = (IEnergyContainerItem) stack.getItem(); - - int needed = MekanismUtils - .clampToInt((MAX_ELECTRICITY - getEnergy()) * MekanismConfig.current().general.TO_RF.val()); - setEnergy(getEnergy() + (item.extractEnergy(stack, needed, false) * MekanismConfig - .current().general.FROM_RF.val())); + int needed = MekanismUtils.clampToInt((MAX_ELECTRICITY - getEnergy()) * MekanismConfig.current().general.TO_RF.val()); + setEnergy(getEnergy() + (item.extractEnergy(stack, needed, false) * MekanismConfig.current().general.FROM_RF.val())); } else if (MekanismUtils.useIC2() && stack.getItem() instanceof IElectricItem) { IElectricItem item = (IElectricItem) stack.getItem(); - if (item.canProvideEnergy(stack)) { - double gain = ElectricItem.manager - .discharge(stack, - (MAX_ELECTRICITY - getEnergy()) * MekanismConfig.current().general.TO_IC2.val(), 4, - true, true, false) - * MekanismConfig.current().general.FROM_IC2.val(); + double gain = ElectricItem.manager.discharge(stack, (MAX_ELECTRICITY - getEnergy()) * MekanismConfig.current().general.TO_IC2.val(), 4, true, true, false) + * MekanismConfig.current().general.FROM_IC2.val(); setEnergy(getEnergy() + gain); } - } else if (stack.getItem() == Items.REDSTONE - && getEnergy() + MekanismConfig.current().general.ENERGY_PER_REDSTONE.val() <= MAX_ELECTRICITY) { + } else if (stack.getItem() == Items.REDSTONE && getEnergy() + MekanismConfig.current().general.ENERGY_PER_REDSTONE.val() <= MAX_ELECTRICITY) { setEnergy(getEnergy() + MekanismConfig.current().general.ENERGY_PER_REDSTONE.val()); stack.shrink(1); } @@ -235,11 +200,9 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine if (!world.isRemote) { if (furnaceBurnTime == 0 && canSmelt()) { currentItemBurnTime = furnaceBurnTime = TileEntityFurnace.getItemBurnTime(inventory.get(29)); - if (furnaceBurnTime > 0) { if (!inventory.get(29).isEmpty()) { inventory.get(29).shrink(1); - if (inventory.get(29).getCount() == 0) { inventory.set(29, inventory.get(29).getItem().getContainerItem(inventory.get(29))); } @@ -249,7 +212,6 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine if (furnaceBurnTime > 0 && canSmelt()) { furnaceCookTime++; - if (furnaceCookTime == 200) { furnaceCookTime = 0; smeltItem(); @@ -262,44 +224,31 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine } private void collectItems() { - List items = world - .getEntitiesWithinAABB(EntityItem.class, getEntityBoundingBox().grow(1.5, 1.5, 1.5)); + List items = world.getEntitiesWithinAABB(EntityItem.class, getEntityBoundingBox().grow(1.5, 1.5, 1.5)); if (!items.isEmpty()) { for (EntityItem item : items) { if (item.cannotPickup() || item.getItem().getItem() instanceof ItemRobit || item.isDead) { continue; } - for (int i = 0; i < 27; i++) { ItemStack itemStack = inventory.get(i); - if (itemStack.isEmpty()) { inventory.set(i, item.getItem()); onItemPickup(item, item.getItem().getCount()); item.setDead(); - - playSound(SoundEvents.ENTITY_ITEM_PICKUP, 1.0F, - ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); - + playSound(SoundEvents.ENTITY_ITEM_PICKUP, 1.0F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); break; - } else if (ItemHandlerHelper.canItemStacksStack(itemStack, item.getItem()) - && itemStack.getCount() < itemStack.getMaxStackSize()) { + } else if (ItemHandlerHelper.canItemStacksStack(itemStack, item.getItem()) && itemStack.getCount() < itemStack.getMaxStackSize()) { int needed = itemStack.getMaxStackSize() - itemStack.getCount(); int toAdd = Math.min(needed, item.getItem().getCount()); - itemStack.grow(toAdd); item.getItem().shrink(toAdd); - onItemPickup(item, toAdd); - if (item.getItem().getCount() == 0) { item.setDead(); } - - playSound(SoundEvents.ENTITY_ITEM_PICKUP, 1.0F, - ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); - + playSound(SoundEvents.ENTITY_ITEM_PICKUP, 1.0F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); break; } } @@ -309,15 +258,12 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine public void goHome() { setFollowing(false); - if (world.provider.getDimension() != homeLocation.dimensionId) { - changeDimension(homeLocation.dimensionId, (world1, entity, yaw) -> entity - .setLocationAndAngles(homeLocation.x + 0.5, homeLocation.y + 0.3, homeLocation.z + 0.5, yaw, - rotationPitch)); + changeDimension(homeLocation.dimensionId, (world1, entity, yaw) -> + entity.setLocationAndAngles(homeLocation.x + 0.5, homeLocation.y + 0.3, homeLocation.z + 0.5, yaw, rotationPitch)); } else { setPositionAndUpdate(homeLocation.x + 0.5, homeLocation.y + 0.3, homeLocation.z + 0.5); } - motionX = 0; motionY = 0; motionZ = 0; @@ -347,7 +293,6 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine if (canSmelt()) { ItemStack input = inventory.get(28); ItemStack result = FurnaceRecipes.instance().getSmeltingResult(input); - ItemStack currentOutput = inventory.get(30); if (currentOutput.isEmpty()) { inventory.set(30, result.copy()); @@ -361,24 +306,19 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine public boolean isOnChargepad() { BlockPos pos = new BlockPos(this); - return world.getTileEntity(pos) instanceof TileEntityChargepad; - } @Nonnull @Override public EnumActionResult applyPlayerInteraction(EntityPlayer entityplayer, Vec3d vec, EnumHand hand) { ItemStack stack = entityplayer.getHeldItem(hand); - if (entityplayer.isSneaking()) { if (!stack.isEmpty() && stack.getItem() instanceof ItemConfigurator) { if (!world.isRemote) { drop(); } - setDead(); - entityplayer.swingArm(hand); return EnumActionResult.SUCCESS; } @@ -392,7 +332,6 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine public void drop() { EntityItem entityItem = new EntityItem(world, posX, posY + 0.3, posZ, new ItemStack(MekanismItems.Robit)); - ItemRobit item = (ItemRobit) entityItem.getItem().getItem(); item.setEnergy(entityItem.getItem(), getEnergy()); item.setInventory(((ISustainedInventory) this).getInventory(), entityItem.getItem()); @@ -402,32 +341,23 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine entityItem.motionX = 0; entityItem.motionY = rand.nextGaussian() * k + 0.2F; entityItem.motionZ = 0; - world.spawnEntity(entityItem); } @Override public void writeEntityToNBT(NBTTagCompound nbtTags) { super.writeEntityToNBT(nbtTags); - nbtTags.setDouble("electricityStored", getEnergy()); - nbtTags.setString("name", getName()); - if (getOwnerUUID() != null) { nbtTags.setString("ownerUUID", getOwnerUUID().toString()); } - nbtTags.setBoolean("follow", getFollowing()); - nbtTags.setBoolean("dropPickup", getDropPickup()); - if (homeLocation != null) { homeLocation.write(nbtTags); } - NBTTagList tagList = new NBTTagList(); - for (int slotCount = 0; slotCount < inventory.size(); slotCount++) { if (!inventory.get(slotCount).isEmpty()) { NBTTagCompound tagCompound = new NBTTagCompound(); @@ -436,31 +366,22 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine tagList.appendTag(tagCompound); } } - nbtTags.setTag("Items", tagList); } @Override public void readEntityFromNBT(NBTTagCompound nbtTags) { super.readEntityFromNBT(nbtTags); - setEnergy(nbtTags.getDouble("electricityStored")); - setCustomNameTag(nbtTags.getString("name")); - if (nbtTags.hasKey("ownerUUID")) { setOwnerUUID(UUID.fromString(nbtTags.getString("ownerUUID"))); } - setFollowing(nbtTags.getBoolean("follow")); - setDropPickup(nbtTags.getBoolean("dropPickup")); - homeLocation = Coord4D.read(nbtTags); - NBTTagList tagList = nbtTags.getTagList("Items", Constants.NBT.TAG_COMPOUND); inventory = NonNullList.withSize(getSizeInventory(), ItemStack.EMPTY); - for (int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(tagCount); byte slotID = tagCompound.getByte("Slot"); @@ -474,7 +395,6 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine @Override protected void damageEntity(@Nonnull DamageSource damageSource, float amount) { amount = ForgeHooks.onLivingHurt(this, damageSource, amount); - if (amount <= 0) { return; } @@ -482,7 +402,6 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine amount = applyArmorCalculations(damageSource, amount); amount = applyPotionDamageCalculations(damageSource, amount); float j = getHealth(); - setEnergy(Math.max(0, getEnergy() - (amount * 1000))); getCombatTracker().trackDamage(damageSource, j, amount); } @@ -567,7 +486,6 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine @Override public void setInventorySlotContents(int slotID, @Nonnull ItemStack itemstack) { inventory.set(slotID, itemstack); - if (!itemstack.isEmpty() && itemstack.getCount() > getInventoryStackLimit()) { itemstack.setCount(getInventoryStackLimit()); } @@ -623,13 +541,10 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine if (nbtTags == null || nbtTags.tagCount() == 0) { return; } - inventory = NonNullList.withSize(getSizeInventory(), ItemStack.EMPTY); - for (int slots = 0; slots < nbtTags.tagCount(); slots++) { NBTTagCompound tagCompound = nbtTags.getCompoundTagAt(slots); byte slotID = tagCompound.getByte("Slot"); - if (slotID >= 0 && slotID < inventory.size()) { inventory.set(slotID, new ItemStack(tagCompound)); } @@ -639,7 +554,6 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine @Override public NBTTagList getInventory(Object... data) { NBTTagList tagList = new NBTTagList(); - for (int slots = 0; slots < inventory.size(); slots++) { if (!inventory.get(slots).isEmpty()) { NBTTagCompound tagCompound = new NBTTagCompound(); @@ -648,7 +562,6 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine tagList.appendTag(tagCompound); } } - return tagList; } @@ -659,7 +572,6 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine return false; } } - return true; } @@ -667,4 +579,4 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine public boolean canBreath() { return true; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/entity/ai/RobitAIFollow.java b/src/main/java/mekanism/common/entity/ai/RobitAIFollow.java index fb7d8d8e9..268ac31a8 100644 --- a/src/main/java/mekanism/common/entity/ai/RobitAIFollow.java +++ b/src/main/java/mekanism/common/entity/ai/RobitAIFollow.java @@ -76,24 +76,21 @@ public class RobitAIFollow extends EntityAIBase { 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.getDistanceSq(player) < (minDist * minDist)) { return false; } else if (theRobit.getEnergy() == 0) { return false; - } else { - theOwner = player; - return true; } + theOwner = player; + return true; } @Override public boolean shouldContinueExecuting() { - return !thePathfinder.noPath() && theRobit.getDistanceSq(theOwner) > (maxDist * maxDist) && theRobit - .getFollowing() && theRobit.getEnergy() > 0 - && theOwner.world.provider.getDimension() == theRobit.world.provider.getDimension(); + return !thePathfinder.noPath() && theRobit.getDistanceSq(theOwner) > (maxDist * maxDist) && theRobit.getFollowing() && theRobit.getEnergy() > 0 + && theOwner.world.provider.getDimension() == theRobit.world.provider.getDimension(); } @Override @@ -113,7 +110,6 @@ public class RobitAIFollow extends EntityAIBase { @Override public void updateTask() { theRobit.getLookHelper().setLookPositionWithEntity(theOwner, 6.0F, theRobit.getVerticalFaceSpeed() / 10); - if (theRobit.getFollowing()) { if (--ticker <= 0) { ticker = 10; @@ -123,17 +119,13 @@ public class RobitAIFollow extends EntityAIBase { int x = MathHelper.floor(theOwner.posX) - 2; int y = MathHelper.floor(theOwner.getEntityBoundingBox().minY); int z = MathHelper.floor(theOwner.posZ) - 2; - for (int l = 0; l <= 4; ++l) { for (int i1 = 0; i1 <= 4; ++i1) { BlockPos pos = new BlockPos(x + l, y, z + i1); BlockPos under = new BlockPos(x + l, y - 1, z + i1); - - if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && world.getBlockState(under) - .isSideSolid(world, under, EnumFacing.UP) && isEmptyBlock(pos) && isEmptyBlock( - new BlockPos(x + l, y + 1, z + i1))) { - theRobit.setLocationAndAngles((x + l) + 0.5F, y, (z + i1) + 0.5F, - theRobit.rotationYaw, theRobit.rotationPitch); + if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && world.getBlockState(under).isSideSolid(world, under, EnumFacing.UP) && isEmptyBlock(pos) && + isEmptyBlock(new BlockPos(x + l, y + 1, z + i1))) { + theRobit.setLocationAndAngles((x + l) + 0.5F, y, (z + i1) + 0.5F, theRobit.rotationYaw, theRobit.rotationPitch); thePathfinder.clearPath(); return; } @@ -148,7 +140,6 @@ public class RobitAIFollow extends EntityAIBase { private boolean isEmptyBlock(BlockPos pos) { IBlockState iblockstate = world.getBlockState(pos); Block block = iblockstate.getBlock(); - return block == Blocks.AIR || !iblockstate.isFullCube(); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/entity/ai/RobitAIPickup.java b/src/main/java/mekanism/common/entity/ai/RobitAIPickup.java index de60905b3..b1dce516e 100644 --- a/src/main/java/mekanism/common/entity/ai/RobitAIPickup.java +++ b/src/main/java/mekanism/common/entity/ai/RobitAIPickup.java @@ -64,23 +64,19 @@ public class RobitAIPickup extends EntityAIBase { return false; } - if (closest != null && closest.getDistanceSq(closest) > 100 - && thePathfinder.getPathToXYZ(closest.posX, closest.posY, closest.posZ) != null) { + if (closest != null && closest.getDistanceSq(closest) > 100 && thePathfinder.getPathToXYZ(closest.posX, closest.posY, closest.posZ) != null) { return true; } List items = theRobit.world.getEntitiesWithinAABB(EntityItem.class, - new AxisAlignedBB(theRobit.posX - 10, theRobit.posY - 10, theRobit.posZ - 10, theRobit.posX + 10, - theRobit.posY + 10, theRobit.posZ + 10)); + new AxisAlignedBB(theRobit.posX - 10, theRobit.posY - 10, theRobit.posZ - 10, theRobit.posX + 10, theRobit.posY + 10, theRobit.posZ + 10)); Iterator iter = items.iterator(); //Cached for slight performance double closestDistance = -1; while (iter.hasNext()) { EntityItem entity = iter.next(); - double distance = theRobit.getDistance(entity); - if (distance <= 10) { if (closestDistance == -1 || distance < closestDistance) { if (thePathfinder.getPathToXYZ(entity.posX, entity.posY, entity.posZ) != null) { @@ -90,17 +86,14 @@ public class RobitAIPickup extends EntityAIBase { } } } - //No valid items return closest != null && !closest.isDead; - } @Override public boolean shouldContinueExecuting() { - return !closest.isDead && !thePathfinder.noPath() && theRobit.getDistanceSq(closest) > 100 && theRobit - .getDropPickup() && theRobit.getEnergy() > 0 - && closest.world.provider.getDimension() == theRobit.world.provider.getDimension(); + return !closest.isDead && !thePathfinder.noPath() && theRobit.getDistanceSq(closest) > 100 && theRobit.getDropPickup() && theRobit.getEnergy() > 0 + && closest.world.provider.getDimension() == theRobit.world.provider.getDimension(); } @Override @@ -121,30 +114,22 @@ public class RobitAIPickup extends EntityAIBase { if (!theRobit.getDropPickup()) { return; } - theRobit.getLookHelper().setLookPositionWithEntity(closest, 6.0F, theRobit.getVerticalFaceSpeed() / 10); - if (--ticker <= 0) { ticker = 10; - if (!thePathfinder.tryMoveToEntityLiving(closest, moveSpeed)) { if (theRobit.getDistanceSq(closest) >= 144.0D) { int x = MathHelper.floor(closest.posX) - 2; int y = MathHelper.floor(closest.getEntityBoundingBox().minY); int z = MathHelper.floor(closest.posZ) - 2; - for (int l = 0; l <= 4; ++l) { for (int i1 = 0; i1 <= 4; ++i1) { BlockPos pos = new BlockPos(x + l, y, z + i1); BlockPos under = new BlockPos(x + l, y - 1, z + i1); - - if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && world.getBlockState(under) - .isSideSolid(world, under, EnumFacing.UP) && isEmptyBlock(pos) && isEmptyBlock( - new BlockPos(x + l, y + 1, z + i1))) { - theRobit.setLocationAndAngles((x + l) + 0.5F, y, (z + i1) + 0.5F, theRobit.rotationYaw, - theRobit.rotationPitch); + if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && world.getBlockState(under).isSideSolid(world, under, EnumFacing.UP) && isEmptyBlock(pos) && + isEmptyBlock(new BlockPos(x + l, y + 1, z + i1))) { + theRobit.setLocationAndAngles((x + l) + 0.5F, y, (z + i1) + 0.5F, theRobit.rotationYaw, theRobit.rotationPitch); thePathfinder.clearPath(); - return; } } @@ -157,7 +142,6 @@ public class RobitAIPickup extends EntityAIBase { private boolean isEmptyBlock(BlockPos pos) { IBlockState iblockstate = world.getBlockState(pos); Block block = iblockstate.getBlock(); - return block == Blocks.AIR || !iblockstate.isFullCube(); } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/fixers/BaseMekanismFixer.java b/src/main/java/mekanism/common/fixers/BaseMekanismFixer.java index e8250279f..bcb50bba7 100644 --- a/src/main/java/mekanism/common/fixers/BaseMekanismFixer.java +++ b/src/main/java/mekanism/common/fixers/BaseMekanismFixer.java @@ -7,6 +7,7 @@ import net.minecraft.util.datafix.IFixableData; * Created by Thiakil on 5/05/2019. */ public abstract class BaseMekanismFixer implements IFixableData { + private final MekFixers fixer; protected BaseMekanismFixer(MekFixers fixer) { @@ -17,4 +18,4 @@ public abstract class BaseMekanismFixer implements IFixableData { public int getFixVersion() { return this.fixer.getFixVersion(); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/fixers/KeybindingFixer.java b/src/main/java/mekanism/common/fixers/KeybindingFixer.java index 56c4ddcdc..57f3da8d5 100644 --- a/src/main/java/mekanism/common/fixers/KeybindingFixer.java +++ b/src/main/java/mekanism/common/fixers/KeybindingFixer.java @@ -40,4 +40,4 @@ public class KeybindingFixer { LOGGER.error("Remap error", e); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/fixers/MekanismDataFixers.java b/src/main/java/mekanism/common/fixers/MekanismDataFixers.java index f4141f3dd..026b7c5bd 100644 --- a/src/main/java/mekanism/common/fixers/MekanismDataFixers.java +++ b/src/main/java/mekanism/common/fixers/MekanismDataFixers.java @@ -10,6 +10,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler; * Created by Thiakil on 5/05/2019. */ public class MekanismDataFixers { + public static final int DATA_VERSION = MekFixers.values().length; public static void register() { @@ -28,10 +29,11 @@ public class MekanismDataFixers { /** * 1 based version number + * * @return the version number to use for this fix */ public int getFixVersion() { return this.ordinal() + 1; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/fixers/TEFixer.java b/src/main/java/mekanism/common/fixers/TEFixer.java index f70748cc7..8ae0b502c 100644 --- a/src/main/java/mekanism/common/fixers/TEFixer.java +++ b/src/main/java/mekanism/common/fixers/TEFixer.java @@ -6,7 +6,6 @@ import javax.annotation.Nonnull; import mekanism.common.Mekanism; import mekanism.common.fixers.MekanismDataFixers.MekFixers; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.datafix.IFixableData; public class TEFixer extends BaseMekanismFixer { @@ -29,7 +28,6 @@ public class TEFixer extends BaseMekanismFixer { @Nonnull public NBTTagCompound fixTagCompound(@Nonnull NBTTagCompound compound) { String teLoc = compound.getString("id"); - //Fix multipart if (teLoc.equals("mcmultipart:multipart.ticking") || teLoc.equals("mcmultipart:multipart.nonticking")) { if (compound.hasKey("parts")) { @@ -47,7 +45,6 @@ public class TEFixer extends BaseMekanismFixer { compound.setString("id", newID); Mekanism.logger.info("Fixed TE from {} to {}", teLoc, newID); } - return compound; } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/frequency/Frequency.java b/src/main/java/mekanism/common/frequency/Frequency.java index d0e2fa6d5..7858fdad8 100644 --- a/src/main/java/mekanism/common/frequency/Frequency.java +++ b/src/main/java/mekanism/common/frequency/Frequency.java @@ -6,8 +6,8 @@ import java.util.Set; import java.util.UUID; import javax.annotation.Nullable; import mekanism.api.Coord4D; -import mekanism.common.PacketHandler; import mekanism.api.TileNetworkList; +import mekanism.common.PacketHandler; import mekanism.common.util.MekanismUtils; import net.minecraft.nbt.NBTTagCompound; @@ -44,7 +44,6 @@ public class Frequency { public Frequency setPublic(boolean isPublic) { publicFreq = isPublic; - return this; } @@ -54,12 +53,10 @@ public class Frequency { public Coord4D getClosestCoords(Coord4D coord) { Coord4D closest = null; - for (Coord4D iterCoord : activeCoords) { if (iterCoord.equals(coord)) { continue; } - if (closest == null) { closest = iterCoord; continue; @@ -67,19 +64,12 @@ public class Frequency { if (coord.dimensionId != closest.dimensionId && coord.dimensionId == iterCoord.dimensionId) { closest = iterCoord; - continue; - } else if (coord.dimensionId == closest.dimensionId && coord.dimensionId != iterCoord.dimensionId) { - continue; - } else { + } else if (coord.dimensionId != closest.dimensionId || coord.dimensionId == iterCoord.dimensionId) { if (coord.distanceTo(closest) > coord.distanceTo(iterCoord)) { closest = iterCoord; - continue; - } else { - continue; } } } - return closest; } @@ -120,8 +110,7 @@ public class Frequency { @Override public boolean equals(Object obj) { - return obj instanceof Frequency && ((Frequency) obj).name.equals(name) - && ((Frequency) obj).ownerUUID.equals(ownerUUID) && ((Frequency) obj).publicFreq == publicFreq; + return obj instanceof Frequency && ((Frequency) obj).name.equals(name) && ((Frequency) obj).ownerUUID.equals(ownerUUID) && ((Frequency) obj).publicFreq == publicFreq; } public Identity getIdentity() { @@ -143,7 +132,6 @@ public class Frequency { if (!data.getString("name").isEmpty()) { return new Identity(data.getString("name"), data.getBoolean("publicFreq")); } - return null; } @@ -154,4 +142,4 @@ public class Frequency { return tag; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/frequency/FrequencyManager.java b/src/main/java/mekanism/common/frequency/FrequencyManager.java index f0158408b..d050922d2 100644 --- a/src/main/java/mekanism/common/frequency/FrequencyManager.java +++ b/src/main/java/mekanism/common/frequency/FrequencyManager.java @@ -21,9 +21,7 @@ import net.minecraftforge.common.util.Constants.NBT; public class FrequencyManager { public static final int MAX_FREQ_LENGTH = 16; - public static final List SPECIAL_CHARS = Arrays - .asList('-', ' ', '|', '\'', '\"', '_', '+', ':', '(', ')', - '?', '!', '/', '@', '$', '`', '~', ',', '.', '#'); + public static final List SPECIAL_CHARS = Arrays.asList('-', ' ', '|', '\'', '\"', '_', '+', ':', '(', ')', '?', '!', '/', '@', '$', '`', '~', ',', '.', '#'); public static boolean loaded; @@ -42,19 +40,16 @@ public class FrequencyManager { public FrequencyManager(Class c, String n) { frequencyClass = c; name = n; - managers.add(this); } public FrequencyManager(Class c, String n, UUID uuid) { this(c, n); - ownerUUID = uuid; } public static void load(World world) { loaded = true; - for (FrequencyManager manager : managers) { manager.createOrLoad(world); } @@ -64,7 +59,6 @@ public class FrequencyManager { if (!loaded) { load(world); } - for (FrequencyManager manager : managers) { manager.tickSelf(world); } @@ -75,7 +69,6 @@ public class FrequencyManager { manager.frequencies.clear(); manager.dataHandler = null; } - loaded = false; } @@ -84,20 +77,16 @@ public class FrequencyManager { if (freq.equals(iterFreq)) { iterFreq.activeCoords.add(coord); dataHandler.markDirty(); - return iterFreq; } } - deactivate(coord); - return null; } public void remove(String name, UUID owner) { for (Iterator iter = getFrequencies().iterator(); iter.hasNext(); ) { Frequency iterFreq = iter.next(); - if (iterFreq.name.equals(name) && iterFreq.ownerUUID.equals(owner)) { iter.remove(); dataHandler.markDirty(); @@ -108,7 +97,6 @@ public class FrequencyManager { public void remove(String name) { for (Iterator iter = getFrequencies().iterator(); iter.hasNext(); ) { Frequency iterFreq = iter.next(); - if (iterFreq.name.equals(name)) { iter.remove(); dataHandler.markDirty(); @@ -128,7 +116,6 @@ public class FrequencyManager { if (freq.equals(iterFreq)) { iterFreq.activeCoords.add(coord); dataHandler.markDirty(); - return iterFreq; } } @@ -138,20 +125,15 @@ public class FrequencyManager { freq.valid = true; frequencies.add(freq); dataHandler.markDirty(); - return freq; } - return null; } public void createOrLoad(World world) { String name = getName(); - if (dataHandler == null) { - dataHandler = (FrequencyDataHandler) world.getPerWorldStorage() - .getOrLoadData(FrequencyDataHandler.class, name); - + dataHandler = (FrequencyDataHandler) world.getPerWorldStorage().getOrLoadData(FrequencyDataHandler.class, name); if (dataHandler == null) { dataHandler = new FrequencyDataHandler(name); dataHandler.setManager(this); @@ -178,7 +160,6 @@ public class FrequencyManager { return true; } } - return false; } @@ -186,18 +167,15 @@ public class FrequencyManager { for (Frequency iterFreq : frequencies) { for (Iterator iter = iterFreq.activeCoords.iterator(); iter.hasNext(); ) { Coord4D coord = iter.next(); - if (coord.dimensionId == world.provider.getDimension()) { if (!coord.exists(world)) { iter.remove(); } else { TileEntity tile = coord.getTileEntity(world); - if (!(tile instanceof IFrequencyHandler)) { iter.remove(); } else { Frequency freq = ((IFrequencyHandler) tile).getFrequency(this); - if (freq == null || !freq.equals(iterFreq)) { iter.remove(); } @@ -210,7 +188,6 @@ public class FrequencyManager { public void writeFrequencies(TileNetworkList data) { data.add(frequencies.size()); - for (Frequency freq : frequencies) { freq.write(data); } @@ -219,7 +196,6 @@ public class FrequencyManager { public Set readFrequencies(ByteBuf dataStream) { Set ret = new HashSet<>(); int size = dataStream.readInt(); - try { for (int i = 0; i < size; i++) { Frequency freq = frequencyClass.getConstructor(new Class[]{ByteBuf.class}).newInstance(dataStream); @@ -229,13 +205,11 @@ public class FrequencyManager { } catch (Exception e) { e.printStackTrace(); } - return ret; } public String getName() { - return ownerUUID != null ? (ownerUUID.toString() + "_" + name + "FrequencyHandler") - : (name + "FrequencyHandler"); + return ownerUUID != null ? (ownerUUID.toString() + "_" + name + "FrequencyHandler") : (name + "FrequencyHandler"); } public static class FrequencyDataHandler extends WorldSavedData { @@ -264,21 +238,15 @@ public class FrequencyManager { public void readFromNBT(@Nonnull NBTTagCompound nbtTags) { try { String frequencyClass = nbtTags.getString("frequencyClass"); - if (nbtTags.hasKey("ownerUUID")) { loadedOwner = UUID.fromString(nbtTags.getString("ownerUUID")); } - NBTTagList list = nbtTags.getTagList("freqList", NBT.TAG_COMPOUND); - loadedFrequencies = new HashSet<>(); - for (int i = 0; i < list.tagCount(); i++) { NBTTagCompound compound = list.getCompoundTagAt(i); - Constructor c = Class.forName(frequencyClass).getConstructor(NBTTagCompound.class); Frequency freq = (Frequency) c.newInstance(compound); - loadedFrequencies.add(freq); } } catch (Exception e) { @@ -290,22 +258,17 @@ public class FrequencyManager { @Override public NBTTagCompound writeToNBT(@Nonnull NBTTagCompound nbtTags) { nbtTags.setString("frequencyClass", manager.frequencyClass.getName()); - if (manager.ownerUUID != null) { nbtTags.setString("ownerUUID", manager.ownerUUID.toString()); } - NBTTagList list = new NBTTagList(); - for (Frequency freq : manager.getFrequencies()) { NBTTagCompound compound = new NBTTagCompound(); freq.write(compound); list.appendTag(compound); } - nbtTags.setTag("freqList", list); - return nbtTags; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/frequency/IFrequencyHandler.java b/src/main/java/mekanism/common/frequency/IFrequencyHandler.java index 141161949..da82af906 100644 --- a/src/main/java/mekanism/common/frequency/IFrequencyHandler.java +++ b/src/main/java/mekanism/common/frequency/IFrequencyHandler.java @@ -3,4 +3,4 @@ package mekanism.common.frequency; public interface IFrequencyHandler { Frequency getFrequency(FrequencyManager manager); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/IMCHandler.java b/src/main/java/mekanism/common/integration/IMCHandler.java index f40f4df29..148647fe6 100644 --- a/src/main/java/mekanism/common/integration/IMCHandler.java +++ b/src/main/java/mekanism/common/integration/IMCHandler.java @@ -18,12 +18,9 @@ public class IMCHandler { String message = msg.key; - if (message.equals("ShapedMekanismRecipe") || - message.equals("ShapelessMekanismRecipe") || - message.equals("DeleteMekanismRecipes") || - message.equals("RemoveMekanismRecipes")) { - Mekanism.logger.warn(msg.getSender() + " tried to send IMC " + message - + " which has been deleted. Please notify the mod developer to use JSON recipes."); + if (message.equals("ShapedMekanismRecipe") || message.equals("ShapelessMekanismRecipe") || message.equals("DeleteMekanismRecipes") || + message.equals("RemoveMekanismRecipes")) { + Mekanism.logger.warn(msg.getSender() + " tried to send IMC " + message + " which has been deleted. Please notify the mod developer to use JSON recipes."); found = true; } @@ -34,43 +31,32 @@ public class IMCHandler { for (Recipe type : Recipe.values()) { if (message.equalsIgnoreCase(type.getRecipeName() + "Recipe") || - message.equalsIgnoreCase(type.getOldRecipeName() + "Recipe")) { + message.equalsIgnoreCase(type.getOldRecipeName() + "Recipe")) { MachineInput input = type.createInput(msg.getNBTValue()); - if (input != null && input.isValid()) { MachineRecipe recipe = type.createRecipe(input, msg.getNBTValue()); - if (recipe != null && recipe.recipeOutput != null) { if (delete) { RecipeHandler.removeRecipe(type, recipe); - Mekanism.logger - .info(msg.getSender() + " removed recipe of type " + type.getRecipeName() - + " from the recipe list."); + Mekanism.logger.info(msg.getSender() + " removed recipe of type " + type.getRecipeName() + " from the recipe list."); } else { RecipeHandler.addRecipe(type, recipe); - Mekanism.logger - .info(msg.getSender() + " added recipe of type " + type.getRecipeName() - + " to the recipe list."); + Mekanism.logger.info(msg.getSender() + " added recipe of type " + type.getRecipeName() + " to the recipe list."); } } else { - Mekanism.logger.error(msg.getSender() + " attempted to " + (delete ? "remove" : "add") - + " recipe of type " + type.getRecipeName() + " with an invalid output."); + Mekanism.logger.error(msg.getSender() + " attempted to " + (delete ? "remove" : "add") + " recipe of type " + type.getRecipeName() + " with an invalid output."); } } else { - Mekanism.logger.error( - msg.getSender() + " attempted to " + (delete ? "remove" : "add") + " recipe of type " - + type.getRecipeName() + " with an invalid input."); + Mekanism.logger.error(msg.getSender() + " attempted to " + (delete ? "remove" : "add") + " recipe of type " + type.getRecipeName() + " with an invalid input."); } - found = true; break; } } - if (!found) { Mekanism.logger.error(msg.getSender() + " sent unknown IMC message with key '" + msg.key + ".'"); } } } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/MekanismHooks.java b/src/main/java/mekanism/common/integration/MekanismHooks.java index 20c7ad469..f7dcdb588 100644 --- a/src/main/java/mekanism/common/integration/MekanismHooks.java +++ b/src/main/java/mekanism/common/integration/MekanismHooks.java @@ -114,12 +114,10 @@ public final class MekanismHooks { public void hookInit() { //Integrate with Waila - FMLInterModComms - .sendMessage(WAILA_MOD_ID, "register", "mekanism.common.integration.WailaDataProvider.register"); + FMLInterModComms.sendMessage(WAILA_MOD_ID, "register", "mekanism.common.integration.WailaDataProvider.register"); //Register TOP handler - FMLInterModComms - .sendFunctionMessage(TOP_MOD_ID, "getTheOneProbe", "mekanism.common.integration.TOPProvider"); + FMLInterModComms.sendFunctionMessage(TOP_MOD_ID, "getTheOneProbe", "mekanism.common.integration.TOPProvider"); if (OCLoaded) { loadOCDrivers(); } @@ -152,13 +150,11 @@ public final class MekanismHooks { if (MALoaded) { registerMysticalAgricultureRecipes(); } - if (CraftTweakerLoaded) { //CraftTweaker must be ran after all other recipe changes CrafttweakerIntegration.registerCommands(); CrafttweakerIntegration.applyRecipeChanges(); } - Wrenches.initialise(); } @@ -168,11 +164,9 @@ public final class MekanismHooks { if (!entry.getInput().getInputs().isEmpty()) { if (!RecipeHandler.Recipe.CRUSHER.containsRecipe(entry.getInput().getInputs().get(0))) { List names = OreDictCache.getOreDictName(entry.getInput().getInputs().get(0)); - for (String name : names) { if (name.startsWith("ingot") || name.startsWith("crystal")) { - RecipeHandler.addCrusherRecipe(entry.getInput().getInputs().get(0), - entry.getOutput().iterator().next()); + RecipeHandler.addCrusherRecipe(entry.getInput().getInputs().get(0), entry.getOutput().iterator().next()); break; } } @@ -262,14 +256,11 @@ public final class MekanismHooks { private void registerAE2P2P() { for (TransmitterType type : TransmitterType.values()) { if (type.getTransmission().equals(TransmissionType.ITEM)) { - FMLInterModComms.sendMessage(APPLIED_ENERGISTICS_2_MOD_ID, "add-p2p-attunement-item", - new ItemStack(MekanismBlocks.Transmitter, 1, type.ordinal())); + FMLInterModComms.sendMessage(APPLIED_ENERGISTICS_2_MOD_ID, "add-p2p-attunement-item", new ItemStack(MekanismBlocks.Transmitter, 1, type.ordinal())); } else if (type.getTransmission().equals(TransmissionType.FLUID)) { - FMLInterModComms.sendMessage(APPLIED_ENERGISTICS_2_MOD_ID, "add-p2p-attunement-fluid", - new ItemStack(MekanismBlocks.Transmitter, 1, type.ordinal())); + FMLInterModComms.sendMessage(APPLIED_ENERGISTICS_2_MOD_ID, "add-p2p-attunement-fluid", new ItemStack(MekanismBlocks.Transmitter, 1, type.ordinal())); } else if (type.getTransmission().equals(TransmissionType.ENERGY)) { - FMLInterModComms.sendMessage(APPLIED_ENERGISTICS_2_MOD_ID, "add-p2p-attunement-fe-power", - new ItemStack(MekanismBlocks.Transmitter, 1, type.ordinal())); + FMLInterModComms.sendMessage(APPLIED_ENERGISTICS_2_MOD_ID, "add-p2p-attunement-fe-power", new ItemStack(MekanismBlocks.Transmitter, 1, type.ordinal())); } } } @@ -339,8 +330,7 @@ public final class MekanismHooks { //there appears to be no way to get this via api, so fall back to unloc names crystalSeed.get().getSubItems(CreativeTabs.SEARCH, seeds); //Crystal seeds use a meta AND NBT to determine growth state, so we need to ignore the NBT, and use the meta which should be fixed on what stage it's at - MachineInput.addCustomItemMatcher(crystalSeed.get().getClass(), - (def, test) -> def.getItem() == test.getItem() && def.getMetadata() == test.getMetadata()); + MachineInput.addCustomItemMatcher(crystalSeed.get().getClass(), (def, test) -> def.getItem() == test.getItem() && def.getMetadata() == test.getMetadata()); for (ItemStack stack : seeds) { String unloc = crystalSeed.get().getTranslationKey(stack); if (unloc.endsWith("certus") && pureCertus.isPresent()) { @@ -352,7 +342,6 @@ public final class MekanismHooks { } } } - } catch (Exception e) { Mekanism.logger.error("Something went wrong with ae2 integration", e); } catch (IncompatibleClassChangeError e) { @@ -407,20 +396,18 @@ public final class MekanismHooks { Item oreItem = ForgeRegistries.ITEMS.getValue(new ResourceLocation(MYSTICALAGRICULTURE_MOD_ID, oreName)); Item dropItem = ForgeRegistries.ITEMS.getValue(new ResourceLocation(MYSTICALAGRICULTURE_MOD_ID, ore.itemName)); if (oreItem != null && dropItem != null) { - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(oreItem), - new ItemStack(dropItem, type.quantity, ore.itemMeta)); - RecipeHandler.addCombinerRecipe(new ItemStack(dropItem, type.quantity + 2, ore.itemMeta), - new ItemStack(type.baseBlock), new ItemStack(oreItem)); + RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(oreItem), new ItemStack(dropItem, type.quantity, ore.itemMeta)); + RecipeHandler.addCombinerRecipe(new ItemStack(dropItem, type.quantity + 2, ore.itemMeta), new ItemStack(type.baseBlock), new ItemStack(oreItem)); } } private void registerMysticalAgricultureRecipes() { - registerMARecipeSet(MAOre.INFERIUM, MAOreType.OVERWORLD); - registerMARecipeSet(MAOre.INFERIUM, MAOreType.NETHER); - registerMARecipeSet(MAOre.INFERIUM, MAOreType.END); - registerMARecipeSet(MAOre.PROSPERITY, MAOreType.OVERWORLD); - registerMARecipeSet(MAOre.PROSPERITY, MAOreType.NETHER); - registerMARecipeSet(MAOre.PROSPERITY, MAOreType.END); + registerMARecipeSet(MAOre.INFERIUM, MAOreType.OVERWORLD); + registerMARecipeSet(MAOre.INFERIUM, MAOreType.NETHER); + registerMARecipeSet(MAOre.INFERIUM, MAOreType.END); + registerMARecipeSet(MAOre.PROSPERITY, MAOreType.OVERWORLD); + registerMARecipeSet(MAOre.PROSPERITY, MAOreType.NETHER); + registerMARecipeSet(MAOre.PROSPERITY, MAOreType.END); } private enum MAOre { @@ -430,7 +417,7 @@ public final class MekanismHooks { private final String itemName; private final int itemMeta; - private MAOre(String name, int meta) { + MAOre(String name, int meta) { itemName = name; itemMeta = meta; } @@ -445,11 +432,10 @@ public final class MekanismHooks { private final Block baseBlock; private final int quantity; - private MAOreType(String prefix, Block base, int quantity) { + MAOreType(String prefix, Block base, int quantity) { orePrefix = prefix; baseBlock = base; this.quantity = quantity; } } - } \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/OreDictManager.java b/src/main/java/mekanism/common/integration/OreDictManager.java index 1a0190c28..5e54b00c7 100644 --- a/src/main/java/mekanism/common/integration/OreDictManager.java +++ b/src/main/java/mekanism/common/integration/OreDictManager.java @@ -32,10 +32,8 @@ import net.minecraftforge.oredict.OreDictionary; public final class OreDictManager { - private static final List minorCompatIngot = Arrays - .asList("Aluminum", "Draconium", "Iridium", "Mithril", "Nickel", "Platinum", "Uranium"); - private static final List minorCompatGem = Arrays - .asList("Amber", "Diamond", "Emerald", "Malachite", "Peridot", "Ruby", "Sapphire", "Tanzanite", "Topaz"); + private static final List minorCompatIngot = Arrays.asList("Aluminum", "Draconium", "Iridium", "Mithril", "Nickel", "Platinum", "Uranium"); + private static final List minorCompatGem = Arrays.asList("Amber", "Diamond", "Emerald", "Malachite", "Peridot", "Ruby", "Sapphire", "Tanzanite", "Topaz"); public static void init() { addLogRecipes(); @@ -58,22 +56,20 @@ public final class OreDictManager { } for (ItemStack ore : OreDictionary.getOres("oreNetherSteel")) { - RecipeHandler - .addEnrichmentChamberRecipe(StackUtils.size(ore, 1), new ItemStack(MekanismItems.OtherDust, 4, 1)); + RecipeHandler.addEnrichmentChamberRecipe(StackUtils.size(ore, 1), new ItemStack(MekanismItems.OtherDust, 4, 1)); } oreDict = OreDictionary.getOres("itemRubber"); if (oreDict.size() > 0) { ItemStack itemRubber = StackUtils.size(oreDict.get(0), 1); for (ItemStack rubber : OreDictionary.getOres("woodRubber")) { - RecipeHandler.addPrecisionSawmillRecipe(StackUtils.size(rubber, 1), - new ItemStack(Blocks.PLANKS, BlockPlanks.EnumType.JUNGLE.getMetadata(), 4), itemRubber, 1F); + RecipeHandler.addPrecisionSawmillRecipe(StackUtils.size(rubber, 1), new ItemStack(Blocks.PLANKS, BlockPlanks.EnumType.JUNGLE.getMetadata(), 4), + itemRubber, 1F); } } for (ItemStack sulfur : OreDictionary.getOres("dustSulfur")) { - RecipeHandler - .addChemicalOxidizerRecipe(StackUtils.size(sulfur, 1), new GasStack(MekanismFluids.SulfurDioxide, 100)); + RecipeHandler.addChemicalOxidizerRecipe(StackUtils.size(sulfur, 1), new GasStack(MekanismFluids.SulfurDioxide, 100)); } for (ItemStack salt : OreDictionary.getOres("dustSalt")) { @@ -82,50 +78,39 @@ public final class OreDictManager { for (ItemStack dust : OreDictionary.getOres("dustRefinedObsidian")) { RecipeHandler.addOsmiumCompressorRecipe(StackUtils.size(dust, 1), new ItemStack(MekanismItems.Ingot, 1, 0)); - RecipeHandler - .addEnrichmentChamberRecipe(StackUtils.size(dust, 1), new ItemStack(MekanismItems.CompressedObsidian)); - - InfuseRegistry - .registerInfuseObject(StackUtils.size(dust, 1), new InfuseObject(InfuseRegistry.get("OBSIDIAN"), 10)); + RecipeHandler.addEnrichmentChamberRecipe(StackUtils.size(dust, 1), new ItemStack(MekanismItems.CompressedObsidian)); + InfuseRegistry.registerInfuseObject(StackUtils.size(dust, 1), new InfuseObject(InfuseRegistry.get("OBSIDIAN"), 10)); } for (Resource resource : Resource.values()) { for (ItemStack clump : OreDictionary.getOres("clump" + resource.getName())) { - RecipeHandler.addCrusherRecipe(StackUtils.size(clump, 1), - new ItemStack(MekanismItems.DirtyDust, 1, resource.ordinal())); + RecipeHandler.addCrusherRecipe(StackUtils.size(clump, 1), new ItemStack(MekanismItems.DirtyDust, 1, resource.ordinal())); } for (ItemStack shard : OreDictionary.getOres("shard" + resource.getName())) { - RecipeHandler.addPurificationChamberRecipe(StackUtils.size(shard, 1), - new ItemStack(MekanismItems.Clump, 1, resource.ordinal())); + RecipeHandler.addPurificationChamberRecipe(StackUtils.size(shard, 1), new ItemStack(MekanismItems.Clump, 1, resource.ordinal())); } for (ItemStack crystal : OreDictionary.getOres("crystal" + resource.getName())) { - RecipeHandler - .addChemicalInjectionChamberRecipe(StackUtils.size(crystal, 1), MekanismFluids.HydrogenChloride, - new ItemStack(MekanismItems.Shard, 1, resource.ordinal())); + RecipeHandler.addChemicalInjectionChamberRecipe(StackUtils.size(crystal, 1), MekanismFluids.HydrogenChloride, + new ItemStack(MekanismItems.Shard, 1, resource.ordinal())); } for (ItemStack dust : OreDictionary.getOres("dustDirty" + resource.getName())) { - RecipeHandler.addEnrichmentChamberRecipe(StackUtils.size(dust, 1), - new ItemStack(MekanismItems.Dust, 1, resource.ordinal())); + RecipeHandler.addEnrichmentChamberRecipe(StackUtils.size(dust, 1), new ItemStack(MekanismItems.Dust, 1, resource.ordinal())); } for (ItemStack ore : OreDictionary.getOres("ore" + resource.getName())) { - RecipeHandler.addEnrichmentChamberRecipe(StackUtils.size(ore, 1), - new ItemStack(MekanismItems.Dust, 2, resource.ordinal())); - RecipeHandler.addPurificationChamberRecipe(StackUtils.size(ore, 1), - new ItemStack(MekanismItems.Clump, 3, resource.ordinal())); - RecipeHandler - .addChemicalInjectionChamberRecipe(StackUtils.size(ore, 1), MekanismFluids.HydrogenChloride, - new ItemStack(MekanismItems.Shard, 4, resource.ordinal())); + RecipeHandler.addEnrichmentChamberRecipe(StackUtils.size(ore, 1), new ItemStack(MekanismItems.Dust, 2, resource.ordinal())); + RecipeHandler.addPurificationChamberRecipe(StackUtils.size(ore, 1), new ItemStack(MekanismItems.Clump, 3, resource.ordinal())); + RecipeHandler.addChemicalInjectionChamberRecipe(StackUtils.size(ore, 1), MekanismFluids.HydrogenChloride, + new ItemStack(MekanismItems.Shard, 4, resource.ordinal())); RecipeHandler.addChemicalDissolutionChamberRecipe(StackUtils.size(ore, 1), new GasStack(GasRegistry.getGas(resource.getName().toLowerCase(Locale.ROOT)), 1000)); } for (ItemStack ingot : OreDictionary.getOres("ingot" + resource.getName())) { - RecipeHandler.addCrusherRecipe(StackUtils.size(ingot, 1), - new ItemStack(MekanismItems.Dust, 1, resource.ordinal())); + RecipeHandler.addCrusherRecipe(StackUtils.size(ingot, 1), new ItemStack(MekanismItems.Dust, 1, resource.ordinal())); } oreDict = OreDictionary.getOres("ore" + resource.getName()); @@ -154,26 +139,21 @@ public final class OreDictManager { for (ItemStack gem : OreDictionary.getOres("gemQuartz")) { RecipeHandler.addCrusherRecipe(StackUtils.size(gem, 1), dustNeterQuartz); } - } - + oreDict = OreDictionary.getOres("oreQuartz"); if (oreDict.size() > 0) { ItemStack oreQuartz = StackUtils.size(oreDict.get(0), 1); oreDict = OreDictionary.getOres("dustQuartz"); if (oreDict.size() > 0) { for (ItemStack dust : oreDict) { - RecipeHandler.addCombinerRecipe(StackUtils.size(dust, 8), new ItemStack(Blocks.COBBLESTONE), - oreQuartz); + RecipeHandler.addCombinerRecipe(StackUtils.size(dust, 8), new ItemStack(Blocks.COBBLESTONE), oreQuartz); } - } - else { + } else { for (ItemStack gem : OreDictionary.getOres("gemQuartz")) { - RecipeHandler.addCombinerRecipe(StackUtils.size(gem, 8), new ItemStack(Blocks.COBBLESTONE), - oreQuartz); + RecipeHandler.addCombinerRecipe(StackUtils.size(gem, 8), new ItemStack(Blocks.COBBLESTONE), oreQuartz); } } - } oreDict = OreDictionary.getOres("gemQuartz"); @@ -182,7 +162,6 @@ public final class OreDictManager { for (ItemStack dust : OreDictionary.getOres("dustNetherQuartz")) { RecipeHandler.addEnrichmentChamberRecipe(StackUtils.size(dust, 1), gemQuartz); } - gemQuartz = StackUtils.size(gemQuartz, 6); for (ItemStack ore : OreDictionary.getOres("oreQuartz")) { RecipeHandler.addEnrichmentChamberRecipe(StackUtils.size(ore, 1), gemQuartz); @@ -203,14 +182,11 @@ public final class OreDictManager { oreDict = OreDictionary.getOres("dustLapis"); if (oreDict.size() > 0) { for (ItemStack dust : oreDict) { - RecipeHandler.addCombinerRecipe(StackUtils.size(dust, 16), new ItemStack(Blocks.COBBLESTONE), - oreLapis); + RecipeHandler.addCombinerRecipe(StackUtils.size(dust, 16), new ItemStack(Blocks.COBBLESTONE), oreLapis); } - } - else { + } else { for (ItemStack gem : OreDictionary.getOres("gemLapis")) { - RecipeHandler.addCombinerRecipe(StackUtils.size(gem, 16), new ItemStack(Blocks.COBBLESTONE), - oreLapis); + RecipeHandler.addCombinerRecipe(StackUtils.size(gem, 16), new ItemStack(Blocks.COBBLESTONE), oreLapis); } } } @@ -232,8 +208,7 @@ public final class OreDictManager { if (oreDict.size() > 0) { ItemStack oreRedstone = StackUtils.size(oreDict.get(0), 1); for (ItemStack dust : OreDictionary.getOres("dustRedstone")) { - RecipeHandler.addCombinerRecipe(StackUtils.size(dust, 16), new ItemStack(Blocks.COBBLESTONE), - oreRedstone); + RecipeHandler.addCombinerRecipe(StackUtils.size(dust, 16), new ItemStack(Blocks.COBBLESTONE), oreRedstone); } } @@ -246,8 +221,7 @@ public final class OreDictManager { } for (ItemStack ore : OreDictionary.getOres("oreCoal")) { - RecipeHandler.addEnrichmentChamberRecipe(StackUtils.size(ore, 1), - new ItemStack(Items.COAL, 2)); + RecipeHandler.addEnrichmentChamberRecipe(StackUtils.size(ore, 1), new ItemStack(Items.COAL, 2)); } oreDict = OreDictionary.getOres("oreAmethyst"); @@ -256,14 +230,11 @@ public final class OreDictManager { oreDict = OreDictionary.getOres("dustAmethyst"); if (oreDict.size() > 0) { for (ItemStack dust : oreDict) { - RecipeHandler.addCombinerRecipe(StackUtils.size(dust, 3), new ItemStack(Blocks.END_STONE), - oreAmethyst); + RecipeHandler.addCombinerRecipe(StackUtils.size(dust, 3), new ItemStack(Blocks.END_STONE), oreAmethyst); } - } - else { + } else { for (ItemStack gem : OreDictionary.getOres("gemAmethyst")) { - RecipeHandler.addCombinerRecipe(StackUtils.size(gem, 3), new ItemStack(Blocks.END_STONE), - oreAmethyst); + RecipeHandler.addCombinerRecipe(StackUtils.size(gem, 3), new ItemStack(Blocks.END_STONE), oreAmethyst); } } } @@ -282,14 +253,11 @@ public final class OreDictManager { oreDict = OreDictionary.getOres("dustApatite"); if (oreDict.size() > 0) { for (ItemStack dust : oreDict) { - RecipeHandler.addCombinerRecipe(StackUtils.size(dust, 6), new ItemStack(Blocks.COBBLESTONE), - oreApatite); + RecipeHandler.addCombinerRecipe(StackUtils.size(dust, 6), new ItemStack(Blocks.COBBLESTONE), oreApatite); } - } - else { + } else { for (ItemStack gem : OreDictionary.getOres("gemApatite")) { - RecipeHandler.addCombinerRecipe(StackUtils.size(gem, 6), new ItemStack(Blocks.COBBLESTONE), - oreApatite); + RecipeHandler.addCombinerRecipe(StackUtils.size(gem, 6), new ItemStack(Blocks.COBBLESTONE), oreApatite); } } } @@ -345,15 +313,13 @@ public final class OreDictManager { oreDict = OreDictionary.getOres("ingotSilver"); if (oreDict.size() > 0) { ItemStack ingotSilver = StackUtils.size(oreDict.get(0), 1); - FurnaceRecipes.instance().addSmeltingRecipe(new ItemStack(MekanismItems.Dust, 1, Resource.SILVER.ordinal()), - ingotSilver, 0.0F); + FurnaceRecipes.instance().addSmeltingRecipe(new ItemStack(MekanismItems.Dust, 1, Resource.SILVER.ordinal()), ingotSilver, 0.0F); } oreDict = OreDictionary.getOres("ingotLead"); if (oreDict.size() > 0) { ItemStack ingotLead = StackUtils.size(oreDict.get(0), 1); - FurnaceRecipes.instance().addSmeltingRecipe(new ItemStack(MekanismItems.Dust, 1, Resource.LEAD.ordinal()), - ingotLead, 0.0F); + FurnaceRecipes.instance().addSmeltingRecipe(new ItemStack(MekanismItems.Dust, 1, Resource.LEAD.ordinal()), ingotLead, 0.0F); } oreDict = OreDictionary.getOres("dustCoal"); @@ -395,8 +361,7 @@ public final class OreDictManager { } for (ItemStack dust : OreDictionary.getOres("dustObsidian")) { - RecipeHandler.addCombinerRecipe(StackUtils.size(dust, 4), new ItemStack(Blocks.COBBLESTONE), - new ItemStack(Blocks.OBSIDIAN)); + RecipeHandler.addCombinerRecipe(StackUtils.size(dust, 4), new ItemStack(Blocks.COBBLESTONE), new ItemStack(Blocks.OBSIDIAN)); RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("DIAMOND"), 10, StackUtils.size(dust, 1), new ItemStack(MekanismItems.OtherDust, 1, 5)); } @@ -411,8 +376,7 @@ public final class OreDictManager { for (ItemStack ore : OreDictionary.getOres("treeSapling")) { if (ore.getItemDamage() == 0 || ore.getItemDamage() == OreDictionary.WILDCARD_VALUE) { - RecipeHandler.addCrusherRecipe(new ItemStack(ore.getItem(), 1, OreDictionary.WILDCARD_VALUE), - new ItemStack(MekanismItems.BioFuel, 2)); + RecipeHandler.addCrusherRecipe(new ItemStack(ore.getItem(), 1, OreDictionary.WILDCARD_VALUE), new ItemStack(MekanismItems.BioFuel, 2)); } } } @@ -425,8 +389,7 @@ public final class OreDictManager { /** - * Handy method for retrieving all log items, finding their corresponding planks, and making recipes with them. - * Credit to CofhCore. + * Handy method for retrieving all log items, finding their corresponding planks, and making recipes with them. Credit to CofhCore. */ private static void addLogRecipes() { Container tempContainer = new Container() { @@ -460,8 +423,8 @@ public final class OreDictManager { ItemStack resultEntry = MekanismUtils.findMatchingRecipe(tempCrafting, null); if (!resultEntry.isEmpty()) { - RecipeHandler.addPrecisionSawmillRecipe(log, StackUtils.size(resultEntry, 6), - new ItemStack(MekanismItems.Sawdust), MekanismConfig.current().general.sawdustChanceLog.val()); + RecipeHandler.addPrecisionSawmillRecipe(log, StackUtils.size(resultEntry, 6), new ItemStack(MekanismItems.Sawdust), + MekanismConfig.current().general.sawdustChanceLog.val()); } } @@ -480,12 +443,11 @@ public final class OreDictManager { if (ores.size() > 0) { for (ItemStack dust : dusts) { - RecipeHandler.addCombinerRecipe(StackUtils.size(dust, 8), new ItemStack(Blocks.COBBLESTONE), - StackUtils.size(ores.get(0), 1)); + RecipeHandler.addCombinerRecipe(StackUtils.size(dust, 8), new ItemStack(Blocks.COBBLESTONE), StackUtils.size(ores.get(0), 1)); } } } - + public static void addStandardOredictGem(String suffix) { NonNullList gems = OreDictionary.getOres("gem" + suffix); NonNullList dusts = OreDictionary.getOres("dust" + suffix); @@ -510,12 +472,11 @@ public final class OreDictManager { for (ItemStack dust : dusts) { RecipeHandler.addCombinerRecipe(StackUtils.size(dust, 3), base, ore); } - } - else { + } else { for (ItemStack gem : gems) { RecipeHandler.addCombinerRecipe(StackUtils.size(gem, 3), base, ore); } } } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/TOPProvider.java b/src/main/java/mekanism/common/integration/TOPProvider.java index f8f72061c..66bbdc685 100644 --- a/src/main/java/mekanism/common/integration/TOPProvider.java +++ b/src/main/java/mekanism/common/integration/TOPProvider.java @@ -33,8 +33,7 @@ public class TOPProvider implements Function, IProbeInfoProv } @Override - public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, - IBlockState blockState, IProbeHitData data) { + public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) { if (mode != ProbeMode.EXTENDED) { return; } @@ -44,10 +43,8 @@ public class TOPProvider implements Function, IProbeInfoProv if (tile != null) { if (tile.hasCapability(Capabilities.GAS_HANDLER_CAPABILITY, null)) { IGasHandler handler = tile.getCapability(Capabilities.GAS_HANDLER_CAPABILITY, null); - if (handler != null) { GasTankInfo[] tanks = handler.getTankInfo(); - for (GasTankInfo tank : tanks) { IProgressStyle style = probeInfo.defaultProgressStyle().suffix("mB"); if (tank.getGas() != null) { diff --git a/src/main/java/mekanism/common/integration/WailaDataProvider.java b/src/main/java/mekanism/common/integration/WailaDataProvider.java index c31d6751f..a7c5b5639 100644 --- a/src/main/java/mekanism/common/integration/WailaDataProvider.java +++ b/src/main/java/mekanism/common/integration/WailaDataProvider.java @@ -55,8 +55,7 @@ public class WailaDataProvider implements IWailaDataProvider { @Nonnull @Override @Method(modid = MekanismHooks.WAILA_MOD_ID) - public List getWailaHead(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { + public List getWailaHead(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { TileEntity tile = accessor.getTileEntity(); if (tile instanceof TileEntityInductionCell) { @@ -76,37 +75,32 @@ public class WailaDataProvider implements IWailaDataProvider { } else if (tile instanceof TileEntityBoundingBlock) { TileEntityBoundingBlock bound = (TileEntityBoundingBlock) tile; Coord4D coord = new Coord4D(bound.getPos(), tile.getWorld()); - //TODO: Switch to IItemHandler though there is no good way to get the name of an IItemHandler if (bound.receivedCoords && coord.getTileEntity(tile.getWorld()) instanceof IInventory) { currenttip.set(0, EnumColor.WHITE + ((IInventory) coord.getTileEntity(tile.getWorld())).getName()); } } - return currenttip; } @Nonnull @Override @Method(modid = MekanismHooks.WAILA_MOD_ID) - public List getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { + public List getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { return currenttip; } @Nonnull @Override @Method(modid = MekanismHooks.WAILA_MOD_ID) - public List getWailaTail(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { + public List getWailaTail(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { return currenttip; } @Nonnull @Override @Method(modid = MekanismHooks.WAILA_MOD_ID) - public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, - BlockPos pos) { + public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) { return tag; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/computer/CCPeripheral.java b/src/main/java/mekanism/common/integration/computer/CCPeripheral.java index 6e445ade0..e42e2758c 100644 --- a/src/main/java/mekanism/common/integration/computer/CCPeripheral.java +++ b/src/main/java/mekanism/common/integration/computer/CCPeripheral.java @@ -40,8 +40,7 @@ public class CCPeripheral implements IPeripheral { @Override @Optional.Method(modid = MekanismHooks.COMPUTERCRAFT_MOD_ID) - public Object[] callMethod(@Nonnull IComputerAccess computer, @Nonnull ILuaContext context, int method, - @Nonnull Object[] arguments) { + public Object[] callMethod(@Nonnull IComputerAccess computer, @Nonnull ILuaContext context, int method, @Nonnull Object[] arguments) { try { return computerTile.invoke(method, arguments); } catch (NoSuchMethodException e) { @@ -73,12 +72,10 @@ public class CCPeripheral implements IPeripheral { @Override public IPeripheral getPeripheral(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side) { TileEntity te = world.getTileEntity(pos); - if (te instanceof IComputerIntegration) { return new CCPeripheral((IComputerIntegration) te); } - return null; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/computer/IComputerIntegration.java b/src/main/java/mekanism/common/integration/computer/IComputerIntegration.java index a1871544a..11c2dafbd 100644 --- a/src/main/java/mekanism/common/integration/computer/IComputerIntegration.java +++ b/src/main/java/mekanism/common/integration/computer/IComputerIntegration.java @@ -10,4 +10,4 @@ public interface IComputerIntegration extends IInventory { String[] getMethods(); Object[] invoke(int method, Object[] args) throws Exception; -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/computer/OCDriver.java b/src/main/java/mekanism/common/integration/computer/OCDriver.java index 457438ba4..314210977 100644 --- a/src/main/java/mekanism/common/integration/computer/OCDriver.java +++ b/src/main/java/mekanism/common/integration/computer/OCDriver.java @@ -29,11 +29,9 @@ public class OCDriver extends DriverSidedTileEntity { @Override public ManagedEnvironment createEnvironment(World world, BlockPos pos, EnumFacing side) { TileEntity tile = world.getTileEntity(pos); - if (tile instanceof IComputerIntegration) { return new OCManagedEnvironment((IComputerIntegration) tile); } - return null; } @@ -46,7 +44,6 @@ public class OCDriver extends DriverSidedTileEntity { public OCManagedEnvironment(IComputerIntegration tile) { computerTile = tile; name = tile.getName().toLowerCase(Locale.ENGLISH).replace(" ", "_"); - setNode(Network.newNode(this, Visibility.Network).withComponent(name, Visibility.Network).create()); } @@ -70,4 +67,4 @@ public class OCDriver extends DriverSidedTileEntity { return name; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/crafttweaker/CrafttweakerIntegration.java b/src/main/java/mekanism/common/integration/crafttweaker/CrafttweakerIntegration.java index e0ce42f7f..d837fda84 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/CrafttweakerIntegration.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/CrafttweakerIntegration.java @@ -16,11 +16,9 @@ public class CrafttweakerIntegration { public static final List LATE_ADDITIONS = new LinkedList<>(); /** - * Apply after (machine)recipes have been applied, but before the FMLLoadCompleteEvent is fired. Preferably in - * (post)init. + * Apply after (machine)recipes have been applied, but before the FMLLoadCompleteEvent is fired. Preferably in (post)init. *

- * Applying to early causes remove to malfunction as no recipes have been registered. Applying to late causes JEI to - * not pickup the changes. + * Applying to early causes remove to malfunction as no recipes have been registered. Applying to late causes JEI to not pickup the changes. */ public static void applyRecipeChanges() { //Remove before addition, so recipes can be overwritten diff --git a/src/main/java/mekanism/common/integration/crafttweaker/commands/GasesCommand.java b/src/main/java/mekanism/common/integration/crafttweaker/commands/GasesCommand.java index 0aa6bbaca..89dcbe38b 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/commands/GasesCommand.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/commands/GasesCommand.java @@ -18,18 +18,15 @@ public class GasesCommand extends CraftTweakerCommand { @Override protected void init() { - setDescription(SpecialMessagesChat.getClickableCommandText(TextFormatting.DARK_GREEN + "/ct " + subCommandName, - "/ct " + subCommandName, true), SpecialMessagesChat.getNormalMessage(TextFormatting.DARK_AQUA + - "Outputs a list of all registered gases to the crafttweaker.log")); + setDescription(SpecialMessagesChat.getClickableCommandText(TextFormatting.DARK_GREEN + "/ct " + subCommandName, "/ct " + subCommandName, true), + SpecialMessagesChat.getNormalMessage(TextFormatting.DARK_AQUA + "Outputs a list of all registered gases to the crafttweaker.log")); } @Override public void executeCommand(MinecraftServer server, ICommandSender sender, String[] args) { CraftTweakerAPI.logCommand("Gases:"); List gases = GasRegistry.getRegisteredGasses(); - gases.forEach( - gas -> CraftTweakerAPI.logCommand(String.format(", %s", gas.getName(), gas.getLocalizedName()))); - sender.sendMessage(SpecialMessagesChat.getLinkToCraftTweakerLog( - "List of " + gases.size() + " gases generated;", sender)); + gases.forEach(gas -> CraftTweakerAPI.logCommand(String.format(", %s", gas.getName(), gas.getLocalizedName()))); + sender.sendMessage(SpecialMessagesChat.getLinkToCraftTweakerLog("List of " + gases.size() + " gases generated;", sender)); } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/crafttweaker/commands/InfuseTypesCommand.java b/src/main/java/mekanism/common/integration/crafttweaker/commands/InfuseTypesCommand.java index 119b6af14..61ef7df97 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/commands/InfuseTypesCommand.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/commands/InfuseTypesCommand.java @@ -17,9 +17,8 @@ public class InfuseTypesCommand extends CraftTweakerCommand { @Override protected void init() { - setDescription(SpecialMessagesChat.getClickableCommandText(TextFormatting.DARK_GREEN + "/ct " + subCommandName, - "/ct " + subCommandName, true), SpecialMessagesChat.getNormalMessage(TextFormatting.DARK_AQUA + - "Outputs a list of all registered metallurgic infuser infusion types to the crafttweaker.log")); + setDescription(SpecialMessagesChat.getClickableCommandText(TextFormatting.DARK_GREEN + "/ct " + subCommandName, "/ct " + subCommandName, true), + SpecialMessagesChat.getNormalMessage(TextFormatting.DARK_AQUA + "Outputs a list of all registered metallurgic infuser infusion types to the crafttweaker.log")); } @Override @@ -27,7 +26,6 @@ public class InfuseTypesCommand extends CraftTweakerCommand { CraftTweakerAPI.logCommand("Infuse Types:"); Set names = InfuseRegistry.getInfuseMap().keySet(); names.forEach(CraftTweakerAPI::logCommand); - sender.sendMessage(SpecialMessagesChat.getLinkToCraftTweakerLog("List of " + names.size() + - " metallurgic infuser infusion types generated;", sender)); + sender.sendMessage(SpecialMessagesChat.getLinkToCraftTweakerLog("List of " + names.size() + " metallurgic infuser infusion types generated;", sender)); } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/crafttweaker/commands/MekRecipesCommand.java b/src/main/java/mekanism/common/integration/crafttweaker/commands/MekRecipesCommand.java index 0a1632750..91711665d 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/commands/MekRecipesCommand.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/commands/MekRecipesCommand.java @@ -40,25 +40,20 @@ public class MekRecipesCommand extends CraftTweakerCommand { public MekRecipesCommand() { super("mekrecipes"); - subCommands = Stream.of("crystallizer", "dissolution", "chemicalInfuser", "injection", "oxidizer", "washer", - "combiner", "crusher", "separator", "smelter", "enrichment", "metallurgicInfuser", "compressor", - "sawmill", "prc", "purification", "solarneutronactivator", "thermalevaporation") - .collect(Collectors.toList()); + subCommands = Stream.of("crystallizer", "dissolution", "chemicalInfuser", "injection", "oxidizer", "washer", "combiner", "crusher", "separator", "smelter", + "enrichment", "metallurgicInfuser", "compressor", "sawmill", "prc", "purification", "solarneutronactivator", "thermalevaporation").collect(Collectors.toList()); } @Override protected void init() { - setDescription(SpecialMessagesChat.getClickableCommandText( - TextFormatting.DARK_GREEN + "/ct " + subCommandName + "", "/ct " + subCommandName, true), - SpecialMessagesChat.getNormalMessage(TextFormatting.DARK_AQUA + - "Outputs a list of all registered Mekanism Machine recipes to the crafttweaker.log for the given machine type.")); + setDescription(SpecialMessagesChat.getClickableCommandText(TextFormatting.DARK_GREEN + "/ct " + subCommandName + "", "/ct " + subCommandName, true), + SpecialMessagesChat.getNormalMessage(TextFormatting.DARK_AQUA + "Outputs a list of all registered Mekanism Machine recipes to the crafttweaker.log for the given machine type.")); } @Override public void executeCommand(MinecraftServer server, ICommandSender sender, String[] args) { if (args.length == 0 || !subCommands.contains(args[0])) { - sender.sendMessage(SpecialMessagesChat.getNormalMessage( - "Recipe Type required, pick one of the following: " + Arrays.toString(subCommands.toArray()))); + sender.sendMessage(SpecialMessagesChat.getNormalMessage("Recipe Type required, pick one of the following: " + Arrays.toString(subCommands.toArray()))); return; } String subCommand = args[0]; @@ -245,14 +240,11 @@ public class MekRecipesCommand extends CraftTweakerCommand { } break; default: - sender.sendMessage(SpecialMessagesChat.getNormalMessage( - "Recipe Type required, pick one of the following: " + Arrays.toString(subCommands.toArray()))); + sender.sendMessage(SpecialMessagesChat.getNormalMessage("Recipe Type required, pick one of the following: " + Arrays.toString(subCommands.toArray()))); return; } - sender.sendMessage(SpecialMessagesChat - .getLinkToCraftTweakerLog("List of " + type.get().size() + " " + subCommand + " recipes generated;", - sender)); + sender.sendMessage(SpecialMessagesChat.getLinkToCraftTweakerLog("List of " + type.get().size() + " " + subCommand + " recipes generated;", sender)); } @Override @@ -262,7 +254,6 @@ public class MekRecipesCommand extends CraftTweakerCommand { return Collections.emptyList(); } String start = args[0].toLowerCase(); - return subCommands.stream().filter(command -> command.toLowerCase().startsWith(start)) - .collect(Collectors.toList()); + return subCommands.stream().filter(command -> command.toLowerCase().startsWith(start)).collect(Collectors.toList()); } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/crafttweaker/gas/CraftTweakerGasStack.java b/src/main/java/mekanism/common/integration/crafttweaker/gas/CraftTweakerGasStack.java index d38fe2917..d2a98d0df 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/gas/CraftTweakerGasStack.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/gas/CraftTweakerGasStack.java @@ -140,8 +140,7 @@ public class CraftTweakerGasStack implements IGasStack { @Override public String toCommandString() { - return stack.amount > 1 ? String.format(" * %s", stack.getGas().getName(), stack.amount) - : String.format("", stack.getGas().getName()); + return stack.amount > 1 ? String.format(" * %s", stack.getGas().getName(), stack.amount) : String.format("", stack.getGas().getName()); } @Override diff --git a/src/main/java/mekanism/common/integration/crafttweaker/gas/GasBracketHandler.java b/src/main/java/mekanism/common/integration/crafttweaker/gas/GasBracketHandler.java index 3e247f649..563d601c8 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/gas/GasBracketHandler.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/gas/GasBracketHandler.java @@ -52,7 +52,6 @@ public class GasBracketHandler implements IBracketHandler { Token token = tokens.get(i); valueBuilder.append(token.getValue()); } - Gas gas = GasRegistry.getGas(valueBuilder.toString()); return gas == null ? null : new GasReferenceSymbol(environment, valueBuilder.toString()); } diff --git a/src/main/java/mekanism/common/integration/crafttweaker/handlers/ChemicalCrystallizer.java b/src/main/java/mekanism/common/integration/crafttweaker/handlers/ChemicalCrystallizer.java index 3a1b3f632..6b21a3000 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/handlers/ChemicalCrystallizer.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/handlers/ChemicalCrystallizer.java @@ -28,18 +28,16 @@ public class ChemicalCrystallizer { @ZenMethod public static void addRecipe(IGasStack gasInput, IItemStack itemOutput) { if (IngredientHelper.checkNotNull(NAME, gasInput, itemOutput)) { - CrafttweakerIntegration.LATE_ADDITIONS - .add(new AddMekanismRecipe<>(NAME, Recipe.CHEMICAL_CRYSTALLIZER, - new CrystallizerRecipe(GasHelper.toGas(gasInput), CraftTweakerMC.getItemStack(itemOutput)))); + CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe<>(NAME, Recipe.CHEMICAL_CRYSTALLIZER, new CrystallizerRecipe(GasHelper.toGas(gasInput), + CraftTweakerMC.getItemStack(itemOutput)))); } } @ZenMethod public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient gasInput) { if (IngredientHelper.checkNotNull(NAME, itemOutput)) { - CrafttweakerIntegration.LATE_REMOVALS - .add(new RemoveMekanismRecipe<>(NAME, Recipe.CHEMICAL_CRYSTALLIZER, new IngredientWrapper(itemOutput), - new IngredientWrapper(gasInput))); + CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<>(NAME, Recipe.CHEMICAL_CRYSTALLIZER, new IngredientWrapper(itemOutput), + new IngredientWrapper(gasInput))); } } diff --git a/src/main/java/mekanism/common/integration/crafttweaker/handlers/ChemicalDissolution.java b/src/main/java/mekanism/common/integration/crafttweaker/handlers/ChemicalDissolution.java index 965a28602..4112239cc 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/handlers/ChemicalDissolution.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/handlers/ChemicalDissolution.java @@ -36,23 +36,20 @@ public class ChemicalDissolution { for (ItemStack stack : CraftTweakerMC.getIngredient(ingredientInput).getMatchingStacks()) { recipes.add(new DissolutionRecipe(stack, output)); } - CrafttweakerIntegration.LATE_ADDITIONS - .add(new AddMekanismRecipe<>(NAME, Recipe.CHEMICAL_DISSOLUTION_CHAMBER, recipes)); + CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe<>(NAME, Recipe.CHEMICAL_DISSOLUTION_CHAMBER, recipes)); } } @ZenMethod public static void removeRecipe(IIngredient gasOutput, @Optional IIngredient itemInput) { if (IngredientHelper.checkNotNull(NAME, gasOutput)) { - CrafttweakerIntegration.LATE_REMOVALS - .add(new RemoveMekanismRecipe<>(NAME, Recipe.CHEMICAL_DISSOLUTION_CHAMBER, - new IngredientWrapper(gasOutput), new IngredientWrapper(itemInput))); + CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<>(NAME, Recipe.CHEMICAL_DISSOLUTION_CHAMBER, new IngredientWrapper(gasOutput), + new IngredientWrapper(itemInput))); } } @ZenMethod public static void removeAllRecipes() { - CrafttweakerIntegration.LATE_REMOVALS - .add(new RemoveAllMekanismRecipe<>(NAME, Recipe.CHEMICAL_DISSOLUTION_CHAMBER)); + CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveAllMekanismRecipe<>(NAME, Recipe.CHEMICAL_DISSOLUTION_CHAMBER)); } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/crafttweaker/handlers/ChemicalInfuser.java b/src/main/java/mekanism/common/integration/crafttweaker/handlers/ChemicalInfuser.java index 0d236745c..78e30aee4 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/handlers/ChemicalInfuser.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/handlers/ChemicalInfuser.java @@ -26,10 +26,8 @@ public class ChemicalInfuser { @ZenMethod public static void addRecipe(IGasStack leftGasInput, IGasStack rightGasInput, IGasStack gasOutput) { if (IngredientHelper.checkNotNull(NAME, leftGasInput, rightGasInput, gasOutput)) { - CrafttweakerIntegration.LATE_ADDITIONS - .add(new AddMekanismRecipe<>(NAME, Recipe.CHEMICAL_INFUSER, - new ChemicalInfuserRecipe(GasHelper.toGas(leftGasInput), GasHelper.toGas(rightGasInput), - GasHelper.toGas(gasOutput)))); + CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe<>(NAME, Recipe.CHEMICAL_INFUSER, new ChemicalInfuserRecipe(GasHelper.toGas(leftGasInput), + GasHelper.toGas(rightGasInput), GasHelper.toGas(gasOutput)))); } } @@ -37,9 +35,8 @@ public class ChemicalInfuser { public static void removeRecipe(IIngredient gasOutput, @Optional IIngredient leftGasInput, @Optional IIngredient rightGasInput) { if (IngredientHelper.checkNotNull(NAME, gasOutput)) { - CrafttweakerIntegration.LATE_REMOVALS - .add(new RemoveMekanismRecipe<>(NAME, Recipe.CHEMICAL_INFUSER, new IngredientWrapper(gasOutput), - new IngredientWrapper(leftGasInput, rightGasInput))); + CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<>(NAME, Recipe.CHEMICAL_INFUSER, new IngredientWrapper(gasOutput), + new IngredientWrapper(leftGasInput, rightGasInput))); } } diff --git a/src/main/java/mekanism/common/integration/crafttweaker/handlers/ChemicalInjection.java b/src/main/java/mekanism/common/integration/crafttweaker/handlers/ChemicalInjection.java index dd2d2e16b..6c8d9cec3 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/handlers/ChemicalInjection.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/handlers/ChemicalInjection.java @@ -40,8 +40,7 @@ public class ChemicalInjection { for (ItemStack stack : CraftTweakerMC.getIngredient(ingredientInput).getMatchingStacks()) { recipes.add(new InjectionRecipe(new AdvancedMachineInput(stack, gas), output)); } - CrafttweakerIntegration.LATE_ADDITIONS - .add(new AddMekanismRecipe<>(NAME, Recipe.CHEMICAL_INJECTION_CHAMBER, recipes)); + CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe<>(NAME, Recipe.CHEMICAL_INJECTION_CHAMBER, recipes)); } } @@ -49,15 +48,13 @@ public class ChemicalInjection { public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional IIngredient gasInput) { if (IngredientHelper.checkNotNull(NAME, itemOutput)) { - CrafttweakerIntegration.LATE_REMOVALS - .add(new RemoveMekanismRecipe<>(NAME, Recipe.CHEMICAL_INJECTION_CHAMBER, - new IngredientWrapper(itemOutput), new IngredientWrapper(itemInput, gasInput))); + CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<>(NAME, Recipe.CHEMICAL_INJECTION_CHAMBER, new IngredientWrapper(itemOutput), + new IngredientWrapper(itemInput, gasInput))); } } @ZenMethod public static void removeAllRecipes() { - CrafttweakerIntegration.LATE_REMOVALS - .add(new RemoveAllMekanismRecipe<>(NAME, Recipe.CHEMICAL_INJECTION_CHAMBER)); + CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveAllMekanismRecipe<>(NAME, Recipe.CHEMICAL_INJECTION_CHAMBER)); } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/crafttweaker/handlers/ChemicalOxidizer.java b/src/main/java/mekanism/common/integration/crafttweaker/handlers/ChemicalOxidizer.java index b3d6e8698..0458865ce 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/handlers/ChemicalOxidizer.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/handlers/ChemicalOxidizer.java @@ -36,17 +36,15 @@ public class ChemicalOxidizer { for (ItemStack stack : CraftTweakerMC.getIngredient(ingredientInput).getMatchingStacks()) { recipes.add(new OxidationRecipe(stack, output)); } - CrafttweakerIntegration.LATE_ADDITIONS - .add(new AddMekanismRecipe<>(NAME, Recipe.CHEMICAL_OXIDIZER, recipes)); + CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe<>(NAME, Recipe.CHEMICAL_OXIDIZER, recipes)); } } @ZenMethod public static void removeRecipe(IIngredient gasOutput, @Optional IIngredient itemInput) { if (IngredientHelper.checkNotNull(NAME, gasOutput)) { - CrafttweakerIntegration.LATE_REMOVALS - .add(new RemoveMekanismRecipe<>(NAME, Recipe.CHEMICAL_OXIDIZER, new IngredientWrapper(gasOutput), - new IngredientWrapper(itemInput))); + CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<>(NAME, Recipe.CHEMICAL_OXIDIZER, new IngredientWrapper(gasOutput), + new IngredientWrapper(itemInput))); } } diff --git a/src/main/java/mekanism/common/integration/crafttweaker/handlers/ChemicalWasher.java b/src/main/java/mekanism/common/integration/crafttweaker/handlers/ChemicalWasher.java index f2e14f1b3..c87147a50 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/handlers/ChemicalWasher.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/handlers/ChemicalWasher.java @@ -26,17 +26,16 @@ public class ChemicalWasher { @ZenMethod public static void addRecipe(IGasStack gasInput, IGasStack gasOutput) { if (IngredientHelper.checkNotNull(NAME, gasInput, gasOutput)) { - CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe<>(NAME, Recipe.CHEMICAL_WASHER, - new WasherRecipe(GasHelper.toGas(gasInput), GasHelper.toGas(gasOutput)))); + CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe<>(NAME, Recipe.CHEMICAL_WASHER, new WasherRecipe(GasHelper.toGas(gasInput), + GasHelper.toGas(gasOutput)))); } } @ZenMethod public static void removeRecipe(IIngredient gasOutput, @Optional IIngredient gasInput) { if (IngredientHelper.checkNotNull(NAME, gasOutput)) { - CrafttweakerIntegration.LATE_REMOVALS - .add(new RemoveMekanismRecipe<>(NAME, Recipe.CHEMICAL_WASHER, new IngredientWrapper(gasOutput), - new IngredientWrapper(gasInput))); + CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<>(NAME, Recipe.CHEMICAL_WASHER, new IngredientWrapper(gasOutput), + new IngredientWrapper(gasInput))); } } diff --git a/src/main/java/mekanism/common/integration/crafttweaker/handlers/Combiner.java b/src/main/java/mekanism/common/integration/crafttweaker/handlers/Combiner.java index 59d5726ca..39079a382 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/handlers/Combiner.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/handlers/Combiner.java @@ -44,8 +44,7 @@ public class Combiner { } /** - * @deprecated Replaced by {@link #addRecipe(IIngredient, IIngredient, IItemStack)}. May be removed with Minecraft - * 1.13. + * @deprecated Replaced by {@link #addRecipe(IIngredient, IIngredient, IItemStack)}. May be removed with Minecraft 1.13. */ @ZenMethod @Deprecated @@ -64,9 +63,8 @@ public class Combiner { public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional IIngredient extraInput) { if (IngredientHelper.checkNotNull(NAME, itemOutput)) { - CrafttweakerIntegration.LATE_REMOVALS - .add(new RemoveMekanismRecipe<>(NAME, Recipe.COMBINER, new IngredientWrapper(itemOutput), - new IngredientWrapper(itemInput, extraInput))); + CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<>(NAME, Recipe.COMBINER, new IngredientWrapper(itemOutput), + new IngredientWrapper(itemInput, extraInput))); } } diff --git a/src/main/java/mekanism/common/integration/crafttweaker/handlers/Compressor.java b/src/main/java/mekanism/common/integration/crafttweaker/handlers/Compressor.java index 6d1ed9181..81bce6c0a 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/handlers/Compressor.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/handlers/Compressor.java @@ -39,8 +39,7 @@ public class Compressor { for (ItemStack stack : CraftTweakerMC.getIngredient(ingredientInput).getMatchingStacks()) { recipes.add(new OsmiumCompressorRecipe(stack, output)); } - CrafttweakerIntegration.LATE_ADDITIONS - .add(new AddMekanismRecipe<>(NAME, Recipe.OSMIUM_COMPRESSOR, recipes)); + CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe<>(NAME, Recipe.OSMIUM_COMPRESSOR, recipes)); } } @@ -53,8 +52,7 @@ public class Compressor { for (ItemStack stack : CraftTweakerMC.getIngredient(ingredientInput).getMatchingStacks()) { recipes.add(new OsmiumCompressorRecipe(new AdvancedMachineInput(stack, gas), output)); } - CrafttweakerIntegration.LATE_ADDITIONS - .add(new AddMekanismRecipe<>(NAME, Recipe.OSMIUM_COMPRESSOR, recipes)); + CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe<>(NAME, Recipe.OSMIUM_COMPRESSOR, recipes)); } } @@ -62,9 +60,8 @@ public class Compressor { public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional IIngredient gasInput) { if (IngredientHelper.checkNotNull(NAME, itemOutput)) { - CrafttweakerIntegration.LATE_REMOVALS - .add(new RemoveMekanismRecipe<>(NAME, Recipe.OSMIUM_COMPRESSOR, new IngredientWrapper(itemOutput), - new IngredientWrapper(itemInput, gasInput))); + CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<>(NAME, Recipe.OSMIUM_COMPRESSOR, new IngredientWrapper(itemOutput), + new IngredientWrapper(itemInput, gasInput))); } } diff --git a/src/main/java/mekanism/common/integration/crafttweaker/handlers/Crusher.java b/src/main/java/mekanism/common/integration/crafttweaker/handlers/Crusher.java index 33fb23ef7..07846703d 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/handlers/Crusher.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/handlers/Crusher.java @@ -41,9 +41,8 @@ public class Crusher { @ZenMethod public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput) { if (IngredientHelper.checkNotNull(NAME, itemOutput)) { - CrafttweakerIntegration.LATE_REMOVALS - .add(new RemoveMekanismRecipe<>(NAME, Recipe.CRUSHER, new IngredientWrapper(itemOutput), - new IngredientWrapper(itemInput))); + CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<>(NAME, Recipe.CRUSHER, new IngredientWrapper(itemOutput), + new IngredientWrapper(itemInput))); } } diff --git a/src/main/java/mekanism/common/integration/crafttweaker/handlers/EnergizedSmelter.java b/src/main/java/mekanism/common/integration/crafttweaker/handlers/EnergizedSmelter.java index b32af24f5..afd933452 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/handlers/EnergizedSmelter.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/handlers/EnergizedSmelter.java @@ -44,8 +44,7 @@ public class EnergizedSmelter { for (ItemStack stack : CraftTweakerMC.getIngredient(ingredientInput).getMatchingStacks()) { recipes.add(new SmeltingRecipe(stack, output)); } - CrafttweakerIntegration.LATE_ADDITIONS - .add(new AddMekanismRecipe<>(NAME, Recipe.ENERGIZED_SMELTER, recipes)); + CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe<>(NAME, Recipe.ENERGIZED_SMELTER, recipes)); addedRecipe = true; } } @@ -53,9 +52,8 @@ public class EnergizedSmelter { @ZenMethod public static void removeRecipe(IIngredient itemInput, @Optional IIngredient itemOutput) { if (IngredientHelper.checkNotNull(NAME, itemInput)) { - CrafttweakerIntegration.LATE_REMOVALS - .add(new RemoveMekanismRecipe<>(NAME, Recipe.ENERGIZED_SMELTER, new IngredientWrapper(itemOutput), - new IngredientWrapper(itemInput))); + CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<>(NAME, Recipe.ENERGIZED_SMELTER, new IngredientWrapper(itemOutput), + new IngredientWrapper(itemInput))); removedRecipe = true; } } diff --git a/src/main/java/mekanism/common/integration/crafttweaker/handlers/Enrichment.java b/src/main/java/mekanism/common/integration/crafttweaker/handlers/Enrichment.java index e1765dbc0..9492729a8 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/handlers/Enrichment.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/handlers/Enrichment.java @@ -34,17 +34,15 @@ public class Enrichment { for (ItemStack stack : CraftTweakerMC.getIngredient(ingredientInput).getMatchingStacks()) { recipes.add(new EnrichmentRecipe(stack, output)); } - CrafttweakerIntegration.LATE_ADDITIONS - .add(new AddMekanismRecipe<>(NAME, Recipe.ENRICHMENT_CHAMBER, recipes)); + CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe<>(NAME, Recipe.ENRICHMENT_CHAMBER, recipes)); } } @ZenMethod public static void removeRecipe(IIngredient itemInput, @Optional IIngredient itemOutput) { if (IngredientHelper.checkNotNull(NAME, itemInput)) { - CrafttweakerIntegration.LATE_REMOVALS - .add(new RemoveMekanismRecipe<>(NAME, Recipe.ENRICHMENT_CHAMBER, new IngredientWrapper(itemOutput), - new IngredientWrapper(itemInput))); + CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<>(NAME, Recipe.ENRICHMENT_CHAMBER, new IngredientWrapper(itemOutput), + new IngredientWrapper(itemInput))); } } diff --git a/src/main/java/mekanism/common/integration/crafttweaker/handlers/Infuser.java b/src/main/java/mekanism/common/integration/crafttweaker/handlers/Infuser.java index 6a895c5fd..83bac01b1 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/handlers/Infuser.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/handlers/Infuser.java @@ -45,8 +45,7 @@ public class Infuser { for (ItemStack stack : CraftTweakerMC.getIngredient(ingredientInput).getMatchingStacks()) { recipes.add(new MetallurgicInfuserRecipe(new InfusionInput(type, infuseAmount, stack), output)); } - CrafttweakerIntegration.LATE_ADDITIONS - .add(new AddMekanismRecipe<>(NAME, Recipe.METALLURGIC_INFUSER, recipes)); + CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe<>(NAME, Recipe.METALLURGIC_INFUSER, recipes)); } } @@ -54,9 +53,8 @@ public class Infuser { public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional String infuseType) { if (IngredientHelper.checkNotNull(NAME, itemOutput)) { - CrafttweakerIntegration.LATE_REMOVALS - .add(new RemoveMekanismRecipe<>(NAME, Recipe.METALLURGIC_INFUSER, new IngredientWrapper(itemOutput), - new IngredientWrapper(itemInput, infuseType))); + CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<>(NAME, Recipe.METALLURGIC_INFUSER, new IngredientWrapper(itemOutput), + new IngredientWrapper(itemInput, infuseType))); } } diff --git a/src/main/java/mekanism/common/integration/crafttweaker/handlers/Purification.java b/src/main/java/mekanism/common/integration/crafttweaker/handlers/Purification.java index 8df5004d1..a879abb23 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/handlers/Purification.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/handlers/Purification.java @@ -39,8 +39,7 @@ public class Purification { for (ItemStack stack : CraftTweakerMC.getIngredient(ingredientInput).getMatchingStacks()) { recipes.add(new PurificationRecipe(stack, output)); } - CrafttweakerIntegration.LATE_ADDITIONS - .add(new AddMekanismRecipe<>(NAME, Recipe.PURIFICATION_CHAMBER, recipes)); + CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe<>(NAME, Recipe.PURIFICATION_CHAMBER, recipes)); } } @@ -53,8 +52,7 @@ public class Purification { for (ItemStack stack : CraftTweakerMC.getIngredient(ingredientInput).getMatchingStacks()) { recipes.add(new PurificationRecipe(new AdvancedMachineInput(stack, gas), output)); } - CrafttweakerIntegration.LATE_ADDITIONS - .add(new AddMekanismRecipe<>(NAME, Recipe.PURIFICATION_CHAMBER, recipes)); + CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe<>(NAME, Recipe.PURIFICATION_CHAMBER, recipes)); } } @@ -62,9 +60,8 @@ public class Purification { public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional IIngredient gasInput) { if (IngredientHelper.checkNotNull(NAME, itemOutput)) { - CrafttweakerIntegration.LATE_REMOVALS - .add(new RemoveMekanismRecipe<>(NAME, Recipe.PURIFICATION_CHAMBER, new IngredientWrapper(itemOutput), - new IngredientWrapper(itemInput, gasInput))); + CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<>(NAME, Recipe.PURIFICATION_CHAMBER, new IngredientWrapper(itemOutput), + new IngredientWrapper(itemInput, gasInput))); } } diff --git a/src/main/java/mekanism/common/integration/crafttweaker/handlers/Reaction.java b/src/main/java/mekanism/common/integration/crafttweaker/handlers/Reaction.java index bd3bf3d79..3145d1ed5 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/handlers/Reaction.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/handlers/Reaction.java @@ -39,15 +39,12 @@ public class Reaction { if (IngredientHelper.checkNotNull(NAME, ingredientInput, liquidInput, gasInput, itemOutput, gasOutput)) { FluidStack fluidInput = IngredientHelper.toFluid(liquidInput); GasStack gas = GasHelper.toGas(gasInput); - PressurizedOutput output = new PressurizedOutput(CraftTweakerMC.getItemStack(itemOutput), - GasHelper.toGas(gasOutput)); + PressurizedOutput output = new PressurizedOutput(CraftTweakerMC.getItemStack(itemOutput), GasHelper.toGas(gasOutput)); List recipes = new ArrayList<>(); for (ItemStack stack : CraftTweakerMC.getIngredient(ingredientInput).getMatchingStacks()) { - recipes.add(new PressurizedRecipe( - new PressurizedInput(stack, fluidInput, gas), output, energy, duration)); + recipes.add(new PressurizedRecipe(new PressurizedInput(stack, fluidInput, gas), output, energy, duration)); } - CrafttweakerIntegration.LATE_ADDITIONS - .add(new AddMekanismRecipe<>(NAME, Recipe.PRESSURIZED_REACTION_CHAMBER, recipes)); + CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe<>(NAME, Recipe.PRESSURIZED_REACTION_CHAMBER, recipes)); } } @@ -55,16 +52,13 @@ public class Reaction { public static void removeRecipe(IIngredient itemOutput, IIngredient gasOutput, @Optional IIngredient itemInput, @Optional IIngredient liquidInput, @Optional IIngredient gasInput) { if (IngredientHelper.checkNotNull(NAME, itemOutput, gasOutput)) { - CrafttweakerIntegration.LATE_REMOVALS - .add(new RemoveMekanismRecipe<>(NAME, Recipe.PRESSURIZED_REACTION_CHAMBER, - new IngredientWrapper(itemOutput, gasOutput), - new IngredientWrapper(itemInput, liquidInput, gasInput))); + CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<>(NAME, Recipe.PRESSURIZED_REACTION_CHAMBER, new IngredientWrapper(itemOutput, gasOutput), + new IngredientWrapper(itemInput, liquidInput, gasInput))); } } @ZenMethod public static void removeAllRecipes() { - CrafttweakerIntegration.LATE_REMOVALS - .add(new RemoveAllMekanismRecipe<>(NAME, Recipe.PRESSURIZED_REACTION_CHAMBER)); + CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveAllMekanismRecipe<>(NAME, Recipe.PRESSURIZED_REACTION_CHAMBER)); } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/crafttweaker/handlers/Sawmill.java b/src/main/java/mekanism/common/integration/crafttweaker/handlers/Sawmill.java index 6b467adf5..2465db900 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/handlers/Sawmill.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/handlers/Sawmill.java @@ -32,15 +32,13 @@ public class Sawmill { public static void addRecipe(IIngredient ingredientInput, IItemStack itemOutput, @Optional IItemStack optionalItemOutput, @Optional double optionalChance) { if (IngredientHelper.checkNotNull(NAME, ingredientInput, itemOutput)) { - ChanceOutput output = optionalItemOutput == null ? new ChanceOutput(CraftTweakerMC.getItemStack(itemOutput)) - : new ChanceOutput(CraftTweakerMC.getItemStack(itemOutput), - CraftTweakerMC.getItemStack(optionalItemOutput), optionalChance); + ChanceOutput output = optionalItemOutput == null ? new ChanceOutput(CraftTweakerMC.getItemStack(itemOutput)) : new ChanceOutput(CraftTweakerMC.getItemStack(itemOutput), + CraftTweakerMC.getItemStack(optionalItemOutput), optionalChance); List recipes = new ArrayList<>(); for (ItemStack stack : CraftTweakerMC.getIngredient(ingredientInput).getMatchingStacks()) { recipes.add(new SawmillRecipe(new ItemStackInput(stack), output)); } - CrafttweakerIntegration.LATE_ADDITIONS - .add(new AddMekanismRecipe<>(NAME, Recipe.PRECISION_SAWMILL, recipes)); + CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe<>(NAME, Recipe.PRECISION_SAWMILL, recipes)); } } @@ -48,9 +46,8 @@ public class Sawmill { public static void removeRecipe(IIngredient itemInput, @Optional IIngredient itemOutput, @Optional IIngredient optionalItemOutput) { if (IngredientHelper.checkNotNull(NAME, itemInput)) { - CrafttweakerIntegration.LATE_REMOVALS - .add(new RemoveMekanismRecipe<>(NAME, Recipe.PRECISION_SAWMILL, - new IngredientWrapper(itemOutput, optionalItemOutput), new IngredientWrapper(itemInput))); + CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<>(NAME, Recipe.PRECISION_SAWMILL, new IngredientWrapper(itemOutput, optionalItemOutput), + new IngredientWrapper(itemInput))); } } diff --git a/src/main/java/mekanism/common/integration/crafttweaker/handlers/Separator.java b/src/main/java/mekanism/common/integration/crafttweaker/handlers/Separator.java index dcabc823e..cbd96cc04 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/handlers/Separator.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/handlers/Separator.java @@ -28,10 +28,8 @@ public class Separator { public static void addRecipe(ILiquidStack liquidInput, double energy, IGasStack leftGasOutput, IGasStack rightGasOutput) { if (IngredientHelper.checkNotNull(NAME, liquidInput, leftGasOutput, rightGasOutput)) { - CrafttweakerIntegration.LATE_ADDITIONS - .add(new AddMekanismRecipe<>(NAME, Recipe.ELECTROLYTIC_SEPARATOR, - new SeparatorRecipe(IngredientHelper.toFluid(liquidInput), energy, - GasHelper.toGas(leftGasOutput), GasHelper.toGas(rightGasOutput)))); + CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe<>(NAME, Recipe.ELECTROLYTIC_SEPARATOR, + new SeparatorRecipe(IngredientHelper.toFluid(liquidInput), energy, GasHelper.toGas(leftGasOutput), GasHelper.toGas(rightGasOutput)))); } } @@ -39,9 +37,8 @@ public class Separator { public static void removeRecipe(IIngredient liquidInput, @Optional IIngredient leftGasOutput, @Optional IIngredient rightGasOutput) { if (IngredientHelper.checkNotNull(NAME, liquidInput)) { - CrafttweakerIntegration.LATE_REMOVALS - .add(new RemoveMekanismRecipe<>(NAME, Recipe.ELECTROLYTIC_SEPARATOR, - new IngredientWrapper(leftGasOutput, rightGasOutput), new IngredientWrapper(liquidInput))); + CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<>(NAME, Recipe.ELECTROLYTIC_SEPARATOR, new IngredientWrapper(leftGasOutput, rightGasOutput), + new IngredientWrapper(liquidInput))); } } diff --git a/src/main/java/mekanism/common/integration/crafttweaker/handlers/SolarNeutronActivator.java b/src/main/java/mekanism/common/integration/crafttweaker/handlers/SolarNeutronActivator.java index 6d6afd95a..11556fe3a 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/handlers/SolarNeutronActivator.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/handlers/SolarNeutronActivator.java @@ -26,18 +26,16 @@ public class SolarNeutronActivator { @ZenMethod public static void addRecipe(IGasStack gasInput, IGasStack gasOutput) { if (IngredientHelper.checkNotNull(NAME, gasInput, gasOutput)) { - CrafttweakerIntegration.LATE_ADDITIONS - .add(new AddMekanismRecipe<>(NAME, Recipe.SOLAR_NEUTRON_ACTIVATOR, - new SolarNeutronRecipe(GasHelper.toGas(gasInput), GasHelper.toGas(gasOutput)))); + CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe<>(NAME, Recipe.SOLAR_NEUTRON_ACTIVATOR, new SolarNeutronRecipe(GasHelper.toGas(gasInput), + GasHelper.toGas(gasOutput)))); } } @ZenMethod public static void removeRecipe(IIngredient gasInput, @Optional IIngredient gasOutput) { if (IngredientHelper.checkNotNull(NAME, gasInput)) { - CrafttweakerIntegration.LATE_REMOVALS - .add(new RemoveMekanismRecipe<>(NAME, Recipe.SOLAR_NEUTRON_ACTIVATOR, - new IngredientWrapper(gasOutput), new IngredientWrapper(gasInput))); + CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<>(NAME, Recipe.SOLAR_NEUTRON_ACTIVATOR, new IngredientWrapper(gasOutput), + new IngredientWrapper(gasInput))); } } diff --git a/src/main/java/mekanism/common/integration/crafttweaker/handlers/ThermalEvaporation.java b/src/main/java/mekanism/common/integration/crafttweaker/handlers/ThermalEvaporation.java index 4ce459018..56944c2a9 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/handlers/ThermalEvaporation.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/handlers/ThermalEvaporation.java @@ -25,25 +25,21 @@ public class ThermalEvaporation { @ZenMethod public static void addRecipe(ILiquidStack liquidInput, ILiquidStack liquidOutput) { if (IngredientHelper.checkNotNull(NAME, liquidInput, liquidOutput)) { - CrafttweakerIntegration.LATE_ADDITIONS - .add(new AddMekanismRecipe<>(NAME, Recipe.THERMAL_EVAPORATION_PLANT, - new ThermalEvaporationRecipe(IngredientHelper.toFluid(liquidInput), - IngredientHelper.toFluid(liquidOutput)))); + CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe<>(NAME, Recipe.THERMAL_EVAPORATION_PLANT, + new ThermalEvaporationRecipe(IngredientHelper.toFluid(liquidInput), IngredientHelper.toFluid(liquidOutput)))); } } @ZenMethod public static void removeRecipe(IIngredient liquidInput, @Optional IIngredient liquidOutput) { if (IngredientHelper.checkNotNull(NAME, liquidInput)) { - CrafttweakerIntegration.LATE_REMOVALS - .add(new RemoveMekanismRecipe<>(NAME, Recipe.THERMAL_EVAPORATION_PLANT, - new IngredientWrapper(liquidOutput), new IngredientWrapper(liquidInput))); + CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<>(NAME, Recipe.THERMAL_EVAPORATION_PLANT, new IngredientWrapper(liquidOutput), + new IngredientWrapper(liquidInput))); } } @ZenMethod public static void removeAllRecipes() { - CrafttweakerIntegration.LATE_REMOVALS - .add(new RemoveAllMekanismRecipe<>(NAME, Recipe.THERMAL_EVAPORATION_PLANT)); + CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveAllMekanismRecipe<>(NAME, Recipe.THERMAL_EVAPORATION_PLANT)); } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/crafttweaker/helpers/IngredientHelper.java b/src/main/java/mekanism/common/integration/crafttweaker/helpers/IngredientHelper.java index 552d9949b..1842fcb39 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/helpers/IngredientHelper.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/helpers/IngredientHelper.java @@ -105,12 +105,10 @@ public class IngredientHelper { return matches(input.itemStack, toMatch.getLeft()) && matches(input.extraStack, toMatch.getRight()); } else if (in instanceof PressurizedInput) { PressurizedInput input = (PressurizedInput) in; - return matches(input.getSolid(), toMatch.getLeft()) && matches(input.getFluid(), toMatch.getMiddle()) - && matches(input.getGas(), toMatch.getRight()); + return matches(input.getSolid(), toMatch.getLeft()) && matches(input.getFluid(), toMatch.getMiddle()) && matches(input.getGas(), toMatch.getRight()); } else if (in instanceof InfusionInput) { InfusionInput input = (InfusionInput) in; - return matches(input.inputStack, toMatch.getIngredient()) && (toMatch.getInfuseType().isEmpty() || toMatch - .getInfuseType().equalsIgnoreCase(input.infuse.getType().name)); + return matches(input.inputStack, toMatch.getIngredient()) && (toMatch.getInfuseType().isEmpty() || toMatch.getInfuseType().equalsIgnoreCase(input.infuse.getType().name)); } else if (in instanceof IntegerInput) { IntegerInput input = (IntegerInput) in; return input.ingredient == toMatch.getAmount(); @@ -130,15 +128,13 @@ public class IngredientHelper { return matches(output.output, toMatch.getIngredient()); } else if (out instanceof ChanceOutput) { ChanceOutput output = (ChanceOutput) out; - return matches(output.primaryOutput, toMatch.getLeft()) && matches(output.secondaryOutput, - toMatch.getRight()); + return matches(output.primaryOutput, toMatch.getLeft()) && matches(output.secondaryOutput, toMatch.getRight()); } else if (out instanceof ChemicalPairOutput) { ChemicalPairOutput output = (ChemicalPairOutput) out; return matches(output.leftGas, toMatch.getLeft()) && matches(output.rightGas, toMatch.getRight()); } else if (out instanceof PressurizedOutput) { PressurizedOutput output = (PressurizedOutput) out; - return matches(output.getItemOutput(), toMatch.getLeft()) && matches(output.getGasOutput(), - toMatch.getRight()); + return matches(output.getItemOutput(), toMatch.getLeft()) && matches(output.getGasOutput(), toMatch.getRight()); } return false; } diff --git a/src/main/java/mekanism/common/integration/crafttweaker/helpers/RecipeInfoHelper.java b/src/main/java/mekanism/common/integration/crafttweaker/helpers/RecipeInfoHelper.java index 66f690631..29e7cf870 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/helpers/RecipeInfoHelper.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/helpers/RecipeInfoHelper.java @@ -43,8 +43,7 @@ public class RecipeInfoHelper { } public static String getGasName(GasStack stack) { - return stack.amount > 1 ? String.format(" * %s", stack.getGas().getName(), stack.amount) - : getGasName(stack.getGas()); + return stack.amount > 1 ? String.format(" * %s", stack.getGas().getName(), stack.amount) : getGasName(stack.getGas()); } public static String getGasName(Gas gas) { @@ -52,8 +51,7 @@ public class RecipeInfoHelper { } public static String getFluidName(FluidStack stack) { - return stack.amount > 1 ? String.format(" * %s", stack.getFluid().getName(), stack.amount) - : getFluidName(stack.getFluid()); + return stack.amount > 1 ? String.format(" * %s", stack.getFluid().getName(), stack.amount) : getFluidName(stack.getFluid()); } public static String getFluidName(Fluid fluid) { diff --git a/src/main/java/mekanism/common/integration/crafttweaker/util/IngredientWrapper.java b/src/main/java/mekanism/common/integration/crafttweaker/util/IngredientWrapper.java index afc13a9a9..b18ce8950 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/util/IngredientWrapper.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/util/IngredientWrapper.java @@ -77,8 +77,7 @@ public class IngredientWrapper { } public boolean isEmpty() { - return left.equals(IngredientAny.INSTANCE) && middle.equals(IngredientAny.INSTANCE) && right - .equals(IngredientAny.INSTANCE) && infuseType.isEmpty(); + return left.equals(IngredientAny.INSTANCE) && middle.equals(IngredientAny.INSTANCE) && right.equals(IngredientAny.INSTANCE) && infuseType.isEmpty(); } private String getDescriptor(IIngredient ingredient) { diff --git a/src/main/java/mekanism/common/integration/crafttweaker/util/RecipeMapModification.java b/src/main/java/mekanism/common/integration/crafttweaker/util/RecipeMapModification.java index 59e9cf4b8..5b267e1ed 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/util/RecipeMapModification.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/util/RecipeMapModification.java @@ -13,8 +13,7 @@ import mekanism.common.recipe.RecipeHandler.Recipe; import mekanism.common.recipe.inputs.MachineInput; import mekanism.common.recipe.machines.MachineRecipe; -public abstract class RecipeMapModification, RECIPE extends MachineRecipe> implements - IAction { +public abstract class RecipeMapModification, RECIPE extends MachineRecipe> implements IAction { protected final HashMap recipes; protected final Map map; @@ -52,15 +51,13 @@ public abstract class RecipeMapModification, R private String getRecipeInfo() { if (!recipes.isEmpty()) { - return recipes.entrySet().stream().filter(Objects::nonNull).map(RecipeInfoHelper::getRecipeInfo) - .collect(Collectors.joining(", ")); + return recipes.entrySet().stream().filter(Objects::nonNull).map(RecipeInfoHelper::getRecipeInfo).collect(Collectors.joining(", ")); } return "Unknown item"; } @Override public String describe() { - return String - .format("%s %d %s Recipe(s) for %s", add ? "Adding" : "Removing", recipes.size(), name, getRecipeInfo()); + return String.format("%s %d %s Recipe(s) for %s", add ? "Adding" : "Removing", recipes.size(), name, getRecipeInfo()); } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/crafttweaker/util/RemoveMekanismRecipe.java b/src/main/java/mekanism/common/integration/crafttweaker/util/RemoveMekanismRecipe.java index e8c25fb56..6b376abfe 100644 --- a/src/main/java/mekanism/common/integration/crafttweaker/util/RemoveMekanismRecipe.java +++ b/src/main/java/mekanism/common/integration/crafttweaker/util/RemoveMekanismRecipe.java @@ -13,8 +13,7 @@ public class RemoveMekanismRecipe, OUTPUT exte private final IngredientWrapper input; private final IngredientWrapper output; - public RemoveMekanismRecipe(String name, Recipe recipeType, IngredientWrapper output, - IngredientWrapper input) { + public RemoveMekanismRecipe(String name, Recipe recipeType, IngredientWrapper output, IngredientWrapper input) { super(name, false, recipeType); this.input = input; this.output = output; @@ -31,8 +30,8 @@ public class RemoveMekanismRecipe, OUTPUT exte if (recipes.isEmpty()) { String warning = ""; if (input.isEmpty()) { - if (!output - .isEmpty()) { //It should never be the case they both are empty but just in case they are ignore it + if (!output.isEmpty()) { + //It should never be the case they both are empty but just in case they are ignore it warning = String.format("output: '%s'", output.toString()); } } else if (output.isEmpty()) { @@ -55,4 +54,4 @@ public class RemoveMekanismRecipe, OUTPUT exte //Don't describe anything. It is too early for us to have a full description return null; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/forgeenergy/ForgeEnergyCableIntegration.java b/src/main/java/mekanism/common/integration/forgeenergy/ForgeEnergyCableIntegration.java index a0f23a186..b7c575cf1 100644 --- a/src/main/java/mekanism/common/integration/forgeenergy/ForgeEnergyCableIntegration.java +++ b/src/main/java/mekanism/common/integration/forgeenergy/ForgeEnergyCableIntegration.java @@ -19,9 +19,8 @@ public class ForgeEnergyCableIntegration implements IEnergyStorage { @Override public int receiveEnergy(int maxReceive, boolean simulate) { - return MekanismUtils.clampToInt(tileEntity - .acceptEnergy(side, maxReceive * MekanismConfig.current().general.FROM_FORGE.val(), simulate) - * MekanismConfig.current().general.TO_FORGE.val()); + return MekanismUtils.clampToInt(tileEntity.acceptEnergy(side, maxReceive * MekanismConfig.current().general.FROM_FORGE.val(), simulate) + * MekanismConfig.current().general.TO_FORGE.val()); } @Override @@ -48,4 +47,4 @@ public class ForgeEnergyCableIntegration implements IEnergyStorage { public boolean canReceive() { return tileEntity.canReceiveEnergy(side); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/forgeenergy/ForgeEnergyIntegration.java b/src/main/java/mekanism/common/integration/forgeenergy/ForgeEnergyIntegration.java index 733f4cace..deea61384 100644 --- a/src/main/java/mekanism/common/integration/forgeenergy/ForgeEnergyIntegration.java +++ b/src/main/java/mekanism/common/integration/forgeenergy/ForgeEnergyIntegration.java @@ -54,4 +54,4 @@ public class ForgeEnergyIntegration implements IEnergyStorage { public boolean canReceive() { return tileEntity.sideIsConsumer(side); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/forgeenergy/ForgeEnergyItemWrapper.java b/src/main/java/mekanism/common/integration/forgeenergy/ForgeEnergyItemWrapper.java index fbd694cbd..678582e29 100644 --- a/src/main/java/mekanism/common/integration/forgeenergy/ForgeEnergyItemWrapper.java +++ b/src/main/java/mekanism/common/integration/forgeenergy/ForgeEnergyItemWrapper.java @@ -24,15 +24,11 @@ public class ForgeEnergyItemWrapper extends ItemCapability implements IEnergySto if (getItem().canReceive(getStack())) { int energyNeeded = getMaxEnergyStored() - getEnergyStored(); int toReceive = Math.min(maxReceive, energyNeeded); - if (!simulate) { - getItem().setEnergy(getStack(), - getItem().getEnergy(getStack()) + toReceive * MekanismConfig.current().general.FROM_TESLA.val()); + getItem().setEnergy(getStack(), getItem().getEnergy(getStack()) + toReceive * MekanismConfig.current().general.FROM_TESLA.val()); } - return toReceive; } - return 0; } @@ -41,28 +37,22 @@ public class ForgeEnergyItemWrapper extends ItemCapability implements IEnergySto if (getItem().canSend(getStack())) { int energyRemaining = getEnergyStored(); int toSend = Math.min(maxExtract, energyRemaining); - if (!simulate) { - getItem().setEnergy(getStack(), - getItem().getEnergy(getStack()) - toSend * MekanismConfig.current().general.FROM_TESLA.val()); + getItem().setEnergy(getStack(), getItem().getEnergy(getStack()) - toSend * MekanismConfig.current().general.FROM_TESLA.val()); } - return toSend; } - return 0; } @Override public int getEnergyStored() { - return MekanismUtils.clampToInt( - Math.round(getItem().getEnergy(getStack()) * MekanismConfig.current().general.TO_FORGE.val())); + return MekanismUtils.clampToInt(Math.round(getItem().getEnergy(getStack()) * MekanismConfig.current().general.TO_FORGE.val())); } @Override public int getMaxEnergyStored() { - return MekanismUtils.clampToInt( - Math.round(getItem().getMaxEnergy(getStack()) * MekanismConfig.current().general.TO_FORGE.val())); + return MekanismUtils.clampToInt(Math.round(getItem().getMaxEnergy(getStack()) * MekanismConfig.current().general.TO_FORGE.val())); } @Override @@ -74,4 +64,4 @@ public class ForgeEnergyItemWrapper extends ItemCapability implements IEnergySto public boolean canReceive() { return getItem().canReceive(getStack()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/ic2/IC2Integration.java b/src/main/java/mekanism/common/integration/ic2/IC2Integration.java index 21651af55..c091889a4 100644 --- a/src/main/java/mekanism/common/integration/ic2/IC2Integration.java +++ b/src/main/java/mekanism/common/integration/ic2/IC2Integration.java @@ -16,7 +16,6 @@ public class IC2Integration { @Method(modid = MekanismHooks.IC2_MOD_ID) public static boolean isOutputter(TileEntity tileEntity, EnumFacing side) { IEnergyTile tile = EnergyNet.instance.getSubTile(tileEntity.getWorld(), tileEntity.getPos()); - return tile instanceof IEnergySource && ((IEnergySource) tile).emitsEnergyTo(null, side.getOpposite()); } @@ -24,27 +23,21 @@ public class IC2Integration { @Method(modid = MekanismHooks.IC2_MOD_ID) public static boolean isAcceptor(TileEntity orig, TileEntity tileEntity, EnumFacing side) { IEnergyTile tile = EnergyNet.instance.getSubTile(tileEntity.getWorld(), tileEntity.getPos()); - if (tile instanceof IEnergySink) { return ((IEnergySink) tile).acceptsEnergyFrom(null, side.getOpposite()); } - return false; } @Method(modid = MekanismHooks.IC2_MOD_ID) - public static double emitEnergy(IEnergyWrapper from, TileEntity tileEntity, EnumFacing side, - double currentSending) { + public static double emitEnergy(IEnergyWrapper from, TileEntity tileEntity, EnumFacing side, double currentSending) { IEnergyTile tile = EnergyNet.instance.getSubTile(tileEntity.getWorld(), tileEntity.getPos()); - if (tile instanceof IEnergySink && ((IEnergySink) tile).acceptsEnergyFrom(from, side.getOpposite())) { double toSend = Math.min(currentSending * MekanismConfig.current().general.TO_IC2.val(), EnergyNet.instance.getPowerFromTier(((IEnergySink) tile).getSinkTier())); toSend = Math.min(toSend, ((IEnergySink) tile).getDemandedEnergy()); - return (toSend - (((IEnergySink) tile).injectEnergy(side.getOpposite(), toSend, 0))) * MekanismConfig - .current().general.FROM_IC2.val(); + return (toSend - ((IEnergySink) tile).injectEnergy(side.getOpposite(), toSend, 0)) * MekanismConfig.current().general.FROM_IC2.val(); } - return 0; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/ic2/IC2ItemManager.java b/src/main/java/mekanism/common/integration/ic2/IC2ItemManager.java index 2154a477a..37a36d75c 100644 --- a/src/main/java/mekanism/common/integration/ic2/IC2ItemManager.java +++ b/src/main/java/mekanism/common/integration/ic2/IC2ItemManager.java @@ -14,7 +14,6 @@ public class IC2ItemManager implements IElectricItemManager { public static IC2ItemManager getManager(IEnergizedItem item) { IC2ItemManager manager = new IC2ItemManager(); manager.energizedItem = item; - return manager; } @@ -22,17 +21,12 @@ public class IC2ItemManager implements IElectricItemManager { public double charge(ItemStack itemStack, double amount, int tier, boolean ignoreTransferLimit, boolean simulate) { if (energizedItem.canReceive(itemStack)) { double energyNeeded = energizedItem.getMaxEnergy(itemStack) - energizedItem.getEnergy(itemStack); - double energyToStore = Math - .min(Math.min(amount * MekanismConfig.current().general.FROM_IC2.val(), - energizedItem.getMaxEnergy(itemStack) * 0.01), energyNeeded); - + double energyToStore = Math.min(Math.min(amount * MekanismConfig.current().general.FROM_IC2.val(), energizedItem.getMaxEnergy(itemStack) * 0.01), energyNeeded); if (!simulate) { energizedItem.setEnergy(itemStack, energizedItem.getEnergy(itemStack) + energyToStore); } - return MekanismUtils.clampToInt(energyToStore * MekanismConfig.current().general.TO_IC2.val()); } - return 0; } @@ -41,16 +35,12 @@ public class IC2ItemManager implements IElectricItemManager { boolean simulate) { if (energizedItem.canSend(itemStack)) { double energyWanted = amount * MekanismConfig.current().general.FROM_IC2.val(); - double energyToGive = Math.min(Math.min(energyWanted, energizedItem.getMaxEnergy(itemStack) * 0.01), - energizedItem.getEnergy(itemStack)); - + 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 MekanismUtils.clampToInt(energyToGive * MekanismConfig.current().general.TO_IC2.val()); } - return 0; } @@ -71,7 +61,6 @@ public class IC2ItemManager implements IElectricItemManager { @Override public void chargeFromArmor(ItemStack itemStack, EntityLivingBase entity) { - } @Override @@ -88,4 +77,4 @@ public class IC2ItemManager implements IElectricItemManager { public int getTier(ItemStack stack) { return 4; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/multipart/MultipartGlowPanel.java b/src/main/java/mekanism/common/integration/multipart/MultipartGlowPanel.java index b8e768df5..a7b2ccd3a 100644 --- a/src/main/java/mekanism/common/integration/multipart/MultipartGlowPanel.java +++ b/src/main/java/mekanism/common/integration/multipart/MultipartGlowPanel.java @@ -23,8 +23,7 @@ import net.minecraft.world.World; public class MultipartGlowPanel implements IMultipart { @Override - public IPartSlot getSlotForPlacement(World world, BlockPos pos, IBlockState state, EnumFacing facing, float hitX, - float hitY, float hitZ, EntityLivingBase placer) { + public IPartSlot getSlotForPlacement(World world, BlockPos pos, IBlockState state, EnumFacing facing, float hitX, float hitY, float hitZ, EntityLivingBase placer) { return EnumFaceSlot.values()[facing.ordinal()]; } @@ -39,7 +38,6 @@ public class MultipartGlowPanel implements IMultipart { if (tile instanceof TileEntityGlowPanel) { EnumFacing facing = EnumFacing.values()[((EnumFaceSlot) part.getSlot()).ordinal()]; EnumColor col = EnumColor.DYES[stack.getItemDamage()]; - TileEntityGlowPanel glowPanel = (TileEntityGlowPanel) tile; glowPanel.setOrientation(facing); glowPanel.setColour(col); @@ -61,13 +59,10 @@ public class MultipartGlowPanel implements IMultipart { @Override public void onPartHarvested(IPartInfo part, EntityPlayer player) { TileEntity tile = part.getTile().getTileEntity(); - if (tile instanceof TileEntityGlowPanel) { IBlockState partState = part.getState(); - partState.getBlock().removedByPlayer(partState, part.getPartWorld(), - part.getContainer().getPartPos(), player, true); + partState.getBlock().removedByPlayer(partState, part.getPartWorld(), part.getContainer().getPartPos(), player, true); } - IMultipart.super.onPartHarvested(part, player); } @@ -75,4 +70,4 @@ public class MultipartGlowPanel implements IMultipart { public Block getBlock() { return MekanismBlocks.GlowPanel; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/multipart/MultipartMekanism.java b/src/main/java/mekanism/common/integration/multipart/MultipartMekanism.java index 18f3d80e7..b3147f657 100644 --- a/src/main/java/mekanism/common/integration/multipart/MultipartMekanism.java +++ b/src/main/java/mekanism/common/integration/multipart/MultipartMekanism.java @@ -61,37 +61,29 @@ public class MultipartMekanism implements IMCMPAddon { public static boolean hasConnectionWith(TileEntity tile, EnumFacing side) { if (tile != null && tile.hasCapability(MCMPCapabilities.MULTIPART_TILE, null)) { IMultipartTile multipartTile = tile.getCapability(MCMPCapabilities.MULTIPART_TILE, null); - - if (multipartTile instanceof MultipartTile && ((MultipartTile) multipartTile).getID() - .equals("transmitter")) { + if (multipartTile instanceof MultipartTile && ((MultipartTile) multipartTile).getID().equals("transmitter")) { IPartInfo partInfo = ((MultipartTile) multipartTile).getInfo(); - if (partInfo != null) { for (IPartInfo info : partInfo.getContainer().getParts().values()) { IMultipart multipart = info.getPart(); Collection origBounds = getTransmitterSideBounds(multipartTile, side); - - if (MultipartOcclusionHelper - .testBoxIntersection(origBounds, multipart.getOcclusionBoxes(info))) { + if (MultipartOcclusionHelper.testBoxIntersection(origBounds, multipart.getOcclusionBoxes(info))) { return false; } } } } } - return true; } public static Collection getTransmitterSideBounds(IMultipartTile tile, EnumFacing side) { if (tile.getTileEntity() instanceof TileEntityTransmitter) { - TileEntityTransmitter transmitter = ((TileEntityTransmitter) tile.getTileEntity()); + TileEntityTransmitter transmitter = (TileEntityTransmitter) tile.getTileEntity(); boolean large = transmitter.getTransmitterType().getSize() == Size.LARGE; - AxisAlignedBB ret = - large ? BlockTransmitter.largeSides[side.ordinal()] : BlockTransmitter.smallSides[side.ordinal()]; + AxisAlignedBB ret = large ? BlockTransmitter.largeSides[side.ordinal()] : BlockTransmitter.smallSides[side.ordinal()]; return Collections.singletonList(ret); } - return Collections.emptyList(); } @@ -105,7 +97,6 @@ public class MultipartMekanism implements IMCMPAddon { container = (IMultipartContainer) possibleContainer; } } - return container; } @@ -115,7 +106,6 @@ public class MultipartMekanism implements IMCMPAddon { if (container != null) { hasCenterSlot = container.getPart(EnumCenterSlot.CENTER).isPresent(); } - return hasCenterSlot; } @@ -127,8 +117,8 @@ public class MultipartMekanism implements IMCMPAddon { return tile; } - public static boolean placeMultipartBlock(Block block, ItemStack is, EntityPlayer player, World world, BlockPos pos, - EnumFacing side, float hitX, float hitY, float hitZ, IBlockState state) { + public static boolean placeMultipartBlock(Block block, ItemStack is, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, + float hitZ, IBlockState state) { return ItemBlockMultipart.placeAt(is, player, player.getActiveHand(), world, pos, side, hitX, hitY, hitZ, block::getStateForPlacement, is.getMetadata(), MultipartRegistry.INSTANCE.getPart(block), ((ItemBlock) is.getItem())::placeBlockAt, ItemBlockMultipart::placePartAt); @@ -137,7 +127,6 @@ public class MultipartMekanism implements IMCMPAddon { @SubscribeEvent public void onAttachTile(AttachCapabilitiesEvent event) { TileEntity tile = event.getObject(); - if (tile instanceof TileEntityTransmitter) { register(event, "transmitter"); } else if (tile instanceof TileEntityGlowPanel) { @@ -148,13 +137,11 @@ public class MultipartMekanism implements IMCMPAddon { @Override public void registerParts(IMultipartRegistry registry) { MinecraftForge.EVENT_BUS.register(this); - registry.registerPartWrapper(MekanismBlocks.Transmitter, TRANSMITTER_MP = new MultipartTransmitter()); //registry.registerStackWrapper(Item.getItemFromBlock(MekanismBlocks.Transmitter), s -> true, MekanismBlocks.Transmitter); registry.registerPartWrapper(MekanismBlocks.GlowPanel, GLOWPANEL_MP = new MultipartGlowPanel()); //registry.registerStackWrapper(Item.getItemFromBlock(MekanismBlocks.GlowPanel), s -> true, MekanismBlocks.GlowPanel); - MultipartCapabilityHelper - .registerCapabilityJoiner(Capabilities.TILE_NETWORK_CAPABILITY, MultipartTileNetworkJoiner::new); + MultipartCapabilityHelper.registerCapabilityJoiner(Capabilities.TILE_NETWORK_CAPABILITY, MultipartTileNetworkJoiner::new); } private void register(AttachCapabilitiesEvent e, String id) { @@ -173,10 +160,8 @@ public class MultipartMekanism implements IMCMPAddon { if (tile == null) { tile = new MultipartTile(e.getObject(), id); } - return MCMPCapabilities.MULTIPART_TILE.cast(tile); } - return null; } }); @@ -188,22 +173,18 @@ public class MultipartMekanism implements IMCMPAddon { public void registerMicroMaterials() { for (int i = 0; i < 16; i++) { - FMLInterModComms - .sendMessage("ForgeMicroblock", "microMaterial", new ItemStack(MekanismBlocks.BasicBlock, 1, i)); + FMLInterModComms.sendMessage("ForgeMicroblock", "microMaterial", new ItemStack(MekanismBlocks.BasicBlock, 1, i)); if (!MachineType.get(MACHINE_BLOCK_1, i).hasModel) { - FMLInterModComms.sendMessage("ForgeMicroblock", "microMaterial", - new ItemStack(MekanismBlocks.MachineBlock, 1, i)); + FMLInterModComms.sendMessage("ForgeMicroblock", "microMaterial", new ItemStack(MekanismBlocks.MachineBlock, 1, i)); } if (!MachineType.get(MACHINE_BLOCK_2, i).hasModel) { - FMLInterModComms.sendMessage("ForgeMicroblock", "microMaterial", - new ItemStack(MekanismBlocks.MachineBlock2, 1, i)); + FMLInterModComms.sendMessage("ForgeMicroblock", "microMaterial", new ItemStack(MekanismBlocks.MachineBlock2, 1, i)); } } - FMLInterModComms - .sendMessage("ForgeMicroblock", "microMaterial", new ItemStack(MekanismBlocks.BasicBlock2, 1, 0)); + FMLInterModComms.sendMessage("ForgeMicroblock", "microMaterial", new ItemStack(MekanismBlocks.BasicBlock2, 1, 0)); FMLInterModComms.sendMessage("ForgeMicroblock", "microMaterial", new ItemStack(MekanismBlocks.CardboardBox)); } @@ -215,13 +196,11 @@ public class MultipartMekanism implements IMCMPAddon { if (state.getBlock() == MekanismBlocks.GlowPanel || state.getBlock() == MekanismBlocks.Transmitter) { EntityPlayer player = ev.getPlayer(); @SuppressWarnings("deprecation") - AxisAlignedBB bb = state.getBlock() - .getSelectedBoundingBox(state, ev.getPartInfo().getPartWorld(), ev.getPartInfo().getPartPos()); + AxisAlignedBB bb = state.getBlock().getSelectedBoundingBox(state, ev.getPartInfo().getPartWorld(), ev.getPartInfo().getPartPos()); //NB rendering code copied from MCMultipart GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, - GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, - GlStateManager.DestFactor.ZERO); + GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, + GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); GlStateManager.glLineWidth(2.0F); GlStateManager.disableTexture2D(); GlStateManager.depthMask(false); @@ -235,4 +214,4 @@ public class MultipartMekanism implements IMCMPAddon { ev.setCanceled(true); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/multipart/MultipartTile.java b/src/main/java/mekanism/common/integration/multipart/MultipartTile.java index a122ce6e9..f8f84d3dd 100644 --- a/src/main/java/mekanism/common/integration/multipart/MultipartTile.java +++ b/src/main/java/mekanism/common/integration/multipart/MultipartTile.java @@ -32,4 +32,4 @@ public class MultipartTile implements IMultipartTile { public IPartInfo getInfo() { return partInfo; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/multipart/MultipartTileNetworkJoiner.java b/src/main/java/mekanism/common/integration/multipart/MultipartTileNetworkJoiner.java index 170a99385..4bcbde222 100644 --- a/src/main/java/mekanism/common/integration/multipart/MultipartTileNetworkJoiner.java +++ b/src/main/java/mekanism/common/integration/multipart/MultipartTileNetworkJoiner.java @@ -9,8 +9,8 @@ import mcmultipart.api.multipart.IMultipartTile; import mcmultipart.api.slot.EnumFaceSlot; import mcmultipart.api.slot.IPartSlot; import mcmultipart.api.world.IMultipartBlockAccess; -import mekanism.common.base.ITileNetwork; import mekanism.api.TileNetworkList; +import mekanism.common.base.ITileNetwork; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.world.IBlockAccess; @@ -18,11 +18,10 @@ import net.minecraft.world.IBlockAccess; /** * Used to route {@link ITileNetwork} packets sent to multipart containers with more than one possible recipient.
*
- * When MCMP is enabled single byte EnumFacing ordinal headers are added to packets sent by glow panels and transmitters - * that are then used by this class to route packets to the part attached to the appropriate side.
+ * When MCMP is enabled single byte EnumFacing ordinal headers are added to packets sent by glow panels and transmitters that are then used by this class to route packets + * to the part attached to the appropriate side.
*
- * In this case, since transmitters do not attach to a side and therefore have no matching EnumFacing the special value - * 6 is used to represent the center slot. + * In this case, since transmitters do not attach to a side and therefore have no matching EnumFacing the special value 6 is used to represent the center slot. */ public class MultipartTileNetworkJoiner implements ITileNetwork { @@ -49,7 +48,6 @@ public class MultipartTileNetworkJoiner implements ITileNetwork { container = (IMultipartContainer) worldTile; } } - if (container != null) { for (IPartSlot slot : container.getParts().keySet()) { Optional partTile = container.getPartTile(slot); @@ -65,11 +63,10 @@ public class MultipartTileNetworkJoiner implements ITileNetwork { } /** - * Determines whether or not an {@link ITileNetwork} joiner is needed and, if so, adds a single byte header used to - * route packets inside multipart containers. + * Determines whether or not an {@link ITileNetwork} joiner is needed and, if so, adds a single byte header used to route packets inside multipart containers. * * @param entity The entity for which getNetworkedData is being called - * @param data The network data list + * @param data The network data list * @param facing The side this part is attached to or null for the center slot */ public static void addMultipartHeader(TileEntity entity, TileNetworkList data, EnumFacing facing) { @@ -77,10 +74,7 @@ public class MultipartTileNetworkJoiner implements ITileNetwork { IMultipartContainer container = MultipartMekanism.getContainer(entity.getWorld(), entity.getPos()); if (container != null) { for (IPartSlot slot : container.getParts().keySet()) { - TileEntity part = container.getPartTile(slot) - .map(IMultipartTile::getTileEntity) - .orElse(null); - + TileEntity part = container.getPartTile(slot).map(IMultipartTile::getTileEntity).orElse(null); if (part instanceof ITileNetwork) { tileNetworkParts++; if (tileNetworkParts > 1) { @@ -89,7 +83,6 @@ public class MultipartTileNetworkJoiner implements ITileNetwork { } } } - if (tileNetworkParts > 1) { data.add(0, (byte) (facing == null ? 6 : facing.ordinal())); } @@ -99,12 +92,10 @@ public class MultipartTileNetworkJoiner implements ITileNetwork { public void handlePacketData(ByteBuf dataStream) throws Exception { while (dataStream.readableBytes() > 0) { byte side = dataStream.readByte(); - ITileNetwork networkTile = tileSideMap.get(side); if (networkTile == null) { break; } - networkTile.handlePacketData(dataStream); } } @@ -117,7 +108,6 @@ public class MultipartTileNetworkJoiner implements ITileNetwork { data.addAll(childData); childData.clear(); } - return data; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/multipart/MultipartTransmitter.java b/src/main/java/mekanism/common/integration/multipart/MultipartTransmitter.java index d2873ad5c..e1a4b2ca0 100644 --- a/src/main/java/mekanism/common/integration/multipart/MultipartTransmitter.java +++ b/src/main/java/mekanism/common/integration/multipart/MultipartTransmitter.java @@ -21,8 +21,7 @@ import net.minecraft.world.World; public class MultipartTransmitter implements IMultipart { @Override - public IPartSlot getSlotForPlacement(World world, BlockPos pos, IBlockState state, EnumFacing facing, float hitX, - float hitY, float hitZ, EntityLivingBase placer) { + public IPartSlot getSlotForPlacement(World world, BlockPos pos, IBlockState state, EnumFacing facing, float hitX, float hitY, float hitZ, EntityLivingBase placer) { return EnumCenterSlot.CENTER; } @@ -34,7 +33,6 @@ public class MultipartTransmitter implements IMultipart { @Override public void onAdded(IPartInfo part) { TileEntity tile = part.getTile().getTileEntity(); - if (tile instanceof TileEntitySidedPipe) { ((TileEntitySidedPipe) tile).onAdded(); } @@ -43,7 +41,6 @@ public class MultipartTransmitter implements IMultipart { @Override public void onPartAdded(IPartInfo part, IPartInfo otherPart) { TileEntity tile = part.getTile().getTileEntity(); - if (tile instanceof TileEntitySidedPipe) { tile.validate(); ((TileEntitySidedPipe) tile).notifyTileChange(); @@ -53,7 +50,6 @@ public class MultipartTransmitter implements IMultipart { @Override public void onPartChanged(IPartInfo part, IPartInfo otherPart) { TileEntity tile = part.getTile().getTileEntity(); - if (tile instanceof TileEntitySidedPipe) { ((TileEntitySidedPipe) tile).onPartChanged(otherPart.getPart()); } @@ -62,26 +58,21 @@ public class MultipartTransmitter implements IMultipart { @Override public void onPartHarvested(IPartInfo part, EntityPlayer player) { TileEntity tile = part.getTile().getTileEntity(); - if (tile instanceof TileEntitySidedPipe) { IBlockState partState = part.getState(); - partState.getBlock().removedByPlayer(partState, part.getPartWorld(), - part.getContainer().getPartPos(), player, true); + partState.getBlock().removedByPlayer(partState, part.getPartWorld(), part.getContainer().getPartPos(), player, true); } - IMultipart.super.onPartHarvested(part, player); } @Override public void onPartPlacedBy(IPartInfo part, EntityLivingBase placer, ItemStack stack) { TileEntity tile = part.getTile().getTileEntity(); - if (tile instanceof TileEntitySidedPipe) { BaseTier baseTier = BaseTier.BASIC; if (stack.hasTagCompound()) { baseTier = BaseTier.values()[stack.getTagCompound().getInteger("tier")]; } - ((TileEntitySidedPipe) tile).setBaseTier(baseTier); } } @@ -90,4 +81,4 @@ public class MultipartTransmitter implements IMultipart { public Block getBlock() { return MekanismBlocks.Transmitter; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/tesla/TeslaCableIntegration.java b/src/main/java/mekanism/common/integration/tesla/TeslaCableIntegration.java index 4094fc8cb..104e5cc0a 100644 --- a/src/main/java/mekanism/common/integration/tesla/TeslaCableIntegration.java +++ b/src/main/java/mekanism/common/integration/tesla/TeslaCableIntegration.java @@ -23,8 +23,6 @@ public class TeslaCableIntegration implements ITeslaConsumer { @Override @Method(modid = MekanismHooks.TESLA_MOD_ID) public long givePower(long power, boolean simulated) { - return Math.round( - tileEntity.acceptEnergy(side, power * MekanismConfig.current().general.FROM_TESLA.val(), simulated) - * MekanismConfig.current().general.TO_TESLA.val()); + return Math.round(tileEntity.acceptEnergy(side, power * MekanismConfig.current().general.FROM_TESLA.val(), simulated) * MekanismConfig.current().general.TO_TESLA.val()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/tesla/TeslaIntegration.java b/src/main/java/mekanism/common/integration/tesla/TeslaIntegration.java index 3e8ebf27d..2c8b4c74a 100644 --- a/src/main/java/mekanism/common/integration/tesla/TeslaIntegration.java +++ b/src/main/java/mekanism/common/integration/tesla/TeslaIntegration.java @@ -53,12 +53,10 @@ public class TeslaIntegration implements ITeslaHolder, ITeslaConsumer, ITeslaPro } public long rfToTesla(int rf) { - return Math.round( - rf * MekanismConfig.current().general.FROM_RF.val() * MekanismConfig.current().general.TO_TESLA.val()); + return Math.round(rf * MekanismConfig.current().general.FROM_RF.val() * MekanismConfig.current().general.TO_TESLA.val()); } public int teslaToRF(long tesla) { - return MekanismUtils.clampToInt( - tesla * MekanismConfig.current().general.FROM_TESLA.val() * MekanismConfig.current().general.TO_RF.val()); + return MekanismUtils.clampToInt(tesla * MekanismConfig.current().general.FROM_TESLA.val() * MekanismConfig.current().general.TO_RF.val()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/tesla/TeslaItemWrapper.java b/src/main/java/mekanism/common/integration/tesla/TeslaItemWrapper.java index f7808f0cf..bea5e798e 100644 --- a/src/main/java/mekanism/common/integration/tesla/TeslaItemWrapper.java +++ b/src/main/java/mekanism/common/integration/tesla/TeslaItemWrapper.java @@ -22,9 +22,8 @@ public class TeslaItemWrapper extends ItemCapability implements ITeslaHolder, IT @Override public boolean canProcess(Capability capability) { - return capability == Capabilities.TESLA_HOLDER_CAPABILITY || - capability == Capabilities.TESLA_CONSUMER_CAPABILITY && getItem().canReceive(getStack()) || - capability == Capabilities.TESLA_PRODUCER_CAPABILITY && getItem().canSend(getStack()); + return capability == Capabilities.TESLA_HOLDER_CAPABILITY || capability == Capabilities.TESLA_CONSUMER_CAPABILITY && getItem().canReceive(getStack()) || + capability == Capabilities.TESLA_PRODUCER_CAPABILITY && getItem().canSend(getStack()); } public IEnergizedItem getItem() { @@ -37,15 +36,11 @@ public class TeslaItemWrapper extends ItemCapability implements ITeslaHolder, IT if (getItem().canSend(getStack())) { long energyRemaining = getStoredPower(); long toSend = Math.min(power, energyRemaining); - if (!simulated) { - getItem().setEnergy(getStack(), - getItem().getEnergy(getStack()) - toSend * MekanismConfig.current().general.FROM_TESLA.val()); + getItem().setEnergy(getStack(), getItem().getEnergy(getStack()) - toSend * MekanismConfig.current().general.FROM_TESLA.val()); } - return toSend; } - return 0; } @@ -55,15 +50,11 @@ public class TeslaItemWrapper extends ItemCapability implements ITeslaHolder, IT if (getItem().canReceive(getStack())) { long energyNeeded = getCapacity() - getStoredPower(); long toReceive = Math.min(power, energyNeeded); - if (!simulated) { - getItem().setEnergy(getStack(), - getItem().getEnergy(getStack()) + toReceive * MekanismConfig.current().general.FROM_TESLA.val()); + getItem().setEnergy(getStack(), getItem().getEnergy(getStack()) + toReceive * MekanismConfig.current().general.FROM_TESLA.val()); } - return toReceive; } - return 0; } @@ -78,4 +69,4 @@ public class TeslaItemWrapper extends ItemCapability implements ITeslaHolder, IT public long getCapacity() { return Math.round(getItem().getEnergy(getStack()) * MekanismConfig.current().general.TO_TESLA.val()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/wrenches/BuildCraftProxy.java b/src/main/java/mekanism/common/integration/wrenches/BuildCraftProxy.java index dda7572c2..9f832d52e 100644 --- a/src/main/java/mekanism/common/integration/wrenches/BuildCraftProxy.java +++ b/src/main/java/mekanism/common/integration/wrenches/BuildCraftProxy.java @@ -27,8 +27,7 @@ public class BuildCraftProxy implements MekWrenchProxy, IMekWrench { @Override public boolean canUseWrench(EntityPlayer player, EnumHand hand, ItemStack stack, RayTraceResult rayTrace) { - return stack.getItem() instanceof IToolWrench && ((IToolWrench) stack.getItem()) - .canWrench(player, hand, stack, rayTrace); + return stack.getItem() instanceof IToolWrench && ((IToolWrench) stack.getItem()).canWrench(player, hand, stack, rayTrace); } @Override @@ -37,4 +36,4 @@ public class BuildCraftProxy implements MekWrenchProxy, IMekWrench { ((IToolWrench) stack.getItem()).wrenchUsed(player, hand, stack, rayTrace); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/wrenches/CofhProxy.java b/src/main/java/mekanism/common/integration/wrenches/CofhProxy.java index 44b2086ae..fdb0eaaa3 100644 --- a/src/main/java/mekanism/common/integration/wrenches/CofhProxy.java +++ b/src/main/java/mekanism/common/integration/wrenches/CofhProxy.java @@ -25,16 +25,10 @@ public class CofhProxy implements MekWrenchProxy, IMekWrench { return stack.getItem() instanceof IToolHammer && ((IToolHammer) stack.getItem()).isUsable(stack, player, pos); } - // uses default method - //@Override - //public boolean canUseWrench(EntityPlayer player, EnumHand hand, ItemStack stack, RayTraceResult rayTrace) { - // return false; - //} - @Override public void wrenchUsed(EntityPlayer player, EnumHand hand, ItemStack wrench, RayTraceResult rayTrace) { if (wrench.getItem() instanceof IToolHammer) { ((IToolHammer) wrench.getItem()).toolUsed(wrench, player, rayTrace.getBlockPos()); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/wrenches/IC2Proxy.java b/src/main/java/mekanism/common/integration/wrenches/IC2Proxy.java index bcb7676f6..6c3b046ec 100644 --- a/src/main/java/mekanism/common/integration/wrenches/IC2Proxy.java +++ b/src/main/java/mekanism/common/integration/wrenches/IC2Proxy.java @@ -16,12 +16,10 @@ public class IC2Proxy implements MekWrenchProxy, IMekWrench { public IC2Proxy() { Class w = null; - try { w = Class.forName(IC2_WRENCH_CLASS); } catch (ClassNotFoundException ignored) { } - wrenchClass = w; } @@ -34,4 +32,4 @@ public class IC2Proxy implements MekWrenchProxy, IMekWrench { public IMekWrench get(ItemStack stack) { return wrenchClass != null && wrenchClass.isInstance(stack.getItem()) ? this : null; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/wrenches/MekPassthrough.java b/src/main/java/mekanism/common/integration/wrenches/MekPassthrough.java index 3cef29651..d3c29380f 100644 --- a/src/main/java/mekanism/common/integration/wrenches/MekPassthrough.java +++ b/src/main/java/mekanism/common/integration/wrenches/MekPassthrough.java @@ -12,4 +12,4 @@ public class MekPassthrough implements MekWrenchProxy { public IMekWrench get(ItemStack stack) { return stack.getItem() instanceof IMekWrench ? (IMekWrench) stack.getItem() : null; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/wrenches/MekWrenchProxy.java b/src/main/java/mekanism/common/integration/wrenches/MekWrenchProxy.java index 339fbc9de..9da3260f3 100644 --- a/src/main/java/mekanism/common/integration/wrenches/MekWrenchProxy.java +++ b/src/main/java/mekanism/common/integration/wrenches/MekWrenchProxy.java @@ -12,7 +12,8 @@ public interface MekWrenchProxy { * Get a handler for the wrench * * @param stack the instance to be used. + * * @return a IMekWrench instance that can handle translation to the external provider. */ IMekWrench get(ItemStack stack); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/integration/wrenches/Wrenches.java b/src/main/java/mekanism/common/integration/wrenches/Wrenches.java index 6c64d5169..a99d3ec73 100644 --- a/src/main/java/mekanism/common/integration/wrenches/Wrenches.java +++ b/src/main/java/mekanism/common/integration/wrenches/Wrenches.java @@ -6,8 +6,8 @@ import mekanism.api.IMekWrench; import net.minecraft.item.ItemStack; /** - * Generic handler for wrenches, exposed as {@link IMekWrench}. Generally you don't want to use the enum directly, - * instead use {@link Wrenches#getHandler(ItemStack)}, and check for nullability. + * Generic handler for wrenches, exposed as {@link IMekWrench}. Generally you don't want to use the enum directly, instead use {@link Wrenches#getHandler(ItemStack)}, and + * check for nullability. */ public enum Wrenches { MEKANISM_PASSTHROUGH(IMekWrench.class.getName(), MekPassthrough::new), @@ -36,7 +36,6 @@ public enum Wrenches { w.itemClass = null; continue; } - try { w.provider = w.mekProxy.get(); } catch (Exception e) { @@ -54,11 +53,10 @@ public enum Wrenches { return w.provider.get(it); } } - return null; } private boolean canHandle(ItemStack it) { - return (enabled && provider != null && itemClass != null && itemClass.isInstance(it.getItem())); + return enabled && provider != null && itemClass != null && itemClass.isInstance(it.getItem()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/inventory/InventoryBin.java b/src/main/java/mekanism/common/inventory/InventoryBin.java index 724bedbbb..c9b18fda9 100644 --- a/src/main/java/mekanism/common/inventory/InventoryBin.java +++ b/src/main/java/mekanism/common/inventory/InventoryBin.java @@ -1,8 +1,8 @@ package mekanism.common.inventory; -import mekanism.common.tier.BinTier; import mekanism.common.base.ITierItem; import mekanism.common.block.states.BlockStateBasic.BasicBlockType; +import mekanism.common.tier.BinTier; import mekanism.common.util.ItemDataUtils; import mekanism.common.util.StackUtils; import net.minecraft.item.ItemStack; @@ -23,21 +23,17 @@ public class InventoryBin { return ret; } - return ItemStack.EMPTY; } public ItemStack removeStack() { ItemStack stack = getStack(); - if (stack.isEmpty()) { return ItemStack.EMPTY; } - if (getTier() != BinTier.CREATIVE) { setItemCount(getItemCount() - stack.getCount()); } - return stack.copy(); } @@ -46,7 +42,6 @@ public class InventoryBin { if (getItemType().isEmpty()) { setItemType(stack); } - if (getTier() != BinTier.CREATIVE) { if (getItemCount() + stack.getCount() <= getMaxStorage()) { setItemCount(getItemCount() + stack.getCount()); @@ -54,32 +49,23 @@ public class InventoryBin { } else { ItemStack rejects = getItemType().copy(); rejects.setCount((getItemCount() + stack.getCount()) - getMaxStorage()); - setItemCount(getMaxStorage()); - return rejects; } } else { setItemCount(Integer.MAX_VALUE); } } - return stack; } public boolean isValid(ItemStack stack) { - if (stack.isEmpty() || stack.getCount() <= 0) { + if (stack.isEmpty() || stack.getCount() <= 0 || BasicBlockType.get(stack) == BasicBlockType.BIN) { return false; } - - if (BasicBlockType.get(stack) == BasicBlockType.BIN) { - return false; - } - if (getItemType().isEmpty()) { return true; } - return stack.isItemEqual(getItemType()) && ItemStack.areItemStackTagsEqual(stack, getItemType()); } @@ -97,7 +83,6 @@ public class InventoryBin { public void setItemCount(int count) { ItemDataUtils.setInt(bin, "itemCount", Math.max(0, count)); - if (getItemCount() == 0) { setItemType(ItemStack.EMPTY); } @@ -107,7 +92,6 @@ public class InventoryBin { if (getItemCount() == 0) { return ItemStack.EMPTY; } - return new ItemStack(ItemDataUtils.getCompound(bin, "storedItem")); } @@ -116,7 +100,6 @@ public class InventoryBin { ItemDataUtils.removeData(bin, "storedItem"); return; } - ItemDataUtils.setCompound(bin, "storedItem", StackUtils.size(stack, 1).writeToNBT(new NBTTagCompound())); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/inventory/InventoryList.java b/src/main/java/mekanism/common/inventory/InventoryList.java index 746970bb4..53fdd46df 100644 --- a/src/main/java/mekanism/common/inventory/InventoryList.java +++ b/src/main/java/mekanism/common/inventory/InventoryList.java @@ -32,8 +32,7 @@ public class InventoryList implements IInventory { @Nonnull @Override public ItemStack getStackInSlot(int index) { - return index >= 0 && index < this.inventoryContents.size() ? this.inventoryContents.get(index) - : ItemStack.EMPTY; + return index >= 0 && index < this.inventoryContents.size() ? this.inventoryContents.get(index) : ItemStack.EMPTY; } /** @@ -43,11 +42,9 @@ public class InventoryList implements IInventory { @Override public ItemStack decrStackSize(int index, int count) { ItemStack itemstack = ItemStackHelper.getAndSplit(this.inventoryContents, index, count); - if (!itemstack.isEmpty()) { this.markDirty(); } - return itemstack; } @@ -58,13 +55,11 @@ public class InventoryList implements IInventory { @Override public ItemStack removeStackFromSlot(int index) { ItemStack itemstack = this.inventoryContents.get(index); - if (itemstack.isEmpty()) { return ItemStack.EMPTY; - } else { - this.inventoryContents.set(index, ItemStack.EMPTY); - return itemstack; } + this.inventoryContents.set(index, ItemStack.EMPTY); + return itemstack; } /** @@ -72,11 +67,9 @@ public class InventoryList implements IInventory { */ public void setInventorySlotContents(int index, @Nonnull ItemStack stack) { this.inventoryContents.set(index, stack); - if (!stack.isEmpty() && stack.getCount() > this.getInventoryStackLimit()) { stack.setCount(this.getInventoryStackLimit()); } - this.markDirty(); } @@ -93,7 +86,6 @@ public class InventoryList implements IInventory { return false; } } - return true; } @@ -117,7 +109,6 @@ public class InventoryList implements IInventory { * Sets the name of this inventory. This is displayed to the client on opening. */ public void setCustomName(String inventoryTitleIn) { - } /** @@ -126,8 +117,7 @@ public class InventoryList implements IInventory { @Nonnull @Override public ITextComponent getDisplayName() { - return (this.hasCustomName() ? new TextComponentString(this.getName()) - : new TextComponentTranslation(this.getName())); + return this.hasCustomName() ? new TextComponentString(this.getName()) : new TextComponentTranslation(this.getName()); } /** @@ -138,8 +128,7 @@ public class InventoryList implements IInventory { } /** - * For tile entities, ensures the chunk containing the tile entity is saved to disk later - the game won't think it - * hasn't changed and skip it. + * For tile entities, ensures the chunk containing the tile entity is saved to disk later - the game won't think it hasn't changed and skip it. */ public void markDirty() { this.te.markDirty(); @@ -159,8 +148,7 @@ public class InventoryList implements IInventory { } /** - * Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot. For - * guis use Slot.isItemValid + * Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot. For guis use Slot.isItemValid */ public boolean isItemValidForSlot(int index, @Nonnull ItemStack stack) { return true; diff --git a/src/main/java/mekanism/common/inventory/InventoryPersonalChest.java b/src/main/java/mekanism/common/inventory/InventoryPersonalChest.java index 3ff6cf90a..d04092b2a 100644 --- a/src/main/java/mekanism/common/inventory/InventoryPersonalChest.java +++ b/src/main/java/mekanism/common/inventory/InventoryPersonalChest.java @@ -18,21 +18,18 @@ public class InventoryPersonalChest extends InventoryBasic { super("PersonalChest", false, 55); itemStack = stack; currentHand = hand; - read(); } public InventoryPersonalChest(ItemStack stack) { super("PersonalChest", false, 55); itemStack = stack; - read(); } @Override public void markDirty() { super.markDirty(); - if (!reading) { write(); } @@ -50,7 +47,6 @@ public class InventoryPersonalChest extends InventoryBasic { public void write() { NBTTagList tagList = new NBTTagList(); - for (int slotCount = 0; slotCount < getSizeInventory(); slotCount++) { if (!getStackInSlot(slotCount).isEmpty()) { NBTTagCompound tagCompound = new NBTTagCompound(); @@ -59,7 +55,6 @@ public class InventoryPersonalChest extends InventoryBasic { tagList.appendTag(tagCompound); } } - if (!getStack().isEmpty()) { ((ISustainedInventory) getStack().getItem()).setInventory(tagList, getStack()); } @@ -69,26 +64,21 @@ public class InventoryPersonalChest extends InventoryBasic { 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 = tagList.getCompoundTagAt(tagCount); byte slotID = tagCompound.getByte("Slot"); - if (slotID >= 0 && slotID < getSizeInventory()) { setInventorySlotContents(slotID, new ItemStack(tagCompound)); } } } - reading = false; } public ItemStack getStack() { return itemStack; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/inventory/container/ContainerAdvancedElectricMachine.java b/src/main/java/mekanism/common/inventory/container/ContainerAdvancedElectricMachine.java index 32ddeee7a..e2625d9c5 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerAdvancedElectricMachine.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerAdvancedElectricMachine.java @@ -1,6 +1,7 @@ package mekanism.common.inventory.container; import java.util.Map; +import java.util.Map.Entry; import javax.annotation.Nonnull; import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge; import mekanism.common.inventory.slot.SlotOutput; @@ -23,11 +24,9 @@ public class ContainerAdvancedElectricMachine extends ContainerMekanism= 4 && slotID <= 30) { - if (!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) { - return ItemStack.EMPTY; - } - } else if (slotID > 30) { - if (!mergeItemStack(slotStack, 4, 30, false)) { - return ItemStack.EMPTY; - } - } else { - if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (slotID >= 4 && slotID <= 30) { + if (!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) { + return ItemStack.EMPTY; } + } else if (slotID > 30) { + if (!mergeItemStack(slotStack, 4, 30, false)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } private boolean isInputItem(ItemStack itemstack) { - for (Map.Entry entry : ((Map) tileEntity - .getRecipes()).entrySet()) { + for (Entry entry : ((Map) tileEntity.getRecipes()).entrySet()) { if (entry.getKey().itemStack.isItemEqual(itemstack)) { return true; } } - return false; } @@ -112,4 +95,4 @@ public class ContainerAdvancedElectricMachine extends ContainerMekanism= 4 && slotID <= 30) { - if (!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) { - return ItemStack.EMPTY; - } - } else if (slotID > 30) { - if (!mergeItemStack(slotStack, 4, 30, false)) { - return ItemStack.EMPTY; - } - } else { - if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (slotID >= 4 && slotID <= 30) { + if (!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) { + return ItemStack.EMPTY; } + } else if (slotID > 30) { + if (!mergeItemStack(slotStack, 4, 30, false)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } @@ -91,4 +79,4 @@ public class ContainerChanceMachine extends ContainerMekanism= 3 && slotID <= 29) { - if (!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) { - return ItemStack.EMPTY; - } - } else if (slotID > 29) { - if (!mergeItemStack(slotStack, 3, 29, false)) { - return ItemStack.EMPTY; - } - } else { - if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (slotID >= 3 && slotID <= 29) { + if (!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) { + return ItemStack.EMPTY; } + } else if (slotID > 29) { + if (!mergeItemStack(slotStack, 3, 29, false)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } @@ -90,4 +76,4 @@ public class ContainerChemicalCrystallizer extends ContainerMekanism { - public ContainerChemicalDissolutionChamber(InventoryPlayer inventory, - TileEntityChemicalDissolutionChamber tile) { + public ContainerChemicalDissolutionChamber(InventoryPlayer inventory, TileEntityChemicalDissolutionChamber tile) { super(tile, inventory); } @@ -25,30 +24,24 @@ public class ContainerChemicalDissolutionChamber extends ContainerMekanism= 4 && slotID <= 30) { - if (!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) { - return ItemStack.EMPTY; - } - } else if (slotID > 30) { - if (!mergeItemStack(slotStack, 4, 30, false)) { - return ItemStack.EMPTY; - } - } else { - if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (slotID >= 4 && slotID <= 30) { + if (!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) { + return ItemStack.EMPTY; } + } else if (slotID > 30) { + if (!mergeItemStack(slotStack, 4, 30, false)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } @@ -101,4 +84,4 @@ public class ContainerChemicalDissolutionChamber extends ContainerMekanism= 4 && slotID <= 30) { - if (!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) { - return ItemStack.EMPTY; - } - } else if (slotID > 30) { - if (!mergeItemStack(slotStack, 4, 30, false)) { - return ItemStack.EMPTY; - } - } else { - if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (slotID >= 4 && slotID <= 30) { + if (!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) { + return ItemStack.EMPTY; } + } else if (slotID > 30) { + if (!mergeItemStack(slotStack, 4, 30, false)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } if (slotStack.getCount() == 0) { @@ -86,4 +76,4 @@ public class ContainerChemicalInfuser extends ContainerMekanism= 3 && slotID <= 29) { - if (!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) { - return ItemStack.EMPTY; - } - } else if (slotID > 29) { - if (!mergeItemStack(slotStack, 3, 29, false)) { - return ItemStack.EMPTY; - } - } else { - if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (slotID >= 3 && slotID <= 29) { + if (!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) { + return ItemStack.EMPTY; } + } else if (slotID > 29) { + if (!mergeItemStack(slotStack, 3, 29, false)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } @@ -97,4 +81,4 @@ public class ContainerChemicalOxidizer extends ContainerMekanism= 4 && slotID <= 30) { - if (!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) { - return ItemStack.EMPTY; - } - } else if (slotID > 30) { - if (!mergeItemStack(slotStack, 4, 30, false)) { - return ItemStack.EMPTY; - } - } else { - if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (slotID >= 4 && slotID <= 30) { + if (!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) { + return ItemStack.EMPTY; } + } else if (slotID > 30) { + if (!mergeItemStack(slotStack, 4, 30, false)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } @@ -104,4 +88,4 @@ public class ContainerChemicalWasher extends ContainerMekanism= 0 && slotID <= 26) { if (!mergeItemStack(slotStack, 27, inventorySlots.size(), false)) { return ItemStack.EMPTY; } - } else { - if (!mergeItemStack(slotStack, 0, 26, false)) { - return ItemStack.EMPTY; - } + } else if (!mergeItemStack(slotStack, 0, 26, false)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/inventory/container/ContainerDigitalMiner.java b/src/main/java/mekanism/common/inventory/container/ContainerDigitalMiner.java index b4a56ed5e..57a108418 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerDigitalMiner.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerDigitalMiner.java @@ -20,44 +20,34 @@ public class ContainerDigitalMiner extends ContainerMekanism 27) { if (!mergeItemStack(slotStack, 27, 28, false)) { return ItemStack.EMPTY; } - } else { - if (!mergeItemStack(slotStack, 28, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } - } - } else { - if (slotID < 27) { - if (!mergeItemStack(slotStack, 28, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } - } else if (!mergeItemStack(slotStack, 0, 27, false)) { + } else if (!mergeItemStack(slotStack, 28, inventorySlots.size(), true)) { return ItemStack.EMPTY; } + } else if (slotID < 27) { + if (!mergeItemStack(slotStack, 28, inventorySlots.size(), true)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 0, 27, false)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } @@ -68,7 +58,6 @@ public class ContainerDigitalMiner extends ContainerMekanism= 4 && slotID <= 30) { - if (!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) { - return ItemStack.EMPTY; - } - } else if (slotID > 30) { - if (!mergeItemStack(slotStack, 4, 30, false)) { - return ItemStack.EMPTY; - } - } else { - if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (slotID >= 4 && slotID <= 30) { + if (!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) { + return ItemStack.EMPTY; } + } else if (slotID > 30) { + if (!mergeItemStack(slotStack, 4, 30, false)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } private boolean isInputItem(ItemStack itemstack) { - for (Map.Entry entry : ((Map) tileEntity - .getRecipes()).entrySet()) { + for (Map.Entry entry : ((Map) tileEntity.getRecipes()).entrySet()) { if (entry.getKey().itemStack.isItemEqual(itemstack)) { return true; } } - return false; } private boolean isExtraItem(ItemStack itemstack) { - for (Map.Entry entry : ((Map) tileEntity - .getRecipes()).entrySet()) { + for (Map.Entry entry : ((Map) tileEntity.getRecipes()).entrySet()) { if (entry.getKey().extraStack.isItemEqual(itemstack)) { return true; } } - return false; } @@ -123,4 +103,4 @@ public class ContainerDoubleElectricMachine extends ContainerMekanism= 3 && slotID <= 29) { - if (!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) { - return ItemStack.EMPTY; - } - } else if (slotID > 29) { - if (!mergeItemStack(slotStack, 3, 29, false)) { - return ItemStack.EMPTY; - } - } else { - if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (slotID >= 3 && slotID <= 29) { + if (!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) { + return ItemStack.EMPTY; } + } else if (slotID > 29) { + if (!mergeItemStack(slotStack, 3, 29, false)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } @@ -90,4 +76,4 @@ public class ContainerElectricMachine extends ContainerMekanism= 2 && slotID <= 28) { - if (!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) { - return ItemStack.EMPTY; - } - } else if (slotID > 28) { - if (!mergeItemStack(slotStack, 2, 28, false)) { - return ItemStack.EMPTY; - } - } else { - if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + } else if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { return ItemStack.EMPTY; } } + } else if (slotID >= 2 && slotID <= 28) { + if (!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) { + return ItemStack.EMPTY; + } + } else if (slotID > 28) { + if (!mergeItemStack(slotStack, 2, 28, false)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerFactory.java b/src/main/java/mekanism/common/inventory/container/ContainerFactory.java index d4dabfd46..cc76bd054 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerFactory.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerFactory.java @@ -28,12 +28,10 @@ public class ContainerFactory extends ContainerMekanism { addSlotToContainer(new Slot(tileEntity, 2, 180, 75)); addSlotToContainer(new Slot(tileEntity, 3, 180, 112)); addSlotToContainer(new Slot(tileEntity, 4, 7, 57)); - if (tileEntity.tier == FactoryTier.BASIC) { for (int i = 0; i < tileEntity.tier.processes; i++) { addSlotToContainer(new FactoryInputSlot(tileEntity, getInputSlotIndex(i), 55 + (i * 38), 13, i)); } - for (int i = 0; i < tileEntity.tier.processes; i++) { addSlotToContainer(new SlotOutput(tileEntity, getOutputSlotIndex(i), 55 + (i * 38), 57)); } @@ -41,7 +39,6 @@ public class ContainerFactory extends ContainerMekanism { for (int i = 0; i < tileEntity.tier.processes; i++) { addSlotToContainer(new FactoryInputSlot(tileEntity, getInputSlotIndex(i), 35 + (i * 26), 13, i)); } - for (int i = 0; i < tileEntity.tier.processes; i++) { addSlotToContainer(new SlotOutput(tileEntity, getOutputSlotIndex(i), 35 + (i * 26), 57)); } @@ -49,7 +46,6 @@ public class ContainerFactory extends ContainerMekanism { for (int i = 0; i < tileEntity.tier.processes; i++) { addSlotToContainer(new FactoryInputSlot(tileEntity, getInputSlotIndex(i), 29 + (i * 19), 13, i)); } - for (int i = 0; i < tileEntity.tier.processes; i++) { addSlotToContainer(new SlotOutput(tileEntity, getOutputSlotIndex(i), 29 + (i * 19), 57)); } @@ -66,17 +62,14 @@ public class ContainerFactory extends ContainerMekanism { public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { ItemStack stack = ItemStack.EMPTY; Slot currentSlot = inventorySlots.get(slotID); - if (currentSlot != null && currentSlot.getHasStack()) { ItemStack slotStack = currentSlot.getStack(); stack = slotStack.copy(); - if (isOutputSlot(slotID)) { if (!mergeItemStack(slotStack, tileEntity.inventory.size() - 1, inventorySlots.size(), true)) { return ItemStack.EMPTY; } - } else if (slotID != 1 && slotID != 2 && isProperMachine(slotStack) && !slotStack - .isItemEqual(tileEntity.getMachineStack())) { + } else if (slotID != 1 && slotID != 2 && isProperMachine(slotStack) && !slotStack.isItemEqual(tileEntity.getMachineStack())) { if (!mergeItemStack(slotStack, 1, 2, false)) { return ItemStack.EMPTY; } @@ -84,9 +77,7 @@ public class ContainerFactory extends ContainerMekanism { if (!mergeItemStack(slotStack, tileEntity.inventory.size() - 1, inventorySlots.size(), true)) { return ItemStack.EMPTY; } - } else if (tileEntity.getRecipeType() - .getAnyRecipe(slotStack, inventorySlots.get(4).getStack(), tileEntity.gasTank.getGasType(), - tileEntity.infuseStored) != null) { + } else if (tileEntity.getRecipeType().getAnyRecipe(slotStack, inventorySlots.get(4).getStack(), tileEntity.gasTank.getGasType(), tileEntity.infuseStored) != null) { if (isInputSlot(slotID)) { if (!mergeItemStack(slotStack, tileEntity.inventory.size() - 1, inventorySlots.size(), true)) { return ItemStack.EMPTY; @@ -107,40 +98,34 @@ public class ContainerFactory extends ContainerMekanism { return ItemStack.EMPTY; } } else if (tileEntity.getRecipeType() == RecipeType.INFUSING && InfuseRegistry.getObject(slotStack) != null - && (tileEntity.infuseStored.getType() == null || tileEntity.infuseStored.getType() == InfuseRegistry - .getObject(slotStack).type)) { + && (tileEntity.infuseStored.getType() == null || tileEntity.infuseStored.getType() == InfuseRegistry.getObject(slotStack).type)) { if (transferExtraSlot(slotID, slotStack)) { return ItemStack.EMPTY; } } else { int slotEnd = tileEntity.inventory.size() - 1; - if (slotID >= slotEnd && slotID <= (slotEnd + 26)) { - if (!mergeItemStack(slotStack, (slotEnd + 27), inventorySlots.size(), false)) { + if (!mergeItemStack(slotStack, slotEnd + 27, inventorySlots.size(), false)) { return ItemStack.EMPTY; } } else if (slotID > (slotEnd + 26)) { - if (!mergeItemStack(slotStack, slotEnd, (slotEnd + 26), false)) { + if (!mergeItemStack(slotStack, slotEnd, slotEnd + 26, false)) { return ItemStack.EMPTY; } } else if (!mergeItemStack(slotStack, slotEnd, inventorySlots.size(), true)) { return ItemStack.EMPTY; } } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } @@ -153,10 +138,8 @@ public class ContainerFactory extends ContainerMekanism { public boolean isProperMachine(ItemStack itemStack) { if (!itemStack.isEmpty() && itemStack.getItem() instanceof ItemBlockMachine) { - return Arrays.stream(RecipeType.values()).findFirst().filter(type -> itemStack.isItemEqual(type.getStack())) - .isPresent(); + return Arrays.stream(RecipeType.values()).findFirst().filter(type -> itemStack.isItemEqual(type.getStack())).isPresent(); } - return false; } @@ -179,8 +162,7 @@ public class ContainerFactory extends ContainerMekanism { private class FactoryInputSlot extends Slot { /** - * The index of the processes slot. 0 <= processNumber < tileEntity.tier.processes For matching the input to - * output slot + * The index of the processes slot. 0 <= processNumber < tileEntity.tier.processes For matching the input to output slot */ private final int processNumber; @@ -192,8 +174,7 @@ public class ContainerFactory extends ContainerMekanism { @Override public boolean isItemValid(ItemStack stack) { ItemStack outputSlotStack = tileEntity.inventory.get(getOutputSlotIndex(this.processNumber)); - return tileEntity.inputProducesOutput(getInputSlotIndex(this.processNumber), stack, outputSlotStack, false) - && super.isItemValid(stack); + return tileEntity.inputProducesOutput(getInputSlotIndex(this.processNumber), stack, outputSlotStack, false) && super.isItemValid(stack); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/inventory/container/ContainerFilter.java b/src/main/java/mekanism/common/inventory/container/ContainerFilter.java index 8d80618d6..63b2010dc 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerFilter.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerFilter.java @@ -18,39 +18,30 @@ public class ContainerFilter extends ContainerMekanism public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { ItemStack stack = ItemStack.EMPTY; Slot currentSlot = inventorySlots.get(slotID); - if (currentSlot != null && currentSlot.getHasStack()) { ItemStack slotStack = currentSlot.getStack(); stack = slotStack.copy(); - if (slotID <= 26) { if (!mergeItemStack(slotStack, 27, inventorySlots.size(), false)) { return ItemStack.EMPTY; } - } else { - if (!mergeItemStack(slotStack, 0, 26, false)) { - return ItemStack.EMPTY; - } + } else if (!mergeItemStack(slotStack, 0, 26, false)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } @Override protected void addSlots() { - } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/inventory/container/ContainerFluidStorage.java b/src/main/java/mekanism/common/inventory/container/ContainerFluidStorage.java index ac66825fb..0b54fe467 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerFluidStorage.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerFluidStorage.java @@ -19,11 +19,9 @@ public abstract class ContainerFluidStorage= 3 && slotID <= 29) { - if (!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) { - return ItemStack.EMPTY; - } - } else if (slotID > 29) { - if (!mergeItemStack(slotStack, 3, 29, false)) { - return ItemStack.EMPTY; - } - } else { - if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (slotID >= 3 && slotID <= 29) { + if (!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) { + return ItemStack.EMPTY; } + } else if (slotID > 29) { + if (!mergeItemStack(slotStack, 3, 29, false)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/inventory/container/ContainerFormulaicAssemblicator.java b/src/main/java/mekanism/common/inventory/container/ContainerFormulaicAssemblicator.java index 1b3e5f3ff..2c5767c19 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerFormulaicAssemblicator.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerFormulaicAssemblicator.java @@ -25,69 +25,54 @@ public class ContainerFormulaicAssemblicator extends ContainerMekanism= 2 && slotID <= 19) { if (!mergeItemStack(slotStack, 34, inventorySlots.size(), true)) { return ItemStack.EMPTY; } - } else if (tileEntity.formula == null || tileEntity.formula - .isIngredient(tileEntity.getWorld(), slotStack)) { + } else if (tileEntity.formula == null || tileEntity.formula.isIngredient(tileEntity.getWorld(), slotStack)) { if (!mergeItemStack(slotStack, 2, 20, false)) { return ItemStack.EMPTY; } - } else { - if (slotID >= 34 && slotID <= 60) { - if (!mergeItemStack(slotStack, 61, inventorySlots.size(), false)) { - return ItemStack.EMPTY; - } - } else if (slotID > 60) { - if (!mergeItemStack(slotStack, 34, 60, false)) { - return ItemStack.EMPTY; - } - } else { - if (!mergeItemStack(slotStack, 34, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (slotID >= 34 && slotID <= 60) { + if (!mergeItemStack(slotStack, 61, inventorySlots.size(), false)) { + return ItemStack.EMPTY; } + } else if (slotID > 60) { + if (!mergeItemStack(slotStack, 34, 60, false)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 34, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } @@ -95,13 +80,11 @@ public class ContainerFormulaicAssemblicator extends ContainerMekanism 0) { if (slotID != 0) { if (!mergeItemStack(slotStack, 0, 1, false)) { return ItemStack.EMPTY; } - } else { - if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - } else { - if (slotID >= 1 && slotID <= 27) { - if (!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) { - return ItemStack.EMPTY; - } - } else if (slotID > 27) { - if (!mergeItemStack(slotStack, 1, 27, false)) { - return ItemStack.EMPTY; - } - } else { - if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (slotID >= 1 && slotID <= 27) { + if (!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) { + return ItemStack.EMPTY; } + } else if (slotID > 27) { + if (!mergeItemStack(slotStack, 1, 27, false)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } @@ -70,4 +58,4 @@ public class ContainerFuelwoodHeater extends ContainerMekanism { public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { ItemStack stack = ItemStack.EMPTY; Slot currentSlot = inventorySlots.get(slotID); - 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, 0, 1, false)) { @@ -32,40 +30,30 @@ public class ContainerGasTank extends ContainerMekanism { return ItemStack.EMPTY; } } - } else { - if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - } else { - if (slotID >= 2 && slotID <= 28) { - if (!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) { - return ItemStack.EMPTY; - } - } else if (slotID > 28) { - if (!mergeItemStack(slotStack, 2, 28, false)) { - return ItemStack.EMPTY; - } - } else { - if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (slotID >= 2 && slotID <= 28) { + if (!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) { + return ItemStack.EMPTY; } + } else if (slotID > 28) { + if (!mergeItemStack(slotStack, 2, 28, false)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } @@ -74,4 +62,4 @@ public class ContainerGasTank extends ContainerMekanism { addSlotToContainer(new SlotStorageTank(tileEntity, 0, 8, 8)); addSlotToContainer(new SlotStorageTank(tileEntity, 1, 8, 40)); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/inventory/container/ContainerLaserAmplifier.java b/src/main/java/mekanism/common/inventory/container/ContainerLaserAmplifier.java index 0353faf77..8acd83dc9 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerLaserAmplifier.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerLaserAmplifier.java @@ -18,34 +18,26 @@ public class ContainerLaserAmplifier extends ContainerMekanism e addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, offset + slotY * 18)); } } - offset += 58; for (int slotY = 0; slotY < 9; slotY++) { addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, offset)); diff --git a/src/main/java/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java b/src/main/java/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java index 80228a1ac..283f3614c 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java @@ -25,14 +25,11 @@ public class ContainerMetallurgicInfuser extends ContainerMekanism input.inputStack.isItemEqual(itemStack)); + return RecipeHandler.getMetallurgicInfuserRecipe(new InfusionInput(tileEntity.infuseStored, itemStack)) != null; } - + return Recipe.METALLURGIC_INFUSER.get().keySet().stream().anyMatch(input -> input.inputStack.isItemEqual(itemStack)); } @Override @@ -95,4 +80,4 @@ public class ContainerMetallurgicInfuser extends ContainerMekanism { @Override protected void addInventorySlots(InventoryPlayer inventory) { } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/inventory/container/ContainerOredictionificator.java b/src/main/java/mekanism/common/inventory/container/ContainerOredictionificator.java index 753ba2534..82c6e87fe 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerOredictionificator.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerOredictionificator.java @@ -19,11 +19,9 @@ public class ContainerOredictionificator extends ContainerMekanism= 2 && slotID <= 28) { - if (!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) { - return ItemStack.EMPTY; - } - } else if (slotID > 28) { - if (!mergeItemStack(slotStack, 2, 28, false)) { - return ItemStack.EMPTY; - } - } else { - if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (slotID >= 2 && slotID <= 28) { + if (!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) { + return ItemStack.EMPTY; } + } else if (slotID > 28) { + if (!mergeItemStack(slotStack, 2, 28, false)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } @@ -80,4 +68,4 @@ public class ContainerOredictionificator extends ContainerMekanism { public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { ItemStack stack = ItemStack.EMPTY; Slot currentSlot = inventorySlots.get(slotID); - if (currentSlot != null && currentSlot.getHasStack()) { ItemStack slotStack = currentSlot.getStack(); stack = slotStack.copy(); - if (slotID == 2) { if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { return ItemStack.EMPTY; @@ -36,50 +34,38 @@ public class ContainerPRC extends ContainerMekanism { if (!mergeItemStack(slotStack, 1, 2, false)) { return ItemStack.EMPTY; } - } else { - if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } } else if (RecipeHandler.isInPressurizedRecipe(slotStack)) { if (slotID != 0) { if (!mergeItemStack(slotStack, 0, 1, false)) { return ItemStack.EMPTY; } - } else { - if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - } else { - if (slotID >= 3 && slotID <= 29) { - if (!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) { - return ItemStack.EMPTY; - } - } else if (slotID > 29) { - if (!mergeItemStack(slotStack, 3, 29, false)) { - return ItemStack.EMPTY; - } - } else { - if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (slotID >= 3 && slotID <= 29) { + if (!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) { + return ItemStack.EMPTY; } + } else if (slotID > 29) { + if (!mergeItemStack(slotStack, 3, 29, false)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } @@ -89,4 +75,4 @@ public class ContainerPRC extends ContainerMekanism { addSlotToContainer(new SlotDischarge(tileEntity, 1, 141, 19)); addSlotToContainer(new SlotOutput(tileEntity, 2, 116, 35)); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/inventory/container/ContainerPersonalChest.java b/src/main/java/mekanism/common/inventory/container/ContainerPersonalChest.java index c48143ba1..4ce525da7 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerPersonalChest.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerPersonalChest.java @@ -18,8 +18,7 @@ public class ContainerPersonalChest extends ContainerMekanism= 0 && hotbarSlotId < 9 && player.inventory.currentItem == hotbarSlotId) { ItemStack itemStack = player.inventory.getStackInSlot(hotbarSlotId); - if (!itemStack.isEmpty() && MachineType.get(itemStack) == MachineType.PERSONAL_CHEST) { return ItemStack.EMPTY; } } - return super.slotClick(slotId, dragType, clickType, player); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/inventory/container/ContainerQuantumEntangloporter.java b/src/main/java/mekanism/common/inventory/container/ContainerQuantumEntangloporter.java index 99460445e..edebab7c6 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerQuantumEntangloporter.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerQuantumEntangloporter.java @@ -18,44 +18,35 @@ public class ContainerQuantumEntangloporter extends ContainerMekanism= 1 && slotID <= 27) { - if (!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) { - return ItemStack.EMPTY; - } - } else if (slotID > 27) { - if (!mergeItemStack(slotStack, 1, 27, false)) { - return ItemStack.EMPTY; - } - } else { - if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (slotID >= 1 && slotID <= 27) { + if (!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) { + return ItemStack.EMPTY; } + } else if (slotID > 27) { + if (!mergeItemStack(slotStack, 1, 27, false)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } @@ -71,4 +59,4 @@ public class ContainerResistiveHeater extends ContainerMekanism= 5 && slotID <= 31) { - if (!mergeItemStack(slotStack, 32, inventorySlots.size(), false)) { - return ItemStack.EMPTY; - } - } else if (slotID > 31) { - if (!mergeItemStack(slotStack, 5, 31, false)) { - return ItemStack.EMPTY; - } - } else { - if (!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (slotID >= 5 && slotID <= 31) { + if (!mergeItemStack(slotStack, 32, inventorySlots.size(), false)) { + return ItemStack.EMPTY; } + } else if (slotID > 31) { + if (!mergeItemStack(slotStack, 5, 31, false)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } @@ -107,4 +89,4 @@ public class ContainerRotaryCondensentrator extends ContainerMekanism= 2 && slotID <= 28) { - if (!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) { - return ItemStack.EMPTY; - } - } else if (slotID > 28) { - if (!mergeItemStack(slotStack, 2, 28, false)) { - return ItemStack.EMPTY; - } - } else { - if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (slotID >= 2 && slotID <= 28) { + if (!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) { + return ItemStack.EMPTY; } + } else if (slotID > 28) { + if (!mergeItemStack(slotStack, 2, 28, false)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } @@ -77,4 +65,4 @@ public class ContainerSecurityDesk extends ContainerMekanism= 1 && slotID <= 27) { - if (!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) { - return ItemStack.EMPTY; - } - } else if (slotID > 27) { - if (!mergeItemStack(slotStack, 1, 27, false)) { - return ItemStack.EMPTY; - } - } else { - if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (slotID >= 1 && slotID <= 27) { + if (!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) { + return ItemStack.EMPTY; } + } else if (slotID > 27) { + if (!mergeItemStack(slotStack, 1, 27, false)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } @@ -71,4 +59,4 @@ public class ContainerSeismicVibrator extends ContainerMekanism= 2 && slotID <= 28) { - if (!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) { - return ItemStack.EMPTY; - } - } else if (slotID > 28) { - if (!mergeItemStack(slotStack, 2, 28, false)) { - return ItemStack.EMPTY; - } - } else { - if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (slotID >= 2 && slotID <= 28) { + if (!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) { + return ItemStack.EMPTY; } + } else if (slotID > 28) { + if (!mergeItemStack(slotStack, 2, 28, false)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } @@ -80,4 +66,4 @@ public class ContainerSolarNeutronActivator extends ContainerMekanism public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { ItemStack stack = ItemStack.EMPTY; Slot currentSlot = inventorySlots.get(slotID); - 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 ItemStack.EMPTY; } - } else { - if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - } else { - if (slotID >= 1 && slotID <= 27) { - if (!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) { - return ItemStack.EMPTY; - } - } else if (slotID > 27) { - if (!mergeItemStack(slotStack, 1, 27, false)) { - return ItemStack.EMPTY; - } - } else { - if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (slotID >= 1 && slotID <= 27) { + if (!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) { + return ItemStack.EMPTY; } + } else if (slotID > 27) { + if (!mergeItemStack(slotStack, 1, 27, false)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } @@ -76,4 +64,4 @@ public class ContainerTeleporter extends ContainerMekanism protected int getInventoryOffset() { return 148; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/inventory/container/ContainerThermalEvaporationController.java b/src/main/java/mekanism/common/inventory/container/ContainerThermalEvaporationController.java index bc1bfd62b..80a44bc3d 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerThermalEvaporationController.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerThermalEvaporationController.java @@ -23,12 +23,10 @@ public class ContainerThermalEvaporationController extends ContainerMekanism= 4 && slotID <= 30) { - if (!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) { - return ItemStack.EMPTY; - } - } else if (slotID > 30) { - if (!mergeItemStack(slotStack, 4, 30, false)) { - return ItemStack.EMPTY; - } - } else { - if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (slotID >= 4 && slotID <= 30) { + if (!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) { + return ItemStack.EMPTY; } + } else if (slotID > 30) { + if (!mergeItemStack(slotStack, 4, 30, false)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } @@ -92,4 +78,4 @@ public class ContainerThermalEvaporationController extends ContainerMekanism= 1 && slotID <= 27) { - if (!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) { - return ItemStack.EMPTY; - } - } else if (slotID > 27) { - if (!mergeItemStack(slotStack, 1, 27, false)) { - return ItemStack.EMPTY; - } - } else { - if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { - return ItemStack.EMPTY; - } + } else if (slotID >= 1 && slotID <= 27) { + if (!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) { + return ItemStack.EMPTY; } + } else if (slotID > 27) { + if (!mergeItemStack(slotStack, 1, 27, false)) { + return ItemStack.EMPTY; + } + } else if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { + return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/inventory/container/robit/ContainerRobit.java b/src/main/java/mekanism/common/inventory/container/robit/ContainerRobit.java index dbc62a700..fb9a20c43 100644 --- a/src/main/java/mekanism/common/inventory/container/robit/ContainerRobit.java +++ b/src/main/java/mekanism/common/inventory/container/robit/ContainerRobit.java @@ -26,7 +26,6 @@ public abstract class ContainerRobit extends Container { addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); } } - for (int slotY = 0; slotY < 9; slotY++) { addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); } diff --git a/src/main/java/mekanism/common/inventory/container/robit/ContainerRobitCrafting.java b/src/main/java/mekanism/common/inventory/container/robit/ContainerRobitCrafting.java index acffc3e93..2826f0bc4 100644 --- a/src/main/java/mekanism/common/inventory/container/robit/ContainerRobitCrafting.java +++ b/src/main/java/mekanism/common/inventory/container/robit/ContainerRobitCrafting.java @@ -20,4 +20,4 @@ public class ContainerRobitCrafting extends ContainerWorkbench { public boolean canInteractWith(@Nonnull EntityPlayer entityplayer) { return !robit.isDead; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/inventory/container/robit/ContainerRobitInventory.java b/src/main/java/mekanism/common/inventory/container/robit/ContainerRobitInventory.java index dc78cdfae..18740c770 100644 --- a/src/main/java/mekanism/common/inventory/container/robit/ContainerRobitInventory.java +++ b/src/main/java/mekanism/common/inventory/container/robit/ContainerRobitInventory.java @@ -18,11 +18,9 @@ public class ContainerRobitInventory extends ContainerRobit { public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { ItemStack stack = ItemStack.EMPTY; Slot currentSlot = inventorySlots.get(slotID); - if (currentSlot != null && currentSlot.getHasStack()) { ItemStack slotStack = currentSlot.getStack(); stack = slotStack.copy(); - if (slotID < 27) { if (!mergeItemStack(slotStack, 27, inventorySlots.size(), true)) { return ItemStack.EMPTY; @@ -30,20 +28,16 @@ public class ContainerRobitInventory extends ContainerRobit { } else if (!mergeItemStack(slotStack, 0, 27, false)) { return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } @@ -55,4 +49,4 @@ public class ContainerRobitInventory extends ContainerRobit { } } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/inventory/container/robit/ContainerRobitMain.java b/src/main/java/mekanism/common/inventory/container/robit/ContainerRobitMain.java index 2038c696c..c8bf93af5 100644 --- a/src/main/java/mekanism/common/inventory/container/robit/ContainerRobitMain.java +++ b/src/main/java/mekanism/common/inventory/container/robit/ContainerRobitMain.java @@ -23,4 +23,4 @@ public class ContainerRobitMain extends ContainerRobit { protected void addSlots() { addSlotToContainer(new SlotDischarge(robit, 27, 153, 17)); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/inventory/container/robit/ContainerRobitRepair.java b/src/main/java/mekanism/common/inventory/container/robit/ContainerRobitRepair.java index 2f3f4d8d5..849172e13 100644 --- a/src/main/java/mekanism/common/inventory/container/robit/ContainerRobitRepair.java +++ b/src/main/java/mekanism/common/inventory/container/robit/ContainerRobitRepair.java @@ -13,7 +13,6 @@ public class ContainerRobitRepair extends ContainerRepair { public ContainerRobitRepair(InventoryPlayer inventory, EntityRobit entity) { super(inventory, entity.world, BlockPos.ORIGIN, inventory.player); - robit = entity; } @@ -21,4 +20,4 @@ public class ContainerRobitRepair extends ContainerRepair { public boolean canInteractWith(@Nonnull EntityPlayer entityplayer) { return !robit.isDead; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/inventory/container/robit/ContainerRobitSmelting.java b/src/main/java/mekanism/common/inventory/container/robit/ContainerRobitSmelting.java index aa78dcb86..89c3b5c9c 100644 --- a/src/main/java/mekanism/common/inventory/container/robit/ContainerRobitSmelting.java +++ b/src/main/java/mekanism/common/inventory/container/robit/ContainerRobitSmelting.java @@ -32,23 +32,17 @@ public class ContainerRobitSmelting extends ContainerRobit { @Override public void detectAndSendChanges() { super.detectAndSendChanges(); - for (IContainerListener listener : listeners) { - IContainerListener icrafting = listener; - if (lastCookTime != robit.furnaceCookTime) { - icrafting.sendWindowProperty(this, 0, robit.furnaceCookTime); + listener.sendWindowProperty(this, 0, robit.furnaceCookTime); } - if (lastBurnTime != robit.furnaceBurnTime) { - icrafting.sendWindowProperty(this, 1, robit.furnaceBurnTime); + listener.sendWindowProperty(this, 1, robit.furnaceBurnTime); } - if (lastItemBurnTime != robit.currentItemBurnTime) { - icrafting.sendWindowProperty(this, 2, robit.currentItemBurnTime); + listener.sendWindowProperty(this, 2, robit.currentItemBurnTime); } } - lastCookTime = robit.furnaceCookTime; lastBurnTime = robit.furnaceBurnTime; lastItemBurnTime = robit.currentItemBurnTime; @@ -59,11 +53,9 @@ public class ContainerRobitSmelting extends ContainerRobit { if (i == 0) { robit.furnaceCookTime = j; } - if (i == 1) { robit.furnaceBurnTime = j; } - if (i == 2) { robit.currentItemBurnTime = j; } @@ -74,11 +66,9 @@ public class ContainerRobitSmelting extends ContainerRobit { public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { ItemStack stack = ItemStack.EMPTY; Slot currentSlot = 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 ItemStack.EMPTY; @@ -102,20 +92,16 @@ public class ContainerRobitSmelting extends ContainerRobit { } else if (!mergeItemStack(slotStack, 3, 39, false)) { return ItemStack.EMPTY; } - if (slotStack.getCount() == 0) { currentSlot.putStack(ItemStack.EMPTY); } else { currentSlot.onSlotChanged(); } - if (slotStack.getCount() == stack.getCount()) { return ItemStack.EMPTY; } - currentSlot.onTake(player, slotStack); } - return stack; } @@ -130,4 +116,4 @@ public class ContainerRobitSmelting extends ContainerRobit { addSlotToContainer(new SlotFurnaceOutput(inventory.player, robit, 30, 116, 35)); super.addInventorySlots(inventory); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/inventory/slot/SlotEnergy.java b/src/main/java/mekanism/common/inventory/slot/SlotEnergy.java index a3294cfcb..649be7a94 100644 --- a/src/main/java/mekanism/common/inventory/slot/SlotEnergy.java +++ b/src/main/java/mekanism/common/inventory/slot/SlotEnergy.java @@ -30,4 +30,4 @@ public class SlotEnergy { return ChargeUtils.canBeDischarged(itemstack); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/inventory/slot/SlotMachineUpgrade.java b/src/main/java/mekanism/common/inventory/slot/SlotMachineUpgrade.java index f3b64b4a7..b7faa2456 100644 --- a/src/main/java/mekanism/common/inventory/slot/SlotMachineUpgrade.java +++ b/src/main/java/mekanism/common/inventory/slot/SlotMachineUpgrade.java @@ -15,4 +15,4 @@ public class SlotMachineUpgrade extends Slot { public boolean isItemValid(ItemStack itemstack) { return itemstack.getItem() instanceof IUpgradeItem; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/inventory/slot/SlotOutput.java b/src/main/java/mekanism/common/inventory/slot/SlotOutput.java index 9bba3b699..05ff0eb6d 100644 --- a/src/main/java/mekanism/common/inventory/slot/SlotOutput.java +++ b/src/main/java/mekanism/common/inventory/slot/SlotOutput.java @@ -14,4 +14,4 @@ public class SlotOutput extends Slot { public boolean isItemValid(ItemStack itemstack) { return false; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/inventory/slot/SlotPersonalChest.java b/src/main/java/mekanism/common/inventory/slot/SlotPersonalChest.java index 7a9e0fdfb..1b5f84609 100644 --- a/src/main/java/mekanism/common/inventory/slot/SlotPersonalChest.java +++ b/src/main/java/mekanism/common/inventory/slot/SlotPersonalChest.java @@ -17,7 +17,6 @@ public class SlotPersonalChest extends Slot { if (inventory.getStackInSlot(getSlotIndex()).isEmpty()) { return false; } - return MachineType.get(inventory.getStackInSlot(getSlotIndex())) != MachineType.PERSONAL_CHEST; } @@ -26,7 +25,6 @@ public class SlotPersonalChest extends Slot { if (MachineType.get(stack) == MachineType.PERSONAL_CHEST) { return false; } - return super.isItemValid(stack); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/inventory/slot/SlotSpecific.java b/src/main/java/mekanism/common/inventory/slot/SlotSpecific.java index d0f491fc0..26145a244 100644 --- a/src/main/java/mekanism/common/inventory/slot/SlotSpecific.java +++ b/src/main/java/mekanism/common/inventory/slot/SlotSpecific.java @@ -11,7 +11,6 @@ public class SlotSpecific extends Slot { public SlotSpecific(IInventory inventory, int index, int x, int y, Class c) { super(inventory, index, x, y); - itemClass = c; } @@ -19,4 +18,4 @@ public class SlotSpecific extends Slot { public boolean isItemValid(ItemStack itemstack) { return itemClass.equals(itemstack.getItem().getClass()) || itemClass.isInstance(itemstack.getItem()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/inventory/slot/SlotStorageTank.java b/src/main/java/mekanism/common/inventory/slot/SlotStorageTank.java index b7b7b5642..a542d19c2 100644 --- a/src/main/java/mekanism/common/inventory/slot/SlotStorageTank.java +++ b/src/main/java/mekanism/common/inventory/slot/SlotStorageTank.java @@ -36,12 +36,10 @@ public class SlotStorageTank extends Slot { if (acceptsAllGasses) { return itemstack.getItem() instanceof IGasItem; } - if (itemstack.getItem() instanceof IGasItem) { - return ((IGasItem) itemstack.getItem()).getGas(itemstack) == null || types - .contains(((IGasItem) itemstack.getItem()).getGas(itemstack).getGas()); + IGasItem gasItem = (IGasItem) itemstack.getItem(); + return gasItem.getGas(itemstack) == null || types.contains(gasItem.getGas(itemstack).getGas()); } - return false; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemAlloy.java b/src/main/java/mekanism/common/item/ItemAlloy.java index 750aa0daf..5ae634a06 100644 --- a/src/main/java/mekanism/common/item/ItemAlloy.java +++ b/src/main/java/mekanism/common/item/ItemAlloy.java @@ -17,30 +17,19 @@ import net.minecraft.world.World; public class ItemAlloy extends ItemMekanism { - public ItemAlloy() { - super(); - } - @Nonnull @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, - float hitX, float hitY, float hitZ) { + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { TileEntity tile = world.getTileEntity(pos); ItemStack stack = player.getHeldItem(hand); - - if (MekanismConfig.current().general.allowTransmitterAlloyUpgrade.val() && CapabilityUtils - .hasCapability(tile, Capabilities.ALLOY_INTERACTION_CAPABILITY, side)) { + if (MekanismConfig.current().general.allowTransmitterAlloyUpgrade.val() && CapabilityUtils.hasCapability(tile, Capabilities.ALLOY_INTERACTION_CAPABILITY, side)) { if (!world.isRemote) { - IAlloyInteraction interaction = CapabilityUtils - .getCapability(tile, Capabilities.ALLOY_INTERACTION_CAPABILITY, side); - int ordinal = stack.getItem() == MekanismItems.EnrichedAlloy ? 1 - : (stack.getItem() == MekanismItems.ReinforcedAlloy ? 2 : 3); + IAlloyInteraction interaction = CapabilityUtils.getCapability(tile, Capabilities.ALLOY_INTERACTION_CAPABILITY, side); + int ordinal = stack.getItem() == MekanismItems.EnrichedAlloy ? 1 : stack.getItem() == MekanismItems.ReinforcedAlloy ? 2 : 3; interaction.onAlloyInteraction(player, hand, stack, ordinal); } - return EnumActionResult.SUCCESS; } - return EnumActionResult.PASS; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemAtomicDisassembler.java b/src/main/java/mekanism/common/item/ItemAtomicDisassembler.java index 27082727f..b4485ee98 100644 --- a/src/main/java/mekanism/common/item/ItemAtomicDisassembler.java +++ b/src/main/java/mekanism/common/item/ItemAtomicDisassembler.java @@ -59,7 +59,6 @@ public class ItemAtomicDisassembler extends ItemEnergized { @Override public void addInformation(ItemStack itemstack, World world, List list, ITooltipFlag flag) { super.addInformation(itemstack, world, list, flag); - list.add(LangUtils.localize("tooltip.mode") + ": " + EnumColor.INDIGO + getModeName(itemstack)); list.add(LangUtils.localize("tooltip.efficiency") + ": " + EnumColor.INDIGO + getEfficiency(itemstack)); } @@ -72,7 +71,6 @@ public class ItemAtomicDisassembler extends ItemEnergized { } else { target.attackEntityFrom(DamageSource.causeMobDamage(attacker), 20); } - setEnergy(itemstack, getEnergy(itemstack) - 2000); } else { if (attacker instanceof EntityPlayer) { @@ -80,9 +78,7 @@ public class ItemAtomicDisassembler extends ItemEnergized { } else { target.attackEntityFrom(DamageSource.causeMobDamage(attacker), 4); } - } - return false; } @@ -92,27 +88,20 @@ public class ItemAtomicDisassembler extends ItemEnergized { } @Override - public boolean onBlockDestroyed(ItemStack itemstack, World world, IBlockState state, BlockPos pos, - EntityLivingBase entityliving) { + public boolean onBlockDestroyed(ItemStack itemstack, World world, IBlockState state, BlockPos pos, EntityLivingBase entityliving) { if (state.getBlockHardness(world, pos) != 0.0D) { - setEnergy(itemstack, - getEnergy(itemstack) - (MekanismConfig.current().general.DISASSEMBLER_USAGE.val() * getEfficiency( - itemstack))); + setEnergy(itemstack, getEnergy(itemstack) - (MekanismConfig.current().general.DISASSEMBLER_USAGE.val() * getEfficiency(itemstack))); } else { - setEnergy(itemstack, getEnergy(itemstack) - ( - MekanismConfig.current().general.DISASSEMBLER_USAGE.val() * (getEfficiency(itemstack)) / 2F)); + setEnergy(itemstack, getEnergy(itemstack) - (MekanismConfig.current().general.DISASSEMBLER_USAGE.val() * getEfficiency(itemstack) / 2F)); } - return true; } private RayTraceResult doRayTrace(IBlockState state, BlockPos pos, EntityPlayer player) { Vec3d positionEyes = player.getPositionEyes(1.0F); Vec3d playerLook = player.getLook(1.0F); - double blockReachDistance = player.getAttributeMap().getAttributeInstance(EntityPlayer.REACH_DISTANCE) - .getAttributeValue(); - Vec3d maxReach = positionEyes.add(playerLook.x * blockReachDistance, playerLook.y * blockReachDistance, - playerLook.z * blockReachDistance); + double blockReachDistance = player.getAttributeMap().getAttributeInstance(EntityPlayer.REACH_DISTANCE).getAttributeValue(); + Vec3d maxReach = positionEyes.add(playerLook.x * blockReachDistance, playerLook.y * blockReachDistance, playerLook.z * blockReachDistance); RayTraceResult res = state.collisionRayTrace(player.world, pos, playerLook, maxReach); //noinspection ConstantConditions - idea thinks it's nonnull due to package level annotations, but it's not return res != null ? res : new RayTraceResult(RayTraceResult.Type.MISS, Vec3d.ZERO, EnumFacing.UP, pos); @@ -121,55 +110,39 @@ public class ItemAtomicDisassembler extends ItemEnergized { @Override public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, EntityPlayer player) { super.onBlockStartBreak(itemstack, pos, player); - if (!player.world.isRemote) { IBlockState state = player.world.getBlockState(pos); Block block = state.getBlock(); int meta = block.getMetaFromState(state); - if (block == Blocks.LIT_REDSTONE_ORE) { block = Blocks.REDSTONE_ORE; } - RayTraceResult raytrace = doRayTrace(state, pos, player); ItemStack stack = block.getPickBlock(state, raytrace, player.world, pos, player); Coord4D orig = new Coord4D(pos, player.world); - List names = OreDictCache.getOreDictName(stack); - boolean isOre = false; - for (String s : names) { if (s.startsWith("ore") || s.equals("logWood")) { isOre = true; } } - if (getMode(itemstack) == 3 && isOre && !player.capabilities.isCreativeMode) { Set found = new Finder(player, stack, new Coord4D(pos, player.world), raytrace).calc(); - for (Coord4D coord : found) { - if (coord.equals(orig) || getEnergy(itemstack) < ( - MekanismConfig.current().general.DISASSEMBLER_USAGE.val() * getEfficiency( - itemstack))) { + if (coord.equals(orig) || getEnergy(itemstack) < (MekanismConfig.current().general.DISASSEMBLER_USAGE.val() * getEfficiency(itemstack))) { continue; } - Block block2 = coord.getBlock(player.world); - block2.onBlockHarvested(player.world, coord.getPos(), state, player); player.world.playEvent(WorldEvents.BREAK_BLOCK_EFFECTS, coord.getPos(), Block.getStateId(state)); player.world.setBlockToAir(coord.getPos()); block2.breakBlock(player.world, coord.getPos(), state); block2.dropBlockAsItem(player.world, coord.getPos(), state, 0); - - setEnergy(itemstack, - getEnergy(itemstack) - (MekanismConfig.current().general.DISASSEMBLER_USAGE.val() - * getEfficiency(itemstack))); + setEnergy(itemstack, getEnergy(itemstack) - (MekanismConfig.current().general.DISASSEMBLER_USAGE.val() * getEfficiency(itemstack))); } } } - return false; } @@ -182,35 +155,26 @@ public class ItemAtomicDisassembler extends ItemEnergized { @Override public ActionResult onItemRightClick(World world, EntityPlayer entityplayer, @Nonnull EnumHand hand) { ItemStack itemstack = entityplayer.getHeldItem(hand); - if (entityplayer.isSneaking()) { if (!world.isRemote) { toggleMode(itemstack); - entityplayer.sendMessage(new TextComponentString( - EnumColor.DARK_BLUE + Mekanism.LOG_TAG + " " + EnumColor.GREY + LangUtils - .localize("tooltip.modeToggle") - + " " + EnumColor.INDIGO + getModeName(itemstack) + EnumColor.AQUA + " (" + getEfficiency( - itemstack) + ")")); + entityplayer.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + Mekanism.LOG_TAG + " " + EnumColor.GREY + LangUtils.localize("tooltip.modeToggle") + + " " + EnumColor.INDIGO + getModeName(itemstack) + EnumColor.AQUA + " (" + getEfficiency(itemstack) + ")")); } - return new ActionResult<>(EnumActionResult.SUCCESS, itemstack); } - return new ActionResult<>(EnumActionResult.PASS, itemstack); } @Nonnull @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, - float hitX, float hitY, float hitZ) { + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); Block block = world.getBlockState(pos).getBlock(); - if (!player.isSneaking() && (block == Blocks.DIRT || block == Blocks.GRASS || block == Blocks.GRASS_PATH)) { if (useHoe(stack, player, world, pos, side) == EnumActionResult.FAIL) { return EnumActionResult.FAIL; } - switch (getEfficiency(stack)) { case 20: for (int x1 = -1; x1 <= +1; x1++) { @@ -218,7 +182,6 @@ public class ItemAtomicDisassembler extends ItemEnergized { useHoe(stack, player, world, pos.add(x1, 0, z1), side); } } - break; case 128: for (int x1 = -2; x1 <= +2; x1++) { @@ -226,56 +189,46 @@ public class ItemAtomicDisassembler extends ItemEnergized { useHoe(stack, player, world, pos.add(x1, 0, z1), side); } } - break; } - return EnumActionResult.SUCCESS; } - return EnumActionResult.PASS; } @SuppressWarnings("incomplete-switch") - private EnumActionResult useHoe(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, - EnumFacing facing) { + private EnumActionResult useHoe(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing facing) { if (!playerIn.canPlayerEdit(pos.offset(facing), facing, stack)) { return EnumActionResult.FAIL; - } else { - int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(stack, playerIn, worldIn, pos); - if (hook != 0) { - return hook > 0 ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; - } - - IBlockState iblockstate = worldIn.getBlockState(pos); - Block block = iblockstate.getBlock(); - - if (facing != EnumFacing.DOWN && worldIn.isAirBlock(pos.up())) { - if (block == Blocks.GRASS || block == Blocks.GRASS_PATH) { - setBlock(stack, playerIn, worldIn, pos, Blocks.FARMLAND.getDefaultState()); - return EnumActionResult.SUCCESS; - } - - if (block == Blocks.DIRT) { - switch (iblockstate.getValue(BlockDirt.VARIANT)) { - case DIRT: - setBlock(stack, playerIn, worldIn, pos, Blocks.FARMLAND.getDefaultState()); - return EnumActionResult.SUCCESS; - case COARSE_DIRT: - setBlock(stack, playerIn, worldIn, pos, Blocks.DIRT.getDefaultState() - .withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT)); - return EnumActionResult.SUCCESS; - } - } - } - - return EnumActionResult.PASS; } + int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(stack, playerIn, worldIn, pos); + if (hook != 0) { + return hook > 0 ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; + } + IBlockState iblockstate = worldIn.getBlockState(pos); + Block block = iblockstate.getBlock(); + if (facing != EnumFacing.DOWN && worldIn.isAirBlock(pos.up())) { + if (block == Blocks.GRASS || block == Blocks.GRASS_PATH) { + setBlock(stack, playerIn, worldIn, pos, Blocks.FARMLAND.getDefaultState()); + return EnumActionResult.SUCCESS; + } + if (block == Blocks.DIRT) { + switch (iblockstate.getValue(BlockDirt.VARIANT)) { + case DIRT: + setBlock(stack, playerIn, worldIn, pos, Blocks.FARMLAND.getDefaultState()); + return EnumActionResult.SUCCESS; + case COARSE_DIRT: + setBlock(stack, playerIn, worldIn, pos, Blocks.DIRT.getDefaultState() + .withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT)); + return EnumActionResult.SUCCESS; + } + } + } + return EnumActionResult.PASS; } protected void setBlock(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos, IBlockState state) { worldIn.playSound(player, pos, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F); - if (!worldIn.isRemote) { worldIn.setBlockState(pos, state, 11); stack.damageItem(1, player); @@ -295,7 +248,6 @@ public class ItemAtomicDisassembler extends ItemEnergized { case 4: return 0; } - return 0; } @@ -305,7 +257,6 @@ public class ItemAtomicDisassembler extends ItemEnergized { public String getModeName(ItemStack itemStack) { int mode = getMode(itemStack); - switch (mode) { case 0: return LangUtils.localize("tooltip.disassembler.normal"); @@ -318,7 +269,6 @@ public class ItemAtomicDisassembler extends ItemEnergized { case 4: return LangUtils.localize("tooltip.disassembler.off"); } - return null; } @@ -336,12 +286,10 @@ public class ItemAtomicDisassembler extends ItemEnergized { @Deprecated public Multimap getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot) { Multimap multimap = super.getItemAttributeModifiers(equipmentSlot); - if (equipmentSlot == EntityEquipmentSlot.MAINHAND) { multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.4000000953674316D, 0)); } - return multimap; } @@ -375,18 +323,13 @@ public class ItemAtomicDisassembler extends ItemEnergized { if (found.contains(pointer) || found.size() > 128) { return; } - found.add(pointer); - for (EnumFacing side : EnumFacing.VALUES) { Coord4D coord = pointer.offset(side); - - ItemStack blockStack = coord.getBlock(world) - .getPickBlock(coord.getBlockState(world), rayTraceResult, world, coord.getPos(), player); - - if (coord.exists(world) && checkID(coord.getBlock(world)) && (stack.isItemEqual(blockStack) || ( - coord.getBlock(world) == startBlock && OreDictCache.getOreDictName(stack).contains("logWood") - && coord.getBlockMeta(world) % 4 == stack.getItemDamage() % 4))) { + ItemStack blockStack = coord.getBlock(world).getPickBlock(coord.getBlockState(world), rayTraceResult, world, coord.getPos(), player); + if (coord.exists(world) && checkID(coord.getBlock(world)) && + (stack.isItemEqual(blockStack) || (coord.getBlock(world) == startBlock && OreDictCache.getOreDictName(stack).contains("logWood") + && coord.getBlockMeta(world) % 4 == stack.getItemDamage() % 4))) { loop(coord); } } @@ -394,14 +337,12 @@ public class ItemAtomicDisassembler extends ItemEnergized { public Set calc() { loop(location); - return found; } public boolean checkID(Block b) { Block origBlock = location.getBlock(world); - return (ignoreBlocks.get(origBlock) == null && b == origBlock) || (ignoreBlocks.get(origBlock) != null - && ignoreBlocks.get(origBlock).contains(b)); + return (ignoreBlocks.get(origBlock) == null && b == origBlock) || (ignoreBlocks.get(origBlock) != null && ignoreBlocks.get(origBlock).contains(b)); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemBalloon.java b/src/main/java/mekanism/common/item/ItemBalloon.java index 686e8c5e8..be0e455ee 100644 --- a/src/main/java/mekanism/common/item/ItemBalloon.java +++ b/src/main/java/mekanism/common/item/ItemBalloon.java @@ -48,7 +48,6 @@ public class ItemBalloon extends ItemMekanism implements IMetaItem { @SideOnly(Side.CLIENT) public int getColorFromItemStack(ItemStack stack, int renderPass) { EnumColor dye = getColor(stack); - return (int) (dye.getColor(0) * 255) << 16 | (int) (dye.getColor(1) * 255) << 8 | (int) (dye.getColor(2) * 255); } @@ -63,7 +62,6 @@ public class ItemBalloon extends ItemMekanism implements IMetaItem { } for (int i = 0; i < EnumColor.DYES.length; i++) { EnumColor color = EnumColor.DYES[i]; - if (color != null) { ItemStack stack = new ItemStack(this); stack.setItemDamage(i); @@ -76,18 +74,13 @@ public class ItemBalloon extends ItemMekanism implements IMetaItem { @Override public ActionResult onItemRightClick(World world, EntityPlayer entityplayer, @Nonnull EnumHand hand) { ItemStack itemstack = entityplayer.getHeldItem(hand); - if (!world.isRemote) { - Pos3D pos = new Pos3D(hand == EnumHand.MAIN_HAND ? -0.4 : 0.4, 0, 0.3) - .rotateYaw(entityplayer.renderYawOffset).translate(new Pos3D(entityplayer)); - + Pos3D pos = new Pos3D(hand == EnumHand.MAIN_HAND ? -0.4 : 0.4, 0, 0.3).rotateYaw(entityplayer.renderYawOffset).translate(new Pos3D(entityplayer)); world.spawnEntity(new EntityBalloon(world, pos.x - 0.5, pos.y - 0.25, pos.z - 0.5, getColor(itemstack))); } - if (!entityplayer.capabilities.isCreativeMode) { itemstack.shrink(1); } - return new ActionResult<>(EnumActionResult.SUCCESS, itemstack); } @@ -96,82 +89,62 @@ public class ItemBalloon extends ItemMekanism implements IMetaItem { public String getItemStackDisplayName(@Nonnull ItemStack stack) { EnumColor color = getColor(stack); String dyeName = color.getDyedName(); - if (I18n.canTranslate(getTranslationKey(stack) + "." + color.dyeName)) { return LangUtils.localize(getTranslationKey(stack) + "." + color.dyeName); } - if (getColor(stack) == EnumColor.BLACK) { dyeName = EnumColor.DARK_GREY + color.getDyeName(); } - return dyeName + " " + LangUtils.localize("tooltip.balloon"); } @Nonnull @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, - float hitX, float hitY, float hitZ) { + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); - if (player.isSneaking()) { AxisAlignedBB bound = new AxisAlignedBB(pos, pos.add(1, 3, 1)); - List balloonsNear = player.world.getEntitiesWithinAABB(EntityBalloon.class, bound); - if (balloonsNear.size() > 0) { return EnumActionResult.FAIL; } - if (world.getBlockState(pos).getBlock().isReplaceable(world, pos)) { pos = pos.down(); } - if (!world.isSideSolid(pos, EnumFacing.UP)) { return EnumActionResult.FAIL; } - if (canReplace(world, pos.up()) && canReplace(world, pos.up(2))) { world.setBlockToAir(pos.up()); world.setBlockToAir(pos.up(2)); - if (!world.isRemote) { world.spawnEntity(new EntityBalloon(world, new Coord4D(pos, world), getColor(stack))); stack.shrink(1); } - return EnumActionResult.SUCCESS; } - return EnumActionResult.FAIL; } - return EnumActionResult.PASS; } @Override - public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity, - EnumHand hand) { + public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity, EnumHand hand) { if (player.isSneaking()) { if (!player.world.isRemote) { - AxisAlignedBB bound = new AxisAlignedBB(entity.posX - 0.2, entity.posY - 0.5, entity.posZ - 0.2, - entity.posX + 0.2, entity.posY + entity.height + 4, entity.posZ + 0.2); - + AxisAlignedBB bound = new AxisAlignedBB(entity.posX - 0.2, entity.posY - 0.5, entity.posZ - 0.2, entity.posX + 0.2, + entity.posY + entity.height + 4, entity.posZ + 0.2); List balloonsNear = player.world.getEntitiesWithinAABB(EntityBalloon.class, bound); - for (EntityBalloon balloon : balloonsNear) { if (balloon.latchedEntity == entity) { return true; } } - player.world.spawnEntity(new EntityBalloon(entity, getColor(stack))); stack.shrink(1); } - return true; } - return false; } @@ -184,36 +157,29 @@ public class ItemBalloon extends ItemMekanism implements IMetaItem { @Nonnull @Override public ItemStack dispenseStack(IBlockSource source, ItemStack stack) { - Coord4D coord = new Coord4D(source.getX(), source.getY(), source.getZ(), - source.getWorld().provider.getDimension()); + Coord4D coord = new Coord4D(source.getX(), source.getY(), source.getZ(), source.getWorld().provider.getDimension()); EnumFacing side = source.getBlockState().getValue(BlockDispenser.FACING); - List entities = source.getWorld() - .getEntitiesWithinAABB(EntityLivingBase.class, coord.offset(side).getBoundingBox()); + List entities = source.getWorld().getEntitiesWithinAABB(EntityLivingBase.class, coord.offset(side).getBoundingBox()); boolean latched = false; for (EntityLivingBase entity : entities) { - AxisAlignedBB bound = new AxisAlignedBB(entity.posX - 0.2, entity.posY - 0.5, entity.posZ - 0.2, - entity.posX + 0.2, entity.posY + entity.height + 4, entity.posZ + 0.2); - + AxisAlignedBB bound = new AxisAlignedBB(entity.posX - 0.2, entity.posY - 0.5, entity.posZ - 0.2, entity.posX + 0.2, + entity.posY + entity.height + 4, entity.posZ + 0.2); List balloonsNear = source.getWorld().getEntitiesWithinAABB(EntityBalloon.class, bound); boolean hasBalloon = false; - for (EntityBalloon balloon : balloonsNear) { if (balloon.latchedEntity == entity) { hasBalloon = true; } } - if (!hasBalloon) { source.getWorld().spawnEntity(new EntityBalloon(entity, getColor(stack))); latched = true; } } - if (!latched) { Pos3D pos = new Pos3D(coord).translate(0, -0.5, 0); - switch (side) { case DOWN: pos = pos.translate(0, -2.5, 0); @@ -236,16 +202,12 @@ public class ItemBalloon extends ItemMekanism implements IMetaItem { default: break; } - if (!source.getWorld().isRemote) { - source.getWorld() - .spawnEntity(new EntityBalloon(source.getWorld(), pos.x, pos.y, pos.z, getColor(stack))); + source.getWorld().spawnEntity(new EntityBalloon(source.getWorld(), pos.x, pos.y, pos.z, getColor(stack))); } } - stack.shrink(1); - return stack; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemBlockBasic.java b/src/main/java/mekanism/common/item/ItemBlockBasic.java index 1502a68af..708e78a24 100644 --- a/src/main/java/mekanism/common/item/ItemBlockBasic.java +++ b/src/main/java/mekanism/common/item/ItemBlockBasic.java @@ -12,14 +12,14 @@ import mekanism.client.MekKeyHandler; import mekanism.client.MekanismKeyHandler; import mekanism.common.Mekanism; import mekanism.common.MekanismBlocks; -import mekanism.common.tier.BaseTier; -import mekanism.common.tier.BinTier; -import mekanism.common.tier.InductionCellTier; -import mekanism.common.tier.InductionProviderTier; import mekanism.common.base.ITierItem; import mekanism.common.block.states.BlockStateBasic.BasicBlockType; import mekanism.common.inventory.InventoryBin; import mekanism.common.network.PacketTileEntity.TileEntityMessage; +import mekanism.common.tier.BaseTier; +import mekanism.common.tier.BinTier; +import mekanism.common.tier.InductionCellTier; +import mekanism.common.tier.InductionProviderTier; import mekanism.common.tile.TileEntityBin; import mekanism.common.tile.TileEntityInductionCell; import mekanism.common.tile.TileEntityInductionProvider; @@ -43,12 +43,10 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; /** - * Item class for handling multiple metal block IDs. 0:0: Osmium Block 0:1: Bronze Block 0:2: Refined Obsidian 0:3: - * Charcoal Block 0:4: Refined Glowstone 0:5: Steel Block 0:6: Bin 0:7: Teleporter Frame 0:8: Steel Casing 0:9: Dynamic - * Tank 0:10: Structural Glass 0:11: Dynamic Valve 0:12: Copper Block 0:13: Tin Block 0:14: Thermal Evaporation - * Controller 0:15: Thermal Evaporation Valve 1:0: Thermal Evaporation Block 1:1: Induction Casing 1:2: Induction Port - * 1:3: Induction Cell 1:4: Induction Provider 1:5: Superheating Element 1:6: Pressure Disperser 1:7: Boiler Casing 1:8: - * Boiler Valve 1:9: Security Desk + * Item class for handling multiple metal block IDs. 0:0: Osmium Block 0:1: Bronze Block 0:2: Refined Obsidian 0:3: Charcoal Block 0:4: Refined Glowstone 0:5: Steel Block + * 0:6: Bin 0:7: Teleporter Frame 0:8: Steel Casing 0:9: Dynamic Tank 0:10: Structural Glass 0:11: Dynamic Valve 0:12: Copper Block 0:13: Tin Block 0:14: Thermal + * Evaporation Controller 0:15: Thermal Evaporation Valve 1:0: Thermal Evaporation Block 1:1: Induction Casing 1:2: Induction Port 1:3: Induction Cell 1:4: Induction + * Provider 1:5: Superheating Element 1:6: Pressure Disperser 1:7: Boiler Casing 1:8: Boiler Valve 1:9: Security Desk * * @author AidanBrady */ @@ -67,21 +65,18 @@ public class ItemBlockBasic extends ItemBlock implements IEnergizedItem, ITierIt if (BasicBlockType.get(stack) == BasicBlockType.BIN) { return 1; // Temporary no stacking due to # } - return super.getItemStackLimit(stack); } public ItemStack getUnchargedCell(InductionCellTier tier) { ItemStack stack = new ItemStack(MekanismBlocks.BasicBlock2, 1, 3); setBaseTier(stack, tier.getBaseTier()); - return stack; } public ItemStack getUnchargedProvider(InductionProviderTier tier) { ItemStack stack = new ItemStack(MekanismBlocks.BasicBlock2, 1, 4); setBaseTier(stack, tier.getBaseTier()); - return stack; } @@ -90,7 +85,6 @@ public class ItemBlockBasic extends ItemBlock implements IEnergizedItem, ITierIt if (itemstack.getTagCompound() == null) { return BaseTier.BASIC; } - return BaseTier.values()[itemstack.getTagCompound().getInteger("tier")]; } @@ -99,7 +93,6 @@ public class ItemBlockBasic extends ItemBlock implements IEnergizedItem, ITierIt if (itemstack.getTagCompound() == null) { itemstack.setTagCompound(new NBTTagCompound()); } - itemstack.getTagCompound().setInteger("tier", tier.ordinal()); } @@ -110,50 +103,35 @@ public class ItemBlockBasic extends ItemBlock implements IEnergizedItem, ITierIt @Override @SideOnly(Side.CLIENT) - public void addInformation(@Nonnull ItemStack itemstack, World world, @Nonnull List list, - @Nonnull ITooltipFlag flag) { + public void addInformation(@Nonnull ItemStack itemstack, World world, @Nonnull List list, @Nonnull ITooltipFlag flag) { BasicBlockType type = BasicBlockType.get(itemstack); - if (type != null && type.hasDescription) { if (!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) { if (type == BasicBlockType.BIN) { InventoryBin inv = new InventoryBin(itemstack); - if (inv.getItemCount() > 0) { list.add(EnumColor.BRIGHT_GREEN + inv.getItemType().getDisplayName()); - String amountStr = inv.getItemCount() == Integer.MAX_VALUE ? LangUtils.localize("gui.infinite") - : "" + inv.getItemCount(); - list.add(EnumColor.PURPLE + LangUtils.localize("tooltip.itemAmount") + ": " + EnumColor.GREY - + amountStr); + String amountStr = inv.getItemCount() == Integer.MAX_VALUE ? LangUtils.localize("gui.infinite") : "" + inv.getItemCount(); + list.add(EnumColor.PURPLE + LangUtils.localize("tooltip.itemAmount") + ": " + EnumColor.GREY + amountStr); } else { list.add(EnumColor.DARK_RED + LangUtils.localize("gui.empty")); } - int cap = BinTier.values()[getBaseTier(itemstack).ordinal()].getStorage(); - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + ( - cap == Integer.MAX_VALUE ? LangUtils.localize("gui.infinite") : cap) + " " + LangUtils - .localize("transmission.Items")); + list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + + (cap == Integer.MAX_VALUE ? LangUtils.localize("gui.infinite") : cap) + " " + LangUtils.localize("transmission.Items")); } else if (type == BasicBlockType.INDUCTION_CELL) { InductionCellTier tier = InductionCellTier.values()[getBaseTier(itemstack).ordinal()]; - - list.add( - tier.getBaseTier().getColor() + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY - + MekanismUtils.getEnergyDisplay(tier.getMaxEnergy())); + list.add(tier.getBaseTier().getColor() + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(tier.getMaxEnergy())); } else if (type == BasicBlockType.INDUCTION_PROVIDER) { InductionProviderTier tier = InductionProviderTier.values()[getBaseTier(itemstack).ordinal()]; - - list.add(tier.getBaseTier().getColor() + LangUtils.localize("tooltip.outputRate") + ": " - + EnumColor.GREY + MekanismUtils.getEnergyDisplay(tier.getOutput())); + list.add(tier.getBaseTier().getColor() + LangUtils.localize("tooltip.outputRate") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(tier.getOutput())); } if (getMaxEnergy(itemstack) > 0) { - list.add(EnumColor.BRIGHT_GREEN + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY - + MekanismUtils.getEnergyDisplay(getEnergy(itemstack))); + list.add(EnumColor.BRIGHT_GREEN + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack))); } - - list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.INDIGO + GameSettings - .getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils - .localize("tooltip.forDetails") + "."); + list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.INDIGO + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + "."); } else { list.addAll(MekanismUtils.splitTooltip(type.getDescription(), itemstack)); } @@ -172,29 +150,23 @@ public class ItemBlockBasic extends ItemBlock implements IEnergizedItem, ITierIt if (!ItemDataUtils.hasData(stack, "newCount")) { return ItemStack.EMPTY; } - int newCount = ItemDataUtils.getInt(stack, "newCount"); ItemDataUtils.removeData(stack, "newCount"); - ItemStack ret = stack.copy(); ItemDataUtils.setInt(ret, "itemCount", newCount); - return ret; } - return ItemStack.EMPTY; } @Override - public boolean placeBlockAt(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, World world, - @Nonnull BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, @Nonnull IBlockState state) { + public boolean placeBlockAt(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, World world, @Nonnull BlockPos pos, EnumFacing side, float hitX, float hitY, + float hitZ, @Nonnull IBlockState state) { boolean place = true; BasicBlockType type = BasicBlockType.get(stack); - if (type == BasicBlockType.SECURITY_DESK) { - if (world.isOutsideBuildHeight(pos.up()) || !world.getBlockState(pos.up()).getBlock() - .isReplaceable(world, pos.up())) { + if (world.isOutsideBuildHeight(pos.up()) || !world.getBlockState(pos.up()).getBlock().isReplaceable(world, pos.up())) { place = false; } } @@ -203,39 +175,31 @@ public class ItemBlockBasic extends ItemBlock implements IEnergizedItem, ITierIt if (type == BasicBlockType.BIN && stack.getTagCompound() != null) { TileEntityBin tileEntity = (TileEntityBin) world.getTileEntity(pos); InventoryBin inv = new InventoryBin(stack); - tileEntity.tier = BinTier.values()[getBaseTier(stack).ordinal()]; - if (!inv.getItemType().isEmpty()) { tileEntity.setItemType(inv.getItemType()); } - tileEntity.setItemCount(inv.getItemCount()); } else if (type == BasicBlockType.INDUCTION_CELL) { TileEntityInductionCell tileEntity = (TileEntityInductionCell) world.getTileEntity(pos); tileEntity.tier = InductionCellTier.values()[getBaseTier(stack).ordinal()]; - if (!world.isRemote) { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), - tileEntity.getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(tileEntity))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new TileNetworkList())), + new Range4D(Coord4D.get(tileEntity))); } } else if (type == BasicBlockType.INDUCTION_PROVIDER) { TileEntityInductionProvider tileEntity = (TileEntityInductionProvider) world.getTileEntity(pos); tileEntity.tier = InductionProviderTier.values()[getBaseTier(stack).ordinal()]; - if (!world.isRemote) { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), - tileEntity.getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(tileEntity))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new TileNetworkList())), + new Range4D(Coord4D.get(tileEntity))); } } - TileEntity tileEntity = world.getTileEntity(pos); - if (tileEntity instanceof IStrictEnergyStorage && !(tileEntity instanceof TileEntityMultiblock)) { ((IStrictEnergyStorage) tileEntity).setEnergy(getEnergy(stack)); } } - return place; } @@ -243,18 +207,13 @@ public class ItemBlockBasic extends ItemBlock implements IEnergizedItem, ITierIt @Override public String getTranslationKey(ItemStack itemstack) { BasicBlockType type = BasicBlockType.get(itemstack); - if (type != null) { String name = getTranslationKey() + "." + type.name; - - if (type == BasicBlockType.BIN || type == BasicBlockType.INDUCTION_CELL - || type == BasicBlockType.INDUCTION_PROVIDER) { + if (type == BasicBlockType.BIN || type == BasicBlockType.INDUCTION_CELL || type == BasicBlockType.INDUCTION_PROVIDER) { name += getBaseTier(itemstack).getSimpleName(); } - return name; } - return "Invalid Basic Block"; } @@ -263,7 +222,6 @@ public class ItemBlockBasic extends ItemBlock implements IEnergizedItem, ITierIt if (BasicBlockType.get(itemStack) == BasicBlockType.INDUCTION_CELL) { return ItemDataUtils.getDouble(itemStack, "energyStored"); } - return 0; } @@ -279,7 +237,6 @@ public class ItemBlockBasic extends ItemBlock implements IEnergizedItem, ITierIt if (BasicBlockType.get(itemStack) == BasicBlockType.INDUCTION_CELL) { return InductionCellTier.values()[getBaseTier(itemStack).ordinal()].getMaxEnergy(); } - return 0; } @@ -303,8 +260,7 @@ public class ItemBlockBasic extends ItemBlock implements IEnergizedItem, ITierIt // If this is a block of charcoal, set burn time to 16000 ticks (per Minecraft standard) if (this.metaBlock == MekanismBlocks.BasicBlock && itemStack.getMetadata() == 3) { return 16000; // ticks - } else { - return super.getItemBurnTime(itemStack); } + return super.getItemBurnTime(itemStack); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemBlockCardboardBox.java b/src/main/java/mekanism/common/item/ItemBlockCardboardBox.java index f13aa701a..7a90db9e1 100644 --- a/src/main/java/mekanism/common/item/ItemBlockCardboardBox.java +++ b/src/main/java/mekanism/common/item/ItemBlockCardboardBox.java @@ -39,24 +39,18 @@ public class ItemBlockCardboardBox extends ItemBlock { super(block); setMaxStackSize(16); metaBlock = block; - MinecraftForge.EVENT_BUS.register(this); } @Override @SideOnly(Side.CLIENT) - public void addInformation(@Nonnull ItemStack itemstack, World world, @Nonnull List list, - @Nonnull ITooltipFlag flag) { - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.blockData") + ": " + LangUtils - .transYesNo(getBlockData(itemstack) != null)); + public void addInformation(@Nonnull ItemStack itemstack, World world, @Nonnull List list, @Nonnull ITooltipFlag flag) { + list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.blockData") + ": " + LangUtils.transYesNo(getBlockData(itemstack) != null)); BlockData data = getBlockData(itemstack); - if (data != null) { try { - list.add(LangUtils.localize("tooltip.block") + ": " + new ItemStack(data.block, 1, data.meta) - .getDisplayName()); + list.add(LangUtils.localize("tooltip.block") + ": " + new ItemStack(data.block, 1, data.meta).getDisplayName()); list.add(LangUtils.localize("tooltip.meta") + ": " + data.meta); - if (data.tileTag != null) { list.add(LangUtils.localize("tooltip.tile") + ": " + data.tileTag.getString("id")); } @@ -72,31 +66,23 @@ public class ItemBlockCardboardBox extends ItemBlock { @Nonnull @Override - public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, - float hitY, float hitZ, EnumHand hand) { + public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); - if (!player.isSneaking() && !world.isAirBlock(pos) && stack.getItemDamage() == 0) { IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); int meta = block.getMetaFromState(state); - - if (!world.isRemote && MekanismAPI.isBlockCompatible(block, meta) - && state.getBlockHardness(world, pos) != -1) { + if (!world.isRemote && MekanismAPI.isBlockCompatible(block, meta) && state.getBlockHardness(world, pos) != -1) { BlockData data = new BlockData(); data.block = block; data.meta = meta; - isMonitoring = true; - if (world.getTileEntity(pos) != null) { TileEntity tile = world.getTileEntity(pos); NBTTagCompound tag = new NBTTagCompound(); - tile.writeToNBT(tag); data.tileTag = tag; } - if (!player.capabilities.isCreativeMode) { stack.shrink(1); } @@ -107,39 +93,30 @@ public class ItemBlockCardboardBox extends ItemBlock { // we need to make sure it has a chance to update. world.setBlockToAir(pos); world.setBlockState(pos, MekanismBlocks.CardboardBox.getStateFromMeta(1)); - isMonitoring = false; - TileEntityCardboardBox tileEntity = (TileEntityCardboardBox) world.getTileEntity(pos); - if (tileEntity != null) { tileEntity.storedData = data; } - return EnumActionResult.SUCCESS; } } - return EnumActionResult.PASS; } @Override - public boolean placeBlockAt(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, World world, - @Nonnull BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, @Nonnull IBlockState state) { + public boolean placeBlockAt(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, World world, @Nonnull BlockPos pos, EnumFacing side, float hitX, float hitY, + float hitZ, @Nonnull IBlockState state) { if (world.isRemote) { return true; } - boolean place = super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, state); - if (place) { TileEntityCardboardBox tileEntity = (TileEntityCardboardBox) world.getTileEntity(pos); - if (tileEntity != null) { tileEntity.storedData = getBlockData(stack); } } - return place; } @@ -151,7 +128,6 @@ public class ItemBlockCardboardBox extends ItemBlock { if (!ItemDataUtils.hasData(itemstack, "blockData")) { return null; } - return BlockData.read(ItemDataUtils.getCompound(itemstack, "blockData")); } @@ -170,4 +146,4 @@ public class ItemBlockCardboardBox extends ItemBlock { } return super.getItemStackLimit(stack); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemBlockEnergyCube.java b/src/main/java/mekanism/common/item/ItemBlockEnergyCube.java index d2fd96f59..e7d715be9 100644 --- a/src/main/java/mekanism/common/item/ItemBlockEnergyCube.java +++ b/src/main/java/mekanism/common/item/ItemBlockEnergyCube.java @@ -16,8 +16,6 @@ import mekanism.client.MekKeyHandler; import mekanism.client.MekanismClient; import mekanism.client.MekanismKeyHandler; import mekanism.common.Mekanism; -import mekanism.common.tier.BaseTier; -import mekanism.common.tier.EnergyCubeTier; import mekanism.common.base.ISideConfiguration; import mekanism.common.base.ISustainedInventory; import mekanism.common.base.ITierItem; @@ -31,6 +29,8 @@ import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.security.ISecurityItem; import mekanism.common.security.ISecurityTile; import mekanism.common.security.ISecurityTile.SecurityMode; +import mekanism.common.tier.BaseTier; +import mekanism.common.tier.EnergyCubeTier; import mekanism.common.tile.TileEntityEnergyCube; import mekanism.common.util.ItemDataUtils; import mekanism.common.util.LangUtils; @@ -61,8 +61,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; @Interface(iface = "cofh.redstoneflux.api.IEnergyContainerItem", modid = MekanismHooks.REDSTONEFLUX_MOD_ID), @Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = MekanismHooks.IC2_MOD_ID) }) -public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, ISpecialElectricItem, ISustainedInventory, - IEnergyContainerItem, ISecurityItem, ITierItem { +public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, ISpecialElectricItem, ISustainedInventory, IEnergyContainerItem, ISecurityItem, ITierItem { public Block metaBlock; @@ -77,38 +76,30 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS @Override @SideOnly(Side.CLIENT) - public void addInformation(@Nonnull ItemStack itemstack, World world, @Nonnull List list, - @Nonnull ITooltipFlag flag) { - list.add(EnumColor.BRIGHT_GREEN + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY - + MekanismUtils.getEnergyDisplay(getEnergy(itemstack))); - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + MekanismUtils - .getEnergyDisplay(EnergyCubeTier.values()[getBaseTier(itemstack).ordinal()].getMaxEnergy())); + public void addInformation(@Nonnull ItemStack itemstack, World world, @Nonnull List list, @Nonnull ITooltipFlag flag) { + list.add(EnumColor.BRIGHT_GREEN + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack))); + list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + + MekanismUtils.getEnergyDisplay(EnergyCubeTier.values()[getBaseTier(itemstack).ordinal()].getMaxEnergy())); if (!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) { - list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + GameSettings - .getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils - .localize("tooltip.forDetails") + "."); + list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + "."); } else { if (hasSecurity(itemstack)) { - list.add(SecurityUtils.getOwnerDisplay(Minecraft.getMinecraft().player, - MekanismClient.clientUUIDMap.get(getOwnerUUID(itemstack)))); - list.add(EnumColor.GREY + LangUtils.localize("gui.security") + ": " + SecurityUtils - .getSecurityDisplay(itemstack, Side.CLIENT)); - + list.add(SecurityUtils.getOwnerDisplay(Minecraft.getMinecraft().player, MekanismClient.clientUUIDMap.get(getOwnerUUID(itemstack)))); + list.add(EnumColor.GREY + LangUtils.localize("gui.security") + ": " + SecurityUtils.getSecurityDisplay(itemstack, Side.CLIENT)); if (SecurityUtils.isOverridden(itemstack, Side.CLIENT)) { list.add(EnumColor.RED + "(" + LangUtils.localize("gui.overridden") + ")"); } } - - list.add(EnumColor.AQUA + LangUtils.localize("tooltip.inventory") + ": " + EnumColor.GREY + LangUtils - .transYesNo(getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0)); + list.add(EnumColor.AQUA + LangUtils.localize("tooltip.inventory") + ": " + EnumColor.GREY + + LangUtils.transYesNo(getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0)); } } public ItemStack getUnchargedItem(EnergyCubeTier tier) { ItemStack stack = new ItemStack(this); setBaseTier(stack, tier.getBaseTier()); - return stack; } @@ -119,45 +110,36 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS } @Override - public boolean placeBlockAt(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, World world, - @Nonnull BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, @Nonnull IBlockState state) { + public boolean placeBlockAt(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, World world, @Nonnull BlockPos pos, EnumFacing side, float hitX, float hitY, + float hitZ, @Nonnull IBlockState state) { boolean place = super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, state); if (place) { TileEntityEnergyCube tileEntity = (TileEntityEnergyCube) world.getTileEntity(pos); tileEntity.tier = EnergyCubeTier.values()[getBaseTier(stack).ordinal()]; tileEntity.electricityStored = getEnergy(stack); - if (tileEntity.tier == EnergyCubeTier.CREATIVE) { tileEntity.configComponent.fillConfig(TransmissionType.ENERGY, tileEntity.getEnergy() > 0 ? 2 : 1); } - ISecurityTile security = tileEntity; security.getSecurity().setOwnerUUID(getOwnerUUID(stack)); - if (hasSecurity(stack)) { security.getSecurity().setMode(getSecurity(stack)); } - if (getOwnerUUID(stack) == null) { security.getSecurity().setOwnerUUID(player.getUniqueID()); } - ISideConfiguration config = tileEntity; - if (ItemDataUtils.hasData(stack, "sideDataStored")) { config.getConfig().read(ItemDataUtils.getDataMap(stack)); config.getEjector().read(ItemDataUtils.getDataMap(stack)); } - ((ISustainedInventory) tileEntity).setInventory(getInventory(stack)); - if (!world.isRemote) { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), - tileEntity.getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(tileEntity))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new TileNetworkList())), + new Range4D(Coord4D.get(tileEntity))); } } - return place; } @@ -166,7 +148,6 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS if (!itemstack.hasTagCompound()) { return BaseTier.BASIC; } - return BaseTier.values()[itemstack.getTagCompound().getInteger("tier")]; } @@ -175,7 +156,6 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS if (!itemstack.hasTagCompound()) { itemstack.setTagCompound(new NBTTagCompound()); } - itemstack.getTagCompound().setInteger("tier", tier.ordinal()); } @@ -191,7 +171,6 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS if (data[0] instanceof ItemStack) { return ItemDataUtils.getList((ItemStack) data[0], "Items"); } - return null; } @@ -200,7 +179,6 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS if (!itemStack.hasTagCompound()) { return 0; } - return ItemDataUtils.getDouble(itemStack, "energyStored"); } @@ -209,7 +187,6 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS if (getBaseTier(itemStack) == BaseTier.CREATIVE && amount != Double.MAX_VALUE) { return; } - ItemDataUtils.setDouble(itemStack, "energyStored", Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0)); } @@ -239,14 +216,11 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS if (canReceive(theItem)) { double energyNeeded = getMaxEnergy(theItem) - getEnergy(theItem); double toReceive = Math.min(energy * MekanismConfig.current().general.FROM_RF.val(), energyNeeded); - if (!simulate) { setEnergy(theItem, getEnergy(theItem) + toReceive); } - return MekanismUtils.clampToInt(toReceive * MekanismConfig.current().general.TO_RF.val()); } - return 0; } @@ -255,15 +229,12 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS public int extractEnergy(ItemStack theItem, int energy, boolean simulate) { if (canSend(theItem)) { double energyRemaining = getEnergy(theItem); - double toSend = Math.min((energy * MekanismConfig.current().general.FROM_RF.val()), energyRemaining); - + double toSend = Math.min(energy * MekanismConfig.current().general.FROM_RF.val(), energyRemaining); if (!simulate) { setEnergy(theItem, getEnergy(theItem) - toSend); } - return MekanismUtils.clampToInt(toSend * MekanismConfig.current().general.TO_RF.val()); } - return 0; } @@ -305,7 +276,6 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS if (ItemDataUtils.hasData(stack, "ownerUUID")) { return UUID.fromString(ItemDataUtils.getString(stack, "ownerUUID")); } - return null; } @@ -313,10 +283,9 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS public void setOwnerUUID(ItemStack stack, UUID owner) { if (owner == null) { ItemDataUtils.removeData(stack, "ownerUUID"); - return; + } else { + ItemDataUtils.setString(stack, "ownerUUID", owner.toString()); } - - ItemDataUtils.setString(stack, "ownerUUID", owner.toString()); } @Override @@ -324,7 +293,6 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS if (!MekanismConfig.current().general.allowProtection.val()) { return SecurityMode.PUBLIC; } - return SecurityMode.values()[ItemDataUtils.getInt(stack, "security")]; } @@ -347,4 +315,4 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { return new ItemCapabilityWrapper(stack, new TeslaItemWrapper(), new ForgeEnergyItemWrapper()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemBlockGasTank.java b/src/main/java/mekanism/common/item/ItemBlockGasTank.java index 4baf0967d..bf2f5c4f4 100644 --- a/src/main/java/mekanism/common/item/ItemBlockGasTank.java +++ b/src/main/java/mekanism/common/item/ItemBlockGasTank.java @@ -15,8 +15,6 @@ import mekanism.client.MekKeyHandler; import mekanism.client.MekanismClient; import mekanism.client.MekanismKeyHandler; import mekanism.common.Mekanism; -import mekanism.common.tier.BaseTier; -import mekanism.common.tier.GasTankTier; import mekanism.common.base.ISideConfiguration; import mekanism.common.base.ISustainedInventory; import mekanism.common.base.ITierItem; @@ -25,6 +23,8 @@ import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.security.ISecurityItem; import mekanism.common.security.ISecurityTile; import mekanism.common.security.ISecurityTile.SecurityMode; +import mekanism.common.tier.BaseTier; +import mekanism.common.tier.GasTankTier; import mekanism.common.tile.TileEntityGasTank; import mekanism.common.util.ItemDataUtils; import mekanism.common.util.LangUtils; @@ -80,81 +80,66 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI } @Override - public boolean placeBlockAt(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, World world, - @Nonnull BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, @Nonnull IBlockState state) { + public boolean placeBlockAt(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, World world, @Nonnull BlockPos pos, EnumFacing side, float hitX, float hitY, + float hitZ, @Nonnull IBlockState state) { boolean place = super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, state); - if (place) { TileEntityGasTank tileEntity = (TileEntityGasTank) world.getTileEntity(pos); tileEntity.tier = GasTankTier.values()[getBaseTier(stack).ordinal()]; tileEntity.gasTank.setMaxGas(tileEntity.tier.getStorage()); tileEntity.gasTank.setGas(getGas(stack)); - ISecurityTile security = tileEntity; security.getSecurity().setOwnerUUID(getOwnerUUID(stack)); if (hasSecurity(stack)) { security.getSecurity().setMode(getSecurity(stack)); } - if (getOwnerUUID(stack) == null) { security.getSecurity().setOwnerUUID(player.getUniqueID()); } ISideConfiguration config = tileEntity; - if (ItemDataUtils.hasData(stack, "sideDataStored")) { config.getConfig().read(ItemDataUtils.getDataMap(stack)); config.getEjector().read(ItemDataUtils.getDataMap(stack)); } ((ISustainedInventory) tileEntity).setInventory(getInventory(stack)); - if (!world.isRemote) { Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(tileEntity))); } } - return place; } @Override @SideOnly(Side.CLIENT) - public void addInformation(@Nonnull ItemStack itemstack, World world, @Nonnull List list, - @Nonnull ITooltipFlag flag) { + public void addInformation(@Nonnull ItemStack itemstack, World world, @Nonnull List list, @Nonnull ITooltipFlag flag) { GasStack gasStack = getGas(itemstack); - if (gasStack == null) { list.add(EnumColor.DARK_RED + LangUtils.localize("gui.empty") + "."); } else { - String amount = - "" + (gasStack.amount == Integer.MAX_VALUE ? LangUtils.localize("gui.infinite") : gasStack.amount); + String amount = gasStack.amount == Integer.MAX_VALUE ? LangUtils.localize("gui.infinite") : Integer.toString(gasStack.amount); list.add(EnumColor.ORANGE + gasStack.getGas().getLocalizedName() + ": " + EnumColor.GREY + amount); } - int cap = GasTankTier.values()[getBaseTier(itemstack).ordinal()].getStorage(); - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + ( - cap == Integer.MAX_VALUE ? LangUtils.localize("gui.infinite") : cap)); + list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + (cap == Integer.MAX_VALUE ? LangUtils.localize("gui.infinite") : cap)); if (!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) { - list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + GameSettings - .getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils - .localize("tooltip.forDetails") + "."); + list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + "."); } else { if (hasSecurity(itemstack)) { - list.add(SecurityUtils.getOwnerDisplay(Minecraft.getMinecraft().player, - MekanismClient.clientUUIDMap.get(getOwnerUUID(itemstack)))); - list.add(EnumColor.GREY + LangUtils.localize("gui.security") + ": " + SecurityUtils - .getSecurityDisplay(itemstack, Side.CLIENT)); - + list.add(SecurityUtils.getOwnerDisplay(Minecraft.getMinecraft().player, MekanismClient.clientUUIDMap.get(getOwnerUUID(itemstack)))); + list.add(EnumColor.GREY + LangUtils.localize("gui.security") + ": " + SecurityUtils.getSecurityDisplay(itemstack, Side.CLIENT)); if (SecurityUtils.isOverridden(itemstack, Side.CLIENT)) { list.add(EnumColor.RED + "(" + LangUtils.localize("gui.overridden") + ")"); } } - list.add(EnumColor.AQUA + LangUtils.localize("tooltip.inventory") + ": " + EnumColor.GREY + LangUtils - .transYesNo(getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0)); + list.add(EnumColor.AQUA + LangUtils.localize("tooltip.inventory") + ": " + EnumColor.GREY + + LangUtils.transYesNo(getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0)); } } @@ -170,7 +155,6 @@ 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); - ItemDataUtils.setCompound(itemstack, "stored", gasStack.write(new NBTTagCompound())); } } @@ -179,7 +163,6 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI ItemStack empty = new ItemStack(this); setBaseTier(empty, tier.getBaseTier()); setGas(empty, null); - return empty; } @@ -193,7 +176,6 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI setBaseTier(empty, tier.getBaseTier()); list.add(empty); } - if (MekanismConfig.current().general.prefilledGasTanks.val()) { for (Gas type : GasRegistry.getRegisteredGasses()) { if (type.isVisible()) { @@ -211,7 +193,6 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI if (!itemstack.hasTagCompound()) { return BaseTier.BASIC; } - return BaseTier.values()[itemstack.getTagCompound().getInteger("tier")]; } @@ -220,7 +201,6 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI if (!itemstack.hasTagCompound()) { itemstack.setTagCompound(new NBTTagCompound()); } - itemstack.getTagCompound().setInteger("tier", tier.ordinal()); } @@ -239,15 +219,12 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI if (getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas()) { return 0; } - if (getBaseTier(itemstack) == BaseTier.CREATIVE) { setGas(itemstack, new GasStack(stack.getGas(), Integer.MAX_VALUE)); return stack.amount; } - 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; } @@ -256,15 +233,11 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI if (getGas(itemstack) == null) { return null; } - Gas type = getGas(itemstack).getGas(); - int gasToUse = Math.min(getStored(itemstack), Math.min(getRate(itemstack), amount)); - if (getBaseTier(itemstack) != BaseTier.CREATIVE) { setGas(itemstack, new GasStack(type, getStored(itemstack) - gasToUse)); } - return new GasStack(type, gasToUse); } @@ -294,7 +267,6 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI if (data[0] instanceof ItemStack) { return ItemDataUtils.getList((ItemStack) data[0], "Items"); } - return null; } @@ -318,7 +290,6 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI if (ItemDataUtils.hasData(stack, "ownerUUID")) { return UUID.fromString(ItemDataUtils.getString(stack, "ownerUUID")); } - return null; } @@ -326,10 +297,9 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI public void setOwnerUUID(ItemStack stack, UUID owner) { if (owner == null) { ItemDataUtils.removeData(stack, "ownerUUID"); - return; + } else { + ItemDataUtils.setString(stack, "ownerUUID", owner.toString()); } - - ItemDataUtils.setString(stack, "ownerUUID", owner.toString()); } @Override @@ -337,7 +307,6 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI if (!MekanismConfig.current().general.allowProtection.val()) { return SecurityMode.PUBLIC; } - return SecurityMode.values()[ItemDataUtils.getInt(stack, "security")]; } @@ -355,4 +324,4 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI public boolean hasOwner(ItemStack stack) { return hasSecurity(stack); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemBlockGlowPanel.java b/src/main/java/mekanism/common/item/ItemBlockGlowPanel.java index 561727013..41535703d 100644 --- a/src/main/java/mekanism/common/item/ItemBlockGlowPanel.java +++ b/src/main/java/mekanism/common/item/ItemBlockGlowPanel.java @@ -5,8 +5,8 @@ import mcmultipart.api.multipart.IMultipart; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.Range4D; -import mekanism.common.Mekanism; import mekanism.api.TileNetworkList; +import mekanism.common.Mekanism; import mekanism.common.integration.MekanismHooks; import mekanism.common.integration.multipart.MultipartMekanism; import mekanism.common.network.PacketTileEntity.TileEntityMessage; @@ -41,41 +41,34 @@ public class ItemBlockGlowPanel extends ItemBlockMultipartAble { } @Override - public boolean placeBlockAt(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, World world, - @Nonnull BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, @Nonnull IBlockState state) { + public boolean placeBlockAt(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, World world, @Nonnull BlockPos pos, EnumFacing side, float hitX, float hitY, + float hitZ, @Nonnull IBlockState state) { if (stack.getItemDamage() >= EnumColor.DYES.length) { return false; } boolean place = super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, state); - if (place) { TileEntityGlowPanel tileEntity = (TileEntityGlowPanel) world.getTileEntity(pos); EnumColor col = EnumColor.DYES[stack.getItemDamage()]; - BlockPos pos1 = pos.offset(side.getOpposite()); - if (world.isSideSolid(pos1, side)) { tileEntity.setOrientation(side.getOpposite()); } - tileEntity.setColour(col); - if (!world.isRemote) { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), - tileEntity.getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(tileEntity))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new TileNetworkList())), + new Range4D(Coord4D.get(tileEntity))); } } - return place; } @Override public void getSubItems(@Nonnull CreativeTabs tab, @Nonnull NonNullList listToAddTo) { - if (!isInCreativeTab(tab)) { - return; - } - for (EnumColor color : EnumColor.DYES) { - listToAddTo.add(new ItemStack(this, 1, color.getMetaValue())); + if (isInCreativeTab(tab)) { + for (EnumColor color : EnumColor.DYES) { + listToAddTo.add(new ItemStack(this, 1, color.getMetaValue())); + } } } @@ -88,17 +81,14 @@ public class ItemBlockGlowPanel extends ItemBlockMultipartAble { } EnumColor colour = EnumColor.DYES[itemDamage]; String colourName; - if (I18n.canTranslate(getTranslationKey(stack) + "." + colour.dyeName)) { return LangUtils.localize(getTranslationKey(stack) + "." + colour.dyeName); } - if (colour == EnumColor.BLACK) { colourName = EnumColor.DARK_GREY + colour.getDyeName(); } else { colourName = colour.getDyedName(); } - return colourName + " " + super.getItemStackDisplayName(stack); } @@ -112,4 +102,4 @@ public class ItemBlockGlowPanel extends ItemBlockMultipartAble { protected IMultipart getMultiPart() { return MultipartMekanism.GLOWPANEL_MP; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemBlockMachine.java b/src/main/java/mekanism/common/item/ItemBlockMachine.java index 1999f837a..2b9c2d26c 100644 --- a/src/main/java/mekanism/common/item/ItemBlockMachine.java +++ b/src/main/java/mekanism/common/item/ItemBlockMachine.java @@ -93,15 +93,12 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; /** - * Item class for handling multiple machine block IDs. 0:0: Enrichment Chamber 0:1: Osmium Compressor 0:2: Combiner 0:3: - * Crusher 0:4: Digital Miner 0:5: Basic Factory 0:6: Advanced Factory 0:7: Elite Factory 0:8: Metallurgic Infuser 0:9: - * Purification Chamber 0:10: Energized Smelter 0:11: Teleporter 0:12: Electric Pump 0:13: Personal Chest 0:14: - * Chargepad 0:15: Logistical Sorter 1:0: Rotary Condensentrator 1:1: Chemical Oxidizer 1:2: Chemical Infuser 1:3: - * Chemical Injection Chamber 1:4: Electrolytic Separator 1:5: Precision Sawmill 1:6: Chemical Dissolution Chamber 1:7: - * Chemical Washer 1:8: Chemical Crystallizer 1:9: Seismic Vibrator 1:10: Pressurized Reaction Chamber 1:11: Portable - * Tank 1:12: Fluidic Plenisher 1:13: Laser 1:14: Laser Amplifier 1:15: Laser Tractor Beam 2:0: Entangled Block 2:1: - * Solar Neutron Activator 2:2: Ambient Accumulator 2:3: Oredictionificator 2:4: Resistive Heater 2:5: Formulaic - * Assemblicator 2:6: Fuelwood Heater + * Item class for handling multiple machine block IDs. 0:0: Enrichment Chamber 0:1: Osmium Compressor 0:2: Combiner 0:3: Crusher 0:4: Digital Miner 0:5: Basic Factory + * 0:6: Advanced Factory 0:7: Elite Factory 0:8: Metallurgic Infuser 0:9: Purification Chamber 0:10: Energized Smelter 0:11: Teleporter 0:12: Electric Pump 0:13: Personal + * Chest 0:14: Chargepad 0:15: Logistical Sorter 1:0: Rotary Condensentrator 1:1: Chemical Oxidizer 1:2: Chemical Infuser 1:3: Chemical Injection Chamber 1:4: + * Electrolytic Separator 1:5: Precision Sawmill 1:6: Chemical Dissolution Chamber 1:7: Chemical Washer 1:8: Chemical Crystallizer 1:9: Seismic Vibrator 1:10: Pressurized + * Reaction Chamber 1:11: Portable Tank 1:12: Fluidic Plenisher 1:13: Laser 1:14: Laser Amplifier 1:15: Laser Tractor Beam 2:0: Entangled Block 2:1: Solar Neutron + * Activator 2:2: Ambient Accumulator 2:3: Oredictionificator 2:4: Resistive Heater 2:5: Formulaic Assemblicator 2:6: Fuelwood Heater * * @author AidanBrady */ @@ -109,9 +106,8 @@ import net.minecraftforge.fml.relauncher.SideOnly; @Interface(iface = "cofh.redstoneflux.api.IEnergyContainerItem", modid = MekanismHooks.REDSTONEFLUX_MOD_ID), @Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = MekanismHooks.IC2_MOD_ID) }) -public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpecialElectricItem, IFactory, - ISustainedInventory, ISustainedTank, IEnergyContainerItem, IFluidItemWrapper, ITierItem, ISecurityItem, - IItemNetwork { +public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpecialElectricItem, IFactory, ISustainedInventory, ISustainedTank, IEnergyContainerItem, + IFluidItemWrapper, ITierItem, ISecurityItem, IItemNetwork { public Block metaBlock; @@ -134,7 +130,6 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec if (MachineType.get(itemstack) != null) { return getTranslationKey() + "." + MachineType.get(itemstack).blockName; } - return "null"; } @@ -142,126 +137,93 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec @Override public String getItemStackDisplayName(@Nonnull ItemStack itemstack) { MachineType type = MachineType.get(itemstack); - - if (type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY - || type == MachineType.ELITE_FACTORY) { + if (type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY || type == MachineType.ELITE_FACTORY) { BaseTier tier = type.factoryTier.getBaseTier(); - RecipeType recipeType = getRecipeTypeOrNull(itemstack); if (recipeType != null) { - String langKey = "tile." + tier.getSimpleName() + recipeType.getTranslationKey() + "Factory"; if (I18n.canTranslate(langKey)) { return LangUtils.localize(langKey); } - - return tier.getLocalizedName() + " " + recipeType.getLocalizedName() + " " + super - .getItemStackDisplayName(itemstack); + return tier.getLocalizedName() + " " + recipeType.getLocalizedName() + " " + super.getItemStackDisplayName(itemstack); } } else if (type == MachineType.FLUID_TANK) { return LangUtils.localize("tile.FluidTank" + getBaseTier(itemstack).getSimpleName() + ".name"); } - return super.getItemStackDisplayName(itemstack); } @Override @SideOnly(Side.CLIENT) - public void addInformation(@Nonnull ItemStack itemstack, World world, @Nonnull List list, - @Nonnull ITooltipFlag flag) { + public void addInformation(@Nonnull ItemStack itemstack, World world, @Nonnull List list, @Nonnull ITooltipFlag flag) { MachineType type = MachineType.get(itemstack); - if (!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) { if (type == MachineType.FLUID_TANK) { FluidStack fluidStack = getFluidStack(itemstack); - if (fluidStack != null) { int amount = getFluidStack(itemstack).amount; String amountStr = amount == Integer.MAX_VALUE ? LangUtils.localize("gui.infinite") : amount + "mB"; - list.add(EnumColor.AQUA + LangUtils.localizeFluidStack(fluidStack) + ": " + EnumColor.GREY - + amountStr); + list.add(EnumColor.AQUA + LangUtils.localizeFluidStack(fluidStack) + ": " + EnumColor.GREY + amountStr); } else { list.add(EnumColor.DARK_RED + LangUtils.localize("gui.empty") + "."); } - int cap = FluidTankTier.values()[getBaseTier(itemstack).ordinal()].getStorage(); - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + ( - cap == Integer.MAX_VALUE ? LangUtils.localize("gui.infinite") : cap + " mB")); + list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + + (cap == Integer.MAX_VALUE ? LangUtils.localize("gui.infinite") : cap + " mB")); } if (type == MachineType.QUANTUM_ENTANGLOPORTER) { - Frequency.Identity freq = Frequency.Identity - .load(ItemDataUtils.getCompound(itemstack, "entangleporter_frequency")); - + Frequency.Identity freq = Frequency.Identity.load(ItemDataUtils.getCompound(itemstack, "entangleporter_frequency")); if (freq != null) { - list.add( - EnumColor.INDIGO + LangUtils.localize("gui.frequency") + ": " + EnumColor.GREY + freq.name); - list.add(EnumColor.INDIGO + LangUtils.localize("gui.mode") + ": " + EnumColor.GREY + LangUtils - .localize("gui." + (!freq.publicFreq ? "private" : "public"))); + list.add(EnumColor.INDIGO + LangUtils.localize("gui.frequency") + ": " + EnumColor.GREY + freq.name); + list.add(EnumColor.INDIGO + LangUtils.localize("gui.mode") + ": " + EnumColor.GREY + LangUtils.localize("gui." + (!freq.publicFreq ? "private" : "public"))); } } - list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.INDIGO + GameSettings - .getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils - .localize("tooltip.forDetails") + "."); - list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + GameSettings - .getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils - .localize("tooltip.and") + " " + EnumColor.AQUA + GameSettings - .getKeyDisplayString(MekanismKeyHandler.modeSwitchKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils - .localize("tooltip.forDesc") + "."); + list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.INDIGO + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + "."); + list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + + EnumColor.GREY + " " + LangUtils.localize("tooltip.and") + " " + EnumColor.AQUA + + GameSettings.getKeyDisplayString(MekanismKeyHandler.modeSwitchKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDesc") + "."); } else if (!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.modeSwitchKey)) { if (hasSecurity(itemstack)) { - list.add(SecurityUtils.getOwnerDisplay(Minecraft.getMinecraft().player, - MekanismClient.clientUUIDMap.get(getOwnerUUID(itemstack)))); - list.add(EnumColor.GREY + LangUtils.localize("gui.security") + ": " + SecurityUtils - .getSecurityDisplay(itemstack, Side.CLIENT)); - + list.add(SecurityUtils.getOwnerDisplay(Minecraft.getMinecraft().player, MekanismClient.clientUUIDMap.get(getOwnerUUID(itemstack)))); + list.add(EnumColor.GREY + LangUtils.localize("gui.security") + ": " + SecurityUtils.getSecurityDisplay(itemstack, Side.CLIENT)); if (SecurityUtils.isOverridden(itemstack, Side.CLIENT)) { list.add(EnumColor.RED + "(" + LangUtils.localize("gui.overridden") + ")"); } } - - if (type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY - || type == MachineType.ELITE_FACTORY) { - + if (type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY || type == MachineType.ELITE_FACTORY) { RecipeType recipeType = getRecipeTypeOrNull(itemstack); if (recipeType != null) { - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.recipeType") + ": " + EnumColor.GREY - + recipeType.getLocalizedName()); + list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.recipeType") + ": " + EnumColor.GREY + recipeType.getLocalizedName()); } } - if (type == MachineType.FLUID_TANK) { - list.add( - EnumColor.INDIGO + LangUtils.localizeWithFormat("mekanism.tooltip.portableTank.bucketMode", LangUtils.transYesNo(getBucketMode(itemstack)))); + list.add(EnumColor.INDIGO + LangUtils.localizeWithFormat("mekanism.tooltip.portableTank.bucketMode", LangUtils.transYesNo(getBucketMode(itemstack)))); } if (type.isElectric) { list.add(EnumColor.BRIGHT_GREEN + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY - + MekanismUtils.getEnergyDisplay(getEnergy(itemstack), getMaxEnergy(itemstack))); + + MekanismUtils.getEnergyDisplay(getEnergy(itemstack), getMaxEnergy(itemstack))); } if (hasTank(itemstack) && type != MachineType.FLUID_TANK) { FluidStack fluidStack = getFluidStack(itemstack); if (fluidStack != null) { - list.add(EnumColor.PINK + LangUtils.localizeFluidStack(fluidStack) + ": " + EnumColor.GREY - + getFluidStack(itemstack).amount + "mB"); + list.add(EnumColor.PINK + LangUtils.localizeFluidStack(fluidStack) + ": " + EnumColor.GREY + getFluidStack(itemstack).amount + "mB"); } } if (type != MachineType.CHARGEPAD && type != MachineType.LOGISTICAL_SORTER) { - list.add(EnumColor.AQUA + LangUtils.localize("tooltip.inventory") + ": " + EnumColor.GREY + LangUtils - .transYesNo(getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0)); + list.add(EnumColor.AQUA + LangUtils.localize("tooltip.inventory") + ": " + EnumColor.GREY + + LangUtils.transYesNo(getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0)); } - if (type.supportsUpgrades && ItemDataUtils.hasData(itemstack, "upgrades")) { Map upgrades = Upgrade.buildMap(ItemDataUtils.getDataMap(itemstack)); - for (Map.Entry entry : upgrades.entrySet()) { - list.add( - entry.getKey().getColor() + "- " + entry.getKey().getName() + (entry.getKey().canMultiply() ? - ": " + EnumColor.GREY + "x" + entry.getValue() : "")); + list.add(entry.getKey().getColor() + "- " + entry.getKey().getName() + (entry.getKey().canMultiply() ? ": " + EnumColor.GREY + "x" + entry.getValue() : "")); } } } else { @@ -271,25 +233,20 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec @Nonnull @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, @Nonnull BlockPos pos, @Nonnull EnumHand hand, - @Nonnull EnumFacing side, float hitX, float hitY, float hitZ) { + public EnumActionResult onItemUse(EntityPlayer player, World world, @Nonnull BlockPos pos, @Nonnull EnumHand hand, @Nonnull EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); MachineType type = MachineType.get(stack); - if (type == MachineType.FLUID_TANK && getBucketMode(stack)) { return EnumActionResult.PASS; } - return super.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ); } @Override - public boolean placeBlockAt(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, World world, - @Nonnull BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, @Nonnull IBlockState state) { + public boolean placeBlockAt(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, World world, @Nonnull BlockPos pos, EnumFacing side, float hitX, float hitY, + float hitZ, @Nonnull IBlockState state) { boolean place = true; - MachineType type = MachineType.get(stack); - if (type == MachineType.DIGITAL_MINER) { BlockPos.MutableBlockPos testPos = new BlockPos.MutableBlockPos(); for (int xPos = -1; xPos <= +1; xPos++) { @@ -297,9 +254,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec for (int zPos = -1; zPos <= +1; zPos++) { testPos.setPos(pos.getX() + xPos, pos.getY() + yPos, pos.getZ() + zPos); Block b = world.getBlockState(testPos).getBlock(); - - if (!world.isValid(testPos) || !world.isBlockLoaded(testPos, false) || !b - .isReplaceable(world, testPos)) { + if (!world.isValid(testPos) || !world.isBlockLoaded(testPos, false) || !b.isReplaceable(world, testPos)) { place = false; } } @@ -314,21 +269,17 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec if (place && super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, state)) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock) world.getTileEntity(pos); - if (tileEntity instanceof TileEntityFluidTank) { TileEntityFluidTank tile = (TileEntityFluidTank) tileEntity; tile.tier = FluidTankTier.values()[getBaseTier(stack).ordinal()]; tile.fluidTank.setCapacity(tile.tier.getStorage()); } - if (tileEntity instanceof ISecurityTile) { ISecurityTile security = (ISecurityTile) tileEntity; security.getSecurity().setOwnerUUID(getOwnerUUID(stack)); - if (hasSecurity(stack)) { security.getSecurity().setMode(getSecurity(stack)); } - if (getOwnerUUID(stack) == null) { security.getSecurity().setOwnerUUID(player.getUniqueID()); } @@ -342,7 +293,6 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec if (tileEntity instanceof ISideConfiguration) { ISideConfiguration config = (ISideConfiguration) tileEntity; - if (ItemDataUtils.hasData(stack, "sideDataStored")) { config.getConfig().read(ItemDataUtils.getDataMap(stack)); config.getEjector().read(ItemDataUtils.getDataMap(stack)); @@ -357,8 +307,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec if (tileEntity instanceof IRedstoneControl) { if (ItemDataUtils.hasData(stack, "controlType")) { - ((IRedstoneControl) tileEntity) - .setControlType(RedstoneControl.values()[ItemDataUtils.getInt(stack, "controlType")]); + ((IRedstoneControl) tileEntity).setControlType(RedstoneControl.values()[ItemDataUtils.getInt(stack, "controlType")]); } } @@ -369,9 +318,8 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec factory.setRecipeType(recipeType); } world.notifyNeighborsOfStateChange(pos, tileEntity.getBlockType(), true); - - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), - tileEntity.getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(tileEntity))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new TileNetworkList())), + new Range4D(Coord4D.get(tileEntity))); } if (tileEntity instanceof ISustainedTank) { @@ -379,62 +327,46 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec ((ISustainedTank) tileEntity).setFluidStack(getFluidStack(stack)); } } - if (tileEntity instanceof ISustainedInventory) { ((ISustainedInventory) tileEntity).setInventory(getInventory(stack)); } - if (tileEntity instanceof TileEntityElectricBlock) { ((TileEntityElectricBlock) tileEntity).electricityStored = getEnergy(stack); } - - if (!world.isRemote && tileEntity instanceof TileEntityQuantumEntangloporter && ItemDataUtils - .hasData(stack, "entangleporter_frequency")) { - Frequency.Identity freq = Frequency.Identity - .load(ItemDataUtils.getCompound(stack, "entangleporter_frequency")); - + if (!world.isRemote && tileEntity instanceof TileEntityQuantumEntangloporter && ItemDataUtils.hasData(stack, "entangleporter_frequency")) { + Frequency.Identity freq = Frequency.Identity.load(ItemDataUtils.getCompound(stack, "entangleporter_frequency")); if (freq != null) { ((TileEntityQuantumEntangloporter) tileEntity).setFrequency(freq.name, freq.publicFreq); } } - return true; } - return false; } public boolean tryPlaceContainedLiquid(World world, ItemStack itemstack, BlockPos pos) { if (getFluidStack(itemstack) == null || !getFluidStack(itemstack).getFluid().canBePlacedInWorld()) { return false; - } else { - Material material = world.getBlockState(pos).getMaterial(); - boolean flag = !material.isSolid(); - - if (!world.isAirBlock(pos) && !flag) { - return false; - } else { - if (world.provider.doesWaterVaporize() && getFluidStack(itemstack).getFluid() == FluidRegistry.WATER) { - world.playSound(null, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, - SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, - 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); - - for (int l = 0; l < 8; l++) { - world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, pos.getX() + Math.random(), - pos.getY() + Math.random(), pos.getZ() + Math.random(), 0.0D, 0.0D, 0.0D); - } - } else { - if (!world.isRemote && flag && !material.isLiquid()) { - world.destroyBlock(pos, true); - } - - world.setBlockState(pos, - MekanismUtils.getFlowingBlock(getFluidStack(itemstack).getFluid()).getDefaultState(), 3); - } - - return true; - } } + Material material = world.getBlockState(pos).getMaterial(); + boolean flag = !material.isSolid(); + if (!world.isAirBlock(pos) && !flag) { + return false; + } + if (world.provider.doesWaterVaporize() && getFluidStack(itemstack).getFluid() == FluidRegistry.WATER) { + world.playSound(null, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, + 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); + for (int l = 0; l < 8; l++) { + world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, pos.getX() + Math.random(), + pos.getY() + Math.random(), pos.getZ() + Math.random(), 0.0D, 0.0D, 0.0D); + } + } else { + if (!world.isRemote && flag && !material.isLiquid()) { + world.destroyBlock(pos, true); + } + world.setBlockState(pos, MekanismUtils.getFlowingBlock(getFluidStack(itemstack).getFluid()).getDefaultState(), 3); + } + return true; } @Nonnull @@ -448,7 +380,6 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec if (getOwnerUUID(itemstack) == null) { setOwnerUUID(itemstack, entityplayer.getUniqueID()); } - if (SecurityUtils.canAccess(entityplayer, itemstack)) { InventoryPersonalChest inventory = new InventoryPersonalChest(itemstack, hand); MekanismUtils.openPersonalChestGui((EntityPlayerMP) entityplayer, null, inventory, false); @@ -462,27 +393,19 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec //It can be null if there is nothing in range if (pos != null && pos.typeOfHit == RayTraceResult.Type.BLOCK) { Coord4D coord = new Coord4D(pos.getBlockPos(), world); - if (!world.provider.canMineBlock(entityplayer, coord.getPos())) { return new ActionResult<>(EnumActionResult.FAIL, itemstack); } - if (!entityplayer.isSneaking()) { if (!entityplayer.canPlayerEdit(coord.getPos(), pos.sideHit, itemstack)) { return new ActionResult<>(EnumActionResult.FAIL, itemstack); } - FluidStack fluid = MekanismUtils.getFluid(world, coord, false); - - if (fluid != null && (getFluidStack(itemstack) == null || getFluidStack(itemstack) - .isFluidEqual(fluid))) { - int needed = getCapacity(itemstack) - (getFluidStack(itemstack) != null ? getFluidStack( - itemstack).amount : 0); - + if (fluid != null && (getFluidStack(itemstack) == null || getFluidStack(itemstack).isFluidEqual(fluid))) { + int needed = getCapacity(itemstack) - (getFluidStack(itemstack) != null ? getFluidStack(itemstack).amount : 0); if (fluid.amount > needed) { return new ActionResult<>(EnumActionResult.FAIL, itemstack); } - if (getFluidStack(itemstack) == null) { setFluidStack(fluid, itemstack); } else { @@ -490,38 +413,30 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec newStack.amount += fluid.amount; setFluidStack(newStack, itemstack); } - world.setBlockToAir(coord.getPos()); } } else { FluidStack stored = getFluidStack(itemstack); - if (stored == null || stored.amount < Fluid.BUCKET_VOLUME) { return new ActionResult<>(EnumActionResult.FAIL, itemstack); } - Coord4D trans = coord.offset(pos.sideHit); - if (!entityplayer.canPlayerEdit(trans.getPos(), pos.sideHit, itemstack)) { return new ActionResult<>(EnumActionResult.FAIL, itemstack); } - if (tryPlaceContainedLiquid(world, itemstack, trans.getPos()) - && !entityplayer.capabilities.isCreativeMode) { + && !entityplayer.capabilities.isCreativeMode) { FluidStack newStack = stored.copy(); newStack.amount -= Fluid.BUCKET_VOLUME; - setFluidStack(newStack.amount > 0 ? newStack : null, itemstack); } } } - return new ActionResult<>(EnumActionResult.SUCCESS, itemstack); } else { SecurityUtils.displayNoAccess(entityplayer); } } - return new ActionResult<>(EnumActionResult.PASS, itemstack); } @@ -530,7 +445,6 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec if (itemStack.getTagCompound() == null) { return 0; } - return itemStack.getTagCompound().getInteger("recipeType"); } @@ -549,7 +463,6 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec if (itemStack.getTagCompound() == null) { itemStack.setTagCompound(new NBTTagCompound()); } - itemStack.getTagCompound().setInteger("recipeType", type); } @@ -565,7 +478,6 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec if (data[0] instanceof ItemStack) { return ItemDataUtils.getList((ItemStack) data[0], "Items"); } - return null; } @@ -573,7 +485,6 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec public void setFluidStack(FluidStack fluidStack, Object... data) { if (data[0] instanceof ItemStack) { ItemStack itemStack = (ItemStack) data[0]; - if (fluidStack == null || fluidStack.amount == 0 || fluidStack.getFluid() == null) { ItemDataUtils.removeData(itemStack, "fluidTank"); } else { @@ -586,14 +497,11 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec public FluidStack getFluidStack(Object... data) { if (data[0] instanceof ItemStack) { ItemStack itemStack = (ItemStack) data[0]; - if (!ItemDataUtils.hasData(itemStack, "fluidTank")) { return null; } - return FluidStack.loadFluidStackFromNBT(ItemDataUtils.getCompound(itemStack, "fluidTank")); } - return null; } @@ -602,11 +510,8 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec if (!(data[0] instanceof ItemStack) || !(((ItemStack) data[0]).getItem() instanceof ISustainedTank)) { return false; } - MachineType type = MachineType.get((ItemStack) data[0]); - - return type == MachineType.ELECTRIC_PUMP || type == MachineType.FLUID_TANK - || type == MachineType.FLUIDIC_PLENISHER; + return type == MachineType.ELECTRIC_PUMP || type == MachineType.FLUID_TANK || type == MachineType.FLUIDIC_PLENISHER; } public void setBucketMode(ItemStack itemStack, boolean bucketMode) { @@ -622,7 +527,6 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec if (!MachineType.get(itemStack).isElectric) { return 0; } - return ItemDataUtils.getDouble(itemStack, "energyStored"); } @@ -631,26 +535,18 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec if (!MachineType.get(itemStack).isElectric) { return; } - ItemDataUtils.setDouble(itemStack, "energyStored", Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0)); } @Override public double getMaxEnergy(ItemStack itemStack) { - MachineType machineType = MachineType - .get(Block.getBlockFromItem(itemStack.getItem()), itemStack.getItemDamage()); - + MachineType machineType = MachineType.get(Block.getBlockFromItem(itemStack.getItem()), itemStack.getItemDamage()); if (machineType.isFactory()) { RecipeType recipeType = getRecipeTypeOrNull(itemStack); int tierProcess = machineType.factoryTier.processes; - double baseMaxEnergy = tierProcess * - (recipeType == null ? 1 : - Math.max(0.5D * recipeType.getEnergyStorage(), recipeType.getEnergyUsage()) - ); - + double baseMaxEnergy = tierProcess * (recipeType == null ? 1 : Math.max(0.5D * recipeType.getEnergyStorage(), recipeType.getEnergyUsage())); return MekanismUtils.getMaxEnergy(itemStack, baseMaxEnergy); } - return MekanismUtils.getMaxEnergy(itemStack, machineType.getStorage()); } @@ -675,14 +571,11 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec if (canReceive(theItem)) { double energyNeeded = getMaxEnergy(theItem) - getEnergy(theItem); double toReceive = Math.min(energy * MekanismConfig.current().general.FROM_RF.val(), energyNeeded); - if (!simulate) { setEnergy(theItem, getEnergy(theItem) + toReceive); } - return MekanismUtils.clampToInt(toReceive * MekanismConfig.current().general.TO_RF.val()); } - return 0; } @@ -691,15 +584,12 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec public int extractEnergy(ItemStack theItem, int energy, boolean simulate) { if (canSend(theItem)) { double energyRemaining = getEnergy(theItem); - double toSend = Math.min((energy * MekanismConfig.current().general.FROM_RF.val()), energyRemaining); - + double toSend = Math.min(energy * MekanismConfig.current().general.FROM_RF.val(), energyRemaining); if (!simulate) { setEnergy(theItem, getEnergy(theItem) - toSend); } - return MekanismUtils.clampToInt(toSend * MekanismConfig.current().general.TO_RF.val()); } - return 0; } @@ -738,28 +628,22 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec setFluidStack(PipeUtils.copy(resource, Integer.MAX_VALUE), container); return resource.amount; } - FluidStack stored = getFluidStack(container); int toFill; - if (stored != null && stored.getFluid() != resource.getFluid()) { return 0; } - if (stored == null) { toFill = Math.min(resource.amount, getCapacity(container)); } else { toFill = Math.min(resource.amount, getCapacity(container) - stored.amount); } - if (doFill) { int fillAmount = toFill + (stored == null ? 0 : stored.amount); - setFluidStack(PipeUtils.copy(resource, (stored != null ? stored.amount : 0) + toFill), container); + setFluidStack(PipeUtils.copy(resource, fillAmount), container); } - return toFill; } - return 0; } @@ -767,19 +651,15 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) { if (MachineType.get(container) == MachineType.FLUID_TANK) { FluidStack stored = getFluidStack(container); - if (stored != null) { FluidStack toDrain = PipeUtils.copy(stored, Math.min(stored.amount, maxDrain)); - if (doDrain && getBaseTier(container) != BaseTier.CREATIVE) { stored.amount -= toDrain.amount; setFluidStack(stored.amount > 0 ? stored : null, container); } - return toDrain; } } - return null; } @@ -788,7 +668,6 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec if (!itemstack.hasTagCompound()) { return BaseTier.BASIC; } - return BaseTier.values()[itemstack.getTagCompound().getInteger("tier")]; } @@ -797,7 +676,6 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec if (!itemstack.hasTagCompound()) { itemstack.setTagCompound(new NBTTagCompound()); } - itemstack.getTagCompound().setInteger("tier", tier.ordinal()); } @@ -806,7 +684,6 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec if (ItemDataUtils.hasData(stack, "ownerUUID")) { return UUID.fromString(ItemDataUtils.getString(stack, "ownerUUID")); } - return null; } @@ -816,7 +693,6 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec ItemDataUtils.removeData(stack, "ownerUUID"); return; } - ItemDataUtils.setString(stack, "ownerUUID", owner.toString()); } @@ -825,7 +701,6 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec if (!MekanismConfig.current().general.allowProtection.val()) { return SecurityMode.PUBLIC; } - return SecurityMode.values()[ItemDataUtils.getInt(stack, "security")]; } @@ -837,9 +712,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec @Override public boolean hasSecurity(ItemStack stack) { MachineType type = MachineType.get(stack); - - return type != MachineType.LASER && type != MachineType.CHARGEPAD && type != MachineType.TELEPORTER - && type != MachineType.QUANTUM_ENTANGLOPORTER; + return type != MachineType.LASER && type != MachineType.CHARGEPAD && type != MachineType.TELEPORTER && type != MachineType.QUANTUM_ENTANGLOPORTER; } @@ -850,14 +723,12 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec @Override public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { - return new ItemCapabilityWrapper(stack, new TeslaItemWrapper(), new ForgeEnergyItemWrapper(), - new FluidItemWrapper()) { + return new ItemCapabilityWrapper(stack, new TeslaItemWrapper(), new ForgeEnergyItemWrapper(), new FluidItemWrapper()) { @Override public boolean hasCapability(@Nonnull Capability capability, EnumFacing facing) { if (capability == CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY) { return MachineType.get(itemStack) == MachineType.FLUID_TANK; } - return super.hasCapability(capability, facing); } }; @@ -872,4 +743,4 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemBlockMultipartAble.java b/src/main/java/mekanism/common/item/ItemBlockMultipartAble.java index 9a7d795d0..495269305 100644 --- a/src/main/java/mekanism/common/item/ItemBlockMultipartAble.java +++ b/src/main/java/mekanism/common/item/ItemBlockMultipartAble.java @@ -36,19 +36,15 @@ public abstract class ItemBlockMultipartAble extends ItemBlock { */ @Nonnull @Override - public EnumActionResult onItemUse(EntityPlayer player, World worldIn, @Nonnull BlockPos pos, @Nonnull EnumHand hand, - @Nonnull EnumFacing facing, float hitX, float hitY, float hitZ) { + public EnumActionResult onItemUse(EntityPlayer player, World worldIn, @Nonnull BlockPos pos, @Nonnull EnumHand hand, @Nonnull EnumFacing facing, float hitX, float hitY, float hitZ) { IBlockState iblockstate = worldIn.getBlockState(pos); Block block = iblockstate.getBlock(); - ItemStack itemstack = player.getHeldItem(hand); if (itemstack.isEmpty()) { return EnumActionResult.FAIL;//WTF } - if (Mekanism.hooks.MCMPLoaded) { - if (!block.isReplaceable(worldIn, pos) && !hasFreeMultiPartSpot(itemstack, worldIn, pos, iblockstate, - facing)) {//free spot handles case of no container + if (!block.isReplaceable(worldIn, pos) && !hasFreeMultiPartSpot(itemstack, worldIn, pos, iblockstate, facing)) {//free spot handles case of no container pos = pos.offset(facing); iblockstate = worldIn.getBlockState(pos); } @@ -56,54 +52,41 @@ public abstract class ItemBlockMultipartAble extends ItemBlock { pos = pos.offset(facing); } - if (player.canPlayerEdit(pos, facing, itemstack) && mayPlace(itemstack, worldIn, pos, iblockstate, hand, - facing)) { + if (player.canPlayerEdit(pos, facing, itemstack) && mayPlace(itemstack, worldIn, pos, iblockstate, hand, facing)) { int i = this.getMetadata(itemstack.getMetadata()); - IBlockState iblockstate1 = this.block - .getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, i, player, hand); - + IBlockState iblockstate1 = this.block.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, i, player, hand); boolean flag; if (Mekanism.hooks.MCMPLoaded) { - flag = MultipartMekanism - .placeMultipartBlock(this.block, itemstack, player, worldIn, pos, facing, hitX, hitY, hitZ, - iblockstate1); + flag = MultipartMekanism.placeMultipartBlock(this.block, itemstack, player, worldIn, pos, facing, hitX, hitY, hitZ, iblockstate1); } else { flag = placeBlockAt(itemstack, player, worldIn, pos, facing, hitX, hitY, hitZ, iblockstate1); } - if (flag) { iblockstate1 = worldIn.getBlockState(pos); SoundType soundtype = iblockstate1.getBlock().getSoundType(iblockstate1, worldIn, pos, player); - worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, - (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); + worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); itemstack.shrink(1); } - return EnumActionResult.SUCCESS; - } else { - return EnumActionResult.FAIL; } + return EnumActionResult.FAIL; } - private boolean mayPlace(ItemStack itemstack, World worldIn, BlockPos pos, IBlockState state, EnumHand hand, - EnumFacing facing) { + private boolean mayPlace(ItemStack itemstack, World worldIn, BlockPos pos, IBlockState state, EnumHand hand, EnumFacing facing) { if (!Mekanism.hooks.MCMPLoaded) { return worldIn.mayPlace(this.block, pos, false, facing, null); } - return worldIn.mayPlace(this.block, pos, false, facing, null) || hasFreeMultiPartSpot(itemstack, worldIn, pos, - state, facing); + return worldIn.mayPlace(this.block, pos, false, facing, null) || hasFreeMultiPartSpot(itemstack, worldIn, pos, state, facing); } - private boolean hasFreeMultiPartSpot(ItemStack itemstack, World worldIn, BlockPos pos, IBlockState state, - EnumFacing facing) { + private boolean hasFreeMultiPartSpot(ItemStack itemstack, World worldIn, BlockPos pos, IBlockState state, EnumFacing facing) { Optional container; if (!Mekanism.hooks.MCMPLoaded || !(container = MultipartHelper.getContainer(worldIn, pos)).isPresent()) { return false; } IMultipart multipart = getMultiPart(); IPartSlot slot = multipart.getSlotForPlacement(worldIn, pos, state, facing, 0, 0, 0, null); - return container.get().canAddPart(slot, this.block - .getStateForPlacement(worldIn, pos, facing, 0, 0, 0, itemstack.getMetadata(), null, EnumHand.MAIN_HAND)); + return container.get().canAddPart(slot, this.block.getStateForPlacement(worldIn, pos, facing, 0, 0, 0, itemstack.getMetadata(), null, EnumHand.MAIN_HAND)); } //FQ needed because it uses java optional interface elsewhere @@ -111,18 +94,16 @@ public abstract class ItemBlockMultipartAble extends ItemBlock { protected abstract IMultipart getMultiPart(); @Override - public boolean canPlaceBlockOnSide(World worldIn, @Nonnull BlockPos pos, @Nonnull EnumFacing side, - EntityPlayer player, ItemStack stack) { - return super.canPlaceBlockOnSide(worldIn, pos, side, player, stack) || (Mekanism.hooks.MCMPLoaded - && MultipartHelper.getContainer(worldIn, pos).isPresent()); + public boolean canPlaceBlockOnSide(World worldIn, @Nonnull BlockPos pos, @Nonnull EnumFacing side, @Nonnull EntityPlayer player, ItemStack stack) { + return super.canPlaceBlockOnSide(worldIn, pos, side, player, stack) || (Mekanism.hooks.MCMPLoaded && MultipartHelper.getContainer(worldIn, pos).isPresent()); } @Override - public boolean placeBlockAt(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, World world, - @Nonnull BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, @Nonnull IBlockState newState) { + public boolean placeBlockAt(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, World world, @Nonnull BlockPos pos, EnumFacing side, float hitX, float hitY, + float hitZ, @Nonnull IBlockState newState) { if (!world.getBlockState(pos).getBlock().isReplaceable(world, pos)) { return false; } return super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemBlockOre.java b/src/main/java/mekanism/common/item/ItemBlockOre.java index 1e49c8dc8..6f5bbfaa6 100644 --- a/src/main/java/mekanism/common/item/ItemBlockOre.java +++ b/src/main/java/mekanism/common/item/ItemBlockOre.java @@ -36,13 +36,10 @@ public class ItemBlockOre extends ItemBlock { public void addInformation(@Nonnull ItemStack itemstack, World world, @Nonnull List list, @Nonnull ITooltipFlag flag) { if (!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) { - list.add( - "Hold " + EnumColor.AQUA + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) - + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + "."); + list.add("Hold " + EnumColor.AQUA + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + EnumColor.GREY + " " + + LangUtils.localize("tooltip.forDetails") + "."); } else { - list.addAll(MekanismUtils.splitTooltip( - LangUtils.localize("tooltip." + getTranslationKey(itemstack).replace("tile.OreBlock.", "")), - itemstack)); + list.addAll(MekanismUtils.splitTooltip(LangUtils.localize("tooltip." + getTranslationKey(itemstack).replace("tile.OreBlock.", "")), itemstack)); } } @@ -55,7 +52,6 @@ public class ItemBlockOre extends ItemBlock { @Override public String getTranslationKey(ItemStack itemstack) { String name; - switch (itemstack.getItemDamage()) { case 0: name = "OsmiumOre"; @@ -70,7 +66,6 @@ public class ItemBlockOre extends ItemBlock { name = "Unknown"; break; } - return getTranslationKey() + "." + name; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemBlockPlastic.java b/src/main/java/mekanism/common/item/ItemBlockPlastic.java index ff9fe1789..9ea6d9ea8 100644 --- a/src/main/java/mekanism/common/item/ItemBlockPlastic.java +++ b/src/main/java/mekanism/common/item/ItemBlockPlastic.java @@ -30,17 +30,14 @@ public class ItemBlockPlastic extends ItemBlock { EnumDyeColor dyeColour = EnumDyeColor.byDyeDamage(stack.getItemDamage() & 15); EnumColor colour = EnumColor.DYES[dyeColour.getDyeDamage()]; String colourName; - if (I18n.canTranslate(getTranslationKey(stack) + "." + colour.dyeName)) { return LangUtils.localize(getTranslationKey(stack) + "." + colour.dyeName); } - if (colour == EnumColor.BLACK) { colourName = EnumColor.DARK_GREY + colour.getDyeName(); } else { colourName = colour.getDyedName(); } - return colourName + " " + super.getItemStackDisplayName(stack); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemBlockTransmitter.java b/src/main/java/mekanism/common/item/ItemBlockTransmitter.java index 3c0722e1d..0c98b1ab2 100644 --- a/src/main/java/mekanism/common/item/ItemBlockTransmitter.java +++ b/src/main/java/mekanism/common/item/ItemBlockTransmitter.java @@ -11,12 +11,12 @@ import mekanism.api.transmitters.TransmissionType; import mekanism.client.MekKeyHandler; import mekanism.client.MekanismKeyHandler; import mekanism.common.Mekanism; -import mekanism.common.tier.BaseTier; import mekanism.common.base.ITierItem; import mekanism.common.block.states.BlockStateTransmitter.TransmitterType; import mekanism.common.integration.MekanismHooks; import mekanism.common.integration.multipart.MultipartMekanism; import mekanism.common.network.PacketTileEntity.TileEntityMessage; +import mekanism.common.tier.BaseTier; import mekanism.common.tier.CableTier; import mekanism.common.tier.ConductorTier; import mekanism.common.tier.PipeTier; @@ -56,69 +56,47 @@ public class ItemBlockTransmitter extends ItemBlockMultipartAble implements ITie } @Override - public boolean placeBlockAt(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, World world, - @Nonnull BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, @Nonnull IBlockState state) { + public boolean placeBlockAt(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, World world, @Nonnull BlockPos pos, EnumFacing side, float hitX, float hitY, + float hitZ, @Nonnull IBlockState state) { boolean place = super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, state); - if (place) { TileEntitySidedPipe tileEntity = (TileEntitySidedPipe) world.getTileEntity(pos); tileEntity.setBaseTier(getBaseTier(stack)); - if (!world.isRemote) { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), - tileEntity.getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(tileEntity))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new TileNetworkList())), + new Range4D(Coord4D.get(tileEntity))); } } - return place; } @Override @SideOnly(Side.CLIENT) - public void addInformation(@Nonnull ItemStack itemstack, World world, @Nonnull List list, - @Nonnull ITooltipFlag flag) { + public void addInformation(@Nonnull ItemStack itemstack, World world, @Nonnull List list, @Nonnull ITooltipFlag flag) { if (!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) { TransmissionType transmission = TransmitterType.values()[itemstack.getItemDamage()].getTransmission(); BaseTier tier = getBaseTier(itemstack); - if (transmission == TransmissionType.ENERGY) { - list.add( - EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + MekanismUtils - .getEnergyDisplay(CableTier.get(tier).getCableCapacity()) + "/t"); + list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + + MekanismUtils.getEnergyDisplay(CableTier.get(tier).getCableCapacity()) + "/t"); } else if (transmission == TransmissionType.FLUID) { - list.add( - EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + PipeTier - .get(tier).getPipeCapacity() + "mB/t"); - list.add( - EnumColor.INDIGO + LangUtils.localize("tooltip.pumpRate") + ": " + EnumColor.GREY + PipeTier - .get(tier).getPipePullAmount() + "mB/t"); + list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + PipeTier.get(tier).getPipeCapacity() + "mB/t"); + list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.pumpRate") + ": " + EnumColor.GREY + PipeTier.get(tier).getPipePullAmount() + "mB/t"); } else if (transmission == TransmissionType.GAS) { - list.add( - EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + TubeTier - .get(tier).getTubeCapacity() + "mB/t"); - list.add( - EnumColor.INDIGO + LangUtils.localize("tooltip.pumpRate") + ": " + EnumColor.GREY + TubeTier - .get(tier).getTubePullAmount() + "mB/t"); + list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + TubeTier.get(tier).getTubeCapacity() + "mB/t"); + list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.pumpRate") + ": " + EnumColor.GREY + TubeTier.get(tier).getTubePullAmount() + "mB/t"); } else if (transmission == TransmissionType.ITEM) { - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.speed") + ": " + EnumColor.GREY + ( - TransporterTier.get(tier).getSpeed() / (100 / 20)) + " m/s"); - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.pumpRate") + ": " + EnumColor.GREY - + TransporterTier.get(tier).getPullAmount() * 2 + "/s"); + list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.speed") + ": " + EnumColor.GREY + (TransporterTier.get(tier).getSpeed() / (100 / 20)) + " m/s"); + list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.pumpRate") + ": " + EnumColor.GREY + TransporterTier.get(tier).getPullAmount() * 2 + "/s"); } else if (transmission == TransmissionType.HEAT) { - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.conduction") + ": " + EnumColor.GREY - + ConductorTier.get(tier).getInverseConduction()); - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.insulation") + ": " + EnumColor.GREY - + ConductorTier.get(tier).getBaseConductionInsulation()); - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.heatCapacity") + ": " + EnumColor.GREY - + ConductorTier.get(tier).getInverseHeatCapacity()); + list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.conduction") + ": " + EnumColor.GREY + ConductorTier.get(tier).getInverseConduction()); + list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.insulation") + ": " + EnumColor.GREY + ConductorTier.get(tier).getBaseConductionInsulation()); + list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.heatCapacity") + ": " + EnumColor.GREY + ConductorTier.get(tier).getInverseHeatCapacity()); } - - list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + GameSettings - .getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils - .localize("tooltip.forDetails")); + list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails")); } else { TransmitterType type = TransmitterType.values()[itemstack.getItemDamage()]; - switch (type) { case UNIVERSAL_CABLE: { list.add(EnumColor.DARK_GREY + LangUtils.localize("tooltip.capableTrans") + ":"); @@ -129,8 +107,7 @@ public class ItemBlockTransmitter extends ItemBlockMultipartAble implements ITie } case MECHANICAL_PIPE: { list.add(EnumColor.DARK_GREY + LangUtils.localize("tooltip.capableTrans") + ":"); - list.add("- " + EnumColor.PURPLE + LangUtils.localize("tooltip.fluids") + " " + EnumColor.GREY - + "(MinecraftForge)"); + list.add("- " + EnumColor.PURPLE + LangUtils.localize("tooltip.fluids") + " " + EnumColor.GREY + "(MinecraftForge)"); break; } case PRESSURIZED_TUBE: { @@ -140,27 +117,21 @@ public class ItemBlockTransmitter extends ItemBlockMultipartAble implements ITie } case LOGISTICAL_TRANSPORTER: { list.add(EnumColor.DARK_GREY + LangUtils.localize("tooltip.capableTrans") + ":"); - list.add("- " + EnumColor.PURPLE + LangUtils.localize("tooltip.items") + " (" + LangUtils - .localize("tooltip.universal") + ")"); - list.add("- " + EnumColor.PURPLE + LangUtils.localize("tooltip.blocks") + " (" + LangUtils - .localize("tooltip.universal") + ")"); + list.add("- " + EnumColor.PURPLE + LangUtils.localize("tooltip.items") + " (" + LangUtils.localize("tooltip.universal") + ")"); + list.add("- " + EnumColor.PURPLE + LangUtils.localize("tooltip.blocks") + " (" + LangUtils.localize("tooltip.universal") + ")"); break; } case RESTRICTIVE_TRANSPORTER: { list.add(EnumColor.DARK_GREY + LangUtils.localize("tooltip.capableTrans") + ":"); - list.add("- " + EnumColor.PURPLE + LangUtils.localize("tooltip.items") + " (" + LangUtils - .localize("tooltip.universal") + ")"); - list.add("- " + EnumColor.PURPLE + LangUtils.localize("tooltip.blocks") + " (" + LangUtils - .localize("tooltip.universal") + ")"); + list.add("- " + EnumColor.PURPLE + LangUtils.localize("tooltip.items") + " (" + LangUtils.localize("tooltip.universal") + ")"); + list.add("- " + EnumColor.PURPLE + LangUtils.localize("tooltip.blocks") + " (" + LangUtils.localize("tooltip.universal") + ")"); list.add("- " + EnumColor.DARK_RED + LangUtils.localize("tooltip.restrictiveDesc")); break; } case DIVERSION_TRANSPORTER: { list.add(EnumColor.DARK_GREY + LangUtils.localize("tooltip.capableTrans") + ":"); - list.add("- " + EnumColor.PURPLE + LangUtils.localize("tooltip.items") + " (" + LangUtils - .localize("tooltip.universal") + ")"); - list.add("- " + EnumColor.PURPLE + LangUtils.localize("tooltip.blocks") + " (" + LangUtils - .localize("tooltip.universal") + ")"); + list.add("- " + EnumColor.PURPLE + LangUtils.localize("tooltip.items") + " (" + LangUtils.localize("tooltip.universal") + ")"); + list.add("- " + EnumColor.PURPLE + LangUtils.localize("tooltip.blocks") + " (" + LangUtils.localize("tooltip.universal") + ")"); list.add("- " + EnumColor.DARK_RED + LangUtils.localize("tooltip.diversionDesc")); break; } @@ -178,12 +149,10 @@ public class ItemBlockTransmitter extends ItemBlockMultipartAble implements ITie public String getTranslationKey(ItemStack stack) { TransmitterType type = TransmitterType.get(stack.getItemDamage()); String name = type.getTranslationKey(); - if (type.hasTiers()) { BaseTier tier = getBaseTier(stack); name = tier.getSimpleName() + name; } - return getTranslationKey() + "." + name; } @@ -192,7 +161,6 @@ public class ItemBlockTransmitter extends ItemBlockMultipartAble implements ITie if (!itemstack.hasTagCompound()) { return BaseTier.BASIC; } - return BaseTier.values()[itemstack.getTagCompound().getInteger("tier")]; } @@ -201,7 +169,6 @@ public class ItemBlockTransmitter extends ItemBlockMultipartAble implements ITie if (!itemstack.hasTagCompound()) { itemstack.setTagCompound(new NBTTagCompound()); } - itemstack.getTagCompound().setInteger("tier", tier.ordinal()); } @@ -210,4 +177,4 @@ public class ItemBlockTransmitter extends ItemBlockMultipartAble implements ITie protected IMultipart getMultiPart() { return MultipartMekanism.TRANSMITTER_MP; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemClump.java b/src/main/java/mekanism/common/item/ItemClump.java index 087c44796..e8f9f7b66 100644 --- a/src/main/java/mekanism/common/item/ItemClump.java +++ b/src/main/java/mekanism/common/item/ItemClump.java @@ -27,11 +27,10 @@ public class ItemClump extends ItemMekanism implements IMetaItem { @Override public void getSubItems(@Nonnull CreativeTabs tabs, @Nonnull NonNullList itemList) { - if (!isInCreativeTab(tabs)) { - return; - } - for (int counter = 0; counter < Resource.values().length; counter++) { - itemList.add(new ItemStack(this, 1, counter)); + if (isInCreativeTab(tabs)) { + for (int counter = 0; counter < Resource.values().length; counter++) { + itemList.add(new ItemStack(this, 1, counter)); + } } } @@ -41,7 +40,6 @@ public class ItemClump extends ItemMekanism implements IMetaItem { if (item.getItemDamage() <= Resource.values().length - 1) { return "item." + Resource.values()[item.getItemDamage()].getName().toLowerCase(Locale.ROOT) + "Clump"; } - return "Invalid"; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemConfigurationCard.java b/src/main/java/mekanism/common/item/ItemConfigurationCard.java index 79feba546..72231d74f 100644 --- a/src/main/java/mekanism/common/item/ItemConfigurationCard.java +++ b/src/main/java/mekanism/common/item/ItemConfigurationCard.java @@ -32,7 +32,6 @@ public class ItemConfigurationCard extends ItemMekanism { public ItemConfigurationCard() { super(); - setMaxStackSize(1); } @@ -40,66 +39,48 @@ public class ItemConfigurationCard extends ItemMekanism { @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, World world, List list, ITooltipFlag flag) { super.addInformation(itemstack, world, list, flag); - - list.add(EnumColor.GREY + LangUtils.localize("gui.data") + ": " + EnumColor.INDIGO + LangUtils - .localize(getDataType(itemstack))); + list.add(EnumColor.GREY + LangUtils.localize("gui.data") + ": " + EnumColor.INDIGO + LangUtils.localize(getDataType(itemstack))); } @Nonnull @Override - public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, - float hitY, float hitZ, EnumHand hand) { + public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); - if (!world.isRemote) { TileEntity tileEntity = world.getTileEntity(pos); - if (CapabilityUtils.hasCapability(tileEntity, Capabilities.CONFIG_CARD_CAPABILITY, side)) { if (SecurityUtils.canAccess(player, tileEntity)) { if (player.isSneaking()) { NBTTagCompound data = getBaseData(tileEntity); - - if (CapabilityUtils - .hasCapability(tileEntity, Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY, side)) { - ISpecialConfigData special = CapabilityUtils - .getCapability(tileEntity, Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY, side); + if (CapabilityUtils.hasCapability(tileEntity, Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY, side)) { + ISpecialConfigData special = CapabilityUtils.getCapability(tileEntity, Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY, side); data = special.getConfigurationData(data); } if (data != null) { data.setString("dataType", getNameFromTile(tileEntity, side)); setData(stack, data); - player.sendMessage(new TextComponentString( - EnumColor.DARK_BLUE + Mekanism.LOG_TAG + " " + EnumColor.GREY + LangUtils - .localize("tooltip.configurationCard.got").replaceAll("%s", - EnumColor.INDIGO + LangUtils.localize(data.getString("dataType")) - + EnumColor.GREY))); + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + Mekanism.LOG_TAG + " " + EnumColor.GREY + + LangUtils.localize("tooltip.configurationCard.got").replaceAll("%s", + EnumColor.INDIGO + LangUtils.localize(data.getString("dataType")) + EnumColor.GREY))); } - return EnumActionResult.SUCCESS; } else if (getData(stack) != null) { if (getNameFromTile(tileEntity, side).equals(getDataType(stack))) { setBaseData(getData(stack), tileEntity); - - if (CapabilityUtils - .hasCapability(tileEntity, Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY, side)) { - ISpecialConfigData special = CapabilityUtils - .getCapability(tileEntity, Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY, side); + if (CapabilityUtils.hasCapability(tileEntity, Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY, side)) { + ISpecialConfigData special = CapabilityUtils.getCapability(tileEntity, Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY, side); special.setConfigurationData(getData(stack)); } - player.sendMessage(new TextComponentString( - EnumColor.DARK_BLUE + Mekanism.LOG_TAG + " " + EnumColor.DARK_GREEN + LangUtils - .localize("tooltip.configurationCard.set").replaceAll("%s", - EnumColor.INDIGO + LangUtils.localize(getDataType(stack)) - + EnumColor.DARK_GREEN))); + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + Mekanism.LOG_TAG + " " + EnumColor.DARK_GREEN + + LangUtils.localize("tooltip.configurationCard.set").replaceAll("%s", + EnumColor.INDIGO + LangUtils.localize(getDataType(stack)) + EnumColor.DARK_GREEN))); setData(stack, null); } else { - player.sendMessage(new TextComponentString( - EnumColor.DARK_BLUE + Mekanism.LOG_TAG + " " + EnumColor.RED + LangUtils - .localize("tooltip.configurationCard.unequal") + ".")); + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + Mekanism.LOG_TAG + " " + EnumColor.RED + + LangUtils.localize("tooltip.configurationCard.unequal") + ".")); } - return EnumActionResult.SUCCESS; } } else { @@ -107,22 +88,18 @@ public class ItemConfigurationCard extends ItemMekanism { } } } - return EnumActionResult.PASS; } private NBTTagCompound getBaseData(TileEntity tile) { NBTTagCompound nbtTags = new NBTTagCompound(); - if (tile instanceof IRedstoneControl) { nbtTags.setInteger("controlType", ((IRedstoneControl) tile).getControlType().ordinal()); } - if (tile instanceof ISideConfiguration) { ((ISideConfiguration) tile).getConfig().write(nbtTags); ((ISideConfiguration) tile).getEjector().write(nbtTags); } - return nbtTags; } @@ -130,7 +107,6 @@ public class ItemConfigurationCard extends ItemMekanism { if (tile instanceof IRedstoneControl) { ((IRedstoneControl) tile).setControlType(RedstoneControl.values()[nbtTags.getInteger("controlType")]); } - if (tile instanceof ISideConfiguration) { ((ISideConfiguration) tile).getConfig().read(nbtTags); ((ISideConfiguration) tile).getEjector().read(nbtTags); @@ -139,17 +115,13 @@ public class ItemConfigurationCard extends ItemMekanism { private String getNameFromTile(TileEntity tile, EnumFacing side) { String ret = Integer.toString(tile.hashCode()); - if (tile instanceof TileEntityContainerBlock) { ret = tile.getBlockType().getTranslationKey() + "." + ((TileEntityContainerBlock) tile).fullName + ".name"; } - if (CapabilityUtils.hasCapability(tile, Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY, side)) { - ISpecialConfigData special = CapabilityUtils - .getCapability(tile, Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY, side); + ISpecialConfigData special = CapabilityUtils.getCapability(tile, Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY, side); ret = special.getDataType(); } - return ret; } @@ -163,21 +135,17 @@ public class ItemConfigurationCard extends ItemMekanism { public NBTTagCompound getData(ItemStack itemstack) { NBTTagCompound data = ItemDataUtils.getCompound(itemstack, "data"); - if (data.isEmpty()) { return null; - } else { - return ItemDataUtils.getCompound(itemstack, "data"); } + return ItemDataUtils.getCompound(itemstack, "data"); } public String getDataType(ItemStack itemstack) { NBTTagCompound data = getData(itemstack); - if (data != null) { return data.getString("dataType"); } - return "gui.none"; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemConfigurator.java b/src/main/java/mekanism/common/item/ItemConfigurator.java index 1dbf26ca5..152586498 100644 --- a/src/main/java/mekanism/common/item/ItemConfigurator.java +++ b/src/main/java/mekanism/common/item/ItemConfigurator.java @@ -76,55 +76,38 @@ public class ItemConfigurator extends ItemEnergized implements IMekWrench, ITool @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, World world, List list, ITooltipFlag flag) { super.addInformation(itemstack, world, list, flag); - list.add( - EnumColor.PINK + LangUtils.localize("gui.state") + ": " + getColor(getState(itemstack)) + getStateDisplay( - getState(itemstack))); + list.add(EnumColor.PINK + LangUtils.localize("gui.state") + ": " + getColor(getState(itemstack)) + getStateDisplay(getState(itemstack))); } @Nonnull @Override - public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, - float hitY, float hitZ, EnumHand hand) { + public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); - if (!world.isRemote) { Block block = world.getBlockState(pos).getBlock(); TileEntity tile = world.getTileEntity(pos); - if (getState(stack).isConfigurating()) //Configurate - { - TransmissionType transmissionType = Objects.requireNonNull(getState(stack).getTransmission(), - "Configurating state requires transmission type"); - if (tile instanceof ISideConfiguration && ((ISideConfiguration) tile).getConfig() - .supports(transmissionType)) { + if (getState(stack).isConfigurating()) { //Configurate + TransmissionType transmissionType = Objects.requireNonNull(getState(stack).getTransmission(), "Configurating state requires transmission type"); + if (tile instanceof ISideConfiguration && ((ISideConfiguration) tile).getConfig().supports(transmissionType)) { ISideConfiguration config = (ISideConfiguration) tile; SideData initial = config.getConfig().getOutput(transmissionType, side, config.getOrientation()); - if (initial != TileComponentConfig.EMPTY) { if (!player.isSneaking()) { - player.sendMessage(new TextComponentString( - EnumColor.DARK_BLUE + Mekanism.LOG_TAG + EnumColor.GREY + " " + getViewModeText( - transmissionType) + ": " + initial.color + initial.localize() - + " (" + initial.color.getColoredName() + ")")); + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + Mekanism.LOG_TAG + EnumColor.GREY + " " + getViewModeText( + transmissionType) + ": " + initial.color + initial.localize() + " (" + initial.color.getColoredName() + ")")); } else { if (getEnergy(stack) >= ENERGY_PER_CONFIGURE) { if (SecurityUtils.canAccess(player, tile)) { setEnergy(stack, getEnergy(stack) - ENERGY_PER_CONFIGURE); - MekanismUtils.incrementOutput(config, transmissionType, - MekanismUtils.getBaseOrientation(side, config.getOrientation())); - SideData data = config.getConfig() - .getOutput(transmissionType, side, config.getOrientation()); - player.sendMessage(new TextComponentString( - EnumColor.DARK_BLUE + Mekanism.LOG_TAG + EnumColor.GREY + " " - + getToggleModeText(transmissionType) + ": " - + data.color + data.localize() + " (" + data.color.getColoredName() - + ")")); - + MekanismUtils.incrementOutput(config, transmissionType, MekanismUtils.getBaseOrientation(side, config.getOrientation())); + SideData data = config.getConfig().getOutput(transmissionType, side, config.getOrientation()); + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + Mekanism.LOG_TAG + EnumColor.GREY + " " + + getToggleModeText(transmissionType) + ": " + data.color + data.localize() + " (" + + data.color.getColoredName() + ")")); if (config instanceof TileEntityBasicBlock) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock) config; - Mekanism.packetHandler.sendToReceivers( - new TileEntityMessage(Coord4D.get(tileEntity), - tileEntity.getNetworkedData(new TileNetworkList())), + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(tileEntity))); } } else { @@ -133,12 +116,9 @@ public class ItemConfigurator extends ItemEnergized implements IMekWrench, ITool } } } - return EnumActionResult.SUCCESS; } else if (CapabilityUtils.hasCapability(tile, Capabilities.CONFIGURABLE_CAPABILITY, side)) { - IConfigurable config = CapabilityUtils - .getCapability(tile, Capabilities.CONFIGURABLE_CAPABILITY, side); - + IConfigurable config = CapabilityUtils.getCapability(tile, Capabilities.CONFIGURABLE_CAPABILITY, side); if (SecurityUtils.canAccess(player, tile)) { if (player.isSneaking()) { return config.onSneakRightClick(player, side); @@ -147,12 +127,10 @@ public class ItemConfigurator extends ItemEnergized implements IMekWrench, ITool } } else { SecurityUtils.displayNoAccess(player); - return EnumActionResult.SUCCESS; } } - } else if (getState(stack) == ConfiguratorMode.EMPTY) //Empty - { + } else if (getState(stack) == ConfiguratorMode.EMPTY) { //Empty if (tile instanceof TileEntityContainerBlock) { if (SecurityUtils.canAccess(player, tile)) { //TODO: Switch this to an IItemHandler @@ -161,46 +139,36 @@ public class ItemConfigurator extends ItemEnergized implements IMekWrench, ITool IInventory inv = (IInventory) tile; for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack slotStack = inv.getStackInSlot(i); - if (!slotStack.isEmpty()) { if (getEnergy(stack) < ENERGY_PER_ITEM_DUMP) { break; } - Block.spawnAsEntity(world, pos, slotStack.copy()); - inv.setInventorySlotContents(i, ItemStack.EMPTY); setEnergy(stack, getEnergy(stack) - ENERGY_PER_ITEM_DUMP); } } - return EnumActionResult.SUCCESS; } else { SecurityUtils.displayNoAccess(player); return EnumActionResult.FAIL; } } - } else if (getState(stack) == ConfiguratorMode.ROTATE) //Rotate - { + } else if (getState(stack) == ConfiguratorMode.ROTATE) { //Rotate EnumFacing[] rotations = block.getValidRotations(world, pos); - if (rotations != null && rotations.length > 0) { List l = Arrays.asList(block.getValidRotations(world, pos)); - if (!player.isSneaking() && l.contains(side)) { block.rotateBlock(world, pos, side); } else if (player.isSneaking() && l.contains(side.getOpposite())) { block.rotateBlock(world, pos, side.getOpposite()); } } - return EnumActionResult.SUCCESS; - } else if (getState(stack) == ConfiguratorMode.WRENCH) //Wrench - { + } else if (getState(stack) == ConfiguratorMode.WRENCH) { //Wrench return EnumActionResult.PASS; } } - return EnumActionResult.PASS; } @@ -352,4 +320,4 @@ public class ItemConfigurator extends ItemEnergized implements IMekWrench, ITool } } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemControlCircuit.java b/src/main/java/mekanism/common/item/ItemControlCircuit.java index ef90ec099..79d428bdf 100644 --- a/src/main/java/mekanism/common/item/ItemControlCircuit.java +++ b/src/main/java/mekanism/common/item/ItemControlCircuit.java @@ -1,8 +1,8 @@ package mekanism.common.item; import javax.annotation.Nonnull; -import mekanism.common.tier.BaseTier; import mekanism.common.base.IMetaItem; +import mekanism.common.tier.BaseTier; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; @@ -26,12 +26,11 @@ public class ItemControlCircuit extends ItemMekanism implements IMetaItem { @Override public void getSubItems(@Nonnull CreativeTabs tabs, @Nonnull NonNullList itemList) { - if (!isInCreativeTab(tabs)) { - return; - } - for (BaseTier tier : BaseTier.values()) { - if (tier.isObtainable()) { - itemList.add(new ItemStack(this, 1, tier.ordinal())); + if (isInCreativeTab(tabs)) { + for (BaseTier tier : BaseTier.values()) { + if (tier.isObtainable()) { + itemList.add(new ItemStack(this, 1, tier.ordinal())); + } } } } @@ -41,4 +40,4 @@ public class ItemControlCircuit extends ItemMekanism implements IMetaItem { public String getTranslationKey(ItemStack item) { return "item." + BaseTier.values()[item.getItemDamage()].getSimpleName() + "ControlCircuit"; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemCraftingFormula.java b/src/main/java/mekanism/common/item/ItemCraftingFormula.java index cf9127bff..4342bdc2f 100644 --- a/src/main/java/mekanism/common/item/ItemCraftingFormula.java +++ b/src/main/java/mekanism/common/item/ItemCraftingFormula.java @@ -25,20 +25,13 @@ import net.minecraftforge.fml.relauncher.SideOnly; public class ItemCraftingFormula extends ItemMekanism { public static ModelResourceLocation MODEL = new ModelResourceLocation("mekanism:CraftingFormula", "inventory"); - public static ModelResourceLocation INVALID_MODEL = new ModelResourceLocation("mekanism:CraftingFormulaInvalid", - "inventory"); - public static ModelResourceLocation ENCODED_MODEL = new ModelResourceLocation("mekanism:CraftingFormulaEncoded", - "inventory"); - - public ItemCraftingFormula() { - super(); - } + public static ModelResourceLocation INVALID_MODEL = new ModelResourceLocation("mekanism:CraftingFormulaInvalid", "inventory"); + public static ModelResourceLocation ENCODED_MODEL = new ModelResourceLocation("mekanism:CraftingFormulaEncoded", "inventory"); @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, World world, List list, ITooltipFlag flag) { NonNullList inv = getInventory(itemstack); - if (inv != null) { addIngredientDetails(inv, list); } @@ -46,26 +39,21 @@ public class ItemCraftingFormula extends ItemMekanism { private void addIngredientDetails(NonNullList inv, List list) { List stacks = new ArrayList<>(); - for (ItemStack stack : inv) { if (!stack.isEmpty()) { boolean found = false; - for (ItemStack iterStack : stacks) { if (InventoryUtils.canStack(stack, iterStack)) { iterStack.grow(stack.getCount()); found = true; } } - if (!found) { stacks.add(stack); } } } - list.add(EnumColor.GREY + LangUtils.localize("tooltip.ingredients") + ":"); - for (ItemStack stack : stacks) { list.add(EnumColor.GREY + " - " + stack.getDisplayName() + " (" + stack.getCount() + ")"); } @@ -75,18 +63,14 @@ public class ItemCraftingFormula extends ItemMekanism { @Override public ActionResult onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { ItemStack stack = player.getHeldItem(hand); - if (player.isSneaking()) { if (!world.isRemote) { setInventory(stack, null); setInvalid(stack, false); - ((EntityPlayerMP) player).sendContainerToPlayer(player.openContainer); } - return new ActionResult<>(EnumActionResult.SUCCESS, stack); } - return new ActionResult<>(EnumActionResult.PASS, stack); } @@ -101,10 +85,8 @@ public class ItemCraftingFormula extends ItemMekanism { if (getInventory(stack) == null) { return super.getItemStackDisplayName(stack); } - - return super.getItemStackDisplayName(stack) + " " + (isInvalid(stack) ? EnumColor.DARK_RED + "(" + LangUtils - .localize("tooltip.invalid") - : EnumColor.DARK_GREEN + "(" + LangUtils.localize("tooltip.encoded")) + ")"; + return super.getItemStackDisplayName(stack) + " " + (isInvalid(stack) ? EnumColor.DARK_RED + "(" + LangUtils.localize("tooltip.invalid") + : EnumColor.DARK_GREEN + "(" + LangUtils.localize("tooltip.encoded")) + ")"; } public boolean isInvalid(ItemStack stack) { @@ -119,19 +101,15 @@ public class ItemCraftingFormula extends ItemMekanism { if (!ItemDataUtils.hasData(stack, "Items")) { return null; } - NBTTagList tagList = ItemDataUtils.getList(stack, "Items"); NonNullList inventory = NonNullList.withSize(9, ItemStack.EMPTY); - for (int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(tagCount); byte slotID = tagCompound.getByte("Slot"); - if (slotID >= 0 && slotID < 9) { inventory.set(slotID, new ItemStack(tagCompound)); } } - return inventory; } @@ -140,9 +118,7 @@ public class ItemCraftingFormula extends ItemMekanism { ItemDataUtils.removeData(stack, "Items"); return; } - NBTTagList tagList = new NBTTagList(); - for (int slotCount = 0; slotCount < 9; slotCount++) { if (!inv.get(slotCount).isEmpty()) { NBTTagCompound tagCompound = new NBTTagCompound(); @@ -151,7 +127,6 @@ public class ItemCraftingFormula extends ItemMekanism { tagList.appendTag(tagCompound); } } - ItemDataUtils.setList(stack, "Items", tagList); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemCrystal.java b/src/main/java/mekanism/common/item/ItemCrystal.java index 8a8f504c2..d35e38a8c 100644 --- a/src/main/java/mekanism/common/item/ItemCrystal.java +++ b/src/main/java/mekanism/common/item/ItemCrystal.java @@ -27,11 +27,10 @@ public class ItemCrystal extends ItemMekanism implements IMetaItem { @Override public void getSubItems(@Nonnull CreativeTabs tabs, @Nonnull NonNullList itemList) { - if (!isInCreativeTab(tabs)) { - return; - } - for (int counter = 0; counter < Resource.values().length; counter++) { - itemList.add(new ItemStack(this, 1, counter)); + if (isInCreativeTab(tabs)) { + for (int counter = 0; counter < Resource.values().length; counter++) { + itemList.add(new ItemStack(this, 1, counter)); + } } } @@ -41,7 +40,6 @@ public class ItemCrystal extends ItemMekanism implements IMetaItem { if (item.getItemDamage() <= Resource.values().length - 1) { return "item." + Resource.values()[item.getItemDamage()].getName().toLowerCase(Locale.ROOT) + "Crystal"; } - return "Invalid"; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemDictionary.java b/src/main/java/mekanism/common/item/ItemDictionary.java index ed1771241..3c6314ade 100644 --- a/src/main/java/mekanism/common/item/ItemDictionary.java +++ b/src/main/java/mekanism/common/item/ItemDictionary.java @@ -30,33 +30,23 @@ public class ItemDictionary extends ItemMekanism { public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); - if (!player.isSneaking()) { IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); - if (world.isRemote) { ItemStack testStack = new ItemStack(block, 1, block.getMetaFromState(state)); List names = OreDictCache.getOreDictName(testStack); - if (!names.isEmpty()) { - player.sendMessage(new TextComponentString( - EnumColor.DARK_BLUE + Mekanism.LOG_TAG + EnumColor.GREY + " " + LangUtils - .localize("tooltip.keysFound") + ":")); - + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + Mekanism.LOG_TAG + EnumColor.GREY + " " + LangUtils.localize("tooltip.keysFound") + ":")); for (String name : names) { player.sendMessage(new TextComponentString(EnumColor.DARK_GREEN + " - " + name)); } } else { - player.sendMessage(new TextComponentString( - EnumColor.DARK_BLUE + Mekanism.LOG_TAG + EnumColor.GREY + " " + LangUtils - .localize("tooltip.noKey") + ".")); + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + Mekanism.LOG_TAG + EnumColor.GREY + " " + LangUtils.localize("tooltip.noKey") + ".")); } } - return EnumActionResult.SUCCESS; } - return EnumActionResult.PASS; } @@ -64,12 +54,10 @@ public class ItemDictionary extends ItemMekanism { @Override public ActionResult onItemRightClick(World world, EntityPlayer entityplayer, @Nonnull EnumHand hand) { ItemStack itemstack = entityplayer.getHeldItem(hand); - if (entityplayer.isSneaking()) { entityplayer.openGui(Mekanism.instance, 0, world, 0, 0, 0); return new ActionResult<>(EnumActionResult.SUCCESS, itemstack); } - return new ActionResult<>(EnumActionResult.PASS, itemstack); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemDirtyDust.java b/src/main/java/mekanism/common/item/ItemDirtyDust.java index 332e9b040..aed8d7901 100644 --- a/src/main/java/mekanism/common/item/ItemDirtyDust.java +++ b/src/main/java/mekanism/common/item/ItemDirtyDust.java @@ -28,11 +28,10 @@ public class ItemDirtyDust extends ItemMekanism implements IMetaItem { @Override public void getSubItems(@Nonnull CreativeTabs tabs, @Nonnull NonNullList itemList) { - if (!isInCreativeTab(tabs)) { - return; - } - for (int counter = 0; counter < Resource.values().length; counter++) { - itemList.add(new ItemStack(this, 1, counter)); + if (isInCreativeTab(tabs)) { + for (int counter = 0; counter < Resource.values().length; counter++) { + itemList.add(new ItemStack(this, 1, counter)); + } } } @@ -42,7 +41,6 @@ public class ItemDirtyDust extends ItemMekanism implements IMetaItem { if (item.getItemDamage() <= Resource.values().length - 1) { return "item.dirty" + Resource.values()[item.getItemDamage()].getName() + "Dust"; } - return "Invalid"; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemDust.java b/src/main/java/mekanism/common/item/ItemDust.java index 33cee41ea..2550a16bc 100644 --- a/src/main/java/mekanism/common/item/ItemDust.java +++ b/src/main/java/mekanism/common/item/ItemDust.java @@ -27,11 +27,10 @@ public class ItemDust extends ItemMekanism implements IMetaItem { @Override public void getSubItems(@Nonnull CreativeTabs tabs, @Nonnull NonNullList itemList) { - if (!isInCreativeTab(tabs)) { - return; - } - for (int counter = 0; counter < Resource.values().length; counter++) { - itemList.add(new ItemStack(this, 1, counter)); + if (isInCreativeTab(tabs)) { + for (int counter = 0; counter < Resource.values().length; counter++) { + itemList.add(new ItemStack(this, 1, counter)); + } } } @@ -41,7 +40,6 @@ public class ItemDust extends ItemMekanism implements IMetaItem { if (item.getItemDamage() <= Resource.values().length - 1) { return "item." + Resource.values()[item.getItemDamage()].getName().toLowerCase(Locale.ROOT) + "Dust"; } - return "Invalid"; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemElectricBow.java b/src/main/java/mekanism/common/item/ItemElectricBow.java index d57751707..4fc0304a4 100644 --- a/src/main/java/mekanism/common/item/ItemElectricBow.java +++ b/src/main/java/mekanism/common/item/ItemElectricBow.java @@ -40,23 +40,18 @@ public class ItemElectricBow extends ItemEnergized implements IItemNetwork { @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, World world, List list, ITooltipFlag flag) { super.addInformation(itemstack, world, list, flag); - - list.add(EnumColor.PINK + LangUtils.localizeWithFormat("mekanism.tooltip.fireMode", LangUtils - .transOnOff(getFireState(itemstack)))); + list.add(EnumColor.PINK + LangUtils.localizeWithFormat("mekanism.tooltip.fireMode", LangUtils.transOnOff(getFireState(itemstack)))); } @Override - public void onPlayerStoppedUsing(ItemStack itemstack, World world, EntityLivingBase entityLiving, - int itemUseCount) { + public void onPlayerStoppedUsing(ItemStack itemstack, World world, EntityLivingBase entityLiving, int itemUseCount) { if (entityLiving instanceof EntityPlayer && getEnergy(itemstack) > 0) { EntityPlayer player = (EntityPlayer) entityLiving; - boolean flag = player.capabilities.isCreativeMode - || EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, itemstack) > 0; + boolean flag = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, itemstack) > 0; ItemStack ammo = findAmmo(player); int maxItemUse = getMaxItemUseDuration(itemstack) - itemUseCount; - maxItemUse = ForgeEventFactory - .onArrowLoose(itemstack, world, player, maxItemUse, !itemstack.isEmpty() || flag); + maxItemUse = ForgeEventFactory.onArrowLoose(itemstack, world, player, maxItemUse, !itemstack.isEmpty() || flag); if (maxItemUse < 0) { return; } @@ -65,54 +60,41 @@ public class ItemElectricBow extends ItemEnergized implements IItemNetwork { if (ammo.isEmpty()) { ammo = new ItemStack(Items.ARROW); } - float f = maxItemUse / 20F; f = (f * f + f * 2.0F) / 3F; - if (f < 0.1D) { return; } - if (f > 1.0F) { f = 1.0F; } - boolean noConsume = flag && itemstack.getItem() instanceof ItemArrow; - if (!world.isRemote) { - ItemArrow itemarrow = (ItemArrow) (ammo.getItem() instanceof ItemArrow ? ammo.getItem() - : Items.ARROW); + ItemArrow itemarrow = (ItemArrow) (ammo.getItem() instanceof ItemArrow ? ammo.getItem() : Items.ARROW); EntityArrow entityarrow = itemarrow.createArrow(world, itemstack, player); entityarrow.shoot(player, player.rotationPitch, player.rotationYaw, 0.0F, f * 3.0F, 1.0F); - if (f == 1.0F) { entityarrow.setIsCritical(true); } - if (!player.capabilities.isCreativeMode) { setEnergy(itemstack, getEnergy(itemstack) - (getFireState(itemstack) ? 1200 : 120)); } - if (noConsume) { entityarrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY; } - entityarrow.setFire(getFireState(itemstack) ? 100 : 0); - world.spawnEntity(entityarrow); } - world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, - SoundCategory.NEUTRAL, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); + world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, + 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); if (!noConsume) { ammo.shrink(1); - if (ammo.getCount() == 0) { player.inventory.deleteStack(ammo); } } - player.addStat(StatList.getObjectUseStats(this)); } } @@ -134,17 +116,14 @@ public class ItemElectricBow extends ItemEnergized implements IItemNetwork { return player.getHeldItem(EnumHand.OFF_HAND); } else if (isArrow(player.getHeldItem(EnumHand.MAIN_HAND))) { return player.getHeldItem(EnumHand.MAIN_HAND); - } else { - for (int i = 0; i < player.inventory.getSizeInventory(); ++i) { - ItemStack itemstack = player.inventory.getStackInSlot(i); - - if (isArrow(itemstack)) { - return itemstack; - } - } - - return ItemStack.EMPTY; } + for (int i = 0; i < player.inventory.getSizeInventory(); ++i) { + ItemStack itemstack = player.inventory.getStackInSlot(i); + if (isArrow(itemstack)) { + return itemstack; + } + } + return ItemStack.EMPTY; } protected boolean isArrow(ItemStack stack) { @@ -156,18 +135,15 @@ public class ItemElectricBow extends ItemEnergized implements IItemNetwork { public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, @Nonnull EnumHand hand) { ItemStack itemStackIn = playerIn.getHeldItem(hand); boolean flag = !findAmmo(playerIn).isEmpty(); - ActionResult ret = ForgeEventFactory.onArrowNock(itemStackIn, worldIn, playerIn, hand, flag); if (ret != null) { return ret; } - if (!playerIn.capabilities.isCreativeMode && !flag) { return new ActionResult<>(EnumActionResult.FAIL, itemStackIn); - } else { - playerIn.setActiveHand(hand); - return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn); } + playerIn.setActiveHand(hand); + return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn); } public void setFireState(ItemStack itemstack, boolean state) { @@ -190,4 +166,4 @@ public class ItemElectricBow extends ItemEnergized implements IItemNetwork { setFireState(stack, state); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemEnergized.java b/src/main/java/mekanism/common/item/ItemEnergized.java index aabf1685b..ef67d229a 100644 --- a/src/main/java/mekanism/common/item/ItemEnergized.java +++ b/src/main/java/mekanism/common/item/ItemEnergized.java @@ -68,8 +68,7 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpec @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, World world, List list, ITooltipFlag flag) { - list.add(EnumColor.AQUA + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY + MekanismUtils - .getEnergyDisplay(getEnergy(itemstack), getMaxEnergy(itemstack))); + list.add(EnumColor.AQUA + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack), getMaxEnergy(itemstack))); } public ItemStack getUnchargedItem() { @@ -124,14 +123,11 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpec if (canReceive(theItem)) { double energyNeeded = getMaxEnergy(theItem) - getEnergy(theItem); double toReceive = Math.min(energy * MekanismConfig.current().general.FROM_RF.val(), energyNeeded); - if (!simulate) { setEnergy(theItem, getEnergy(theItem) + toReceive); } - return MekanismUtils.clampToInt(toReceive * MekanismConfig.current().general.TO_RF.val()); } - return 0; } @@ -139,15 +135,12 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpec public int extractEnergy(ItemStack theItem, int energy, boolean simulate) { if (canSend(theItem)) { double energyRemaining = getEnergy(theItem); - double toSend = Math.min((energy * MekanismConfig.current().general.FROM_RF.val()), energyRemaining); - + double toSend = Math.min(energy * MekanismConfig.current().general.FROM_RF.val(), energyRemaining); if (!simulate) { setEnergy(theItem, getEnergy(theItem) - toSend); } - return MekanismUtils.clampToInt(toSend * MekanismConfig.current().general.TO_RF.val()); } - return 0; } @@ -171,4 +164,4 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpec public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { return new ItemCapabilityWrapper(stack, new TeslaItemWrapper(), new ForgeEnergyItemWrapper()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemFlamethrower.java b/src/main/java/mekanism/common/item/ItemFlamethrower.java index 65f4971c6..5817eacb9 100644 --- a/src/main/java/mekanism/common/item/ItemFlamethrower.java +++ b/src/main/java/mekanism/common/item/ItemFlamethrower.java @@ -16,7 +16,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.NonNullList; import net.minecraft.util.math.MathHelper; -import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; @@ -35,16 +34,12 @@ public class ItemFlamethrower extends ItemMekanism implements IGasItem { @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, World world, List list, ITooltipFlag flag) { GasStack gasStack = getGas(itemstack); - if (gasStack == null) { list.add(LangUtils.localize("tooltip.noGas") + "."); } else { - list.add(LangUtils.localize("tooltip.stored") + " " + gasStack.getGas().getLocalizedName() + ": " - + gasStack.amount); + list.add(LangUtils.localize("tooltip.stored") + " " + gasStack.getGas().getLocalizedName() + ": " + gasStack.amount); } - - list.add(EnumColor.GREY + LangUtils.localize("tooltip.mode") + ": " + EnumColor.GREY + getMode(itemstack) - .getName()); + list.add(EnumColor.GREY + LangUtils.localize("tooltip.mode") + ": " + EnumColor.GREY + getMode(itemstack).getName()); } public void useGas(ItemStack stack) { @@ -68,14 +63,11 @@ public class ItemFlamethrower extends ItemMekanism implements IGasItem { if (getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas()) { return 0; } - if (stack.getGas() != MekanismFluids.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; } @@ -125,7 +117,6 @@ public class ItemFlamethrower extends ItemMekanism implements IGasItem { } else { int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack))); GasStack gasStack = new GasStack(stack.getGas(), amount); - ItemDataUtils.setCompound(itemstack, "stored", gasStack.write(new NBTTagCompound())); } } @@ -189,4 +180,4 @@ public class ItemFlamethrower extends ItemMekanism implements IGasItem { return component; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemFreeRunners.java b/src/main/java/mekanism/common/item/ItemFreeRunners.java index b409b3655..a9b88e84c 100644 --- a/src/main/java/mekanism/common/item/ItemFreeRunners.java +++ b/src/main/java/mekanism/common/item/ItemFreeRunners.java @@ -74,8 +74,7 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci @Override @SideOnly(Side.CLIENT) - public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, - ModelBiped _default) { + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, ModelBiped _default) { ModelCustomArmor model = ModelCustomArmor.INSTANCE; model.modelType = ArmorModel.FREERUNNERS; return model; @@ -84,10 +83,8 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, World world, List list, ITooltipFlag flag) { - list.add(EnumColor.AQUA + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY + MekanismUtils - .getEnergyDisplay(getEnergy(itemstack), getMaxEnergy(itemstack))); - list.add(EnumColor.GREY + LangUtils.localize("tooltip.mode") + ": " + EnumColor.GREY + getMode(itemstack) - .getName()); + list.add(EnumColor.AQUA + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack), getMaxEnergy(itemstack))); + list.add(EnumColor.GREY + LangUtils.localize("tooltip.mode") + ": " + EnumColor.GREY + getMode(itemstack).getName()); } public ItemStack getUnchargedItem() { @@ -142,14 +139,11 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci if (canReceive(theItem)) { double energyNeeded = getMaxEnergy(theItem) - getEnergy(theItem); double toReceive = Math.min(energy * MekanismConfig.current().general.FROM_RF.val(), energyNeeded); - if (!simulate) { setEnergy(theItem, getEnergy(theItem) + toReceive); } - return MekanismUtils.clampToInt(toReceive * MekanismConfig.current().general.TO_RF.val()); } - return 0; } @@ -158,15 +152,12 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci public int extractEnergy(ItemStack theItem, int energy, boolean simulate) { if (canSend(theItem)) { double energyRemaining = getEnergy(theItem); - double toSend = Math.min((energy * MekanismConfig.current().general.FROM_RF.val()), energyRemaining); - + double toSend = Math.min(energy * MekanismConfig.current().general.FROM_RF.val(), energyRemaining); if (!simulate) { setEnergy(theItem, getEnergy(theItem) - toSend); } - return MekanismUtils.clampToInt(toSend * MekanismConfig.current().general.TO_RF.val()); } - return 0; } @@ -207,12 +198,10 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci public void onEntityAttacked(LivingAttackEvent event) { EntityLivingBase base = event.getEntityLiving(); ItemStack stack = base.getItemStackFromSlot(EntityEquipmentSlot.FEET); - if (!stack.isEmpty() && stack.getItem() instanceof ItemFreeRunners) { ItemFreeRunners boots = (ItemFreeRunners) stack.getItem(); - if (boots.getMode(stack) == FreeRunnerMode.NORMAL && boots.getEnergy(stack) > 0 - && event.getSource() == DamageSource.FALL) { + && event.getSource() == DamageSource.FALL) { boots.setEnergy(stack, boots.getEnergy(stack) - event.getAmount() * 50); event.setCanceled(true); } @@ -256,4 +245,4 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci return color + LangUtils.localize(unlocalized); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemGasMask.java b/src/main/java/mekanism/common/item/ItemGasMask.java index cac7274fc..b5d7f1734 100644 --- a/src/main/java/mekanism/common/item/ItemGasMask.java +++ b/src/main/java/mekanism/common/item/ItemGasMask.java @@ -20,9 +20,8 @@ import net.minecraftforge.fml.relauncher.SideOnly; public class ItemGasMask extends ItemArmor { public ItemGasMask() { - super(EnumHelper - .addArmorMaterial("GASMASK", "gasmask", 0, new int[]{0, 0, 0, 0}, 0, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, - 0), 0, EntityEquipmentSlot.HEAD); + super(EnumHelper.addArmorMaterial("GASMASK", "gasmask", 0, new int[]{0, 0, 0, 0}, 0, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, + 0), 0, EntityEquipmentSlot.HEAD); setCreativeTab(Mekanism.tabMekanism); } @@ -38,8 +37,7 @@ public class ItemGasMask extends ItemArmor { @Override @SideOnly(Side.CLIENT) - public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, - ModelBiped _default) { + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, ModelBiped _default) { ModelCustomArmor model = ModelCustomArmor.INSTANCE; model.modelType = ArmorModel.GASMASK; return model; @@ -48,16 +46,12 @@ public class ItemGasMask extends ItemArmor { @SubscribeEvent public void onEntityAttacked(LivingAttackEvent event) { EntityLivingBase base = event.getEntityLiving(); - ItemStack headStack = base.getItemStackFromSlot(EntityEquipmentSlot.HEAD); ItemStack chestStack = base.getItemStackFromSlot(EntityEquipmentSlot.CHEST); - if (!headStack.isEmpty() && headStack.getItem() instanceof ItemGasMask) { ItemGasMask mask = (ItemGasMask) headStack.getItem(); - if (!chestStack.isEmpty() && chestStack.getItem() instanceof ItemScubaTank) { ItemScubaTank tank = (ItemScubaTank) chestStack.getItem(); - if (tank.getFlowing(chestStack) && tank.getGas(chestStack) != null) { if (event.getSource() == DamageSource.MAGIC) { event.setCanceled(true); @@ -66,4 +60,4 @@ public class ItemGasMask extends ItemArmor { } } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemGaugeDropper.java b/src/main/java/mekanism/common/item/ItemGaugeDropper.java index 113fd0fa6..610248ccd 100644 --- a/src/main/java/mekanism/common/item/ItemGaugeDropper.java +++ b/src/main/java/mekanism/common/item/ItemGaugeDropper.java @@ -46,10 +46,9 @@ public class ItemGaugeDropper extends ItemMekanism implements IGasItem { @Override public void getSubItems(@Nonnull CreativeTabs tabs, @Nonnull NonNullList list) { - if (!isInCreativeTab(tabs)) { - return; + if (isInCreativeTab(tabs)) { + list.add(getEmptyItem()); } - list.add(getEmptyItem()); } @Override @@ -59,11 +58,8 @@ public class ItemGaugeDropper extends ItemMekanism implements IGasItem { @Override public double getDurabilityForDisplay(ItemStack stack) { - double gasRatio = ((getGas(stack) != null ? (double) getGas(stack).amount : 0D) / (double) CAPACITY); - double fluidRatio = ( - (FluidUtil.getFluidContained(stack) != null ? (double) FluidUtil.getFluidContained(stack).amount : 0D) - / (double) CAPACITY); - + double gasRatio = (getGas(stack) != null ? (double) getGas(stack).amount : 0D) / (double) CAPACITY; + double fluidRatio = (FluidUtil.getFluidContained(stack) != null ? (double) FluidUtil.getFluidContained(stack).amount : 0D) / (double) CAPACITY; return 1D - Math.max(gasRatio, fluidRatio); } @@ -71,16 +67,12 @@ public class ItemGaugeDropper extends ItemMekanism implements IGasItem { @Override public ActionResult onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { ItemStack stack = player.getHeldItem(hand); - if (player.isSneaking() && !world.isRemote) { setGas(stack, null); FluidUtil.getFluidHandler(stack).drain(CAPACITY, true); - ((EntityPlayerMP) player).sendContainerToPlayer(player.openContainer); - return new ActionResult<>(EnumActionResult.SUCCESS, stack); } - return new ActionResult<>(EnumActionResult.PASS, stack); } @@ -89,16 +81,12 @@ public class ItemGaugeDropper extends ItemMekanism implements IGasItem { public void addInformation(ItemStack itemstack, World world, List list, ITooltipFlag flag) { GasStack gasStack = getGas(itemstack); FluidStack fluidStack = FluidUtil.getFluidContained(itemstack); - if (gasStack == null && fluidStack == null) { list.add(LangUtils.localize("gui.empty") + "."); } else if (gasStack != null) { - list.add(LangUtils.localize("tooltip.stored") + " " + gasStack.getGas().getLocalizedName() + ": " - + gasStack.amount); + list.add(LangUtils.localize("tooltip.stored") + " " + gasStack.getGas().getLocalizedName() + ": " + gasStack.amount); } else { - list.add( - LangUtils.localize("tooltip.stored") + " " + fluidStack.getFluid().getLocalizedName(fluidStack) + ": " - + fluidStack.amount); + list.add(LangUtils.localize("tooltip.stored") + " " + fluidStack.getFluid().getLocalizedName(fluidStack) + ": " + fluidStack.amount); } } @@ -112,10 +100,8 @@ public class ItemGaugeDropper extends ItemMekanism implements IGasItem { 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; } @@ -124,12 +110,9 @@ public class ItemGaugeDropper extends ItemMekanism implements IGasItem { if (getGas(itemstack) == null) { 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); } @@ -163,7 +146,6 @@ public class ItemGaugeDropper extends ItemMekanism implements IGasItem { } else { int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack))); GasStack gasStack = new GasStack(stack.getGas(), amount); - ItemDataUtils.setCompound(itemstack, "gasStack", gasStack.write(new NBTTagCompound())); } } @@ -177,4 +159,4 @@ public class ItemGaugeDropper extends ItemMekanism implements IGasItem { public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { return new FluidHandlerItemStack(stack, CAPACITY); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemHDPE.java b/src/main/java/mekanism/common/item/ItemHDPE.java index 3be5095a0..fdf30e7ae 100644 --- a/src/main/java/mekanism/common/item/ItemHDPE.java +++ b/src/main/java/mekanism/common/item/ItemHDPE.java @@ -27,11 +27,10 @@ public class ItemHDPE extends ItemMekanism implements IMetaItem { @Override public void getSubItems(@Nonnull CreativeTabs tabs, @Nonnull NonNullList itemList) { - if (!isInCreativeTab(tabs)) { - return; - } - for (int counter = 0; counter < PlasticItem.values().length; counter++) { - itemList.add(new ItemStack(this, 1, counter)); + if (isInCreativeTab(tabs)) { + for (int counter = 0; counter < PlasticItem.values().length; counter++) { + itemList.add(new ItemStack(this, 1, counter)); + } } } @@ -57,4 +56,4 @@ public class ItemHDPE extends ItemMekanism implements IMetaItem { return name; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemIngot.java b/src/main/java/mekanism/common/item/ItemIngot.java index d85704338..1e489cb9c 100644 --- a/src/main/java/mekanism/common/item/ItemIngot.java +++ b/src/main/java/mekanism/common/item/ItemIngot.java @@ -9,9 +9,7 @@ import net.minecraft.util.NonNullList; public class ItemIngot extends ItemMekanism implements IMetaItem { - public static String[] en_USNames = {"Obsidian", "Osmium", "Bronze", - "Glowstone", "Steel", "Copper", - "Tin"}; + public static String[] en_USNames = {"Obsidian", "Osmium", "Bronze", "Glowstone", "Steel", "Copper", "Tin"}; public ItemIngot() { super(); @@ -30,11 +28,10 @@ public class ItemIngot extends ItemMekanism implements IMetaItem { @Override public void getSubItems(@Nonnull CreativeTabs tabs, @Nonnull NonNullList itemList) { - if (!isInCreativeTab(tabs)) { - return; - } - for (int counter = 0; counter < en_USNames.length; counter++) { - itemList.add(new ItemStack(this, 1, counter)); + if (isInCreativeTab(tabs)) { + for (int counter = 0; counter < en_USNames.length; counter++) { + itemList.add(new ItemStack(this, 1, counter)); + } } } @@ -43,4 +40,4 @@ public class ItemIngot extends ItemMekanism implements IMetaItem { public String getTranslationKey(ItemStack item) { return "item." + en_USNames[item.getItemDamage()].toLowerCase(Locale.ROOT) + "Ingot"; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemJetpack.java b/src/main/java/mekanism/common/item/ItemJetpack.java index d7df95a4e..0fd82bbd1 100644 --- a/src/main/java/mekanism/common/item/ItemJetpack.java +++ b/src/main/java/mekanism/common/item/ItemJetpack.java @@ -39,9 +39,8 @@ public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor { public int TRANSFER_RATE = 16; public ItemJetpack() { - super(EnumHelper - .addArmorMaterial("JETPACK", "jetpack", 0, new int[]{0, 0, 0, 0}, 0, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, - 0), 0, EntityEquipmentSlot.CHEST); + super(EnumHelper.addArmorMaterial("JETPACK", "jetpack", 0, new int[]{0, 0, 0, 0}, 0, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, + 0), 0, EntityEquipmentSlot.CHEST); setCreativeTab(Mekanism.tabMekanism); } @@ -68,12 +67,9 @@ public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor { if (gasStack == null) { list.add(LangUtils.localize("tooltip.noGas") + "."); } else { - list.add(LangUtils.localize("tooltip.stored") + " " + gasStack.getGas().getLocalizedName() + ": " - + gasStack.amount); + list.add(LangUtils.localize("tooltip.stored") + " " + gasStack.getGas().getLocalizedName() + ": " + gasStack.amount); } - - list.add(EnumColor.GREY + LangUtils.localize("tooltip.mode") + ": " + EnumColor.GREY + getMode(itemstack) - .getName()); + list.add(EnumColor.GREY + LangUtils.localize("tooltip.mode") + ": " + EnumColor.GREY + getMode(itemstack).getName()); } @Override @@ -88,16 +84,13 @@ public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor { @Override @SideOnly(Side.CLIENT) - public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, - ModelBiped _default) { + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, ModelBiped _default) { ModelCustomArmor model = ModelCustomArmor.INSTANCE; - if (this == MekanismItems.Jetpack) { model.modelType = ArmorModel.JETPACK; } else if (this == MekanismItems.ArmoredJetpack) { model.modelType = ArmorModel.ARMOREDJETPACK; } - return model; } @@ -124,14 +117,11 @@ public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor { if (getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas()) { return 0; } - if (stack.getGas() != MekanismFluids.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; } @@ -174,7 +164,6 @@ 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); - ItemDataUtils.setCompound(itemstack, "stored", gasStack.write(new NBTTagCompound())); } } @@ -208,7 +197,6 @@ public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor { return new ArmorProperties(1, MekanismConfig.current().general.armoredJetpackDamageRatio.val(), MekanismConfig.current().general.armoredJetpackDamageMax.val()); } - return new ArmorProperties(0, 0, 0); } @@ -219,13 +207,11 @@ public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor { } else if (armor.getItem() == MekanismItems.ArmoredJetpack) { return 12; } - return 0; } @Override - public void damageArmor(EntityLivingBase entity, @Nonnull ItemStack stack, DamageSource source, int damage, - int slot) { + public void damageArmor(EntityLivingBase entity, @Nonnull ItemStack stack, DamageSource source, int damage, int slot) { } public enum JetpackMode { @@ -249,4 +235,4 @@ public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor { return color + LangUtils.localize(unlocalized); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemMekanism.java b/src/main/java/mekanism/common/item/ItemMekanism.java index 0ed441824..1c4bf2f67 100644 --- a/src/main/java/mekanism/common/item/ItemMekanism.java +++ b/src/main/java/mekanism/common/item/ItemMekanism.java @@ -9,4 +9,4 @@ public class ItemMekanism extends Item { super(); setCreativeTab(Mekanism.tabMekanism); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemNetworkReader.java b/src/main/java/mekanism/common/item/ItemNetworkReader.java index ac8226921..210b48038 100644 --- a/src/main/java/mekanism/common/item/ItemNetworkReader.java +++ b/src/main/java/mekanism/common/item/ItemNetworkReader.java @@ -33,137 +33,79 @@ public class ItemNetworkReader extends ItemEnergized { @Nonnull @Override - public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, - float hitY, float hitZ, EnumHand hand) { + public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); - if (!world.isRemote) { TileEntity tileEntity = world.getTileEntity(pos); boolean drain = !player.capabilities.isCreativeMode; - if (getEnergy(stack) >= ENERGY_PER_USE && tileEntity != null) { - if (CapabilityUtils - .hasCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, side.getOpposite())) { + if (CapabilityUtils.hasCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, side.getOpposite())) { if (drain) { setEnergy(stack, getEnergy(stack) - ENERGY_PER_USE); } + IGridTransmitter transmitter = CapabilityUtils.getCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, side.getOpposite()); - IGridTransmitter transmitter = CapabilityUtils - .getCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, side.getOpposite()); + player.sendMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + Mekanism.LOG_TAG + EnumColor.GREY + " -------------")); + player.sendMessage(new TextComponentString(EnumColor.GREY + " *Transmitters: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetworkSize())); + player.sendMessage(new TextComponentString(EnumColor.GREY + " *Acceptors: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetworkAcceptorSize())); + player.sendMessage(new TextComponentString(EnumColor.GREY + " *Needed: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetworkNeeded())); + player.sendMessage(new TextComponentString(EnumColor.GREY + " *Buffer: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetworkBuffer())); + player.sendMessage(new TextComponentString(EnumColor.GREY + " *Throughput: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetworkFlow())); + player.sendMessage(new TextComponentString(EnumColor.GREY + " *Capacity: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetworkCapacity())); - player.sendMessage(new TextComponentString( - EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + Mekanism.LOG_TAG + EnumColor.GREY - + " -------------")); - player.sendMessage(new TextComponentString( - EnumColor.GREY + " *Transmitters: " + EnumColor.DARK_GREY + transmitter - .getTransmitterNetworkSize())); - player.sendMessage(new TextComponentString( - EnumColor.GREY + " *Acceptors: " + EnumColor.DARK_GREY + transmitter - .getTransmitterNetworkAcceptorSize())); - player.sendMessage(new TextComponentString( - EnumColor.GREY + " *Needed: " + EnumColor.DARK_GREY + transmitter - .getTransmitterNetworkNeeded())); - player.sendMessage(new TextComponentString( - EnumColor.GREY + " *Buffer: " + EnumColor.DARK_GREY + transmitter - .getTransmitterNetworkBuffer())); - player.sendMessage(new TextComponentString( - EnumColor.GREY + " *Throughput: " + EnumColor.DARK_GREY + transmitter - .getTransmitterNetworkFlow())); - player.sendMessage(new TextComponentString( - EnumColor.GREY + " *Capacity: " + EnumColor.DARK_GREY + transmitter - .getTransmitterNetworkCapacity())); - - if (CapabilityUtils - .hasCapability(tileEntity, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite())) { - IHeatTransfer transfer = CapabilityUtils - .getCapability(tileEntity, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite()); - player.sendMessage(new TextComponentString( - EnumColor.GREY + " *Temperature: " + EnumColor.DARK_GREY + transfer.getTemp() - + "K above ambient")); + if (CapabilityUtils.hasCapability(tileEntity, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite())) { + IHeatTransfer transfer = CapabilityUtils.getCapability(tileEntity, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite()); + player.sendMessage(new TextComponentString(EnumColor.GREY + " *Temperature: " + EnumColor.DARK_GREY + transfer.getTemp() + "K above ambient")); } - player.sendMessage(new TextComponentString( - EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY - + " -------------")); - + player.sendMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); return EnumActionResult.SUCCESS; - } else if (CapabilityUtils - .hasCapability(tileEntity, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite())) { + } else if (CapabilityUtils.hasCapability(tileEntity, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite())) { if (drain) { setEnergy(stack, getEnergy(stack) - ENERGY_PER_USE); } - IHeatTransfer transfer = CapabilityUtils - .getCapability(tileEntity, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite()); - player.sendMessage(new TextComponentString( - EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + Mekanism.LOG_TAG + EnumColor.GREY - + " -------------")); - player.sendMessage(new TextComponentString( - EnumColor.GREY + " *Temperature: " + EnumColor.DARK_GREY + transfer.getTemp() - + "K above ambient")); - player.sendMessage(new TextComponentString( - EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY - + " -------------")); - + IHeatTransfer transfer = CapabilityUtils.getCapability(tileEntity, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite()); + player.sendMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + Mekanism.LOG_TAG + EnumColor.GREY + " -------------")); + player.sendMessage(new TextComponentString(EnumColor.GREY + " *Temperature: " + EnumColor.DARK_GREY + transfer.getTemp() + "K above ambient")); + player.sendMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); return EnumActionResult.SUCCESS; } else { if (drain) { setEnergy(stack, getEnergy(stack) - ENERGY_PER_USE); } - Set iteratedNetworks = new HashSet<>(); for (EnumFacing iterSide : EnumFacing.VALUES) { Coord4D coord = Coord4D.get(tileEntity).offset(iterSide); - TileEntity tile = coord.getTileEntity(world); + if (CapabilityUtils.hasCapability(tile, Capabilities.GRID_TRANSMITTER_CAPABILITY, iterSide.getOpposite())) { + IGridTransmitter transmitter = CapabilityUtils.getCapability(tile, Capabilities.GRID_TRANSMITTER_CAPABILITY, iterSide.getOpposite()); - if (CapabilityUtils - .hasCapability(tile, Capabilities.GRID_TRANSMITTER_CAPABILITY, iterSide.getOpposite())) { - IGridTransmitter transmitter = CapabilityUtils - .getCapability(tile, Capabilities.GRID_TRANSMITTER_CAPABILITY, - iterSide.getOpposite()); - - if (transmitter.getTransmitterNetwork().getPossibleAcceptors() - .contains(coord.offset(iterSide.getOpposite())) && !iteratedNetworks - .contains(transmitter.getTransmitterNetwork())) { - player.sendMessage(new TextComponentString( - EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[" + transmitter - .getTransmissionType().getName() + "]" + EnumColor.GREY - + " -------------")); - player.sendMessage(new TextComponentString( - EnumColor.GREY + " *Connected sides: " + EnumColor.DARK_GREY + transmitter - .getTransmitterNetwork().getAcceptorDirections() - .get(coord.offset(iterSide.getOpposite())))); - player.sendMessage(new TextComponentString( - EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" - + EnumColor.GREY + " -------------")); - + if (transmitter.getTransmitterNetwork().getPossibleAcceptors().contains(coord.offset(iterSide.getOpposite())) && + !iteratedNetworks.contains(transmitter.getTransmitterNetwork())) { + player.sendMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[" + + transmitter.getTransmissionType().getName() + "]" + EnumColor.GREY + " -------------")); + player.sendMessage(new TextComponentString(EnumColor.GREY + " *Connected sides: " + EnumColor.DARK_GREY + + transmitter.getTransmitterNetwork().getAcceptorDirections().get(coord.offset(iterSide.getOpposite())))); + player.sendMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); iteratedNetworks.add(transmitter.getTransmitterNetwork()); } } } - return EnumActionResult.SUCCESS; } } if (player.isSneaking() && MekanismAPI.debug) { String[] strings = TransmitterNetworkRegistry.getInstance().toStrings(); - player.sendMessage(new TextComponentString( - EnumColor.GREY + "---------- " + EnumColor.DARK_BLUE + "[Mekanism Debug]" + EnumColor.GREY - + " ----------")); - + player.sendMessage(new TextComponentString(EnumColor.GREY + "---------- " + EnumColor.DARK_BLUE + "[Mekanism Debug]" + EnumColor.GREY + " ----------")); for (String s : strings) { player.sendMessage(new TextComponentString(EnumColor.DARK_GREY + s)); } - - player.sendMessage(new TextComponentString( - EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY - + " -------------")); + player.sendMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); } } - return EnumActionResult.PASS; } @@ -171,4 +113,4 @@ public class ItemNetworkReader extends ItemEnergized { public boolean canSend(ItemStack itemstack) { return false; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemNugget.java b/src/main/java/mekanism/common/item/ItemNugget.java index 09b695735..b9a1ff3f3 100644 --- a/src/main/java/mekanism/common/item/ItemNugget.java +++ b/src/main/java/mekanism/common/item/ItemNugget.java @@ -26,11 +26,10 @@ public class ItemNugget extends ItemMekanism implements IMetaItem { @Override public void getSubItems(@Nonnull CreativeTabs tabs, @Nonnull NonNullList itemList) { - if (!isInCreativeTab(tabs)) { - return; - } - for (int counter = 0; counter < ItemIngot.en_USNames.length; counter++) { - itemList.add(new ItemStack(this, 1, counter)); + if (isInCreativeTab(tabs)) { + for (int counter = 0; counter < ItemIngot.en_USNames.length; counter++) { + itemList.add(new ItemStack(this, 1, counter)); + } } } @@ -39,4 +38,4 @@ public class ItemNugget extends ItemMekanism implements IMetaItem { public String getTranslationKey(ItemStack item) { return "item." + ItemIngot.en_USNames[item.getItemDamage()].toLowerCase(Locale.ROOT) + "Nugget"; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemOtherDust.java b/src/main/java/mekanism/common/item/ItemOtherDust.java index c6aa488db..1f9a99f60 100644 --- a/src/main/java/mekanism/common/item/ItemOtherDust.java +++ b/src/main/java/mekanism/common/item/ItemOtherDust.java @@ -9,8 +9,7 @@ import net.minecraft.util.NonNullList; public class ItemOtherDust extends ItemMekanism implements IMetaItem { - public static String[] subtypes = {"Diamond", "Steel", "null", "Sulfur", - "Lithium", "RefinedObsidian", "Obsidian"}; + public static String[] subtypes = {"Diamond", "Steel", "null", "Sulfur", "Lithium", "RefinedObsidian", "Obsidian"}; public ItemOtherDust() { super(); @@ -22,7 +21,6 @@ public class ItemOtherDust extends ItemMekanism implements IMetaItem { if (meta == 2) { return null; } - return subtypes[meta] + "Dust"; } @@ -33,12 +31,11 @@ public class ItemOtherDust extends ItemMekanism implements IMetaItem { @Override public void getSubItems(@Nonnull CreativeTabs tabs, @Nonnull NonNullList itemList) { - if (!isInCreativeTab(tabs)) { - return; - } - for (int counter = 0; counter < subtypes.length; counter++) { - if (counter != 2) { - itemList.add(new ItemStack(this, 1, counter)); + if (isInCreativeTab(tabs)) { + for (int counter = 0; counter < subtypes.length; counter++) { + if (counter != 2) { + itemList.add(new ItemStack(this, 1, counter)); + } } } } @@ -48,4 +45,4 @@ public class ItemOtherDust extends ItemMekanism implements IMetaItem { public String getTranslationKey(ItemStack item) { return "item." + subtypes[item.getItemDamage()].toLowerCase(Locale.ROOT) + "Dust"; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemPortableTeleporter.java b/src/main/java/mekanism/common/item/ItemPortableTeleporter.java index be9f2c850..86dc6321a 100644 --- a/src/main/java/mekanism/common/item/ItemPortableTeleporter.java +++ b/src/main/java/mekanism/common/item/ItemPortableTeleporter.java @@ -38,32 +38,25 @@ public class ItemPortableTeleporter extends ItemEnergized implements IOwnerItem if (coords == null) { return 0; } - int neededEnergy = MekanismConfig.current().usage.teleporterBase.val(); - if (entity.world.provider.getDimension() != coords.dimensionId) { neededEnergy += MekanismConfig.current().usage.teleporterDimensionPenalty.val(); } else { int distance = (int) entity.getDistance(coords.x, coords.y, coords.z); - neededEnergy += (distance * MekanismConfig.current().usage.teleporterDistance.val()); + neededEnergy += distance * MekanismConfig.current().usage.teleporterDistance.val(); } - return neededEnergy; } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, World world, List list, ITooltipFlag flag) { - list.add(SecurityUtils.getOwnerDisplay(Minecraft.getMinecraft().player, - MekanismClient.clientUUIDMap.get(getOwnerUUID(itemstack)))); - + list.add(SecurityUtils.getOwnerDisplay(Minecraft.getMinecraft().player, MekanismClient.clientUUIDMap.get(getOwnerUUID(itemstack)))); if (getFrequency(itemstack) != null) { - list.add(EnumColor.INDIGO + LangUtils.localize("gui.frequency") + ": " + EnumColor.GREY + getFrequency( - itemstack).name); - list.add(EnumColor.INDIGO + LangUtils.localize("gui.mode") + ": " + EnumColor.GREY + LangUtils - .localize("gui." + (!getFrequency(itemstack).publicFreq ? "private" : "public"))); + list.add(EnumColor.INDIGO + LangUtils.localize("gui.frequency") + ": " + EnumColor.GREY + getFrequency(itemstack).name); + list.add(EnumColor.INDIGO + LangUtils.localize("gui.mode") + ": " + EnumColor.GREY + + LangUtils.localize("gui." + (!getFrequency(itemstack).publicFreq ? "private" : "public"))); } - super.addInformation(itemstack, world, list, flag); } @@ -71,24 +64,17 @@ public class ItemPortableTeleporter extends ItemEnergized implements IOwnerItem @Override public ActionResult onItemRightClick(World world, EntityPlayer entityplayer, @Nonnull EnumHand hand) { ItemStack itemstack = entityplayer.getHeldItem(hand); - if (!world.isRemote) { if (getOwnerUUID(itemstack) == null) { setOwnerUUID(itemstack, entityplayer.getUniqueID()); - Mekanism.packetHandler - .sendToAll(new SecurityUpdateMessage(SecurityPacket.UPDATE, entityplayer.getUniqueID(), null)); - entityplayer.sendMessage(new TextComponentString( - EnumColor.DARK_BLUE + Mekanism.LOG_TAG + " " + EnumColor.GREY + LangUtils - .localize("gui.nowOwn"))); + Mekanism.packetHandler.sendToAll(new SecurityUpdateMessage(SecurityPacket.UPDATE, entityplayer.getUniqueID(), null)); + entityplayer.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + Mekanism.LOG_TAG + " " + EnumColor.GREY + LangUtils.localize("gui.nowOwn"))); + } else if (SecurityUtils.canAccess(entityplayer, itemstack)) { + entityplayer.openGui(Mekanism.instance, 14, world, hand.ordinal(), 0, 0); } else { - if (SecurityUtils.canAccess(entityplayer, itemstack)) { - entityplayer.openGui(Mekanism.instance, 14, world, hand.ordinal(), 0, 0); - } else { - SecurityUtils.displayNoAccess(entityplayer); - } + SecurityUtils.displayNoAccess(entityplayer); } } - return new ActionResult<>(EnumActionResult.SUCCESS, itemstack); } @@ -102,19 +88,16 @@ public class ItemPortableTeleporter extends ItemEnergized implements IOwnerItem if (ItemDataUtils.hasData(stack, "ownerUUID")) { return UUID.fromString(ItemDataUtils.getString(stack, "ownerUUID")); } - return null; } @Override public void setOwnerUUID(ItemStack stack, UUID owner) { setFrequency(stack, null); - if (owner == null) { ItemDataUtils.removeData(stack, "ownerUUID"); return; } - ItemDataUtils.setString(stack, "ownerUUID", owner.toString()); } @@ -127,7 +110,6 @@ public class ItemPortableTeleporter extends ItemEnergized implements IOwnerItem if (ItemDataUtils.hasData(stack, "frequency")) { return Frequency.Identity.load(ItemDataUtils.getCompound(stack, "frequency")); } - return null; } @@ -136,7 +118,6 @@ public class ItemPortableTeleporter extends ItemEnergized implements IOwnerItem ItemDataUtils.removeData(stack, "frequency"); return; } - ItemDataUtils.setCompound(stack, "frequency", frequency.getIdentity().serialize()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemProxy.java b/src/main/java/mekanism/common/item/ItemProxy.java index 60a1689cb..721673b01 100644 --- a/src/main/java/mekanism/common/item/ItemProxy.java +++ b/src/main/java/mekanism/common/item/ItemProxy.java @@ -41,7 +41,6 @@ public class ItemProxy extends Item { if (ItemDataUtils.getBoolean(stack, "hasStack")) { return new ItemStack(ItemDataUtils.getCompound(stack, "savedItem")); } - return ItemStack.EMPTY; } @@ -49,13 +48,11 @@ public class ItemProxy extends Item { public void onUpdate(ItemStack stacks, World world, Entity entity, int j, boolean flag) { if (entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; - for (int i = 0; i < player.inventory.mainInventory.size(); i++) { - if (!player.inventory.mainInventory.get(i).isEmpty() - && player.inventory.mainInventory.get(i).getItem() == this) { + if (!player.inventory.mainInventory.get(i).isEmpty() && player.inventory.mainInventory.get(i).getItem() == this) { player.inventory.mainInventory.remove(i); } } } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemRobit.java b/src/main/java/mekanism/common/item/ItemRobit.java index fdcd8d790..a69e5b996 100644 --- a/src/main/java/mekanism/common/item/ItemRobit.java +++ b/src/main/java/mekanism/common/item/ItemRobit.java @@ -32,41 +32,31 @@ public class ItemRobit extends ItemEnergized implements ISustainedInventory { @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, World world, List list, ITooltipFlag flag) { super.addInformation(itemstack, world, list, flag); - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.name") + ": " + EnumColor.GREY + getName(itemstack)); - list.add(EnumColor.AQUA + LangUtils.localize("tooltip.inventory") + ": " + EnumColor.GREY + ( - getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0)); + list.add(EnumColor.AQUA + LangUtils.localize("tooltip.inventory") + ": " + EnumColor.GREY + (getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0)); } @Nonnull @Override - public EnumActionResult onItemUse(EntityPlayer entityplayer, World world, BlockPos pos, EnumHand hand, - EnumFacing side, float posX, float posY, float posZ) { + public EnumActionResult onItemUse(EntityPlayer entityplayer, World world, BlockPos pos, EnumHand hand, EnumFacing side, float posX, float posY, float posZ) { TileEntity tileEntity = world.getTileEntity(pos); ItemStack itemstack = entityplayer.getHeldItem(hand); - if (tileEntity instanceof TileEntityChargepad) { TileEntityChargepad chargepad = (TileEntityChargepad) tileEntity; - if (!chargepad.isActive) { if (!world.isRemote) { EntityRobit robit = new EntityRobit(world, pos.getX() + 0.5, pos.getY() + 0.1, pos.getZ() + 0.5); - robit.setHome(Coord4D.get(chargepad)); robit.setEnergy(getEnergy(itemstack)); robit.setOwnerUUID(entityplayer.getUniqueID()); robit.setInventory(getInventory(itemstack)); robit.setCustomNameTag(getName(itemstack)); - world.spawnEntity(robit); } - entityplayer.setHeldItem(hand, ItemStack.EMPTY); - return EnumActionResult.SUCCESS; } } - return EnumActionResult.PASS; } @@ -81,7 +71,6 @@ public class ItemRobit extends ItemEnergized implements ISustainedInventory { public String getName(ItemStack itemstack) { String name = ItemDataUtils.getString(itemstack, "name"); - return name.isEmpty() ? "Robit" : name; } @@ -97,7 +86,6 @@ public class ItemRobit extends ItemEnergized implements ISustainedInventory { if (data[0] instanceof ItemStack) { return ItemDataUtils.getList((ItemStack) data[0], "Items"); } - return null; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemScubaTank.java b/src/main/java/mekanism/common/item/ItemScubaTank.java index c35cfcc86..564c6f27a 100644 --- a/src/main/java/mekanism/common/item/ItemScubaTank.java +++ b/src/main/java/mekanism/common/item/ItemScubaTank.java @@ -44,16 +44,12 @@ public class ItemScubaTank extends ItemArmor implements IGasItem { @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, World world, List list, ITooltipFlag flag) { GasStack gasStack = getGas(itemstack); - if (gasStack == null) { list.add(LangUtils.localize("tooltip.noGas") + "."); } else { - list.add(LangUtils.localize("tooltip.stored") + " " + gasStack.getGas().getLocalizedName() + ": " - + gasStack.amount); + list.add(LangUtils.localize("tooltip.stored") + " " + gasStack.getGas().getLocalizedName() + ": " + gasStack.amount); } - - list.add(EnumColor.GREY + LangUtils.localize("tooltip.flowing") + ": " + (getFlowing(itemstack) - ? EnumColor.DARK_GREEN : EnumColor.DARK_RED) + getFlowingStr(itemstack)); + list.add(EnumColor.GREY + LangUtils.localize("tooltip.flowing") + ": " + (getFlowing(itemstack) ? EnumColor.DARK_GREEN : EnumColor.DARK_RED) + getFlowingStr(itemstack)); } @Override @@ -83,8 +79,7 @@ public class ItemScubaTank extends ItemArmor implements IGasItem { @Override @SideOnly(Side.CLIENT) - public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, - ModelBiped _default) { + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, ModelBiped _default) { ModelCustomArmor model = ModelCustomArmor.INSTANCE; model.modelType = ArmorModel.SCUBATANK; return model; @@ -98,12 +93,9 @@ public class ItemScubaTank extends ItemArmor implements IGasItem { if (getGas(itemstack) == null) { 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); } @@ -122,14 +114,11 @@ public class ItemScubaTank extends ItemArmor implements IGasItem { if (getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas()) { return 0; } - if (stack.getGas() != MekanismFluids.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; } @@ -152,7 +141,6 @@ public class ItemScubaTank extends ItemArmor implements IGasItem { public String getFlowingStr(ItemStack stack) { boolean flowing = getFlowing(stack); - return LangUtils.localize("tooltip." + (flowing ? "yes" : "no")); } @@ -182,7 +170,6 @@ 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); - ItemDataUtils.setCompound(itemstack, "stored", gasStack.write(new NBTTagCompound())); } } @@ -190,7 +177,6 @@ public class ItemScubaTank extends ItemArmor implements IGasItem { public ItemStack getEmptyItem() { ItemStack empty = new ItemStack(this); setGas(empty, null); - return empty; } @@ -202,9 +188,8 @@ public class ItemScubaTank extends ItemArmor implements IGasItem { ItemStack empty = new ItemStack(this); setGas(empty, null); list.add(empty); - ItemStack filled = new ItemStack(this); setGas(filled, new GasStack(MekanismFluids.Oxygen, ((IGasItem) filled.getItem()).getMaxGas(filled))); list.add(filled); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemSeismicReader.java b/src/main/java/mekanism/common/item/ItemSeismicReader.java index a3aecf781..59738e32a 100644 --- a/src/main/java/mekanism/common/item/ItemSeismicReader.java +++ b/src/main/java/mekanism/common/item/ItemSeismicReader.java @@ -35,14 +35,11 @@ public class ItemSeismicReader extends ItemEnergized { @Override public void addInformation(ItemStack itemstack, World world, List list, ITooltipFlag flag) { if (!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) { - list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.INDIGO + GameSettings - .getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils - .localize("tooltip.forDetails") + "."); - list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + GameSettings - .getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils - .localize("tooltip.and") + " " + EnumColor.AQUA + GameSettings - .getKeyDisplayString(MekanismKeyHandler.modeSwitchKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils - .localize("tooltip.forDesc") + "."); + list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.INDIGO + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + "."); + list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + + EnumColor.GREY + " " + LangUtils.localize("tooltip.and") + " " + EnumColor.AQUA + + GameSettings.getKeyDisplayString(MekanismKeyHandler.modeSwitchKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDesc") + "."); } else if (!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.modeSwitchKey)) { super.addInformation(itemstack, world, list, flag); } else { @@ -58,28 +55,22 @@ public class ItemSeismicReader extends ItemEnergized { if (getEnergy(itemstack) < ENERGY_USAGE && !entityplayer.capabilities.isCreativeMode) { if (!world.isRemote) { - entityplayer.sendMessage(new TextComponentString( - EnumColor.DARK_BLUE + Mekanism.LOG_TAG + " " + EnumColor.RED + LangUtils - .localize("tooltip.seismicReader.needsEnergy"))); + entityplayer.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + Mekanism.LOG_TAG + " " + EnumColor.RED + + LangUtils.localize("tooltip.seismicReader.needsEnergy"))); } return new ActionResult<>(EnumActionResult.SUCCESS, itemstack); } else if (!MekanismUtils.isChunkVibrated(chunk)) { if (!world.isRemote) { - entityplayer.sendMessage(new TextComponentString( - EnumColor.DARK_BLUE + Mekanism.LOG_TAG + " " + EnumColor.RED + LangUtils - .localize("tooltip.seismicReader.noVibrations"))); + entityplayer.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + Mekanism.LOG_TAG + " " + EnumColor.RED + + LangUtils.localize("tooltip.seismicReader.noVibrations"))); } - return new ActionResult<>(EnumActionResult.SUCCESS, itemstack); } - if (!entityplayer.capabilities.isCreativeMode) { setEnergy(itemstack, getEnergy(itemstack) - ENERGY_USAGE); } - entityplayer.openGui(Mekanism.instance, 38, world, hand.ordinal(), 0, 0); - return new ActionResult<>(EnumActionResult.PASS, itemstack); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemShard.java b/src/main/java/mekanism/common/item/ItemShard.java index 3db4f77ca..fa84aadb2 100644 --- a/src/main/java/mekanism/common/item/ItemShard.java +++ b/src/main/java/mekanism/common/item/ItemShard.java @@ -27,11 +27,10 @@ public class ItemShard extends ItemMekanism implements IMetaItem { @Override public void getSubItems(@Nonnull CreativeTabs tabs, @Nonnull NonNullList itemList) { - if (!isInCreativeTab(tabs)) { - return; - } - for (int counter = 0; counter < Resource.values().length; counter++) { - itemList.add(new ItemStack(this, 1, counter)); + if (isInCreativeTab(tabs)) { + for (int counter = 0; counter < Resource.values().length; counter++) { + itemList.add(new ItemStack(this, 1, counter)); + } } } @@ -41,7 +40,6 @@ public class ItemShard extends ItemMekanism implements IMetaItem { if (item.getItemDamage() <= Resource.values().length - 1) { return "item." + Resource.values()[item.getItemDamage()].getName().toLowerCase(Locale.ROOT) + "Shard"; } - return "Invalid"; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemTierInstaller.java b/src/main/java/mekanism/common/item/ItemTierInstaller.java index 7a9b4530d..6a820a1bb 100644 --- a/src/main/java/mekanism/common/item/ItemTierInstaller.java +++ b/src/main/java/mekanism/common/item/ItemTierInstaller.java @@ -2,9 +2,9 @@ package mekanism.common.item; import java.util.Locale; import javax.annotation.Nonnull; -import mekanism.common.tier.BaseTier; import mekanism.common.base.IMetaItem; import mekanism.common.base.ITierUpgradeable; +import mekanism.common.tier.BaseTier; import mekanism.common.tile.prefab.TileEntityBasicBlock; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -27,32 +27,25 @@ public class ItemTierInstaller extends ItemMekanism implements IMetaItem { @Nonnull @Override - public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, - float hitY, float hitZ, EnumHand hand) { + public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { if (world.isRemote) { return EnumActionResult.PASS; } - TileEntity tile = world.getTileEntity(pos); ItemStack stack = player.getHeldItem(hand); BaseTier tier = BaseTier.values()[stack.getItemDamage()]; - if (tile instanceof ITierUpgradeable) { if (tile instanceof TileEntityBasicBlock && ((TileEntityBasicBlock) tile).playersUsing.size() > 0) { return EnumActionResult.FAIL; } - if (((ITierUpgradeable) tile).upgrade(tier)) { if (!player.capabilities.isCreativeMode) { stack.shrink(1); } - return EnumActionResult.SUCCESS; } - return EnumActionResult.PASS; } - return EnumActionResult.PASS; } @@ -68,12 +61,11 @@ public class ItemTierInstaller extends ItemMekanism implements IMetaItem { @Override public void getSubItems(@Nonnull CreativeTabs tabs, @Nonnull NonNullList itemList) { - if (!isInCreativeTab(tabs)) { - return; - } - for (BaseTier tier : BaseTier.values()) { - if (tier.isObtainable()) { - itemList.add(new ItemStack(this, 1, tier.ordinal())); + if (isInCreativeTab(tabs)) { + for (BaseTier tier : BaseTier.values()) { + if (tier.isObtainable()) { + itemList.add(new ItemStack(this, 1, tier.ordinal())); + } } } } @@ -81,7 +73,6 @@ public class ItemTierInstaller extends ItemMekanism implements IMetaItem { @Nonnull @Override public String getTranslationKey(ItemStack item) { - return "item." + BaseTier.values()[item.getItemDamage()].getSimpleName().toLowerCase(Locale.ROOT) - + "TierInstaller"; + return "item." + BaseTier.values()[item.getItemDamage()].getSimpleName().toLowerCase(Locale.ROOT) + "TierInstaller"; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemUpgrade.java b/src/main/java/mekanism/common/item/ItemUpgrade.java index e4d79a6c0..7fad719d3 100644 --- a/src/main/java/mekanism/common/item/ItemUpgrade.java +++ b/src/main/java/mekanism/common/item/ItemUpgrade.java @@ -36,9 +36,7 @@ public class ItemUpgrade extends ItemMekanism implements IUpgradeItem { @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, World world, List list, ITooltipFlag flag) { if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - list.add( - LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + "shift" + EnumColor.GREY + " " + LangUtils - .localize("tooltip.forDetails")); + list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + "shift" + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails")); } else { list.addAll(MekanismUtils.splitTooltip(getUpgradeType(itemstack).getDescription(), itemstack)); } @@ -51,27 +49,22 @@ public class ItemUpgrade extends ItemMekanism implements IUpgradeItem { @Nonnull @Override - public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, - float hitY, float hitZ, EnumHand hand) { + public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { if (player.isSneaking()) { TileEntity tile = world.getTileEntity(pos); ItemStack stack = player.getHeldItem(hand); Upgrade type = getUpgradeType(stack); - if (tile instanceof IUpgradeTile) { TileComponentUpgrade component = ((IUpgradeTile) tile).getComponent(); - if (component.supports(type)) { if (!world.isRemote && component.getUpgrades(type) < type.getMax()) { component.addUpgrade(type); stack.shrink(1); } } - return EnumActionResult.SUCCESS; } } - return EnumActionResult.PASS; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemWalkieTalkie.java b/src/main/java/mekanism/common/item/ItemWalkieTalkie.java index 29d5b1bd1..c78653c9c 100644 --- a/src/main/java/mekanism/common/item/ItemWalkieTalkie.java +++ b/src/main/java/mekanism/common/item/ItemWalkieTalkie.java @@ -34,9 +34,7 @@ public class ItemWalkieTalkie extends ItemMekanism implements IItemNetwork { } public static ModelResourceLocation getModel(int channel) { - CHANNEL_MODELS - .computeIfAbsent(channel, c -> new ModelResourceLocation("mekanism:WalkieTalkie_ch" + c, "inventory")); - + CHANNEL_MODELS.computeIfAbsent(channel, c -> new ModelResourceLocation("mekanism:WalkieTalkie_ch" + c, "inventory")); return CHANNEL_MODELS.get(channel); } @@ -44,11 +42,8 @@ public class ItemWalkieTalkie extends ItemMekanism implements IItemNetwork { @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, World world, List list, ITooltipFlag flag) { super.addInformation(itemstack, world, list, flag); - - list.add((getOn(itemstack) ? EnumColor.DARK_GREEN : EnumColor.DARK_RED) + LangUtils - .localize("gui." + (getOn(itemstack) ? "on" : "off"))); - list.add(EnumColor.DARK_AQUA + LangUtils.localize("tooltip.channel") + ": " + EnumColor.GREY + getChannel( - itemstack)); + list.add((getOn(itemstack) ? EnumColor.DARK_GREEN : EnumColor.DARK_RED) + LangUtils.localize("gui." + (getOn(itemstack) ? "on" : "off"))); + list.add(EnumColor.DARK_AQUA + LangUtils.localize("tooltip.channel") + ": " + EnumColor.GREY + getChannel(itemstack)); if (!MekanismConfig.current().general.voiceServerEnabled.val()) { list.add(EnumColor.DARK_RED + LangUtils.localize("tooltip.walkie_disabled")); } @@ -58,13 +53,10 @@ public class ItemWalkieTalkie extends ItemMekanism implements IItemNetwork { @Override public ActionResult onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { ItemStack itemStack = player.getHeldItem(hand); - if (player.isSneaking()) { setOn(itemStack, !getOn(itemStack)); - return new ActionResult<>(EnumActionResult.SUCCESS, itemStack); } - return new ActionResult<>(EnumActionResult.PASS, itemStack); } @@ -87,12 +79,10 @@ public class ItemWalkieTalkie extends ItemMekanism implements IItemNetwork { public int getChannel(ItemStack itemStack) { int channel = ItemDataUtils.getInt(itemStack, "channel"); - if (channel == 0) { setChannel(itemStack, 1); channel = 1; } - return channel; } @@ -103,4 +93,4 @@ public class ItemWalkieTalkie extends ItemMekanism implements IItemNetwork { setChannel(stack, channel); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/multiblock/IMultiblock.java b/src/main/java/mekanism/common/multiblock/IMultiblock.java index 14147949c..6eddef52e 100644 --- a/src/main/java/mekanism/common/multiblock/IMultiblock.java +++ b/src/main/java/mekanism/common/multiblock/IMultiblock.java @@ -11,4 +11,4 @@ public interface IMultiblock> { boolean onActivate(EntityPlayer player, EnumHand hand, ItemStack stack); void doUpdate(); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/multiblock/IStructuralMultiblock.java b/src/main/java/mekanism/common/multiblock/IStructuralMultiblock.java index ad974e611..3800a1af9 100644 --- a/src/main/java/mekanism/common/multiblock/IStructuralMultiblock.java +++ b/src/main/java/mekanism/common/multiblock/IStructuralMultiblock.java @@ -15,4 +15,4 @@ public interface IStructuralMultiblock { void setController(Coord4D coord); void doUpdate(); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/multiblock/MultiblockCache.java b/src/main/java/mekanism/common/multiblock/MultiblockCache.java index 53b41ddee..247e62a36 100644 --- a/src/main/java/mekanism/common/multiblock/MultiblockCache.java +++ b/src/main/java/mekanism/common/multiblock/MultiblockCache.java @@ -15,4 +15,4 @@ public abstract class MultiblockCache> { public abstract void load(NBTTagCompound nbtTags); public abstract void save(NBTTagCompound nbtTags); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/multiblock/MultiblockManager.java b/src/main/java/mekanism/common/multiblock/MultiblockManager.java index 77a57770f..d58aa7bdd 100644 --- a/src/main/java/mekanism/common/multiblock/MultiblockManager.java +++ b/src/main/java/mekanism/common/multiblock/MultiblockManager.java @@ -42,7 +42,6 @@ public class MultiblockManager> { if (!(tile1 instanceof TileEntityMultiblock) || !(tile2 instanceof TileEntityMultiblock)) { return false; } - return ((TileEntityMultiblock) tile1).getManager() == ((TileEntityMultiblock) tile2).getManager(); } @@ -56,23 +55,20 @@ public class MultiblockManager> { * 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 + * @param id - inventory ID to pull + * * @return correct multiblock inventory cache */ public MultiblockCache pullInventory(World world, String id) { MultiblockCache toReturn = inventories.get(id); - for (Coord4D obj : inventories.get(id).locations) { TileEntityMultiblock tileEntity = (TileEntityMultiblock) obj.getTileEntity(world); - if (tileEntity != null) { tileEntity.cachedData = tileEntity.getNewCache(); tileEntity.cachedID = null; } } - inventories.remove(id); - return toReturn; } @@ -88,38 +84,30 @@ public class MultiblockManager> { public void tickSelf(World world) { ArrayList idsToKill = new ArrayList<>(); HashMap> tilesToKill = new HashMap<>(); - for (Map.Entry> entry : inventories.entrySet()) { String inventoryID = entry.getKey(); - for (Coord4D obj : entry.getValue().locations) { if (obj.dimensionId == world.provider.getDimension() && obj.exists(world)) { TileEntity tileEntity = obj.getTileEntity(world); - if (!(tileEntity instanceof TileEntityMultiblock) - || ((TileEntityMultiblock) tileEntity).getManager() != this || ( - getStructureId(((TileEntityMultiblock) tileEntity)) != null && !Objects - .equals(getStructureId(((TileEntityMultiblock) tileEntity)), inventoryID))) { + if (!(tileEntity instanceof TileEntityMultiblock) || ((TileEntityMultiblock) tileEntity).getManager() != this || + (getStructureId((TileEntityMultiblock) tileEntity) != null && !Objects.equals(getStructureId((TileEntityMultiblock) tileEntity), 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()) { inventories.get(entry.getKey()).locations.remove(obj); } } - for (String inventoryID : idsToKill) { inventories.remove(inventoryID); } @@ -129,10 +117,8 @@ public class MultiblockManager> { if (!inventories.containsKey(tile.cachedID)) { tile.cachedData.locations.add(Coord4D.get(tile)); inventories.put(tile.cachedID, tile.cachedData); - return; } - inventories.get(tile.cachedID).locations.add(Coord4D.get(tile)); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/multiblock/SynchronizedData.java b/src/main/java/mekanism/common/multiblock/SynchronizedData.java index ba5dcc940..b319f9118 100644 --- a/src/main/java/mekanism/common/multiblock/SynchronizedData.java +++ b/src/main/java/mekanism/common/multiblock/SynchronizedData.java @@ -55,17 +55,13 @@ public abstract class SynchronizedData> { if (obj == null || obj.getClass() != getClass()) { return false; } - SynchronizedData data = (SynchronizedData) obj; - if (!data.locations.equals(locations)) { return false; } - if (data.volLength != volLength || data.volWidth != volWidth || data.volHeight != volHeight) { return false; } - return data.volume == volume; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/multiblock/TileEntityInternalMultiblock.java b/src/main/java/mekanism/common/multiblock/TileEntityInternalMultiblock.java index 392de9e0a..abae183a5 100644 --- a/src/main/java/mekanism/common/multiblock/TileEntityInternalMultiblock.java +++ b/src/main/java/mekanism/common/multiblock/TileEntityInternalMultiblock.java @@ -1,8 +1,8 @@ package mekanism.common.multiblock; import io.netty.buffer.ByteBuf; -import mekanism.common.PacketHandler; import mekanism.api.TileNetworkList; +import mekanism.common.PacketHandler; import mekanism.common.tile.prefab.TileEntityBasicBlock; import net.minecraftforge.fml.common.FMLCommonHandler; @@ -17,7 +17,6 @@ public class TileEntityInternalMultiblock extends TileEntityBasicBlock { @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { if (dataStream.readBoolean()) { multiblockUUID = PacketHandler.readString(dataStream); @@ -30,14 +29,12 @@ public class TileEntityInternalMultiblock extends TileEntityBasicBlock { @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - if (multiblockUUID != null) { data.add(true); data.add(multiblockUUID); } else { data.add(false); } - return data; } @@ -45,5 +42,7 @@ public class TileEntityInternalMultiblock extends TileEntityBasicBlock { multiblockUUID = id; } - public String getMultiblock() { return multiblockUUID; } -} + public String getMultiblock() { + return multiblockUUID; + } +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/multiblock/UpdateProtocol.java b/src/main/java/mekanism/common/multiblock/UpdateProtocol.java index 4b6810f96..8dc5ffebe 100644 --- a/src/main/java/mekanism/common/multiblock/UpdateProtocol.java +++ b/src/main/java/mekanism/common/multiblock/UpdateProtocol.java @@ -57,8 +57,8 @@ public abstract class UpdateProtocol> { int x = 0, y = 0, z = 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))) { + (isViableNode(origX, origY + 1, origZ) && isViableNode(origX, origY - 1, origZ)) || + (isViableNode(origX, origY, origZ + 1) && isViableNode(origX, origY, origZ - 1))) { isCorner = false; } @@ -222,6 +222,7 @@ public abstract class UpdateProtocol> { * @param x - x coordinate * @param y - y coordinate * @param z - z coordinate + * * @return Whether or not the block at the specified location is an air block. */ protected boolean isAir(int x, int y, int z) { @@ -236,6 +237,7 @@ public abstract class UpdateProtocol> { * @param x - x coordinate * @param y - y coordinate * @param z - z coordinate + * * @return Whether or not the block at the specified location is a viable node for a multiblock structure. */ public boolean isViableNode(int x, int y, int z) { @@ -254,6 +256,7 @@ public abstract class UpdateProtocol> { /** * @param pos - coordinates + * * @return Whether or not the block at the specified location is a viable node for a multiblock structure. */ public boolean isViableNode(BlockPos pos) { @@ -274,12 +277,12 @@ public abstract class UpdateProtocol> { } /** - * @param obj - location to check + * @param obj - location to check * @param xmin - minimum x value * @param ymin - minimum y value * @param zmin - minimum z value - * @return If the block at the specified location is on the minimum of all angles of this multiblock structure, and - * the one to use for the actual calculation. + * + * @return If the block at the specified location is on the minimum of all angles of this multiblock structure, and the one to use for the actual calculation. */ private boolean isCorrectCorner(Coord4D obj, int xmin, int ymin, int zmin) { return obj.x == xmin && obj.y == ymin && obj.z == zmin; @@ -287,13 +290,14 @@ public abstract class UpdateProtocol> { } /** - * @param obj - location to check + * @param obj - location to check * @param xmin - minimum x value * @param xmax - maximum x value * @param ymin - minimum y value * @param ymax - maximum y value * @param zmin - minimum z value * @param zmax - maximum z value + * * @return Whether or not the block at the specified location is considered a frame on the multiblock structure. */ private boolean isFrame(Coord4D obj, int xmin, int xmax, int ymin, int ymax, int zmin, int zmax) { @@ -340,6 +344,7 @@ public abstract class UpdateProtocol> { * @param x - x coordinate * @param y - y coordinate * @param z - z coordinate + * * @return Whether or not the block at the specified location serves as a frame for a multiblock structure. */ protected abstract boolean isValidFrame(int x, int y, int z); @@ -426,7 +431,7 @@ public abstract class UpdateProtocol> { TileEntity tileEntity = obj.getTileEntity(pointer.getWorld()); if (tileEntity instanceof TileEntityMultiblock - && ((TileEntityMultiblock) tileEntity).cachedID != null) { + && ((TileEntityMultiblock) tileEntity).cachedID != null) { idsFound.add(((TileEntityMultiblock) tileEntity).cachedID); } } @@ -526,14 +531,11 @@ public abstract class UpdateProtocol> { public void loop(Coord4D pos) { iterated.add(pos); - if (!checker.shouldContinue(iterated.size())) { return; } - for (EnumFacing side : EnumFacing.VALUES) { Coord4D coord = pos.offset(side); - if (!iterated.contains(coord) && checker.isValid(coord)) { loop(coord); } @@ -544,10 +546,8 @@ public abstract class UpdateProtocol> { if (!checker.isValid(coord)) { return 0; } - loop(coord); - return iterated.size(); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/network/PacketBoxBlacklist.java b/src/main/java/mekanism/common/network/PacketBoxBlacklist.java index f4b5fd4f6..e4e9a818d 100644 --- a/src/main/java/mekanism/common/network/PacketBoxBlacklist.java +++ b/src/main/java/mekanism/common/network/PacketBoxBlacklist.java @@ -21,22 +21,16 @@ public class PacketBoxBlacklist implements IMessageHandler boxIgnore = MekanismAPI.getBoxIgnore(); dataStream.writeInt(boxIgnore.size()); - for (BlockInfo info : boxIgnore) { dataStream.writeInt(Block.getIdFromBlock(info.block)); dataStream.writeInt(info.meta); } - Set boxModIgnore = MekanismAPI.getBoxModIgnore(); dataStream.writeInt(boxModIgnore.size()); - for (String modid : boxModIgnore) { ByteBufUtils.writeUTF8String(dataStream, modid); } @@ -45,21 +39,15 @@ public class PacketBoxBlacklist implements IMessageHandler - { + PacketHandler.handlePacket(() -> { TileEntity tileEntity = message.coord4D.getTileEntity(player.world); - if (tileEntity instanceof IFluidContainerManager) { ((IFluidContainerManager) tileEntity).setContainerEditMode(message.value); } }, player); - return null; } @@ -46,7 +42,6 @@ public class PacketContainerEditMode implements IMessageHandler - { + PacketHandler.handlePacket(() -> { World worldServer = DimensionManager.getWorld(message.coord4D.dimensionId); - if (worldServer != null) { TileEntity tileEntity = message.coord4D.getTileEntity(worldServer); - if (tileEntity instanceof TileEntityMultiblock) { ((TileEntityMultiblock) tileEntity).sendStructure = true; } - if (CapabilityUtils.hasCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, null)) { - IGridTransmitter transmitter = CapabilityUtils - .getCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, null); - + IGridTransmitter transmitter = CapabilityUtils.getCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, null); transmitter.setRequestsUpdate(); - if (transmitter.hasTransmitterNetwork()) { transmitter.getTransmitterNetwork().addUpdate(player); } } - if (CapabilityUtils.hasCapability(tileEntity, Capabilities.TILE_NETWORK_CAPABILITY, null)) { - ITileNetwork network = CapabilityUtils - .getCapability(tileEntity, Capabilities.TILE_NETWORK_CAPABILITY, null); - - Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(tileEntity), - network.getNetworkedData(new TileNetworkList())), (EntityPlayerMP) player); + ITileNetwork network = CapabilityUtils.getCapability(tileEntity, Capabilities.TILE_NETWORK_CAPABILITY, null); + Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(tileEntity), network.getNetworkedData(new TileNetworkList())), (EntityPlayerMP) player); } } }, player); - return null; } @@ -83,4 +70,4 @@ public class PacketDataRequest implements IMessageHandler - { + PacketHandler.handlePacket(() -> { if (!player.world.isRemote) { - World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance() - .getWorld(message.coord4D.dimensionId); + World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(message.coord4D.dimensionId); if (message.coord4D.getTileEntity(worldServer) instanceof TileEntityDigitalMiner) { - DigitalMinerGuiMessage - .openServerGui(message.packetType, message.guiType, worldServer, (EntityPlayerMP) player, - message.coord4D, message.index); + DigitalMinerGuiMessage.openServerGui(message.packetType, message.guiType, worldServer, (EntityPlayerMP) player, message.coord4D, message.index); } - } else { - if (message.coord4D.getTileEntity(player.world) instanceof TileEntityDigitalMiner) { - try { - if (message.packetType == MinerGuiPacket.CLIENT) { - FMLCommonHandler.instance().showGuiScreen(DigitalMinerGuiMessage - .getGui(message.packetType, message.guiType, player, player.world, - message.coord4D.getPos(), -1)); - } else if (message.packetType == MinerGuiPacket.CLIENT_INDEX) { - FMLCommonHandler.instance().showGuiScreen(DigitalMinerGuiMessage - .getGui(message.packetType, message.guiType, player, player.world, - message.coord4D.getPos(), message.index)); - } - - player.openContainer.windowId = message.windowId; - } catch (Exception e) { - e.printStackTrace(); + } else if (message.coord4D.getTileEntity(player.world) instanceof TileEntityDigitalMiner) { + try { + if (message.packetType == MinerGuiPacket.CLIENT) { + FMLCommonHandler.instance().showGuiScreen(DigitalMinerGuiMessage.getGui(message.packetType, message.guiType, player, player.world, + message.coord4D.getPos(), -1)); + } else if (message.packetType == MinerGuiPacket.CLIENT_INDEX) { + FMLCommonHandler.instance().showGuiScreen(DigitalMinerGuiMessage.getGui(message.packetType, message.guiType, player, player.world, + message.coord4D.getPos(), message.index)); } + player.openContainer.windowId = message.windowId; + } catch (Exception e) { + e.printStackTrace(); } } }, player); - return null; } public enum MinerGuiPacket { - SERVER, CLIENT, SERVER_INDEX, CLIENT_INDEX + SERVER, + CLIENT, + SERVER_INDEX, + CLIENT_INDEX } public static class DigitalMinerGuiMessage implements IMessage { @@ -94,10 +86,8 @@ public class PacketDigitalMinerGui implements IMessageHandler - { + PacketHandler.handlePacket(() -> { TileEntity tileEntity = message.coord4D.getTileEntity(player.world); - if (tileEntity instanceof ITankManager) { try { Object tank = ((ITankManager) tileEntity).getTanks()[message.tankId]; - if (tank != null) { DropperHandler.useDropper(player, tank, message.mouseButton); } @@ -34,7 +30,6 @@ public class PacketDropperUse implements IMessageHandler - { + worldServer.addScheduledTask(() -> { if (message.type == 0 && message.coord4D.getTileEntity(worldServer) instanceof TileEntityLogisticalSorter) { - TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter) message.coord4D - .getTileEntity(worldServer); + TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter) message.coord4D.getTileEntity(worldServer); if (!sorter.filters.contains(message.tFilter)) { return; } - int index = sorter.filters.indexOf(message.tFilter); - sorter.filters.remove(index); - if (!message.delete) { sorter.filters.add(index, message.tEdited); } - for (EntityPlayer iterPlayer : sorter.playersUsing) { - Mekanism.packetHandler.sendTo( - new TileEntityMessage(Coord4D.get(sorter), sorter.getFilterPacket(new TileNetworkList())), - (EntityPlayerMP) iterPlayer); + Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(sorter), sorter.getFilterPacket(new TileNetworkList())), (EntityPlayerMP) iterPlayer); } - } else if (message.type == 1 && message.coord4D - .getTileEntity(worldServer) instanceof TileEntityDigitalMiner) { + } else if (message.type == 1 && message.coord4D.getTileEntity(worldServer) instanceof TileEntityDigitalMiner) { TileEntityDigitalMiner miner = (TileEntityDigitalMiner) message.coord4D.getTileEntity(worldServer); if (!miner.filters.contains(message.mFilter)) { return; } - int index = miner.filters.indexOf(message.mFilter); - miner.filters.remove(index); - if (!message.delete) { miner.filters.add(index, message.mEdited); } - for (EntityPlayer iterPlayer : miner.playersUsing) { - Mekanism.packetHandler.sendTo( - new TileEntityMessage(Coord4D.get(miner), miner.getFilterPacket(new TileNetworkList())), - (EntityPlayerMP) iterPlayer); + Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(miner), miner.getFilterPacket(new TileNetworkList())), (EntityPlayerMP) iterPlayer); } - } else if (message.type == 2 && message.coord4D - .getTileEntity(worldServer) instanceof TileEntityOredictionificator) { - TileEntityOredictionificator oredictionificator = (TileEntityOredictionificator) message.coord4D - .getTileEntity(worldServer); - + } else if (message.type == 2 && message.coord4D.getTileEntity(worldServer) instanceof TileEntityOredictionificator) { + TileEntityOredictionificator oredictionificator = (TileEntityOredictionificator) message.coord4D.getTileEntity(worldServer); if (!oredictionificator.filters.contains(message.oFilter)) { return; } - int index = oredictionificator.filters.indexOf(message.oFilter); - oredictionificator.filters.remove(index); - if (!message.delete) { oredictionificator.filters.add(index, message.oEdited); } - for (EntityPlayer iterPlayer : oredictionificator.playersUsing) { Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(oredictionificator), oredictionificator.getFilterPacket(new TileNetworkList())), (EntityPlayerMP) iterPlayer); } } }); - return null; } @@ -125,27 +101,21 @@ public class PacketEditFilter implements IMessageHandler - { + PacketHandler.handlePacket(() -> { Entity entity = player.world.getEntityByID(message.entityId); - if (entity != null) { - entity.setLocationAndAngles(message.pos.x, message.pos.y, message.pos.z, entity.rotationYaw, - entity.rotationPitch); + entity.setLocationAndAngles(message.pos.x, message.pos.y, message.pos.z, entity.rotationYaw, entity.rotationPitch); } }, player); - return null; } @@ -46,7 +41,6 @@ public class PacketEntityMove implements IMessageHandler { - if (message.packetType == FlamethrowerPacket.UPDATE) { - Mekanism.playerState.setFlamethrowerState(message.uuid, message.value, false); - - // If we got this packet on the server, resend out to all clients in same dimension - // TODO: Why is this a dimensional thing?! - if (!player.world.isRemote) { - Mekanism.packetHandler.sendToDimension(message, player.world.provider.getDimension()); - } - } else if (message.packetType == FlamethrowerPacket.MODE) { - ItemStack stack = player.getHeldItem(message.currentHand); - if (!stack.isEmpty() && stack.getItem() instanceof ItemFlamethrower) { - ((ItemFlamethrower) stack.getItem()).incrementMode(stack); - } - } - }, - player); + if (message.packetType == FlamethrowerPacket.UPDATE) { + Mekanism.playerState.setFlamethrowerState(message.uuid, message.value, false); + // If we got this packet on the server, resend out to all clients in same dimension + // TODO: Why is this a dimensional thing?! + if (!player.world.isRemote) { + Mekanism.packetHandler.sendToDimension(message, player.world.provider.getDimension()); + } + } else if (message.packetType == FlamethrowerPacket.MODE) { + ItemStack stack = player.getHeldItem(message.currentHand); + if (!stack.isEmpty() && stack.getItem() instanceof ItemFlamethrower) { + ((ItemFlamethrower) stack.getItem()).incrementMode(stack); + } + } + }, player); return null; } @@ -57,7 +55,6 @@ public class PacketFlamethrowerData implements IMessageHandler - { + PacketHandler.handlePacket(() -> { ItemStack stack = player.getHeldItem(message.currentHand); - if (!stack.isEmpty() && stack.getItem() instanceof IItemNetwork) { IItemNetwork network = (IItemNetwork) stack.getItem(); - try { network.handlePacketData(stack, message.storedBuffer); } catch (Exception e) { e.printStackTrace(); } - message.storedBuffer.release(); } }, player); - return null; } @@ -63,21 +56,17 @@ public class PacketItemStack implements IMessageHandler { - if (message.packetType == JetpackPacket.UPDATE) { - Mekanism.playerState.setJetpackState(message.uuid, message.value, false); - - // If we got this packet on the server, propagate it out to all players in the same - // dimension - // TODO: Why is this a dimensional thing?! - if (!player.world.isRemote) { - Mekanism.packetHandler.sendToDimension(message, player.world.provider.getDimension()); - } - } else if (message.packetType == JetpackPacket.MODE) { - // Use has changed the mode of their jetpack; update it - ItemStack stack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); - if (!stack.isEmpty() && stack.getItem() instanceof ItemJetpack) { - if (!message.value) { - ((ItemJetpack) stack.getItem()).incrementMode(stack); - } else { - ((ItemJetpack) stack.getItem()).setMode(stack, JetpackMode.DISABLED); - } - } - } else if (message.packetType == JetpackPacket.FULL) { - // This is a full sync; merge it into our player state - Mekanism.playerState.setActiveJetpacks(message.activeJetpacks); - } - }, - player); + if (message.packetType == JetpackPacket.UPDATE) { + Mekanism.playerState.setJetpackState(message.uuid, message.value, false); + // If we got this packet on the server, propagate it out to all players in the same + // dimension + // TODO: Why is this a dimensional thing?! + if (!player.world.isRemote) { + Mekanism.packetHandler.sendToDimension(message, player.world.provider.getDimension()); + } + } else if (message.packetType == JetpackPacket.MODE) { + // Use has changed the mode of their jetpack; update it + ItemStack stack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); + if (!stack.isEmpty() && stack.getItem() instanceof ItemJetpack) { + if (!message.value) { + ((ItemJetpack) stack.getItem()).incrementMode(stack); + } else { + ((ItemJetpack) stack.getItem()).setMode(stack, JetpackMode.DISABLED); + } + } + } else if (message.packetType == JetpackPacket.FULL) { + // This is a full sync; merge it into our player state + Mekanism.playerState.setActiveJetpacks(message.activeJetpacks); + } + }, player); return null; } @@ -95,7 +93,6 @@ public class PacketJetpackData implements IMessageHandler { } else { Mekanism.keyMap.remove(PacketHandler.getPlayer(context), message.key); } - return null; } @@ -46,4 +45,4 @@ public class PacketKey implements IMessageHandler { add = dataStream.readBoolean(); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/network/PacketLogisticalSorterGui.java b/src/main/java/mekanism/common/network/PacketLogisticalSorterGui.java index 77fccd239..95daaad60 100644 --- a/src/main/java/mekanism/common/network/PacketLogisticalSorterGui.java +++ b/src/main/java/mekanism/common/network/PacketLogisticalSorterGui.java @@ -33,44 +33,36 @@ public class PacketLogisticalSorterGui implements IMessageHandler - { + PacketHandler.handlePacket(() -> { if (!player.world.isRemote) { - World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance() - .getWorld(message.coord4D.dimensionId); + World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(message.coord4D.dimensionId); if (message.coord4D.getTileEntity(worldServer) instanceof TileEntityLogisticalSorter) { - LogisticalSorterGuiMessage - .openServerGui(message.packetType, message.guiType, worldServer, (EntityPlayerMP) player, - message.coord4D, message.index); + LogisticalSorterGuiMessage.openServerGui(message.packetType, message.guiType, worldServer, (EntityPlayerMP) player, message.coord4D, message.index); } - } else { - if (message.coord4D.getTileEntity(player.world) instanceof TileEntityLogisticalSorter) { - try { - if (message.packetType == SorterGuiPacket.CLIENT) { - FMLCommonHandler.instance().showGuiScreen(LogisticalSorterGuiMessage - .getGui(message.packetType, message.guiType, player, player.world, - message.coord4D.getPos(), -1)); - } else if (message.packetType == SorterGuiPacket.CLIENT_INDEX) { - FMLCommonHandler.instance().showGuiScreen(LogisticalSorterGuiMessage - .getGui(message.packetType, message.guiType, player, player.world, - message.coord4D.getPos(), message.index)); - } - - player.openContainer.windowId = message.windowId; - } catch (Exception e) { - e.printStackTrace(); + } else if (message.coord4D.getTileEntity(player.world) instanceof TileEntityLogisticalSorter) { + try { + if (message.packetType == SorterGuiPacket.CLIENT) { + FMLCommonHandler.instance().showGuiScreen(LogisticalSorterGuiMessage.getGui(message.packetType, message.guiType, player, player.world, + message.coord4D.getPos(), -1)); + } else if (message.packetType == SorterGuiPacket.CLIENT_INDEX) { + FMLCommonHandler.instance().showGuiScreen(LogisticalSorterGuiMessage.getGui(message.packetType, message.guiType, player, player.world, + message.coord4D.getPos(), message.index)); } + player.openContainer.windowId = message.windowId; + } catch (Exception e) { + e.printStackTrace(); } } }, player); - return null; } public enum SorterGuiPacket { - SERVER, CLIENT, SERVER_INDEX, CLIENT_INDEX + SERVER, + CLIENT, + SERVER_INDEX, + CLIENT_INDEX } public static class LogisticalSorterGuiMessage implements IMessage { @@ -115,63 +107,47 @@ public class PacketLogisticalSorterGui implements IMessageHandler - { + worldServer.addScheduledTask(() -> { if (message.type == 0 && message.coord4D.getTileEntity(worldServer) instanceof TileEntityLogisticalSorter) { - TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter) message.coord4D - .getTileEntity(worldServer); - + TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter) message.coord4D.getTileEntity(worldServer); sorter.filters.add(message.tFilter); - for (EntityPlayer iterPlayer : sorter.playersUsing) { - Mekanism.packetHandler.sendTo( - new TileEntityMessage(Coord4D.get(sorter), sorter.getFilterPacket(new TileNetworkList())), - (EntityPlayerMP) iterPlayer); + Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(sorter), sorter.getFilterPacket(new TileNetworkList())), (EntityPlayerMP) iterPlayer); } - } else if (message.type == 1 && message.coord4D - .getTileEntity(worldServer) instanceof TileEntityDigitalMiner) { + } else if (message.type == 1 && message.coord4D.getTileEntity(worldServer) instanceof TileEntityDigitalMiner) { TileEntityDigitalMiner miner = (TileEntityDigitalMiner) message.coord4D.getTileEntity(worldServer); - miner.filters.add(message.mFilter); - for (EntityPlayer iterPlayer : miner.playersUsing) { - Mekanism.packetHandler.sendTo( - new TileEntityMessage(Coord4D.get(miner), miner.getFilterPacket(new TileNetworkList())), - (EntityPlayerMP) iterPlayer); + Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(miner), miner.getFilterPacket(new TileNetworkList())), (EntityPlayerMP) iterPlayer); } - } else if (message.type == 2 && message.coord4D - .getTileEntity(worldServer) instanceof TileEntityOredictionificator) { - TileEntityOredictionificator oredictionificator = (TileEntityOredictionificator) message.coord4D - .getTileEntity(worldServer); - + } else if (message.type == 2 && message.coord4D.getTileEntity(worldServer) instanceof TileEntityOredictionificator) { + TileEntityOredictionificator oredictionificator = (TileEntityOredictionificator) message.coord4D.getTileEntity(worldServer); oredictionificator.filters.add(message.oFilter); - for (EntityPlayer iterPlayer : oredictionificator.playersUsing) { Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(oredictionificator), oredictionificator.getFilterPacket(new TileNetworkList())), (EntityPlayerMP) iterPlayer); } } }); - return null; } @@ -102,11 +85,8 @@ public class PacketNewFilter implements IMessageHandler - { + PacketHandler.handlePacket(() -> { if (!player.world.isRemote) { - World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance() - .getWorld(message.coord4D.dimensionId); + World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(message.coord4D.dimensionId); if (message.coord4D.getTileEntity(worldServer) instanceof TileEntityOredictionificator) { - OredictionificatorGuiMessage - .openServerGui(message.packetType, message.guiType, worldServer, (EntityPlayerMP) player, - message.coord4D, message.index); + OredictionificatorGuiMessage.openServerGui(message.packetType, message.guiType, worldServer, (EntityPlayerMP) player, message.coord4D, message.index); } - } else { - if (message.coord4D.getTileEntity(player.world) instanceof TileEntityOredictionificator) { - try { - if (message.packetType == OredictionificatorGuiPacket.CLIENT) { - FMLCommonHandler.instance().showGuiScreen(OredictionificatorGuiMessage - .getGui(message.packetType, message.guiType, player, player.world, - message.coord4D.getPos(), -1)); - } else if (message.packetType == OredictionificatorGuiPacket.CLIENT_INDEX) { - FMLCommonHandler.instance().showGuiScreen(OredictionificatorGuiMessage - .getGui(message.packetType, message.guiType, player, player.world, - message.coord4D.getPos(), message.index)); - } - - player.openContainer.windowId = message.windowId; - } catch (Exception e) { - e.printStackTrace(); + } else if (message.coord4D.getTileEntity(player.world) instanceof TileEntityOredictionificator) { + try { + if (message.packetType == OredictionificatorGuiPacket.CLIENT) { + FMLCommonHandler.instance().showGuiScreen(OredictionificatorGuiMessage.getGui(message.packetType, message.guiType, player, player.world, + message.coord4D.getPos(), -1)); + } else if (message.packetType == OredictionificatorGuiPacket.CLIENT_INDEX) { + FMLCommonHandler.instance().showGuiScreen(OredictionificatorGuiMessage.getGui(message.packetType, message.guiType, player, player.world, + message.coord4D.getPos(), message.index)); } + player.openContainer.windowId = message.windowId; + } catch (Exception e) { + e.printStackTrace(); } } }, player); @@ -68,7 +58,10 @@ public class PacketOredictionificatorGui implements IMessageHandler { if (message.packetType == PersonalChestPacketType.SERVER_OPEN) { try { if (message.isBlock) { - TileEntityPersonalChest tileEntity = (TileEntityPersonalChest) message.coord4D - .getTileEntity(player.world); + TileEntityPersonalChest tileEntity = (TileEntityPersonalChest) message.coord4D.getTileEntity(player.world); MekanismUtils.openPersonalChestGui((EntityPlayerMP) player, tileEntity, null, true); } else { ItemStack stack = player.getHeldItem(message.currentHand); - if (MachineType.get(stack) == MachineType.PERSONAL_CHEST) { InventoryPersonalChest inventory = new InventoryPersonalChest(stack, message.currentHand); MekanismUtils.openPersonalChestGui((EntityPlayerMP) player, null, inventory, false); } } } catch (Exception e) { - Mekanism.logger.error("Error while handling electric chest open packet."); - e.printStackTrace(); + Mekanism.logger.error("Error while handling electric chest open packet.", e); } } else if (message.packetType == PersonalChestPacketType.CLIENT_OPEN) { try { Mekanism.proxy.openPersonalChest(player, message.guiType, message.windowId, message.isBlock, message.coord4D == null ? BlockPos.ORIGIN : message.coord4D.getPos(), message.currentHand); } catch (Exception e) { - Mekanism.logger.error("Error while handling electric chest open packet."); - e.printStackTrace(); + Mekanism.logger.error("Error while handling electric chest open packet.", e); } } }, player); - return null; } @@ -88,23 +82,19 @@ public class PacketPersonalChest implements IMessageHandler { ItemStack itemstack = player.getHeldItem(message.currentHand); World world = player.world; - if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemPortableTeleporter) { ItemPortableTeleporter item = (ItemPortableTeleporter) itemstack.getItem(); - switch (message.packetType) { case DATA_REQUEST: sendDataResponse(message.frequency, world, player, item, itemstack, message.currentHand); @@ -48,121 +45,83 @@ public class PacketPortableTeleporter implements IMessageHandler publicFreqs = new ArrayList<>(getManager(null, world).getFrequencies()); - List privateFreqs = new ArrayList<>(getManager(player.getUniqueID(), world).getFrequencies()); - byte status = 3; - if (given != null) { - FrequencyManager manager = - given.isPublic() ? getManager(null, world) : getManager(player.getUniqueID(), world); + FrequencyManager manager = given.isPublic() ? getManager(null, world) : getManager(player.getUniqueID(), world); boolean found = false; - for (Frequency iterFreq : manager.getFrequencies()) { if (given.equals(iterFreq)) { given = iterFreq; found = true; - break; } } - if (!found) { given = null; } @@ -174,7 +133,6 @@ public class PacketPortableTeleporter implements IMessageHandler item.getEnergy(itemstack)) { status = 4; } else { @@ -182,23 +140,18 @@ public class PacketPortableTeleporter implements IMessageHandler publicFreqs, - List privateFreqs) { + public PortableTeleporterMessage(EnumHand hand, Frequency freq, byte b, List publicFreqs, List privateFreqs) { packetType = PortableTeleporterPacketType.DATA_RESPONSE; currentHand = hand; @@ -256,7 +207,6 @@ public class PacketPortableTeleporter implements IMessageHandler - { + PacketHandler.handlePacket(() -> { Random random = new Random(); - for (int i = 0; i < 50; i++) { - player.world.spawnParticle(EnumParticleTypes.PORTAL, message.coord4D.x + random.nextFloat(), - message.coord4D.y + random.nextFloat(), message.coord4D.z + random.nextFloat(), 0.0F, 0.0F, 0.0F); - player.world.spawnParticle(EnumParticleTypes.PORTAL, message.coord4D.x + random.nextFloat(), - message.coord4D.y + 1 + random.nextFloat(), message.coord4D.z + random.nextFloat(), 0.0F, 0.0F, - 0.0F); + player.world.spawnParticle(EnumParticleTypes.PORTAL, message.coord4D.x + random.nextFloat(), message.coord4D.y + random.nextFloat(), + message.coord4D.z + random.nextFloat(), 0.0F, 0.0F, 0.0F); + player.world.spawnParticle(EnumParticleTypes.PORTAL, message.coord4D.x + random.nextFloat(), message.coord4D.y + 1 + random.nextFloat(), + message.coord4D.z + random.nextFloat(), 0.0F, 0.0F, 0.0F); } }, player); - return null; } @@ -54,4 +49,4 @@ public class PacketPortalFX implements IMessageHandler - { + PacketHandler.handlePacket(() -> { TileEntity tileEntity = message.coord4D.getTileEntity(player.world); - if (tileEntity instanceof IRedstoneControl) { ((IRedstoneControl) tileEntity).setControlType(message.value); } }, player); - return null; } @@ -46,7 +42,6 @@ public class PacketRedstoneControl implements IMessageHandler - { + PacketHandler.handlePacket(() -> { TileEntity tileEntity = message.coord4D.getTileEntity(player.world); - if (tileEntity instanceof IUpgradeTile && tileEntity instanceof TileEntityBasicBlock) { IUpgradeTile upgradeTile = (IUpgradeTile) tileEntity; Upgrade upgrade = Upgrade.values()[message.upgradeType]; - if (upgradeTile.getComponent().getUpgrades(upgrade) > 0) { if (player.inventory.addItemStackToInventory(upgrade.getStack())) { upgradeTile.getComponent().removeUpgrade(upgrade); @@ -34,7 +30,6 @@ public class PacketRemoveUpgrade implements IMessageHandler { @Override public IMessage onMessage(RobitMessage message, MessageContext context) { EntityPlayer player = PacketHandler.getPlayer(context); - - PacketHandler.handlePacket(() -> - { + PacketHandler.handlePacket(() -> { if (message.activeType == RobitPacketType.GUI) { if (message.guiType == 0) { player.openGui(Mekanism.instance, 21, player.world, message.entityId, 0, 0); @@ -32,31 +30,26 @@ public class PacketRobit implements IMessageHandler { } } else if (message.activeType == RobitPacketType.FOLLOW) { EntityRobit robit = (EntityRobit) player.world.getEntityByID(message.entityId); - if (robit != null) { robit.setFollowing(!robit.getFollowing()); } } else if (message.activeType == RobitPacketType.NAME) { EntityRobit robit = (EntityRobit) player.world.getEntityByID(message.entityId); - if (robit != null) { robit.setCustomNameTag(message.name); } } else if (message.activeType == RobitPacketType.GO_HOME) { EntityRobit robit = (EntityRobit) player.world.getEntityByID(message.entityId); - if (robit != null) { robit.goHome(); } } else if (message.activeType == RobitPacketType.DROP_PICKUP) { EntityRobit robit = (EntityRobit) player.world.getEntityByID(message.entityId); - if (robit != null) { robit.setDropPickup(!robit.getDropPickup()); } } }, player); - return null; } @@ -82,7 +75,6 @@ public class PacketRobit implements IMessageHandler { public RobitMessage(RobitPacketType type, int i1, int i2, String s) { activeType = type; - switch (activeType) { case GUI: guiType = i1; @@ -107,7 +99,6 @@ public class PacketRobit implements IMessageHandler { @Override public void toBytes(ByteBuf dataStream) { dataStream.writeInt(activeType.ordinal()); - switch (activeType) { case GUI: dataStream.writeInt(guiType); @@ -132,7 +123,6 @@ public class PacketRobit implements IMessageHandler { @Override public void fromBytes(ByteBuf dataStream) { activeType = RobitPacketType.values()[dataStream.readInt()]; - if (activeType == RobitPacketType.GUI) { guiType = dataStream.readInt(); entityId = dataStream.readInt(); @@ -148,4 +138,4 @@ public class PacketRobit implements IMessageHandler { } } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/network/PacketScubaTankData.java b/src/main/java/mekanism/common/network/PacketScubaTankData.java index 5ccaf49c3..0ce1a46c3 100644 --- a/src/main/java/mekanism/common/network/PacketScubaTankData.java +++ b/src/main/java/mekanism/common/network/PacketScubaTankData.java @@ -22,26 +22,24 @@ public class PacketScubaTankData implements IMessageHandler { - if (message.packetType == ScubaTankPacket.UPDATE) { - Mekanism.playerState.setGasmaskState(message.uuid, message.value, false); - - // If we got this on the server, relay out to all players in the same dimension - // TODO: Why is this a dimensional thing?! - if (!player.world.isRemote) { - Mekanism.packetHandler.sendToDimension(message, player.world.provider.getDimension()); - } - } else if (message.packetType == ScubaTankPacket.MODE) { - // Use has changed the mode of their gasmask; update it - ItemStack stack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); - if (!stack.isEmpty() && stack.getItem() instanceof ItemScubaTank) { - ((ItemScubaTank) stack.getItem()).toggleFlowing(stack); - } - } else if (message.packetType == ScubaTankPacket.FULL) { - // This is a full sync; merge into our player state - Mekanism.playerState.setActiveGasmasks(message.activeGasmasks); - } - }, - player); + if (message.packetType == ScubaTankPacket.UPDATE) { + Mekanism.playerState.setGasmaskState(message.uuid, message.value, false); + // If we got this on the server, relay out to all players in the same dimension + // TODO: Why is this a dimensional thing?! + if (!player.world.isRemote) { + Mekanism.packetHandler.sendToDimension(message, player.world.provider.getDimension()); + } + } else if (message.packetType == ScubaTankPacket.MODE) { + // Use has changed the mode of their gasmask; update it + ItemStack stack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); + if (!stack.isEmpty() && stack.getItem() instanceof ItemScubaTank) { + ((ItemScubaTank) stack.getItem()).toggleFlowing(stack); + } + } else if (message.packetType == ScubaTankPacket.FULL) { + // This is a full sync; merge into our player state + Mekanism.playerState.setActiveGasmasks(message.activeGasmasks); + } + }, player); return null; } @@ -81,7 +79,7 @@ public class PacketScubaTankData implements IMessageHandler activeNames) { - ScubaTankDataMessage m = new ScubaTankDataMessage((ScubaTankPacket.FULL)); + ScubaTankDataMessage m = new ScubaTankDataMessage(ScubaTankPacket.FULL); m.activeGasmasks = activeNames; return m; } @@ -89,7 +87,6 @@ public class PacketScubaTankData implements IMessageHandler - { + PacketHandler.handlePacket(() -> { if (message.packetType == SecurityPacketType.BLOCK) { TileEntity tileEntity = message.coord4D.getTileEntity(player.world); - if (tileEntity instanceof ISecurityTile) { UUID owner = ((ISecurityTile) tileEntity).getSecurity().getOwnerUUID(); - if (owner != null && player.getUniqueID().equals(owner)) { ((ISecurityTile) tileEntity).getSecurity().setMode(message.value); tileEntity.markDirty(); @@ -37,13 +33,11 @@ public class PacketSecurityMode implements IMessageHandler frequencies = new ArrayList<>(); - for (Frequency frequency : Mekanism.securityFrequencies.getFrequencies()) { if (frequency instanceof SecurityFrequency) { frequencies.add((SecurityFrequency) frequency); } } - dataStream.writeInt(frequencies.size()); - for (SecurityFrequency frequency : frequencies) { PacketHandler.writeString(dataStream, frequency.ownerUUID.toString()); PacketHandler.writeString(dataStream, MekanismUtils.getLastKnownUsername(frequency.ownerUUID)); @@ -91,21 +84,16 @@ public class PacketSecurityUpdate implements IMessageHandler - { + PacketHandler.handlePacket(() -> { if (!player.world.isRemote) { - World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance() - .getWorld(message.coord4D.dimensionId); - + World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(message.coord4D.dimensionId); if (message.coord4D.getTileEntity(worldServer) instanceof TileEntityBasicBlock) { if (message.guiId == -1) { return; } - - SimpleGuiMessage - .openServerGui(message.guiHandler, message.guiId, (EntityPlayerMP) player, player.world, - message.coord4D); + SimpleGuiMessage.openServerGui(message.guiHandler, message.guiId, (EntityPlayerMP) player, player.world, message.coord4D); } } else { - FMLCommonHandler.instance().showGuiScreen(SimpleGuiMessage - .getGui(message.guiHandler, message.guiId, player, player.world, message.coord4D)); + FMLCommonHandler.instance().showGuiScreen(SimpleGuiMessage.getGui(message.guiHandler, message.guiId, player, player.world, message.coord4D)); player.openContainer.windowId = message.windowId; } }, player); - return null; } @@ -80,11 +71,8 @@ public class PacketSimpleGui implements IMessageHandler - { + PacketHandler.handlePacket(() -> { TileEntity tileEntity = message.coord4D.getTileEntity(player.world); - if (CapabilityUtils.hasCapability(tileEntity, Capabilities.TILE_NETWORK_CAPABILITY, null)) { - ITileNetwork network = CapabilityUtils - .getCapability(tileEntity, Capabilities.TILE_NETWORK_CAPABILITY, null); - + ITileNetwork network = CapabilityUtils.getCapability(tileEntity, Capabilities.TILE_NETWORK_CAPABILITY, null); try { network.handlePacketData(message.storedBuffer); } catch (Exception e) { e.printStackTrace(); } - message.storedBuffer.release(); } }, player); - return null; } @@ -67,14 +59,10 @@ public class PacketTileEntity implements IMessageHandler { if (message.coord4D == null) { return; } TileEntity tileEntity = message.coord4D.getTileEntity(player.world); - if (CapabilityUtils.hasCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, null)) { - IGridTransmitter transmitter = CapabilityUtils - .getCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, null); + IGridTransmitter transmitter = CapabilityUtils.getCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, null); if (transmitter == null) { //Should never be the case, but removes the warning return; } - if (message.packetType == PacketType.UPDATE) { - DynamicNetwork network = transmitter.hasTransmitterNetwork() && !message.newNetwork ? transmitter - .getTransmitterNetwork() : transmitter.createEmptyNetwork(); + DynamicNetwork network = transmitter.hasTransmitterNetwork() && !message.newNetwork ? transmitter.getTransmitterNetwork() : transmitter.createEmptyNetwork(); network.register(); transmitter.setTransmitterNetwork(network); - for (Coord4D coord : message.transmitterCoords) { TileEntity tile = coord.getTileEntity(player.world); - if (CapabilityUtils.hasCapability(tile, Capabilities.GRID_TRANSMITTER_CAPABILITY, null)) { - CapabilityUtils.getCapability(tile, Capabilities.GRID_TRANSMITTER_CAPABILITY, null) - .setTransmitterNetwork(network); + CapabilityUtils.getCapability(tile, Capabilities.GRID_TRANSMITTER_CAPABILITY, null).setTransmitterNetwork(network); } } - network.updateCapacity(); return; } - if (MekanismConfig.current().client.opaqueTransmitters.val() || !transmitter.hasTransmitterNetwork()) { return; } - TransmissionType transmissionType = transmitter.getTransmissionType(); if (message.packetType == PacketType.ENERGY) { if (transmissionType == TransmissionType.ENERGY) { @@ -82,29 +70,24 @@ public class PacketTransmitterUpdate implements IMessageHandler(); @@ -248,4 +220,4 @@ public class PacketTransmitterUpdate implements IMessageHandler"); + Preconditions.checkState(Loader.instance().getLoaderState().ordinal() < LoaderState.POSTINITIALIZATION.ordinal(), + "Recipes should be registered before PostInit. Try net.minecraftforge.event.RegistryEvent.Register"); } @Override @@ -80,15 +79,13 @@ public class APIHandler implements MekanismRecipeHelper { } @Override - public void addElectrolyticSeparatorRecipe(FluidStack fluid, double energy, GasStack leftOutput, - GasStack rightOutput) { + public void addElectrolyticSeparatorRecipe(FluidStack fluid, double energy, GasStack leftOutput, GasStack rightOutput) { checkPhase(); RecipeHandler.addElectrolyticSeparatorRecipe(fluid, energy, leftOutput, rightOutput); } @Override - public void addPrecisionSawmillRecipe(ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, - double chance) { + public void addPrecisionSawmillRecipe(ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, double chance) { checkPhase(); RecipeHandler.addPrecisionSawmillRecipe(input, primaryOutput, secondaryOutput, chance); } @@ -118,8 +115,7 @@ public class APIHandler implements MekanismRecipeHelper { } @Override - public void addPRCRecipe(ItemStack inputSolid, FluidStack inputFluid, GasStack inputGas, ItemStack outputSolid, - GasStack outputGas, double extraEnergy, int ticks) { + public void addPRCRecipe(ItemStack inputSolid, FluidStack inputFluid, GasStack inputGas, ItemStack outputSolid, GasStack outputGas, double extraEnergy, int ticks) { checkPhase(); RecipeHandler.addPRCRecipe(inputSolid, inputFluid, inputGas, outputSolid, outputGas, extraEnergy, ticks); } @@ -135,4 +131,4 @@ public class APIHandler implements MekanismRecipeHelper { checkPhase(); RecipeHandler.addSolarNeutronRecipe(inputGas, outputGas); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/BinRecipe.java b/src/main/java/mekanism/common/recipe/BinRecipe.java index 7e9d1295c..e7d9dc5be 100644 --- a/src/main/java/mekanism/common/recipe/BinRecipe.java +++ b/src/main/java/mekanism/common/recipe/BinRecipe.java @@ -28,7 +28,6 @@ public class BinRecipe extends IForgeRegistryEntry.Impl implements IRec MinecraftForge.EVENT_BUS.register(this); registered = true; } - setRegistryName("bin"); } @@ -41,7 +40,6 @@ public class BinRecipe extends IForgeRegistryEntry.Impl implements IRec if (itemStack.isEmpty()) { return false; } - return BasicBlockType.get(itemStack) == BasicBlockType.BIN && itemStack.getCount() <= 1; } @@ -53,15 +51,12 @@ public class BinRecipe extends IForgeRegistryEntry.Impl implements IRec public ItemStack getResult(IInventory inv) { ItemStack bin = ItemStack.EMPTY; - for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if (isBin(stack)) { if (!bin.isEmpty()) { return ItemStack.EMPTY; } - bin = stack.copy(); } } @@ -71,15 +66,12 @@ public class BinRecipe extends IForgeRegistryEntry.Impl implements IRec } ItemStack addStack = ItemStack.EMPTY; - for (int i = 0; i < 9; i++) { ItemStack stack = inv.getStackInSlot(i); - if (!stack.isEmpty() && !isBin(stack)) { if (!addStack.isEmpty()) { return ItemStack.EMPTY; } - addStack = stack.copy(); } } @@ -91,14 +83,11 @@ public class BinRecipe extends IForgeRegistryEntry.Impl implements IRec if (!binInv.getItemType().isEmpty() && !binInv.getItemType().isItemEqual(addStack)) { return ItemStack.EMPTY; } - binInv.add(addStack); } - return bin; - } else { - return binInv.removeStack(); } + return binInv.removeStack(); } @Nonnull @@ -128,10 +117,8 @@ public class BinRecipe extends IForgeRegistryEntry.Impl implements IRec InventoryBin inv = new InventoryBin(bin.copy()); int size = inv.getItemCount(); - ItemStack testRemove = inv.removeStack(); int newCount = size - (!testRemove.isEmpty() ? testRemove.getCount() : 0); - if (inv.getTier() == BinTier.CREATIVE) { newCount = size; } @@ -142,12 +129,10 @@ public class BinRecipe extends IForgeRegistryEntry.Impl implements IRec } else { int bin = -1; int other = -1; - for (int i = 0; i < event.craftMatrix.getSizeInventory(); i++) { if (isBin(event.craftMatrix.getStackInSlot(i))) { bin = i; - } else if (!isBin(event.craftMatrix.getStackInSlot(i)) && !event.craftMatrix.getStackInSlot(i) - .isEmpty()) { + } else if (!isBin(event.craftMatrix.getStackInSlot(i)) && !event.craftMatrix.getStackInSlot(i).isEmpty()) { other = i; } } @@ -156,7 +141,6 @@ public class BinRecipe extends IForgeRegistryEntry.Impl implements IRec ItemStack otherStack = event.craftMatrix.getStackInSlot(other); ItemStack testRemain = new InventoryBin(binStack.copy()).add(otherStack.copy()); - if (!testRemain.isEmpty() && testRemain.getCount() > 0) { ItemStack proxy = new ItemStack(MekanismItems.ItemProxy); ((ItemProxy) proxy.getItem()).setSavedItem(proxy, testRemain.copy()); @@ -172,4 +156,4 @@ public class BinRecipe extends IForgeRegistryEntry.Impl implements IRec public boolean canFit(int width, int height) { return width * height >= 1; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/MekanismIngredient.java b/src/main/java/mekanism/common/recipe/MekanismIngredient.java index a6a1ede8a..49d3aad1e 100644 --- a/src/main/java/mekanism/common/recipe/MekanismIngredient.java +++ b/src/main/java/mekanism/common/recipe/MekanismIngredient.java @@ -28,7 +28,6 @@ public class MekanismIngredient extends Ingredient { } } } - return EMPTY; } @@ -47,8 +46,7 @@ public class MekanismIngredient extends Ingredient { @Override public Ingredient parse(JsonContext context, JsonObject json) { final ItemStack stack = CraftingHelper.getItemStack(json, context); - return MekanismIngredient.fromStacks(stack); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/MekanismRecipeEnabledCondition.java b/src/main/java/mekanism/common/recipe/MekanismRecipeEnabledCondition.java index 0b9d6ba56..0e672a488 100644 --- a/src/main/java/mekanism/common/recipe/MekanismRecipeEnabledCondition.java +++ b/src/main/java/mekanism/common/recipe/MekanismRecipeEnabledCondition.java @@ -28,8 +28,7 @@ public class MekanismRecipeEnabledCondition implements IConditionFactory { if (Loader.isModLoaded(MekanismGenerators.MODID) && JsonUtils.hasField(json, "generatorType")) { final String generatorType = JsonUtils.getString(json, "generatorType"); - final BlockStateGenerator.GeneratorType type = MekanismConfig.current().generators.generatorsManager - .typeFromName(generatorType); + final BlockStateGenerator.GeneratorType type = MekanismConfig.current().generators.generatorsManager.typeFromName(generatorType); //noinspection Convert2Lambda - classloading issues if generators not installed return new BooleanSupplier() { @Override @@ -43,7 +42,7 @@ public class MekanismRecipeEnabledCondition implements IConditionFactory { return () -> MekanismConfig.current().general.controlCircuitOreDict.val(); } - throw new IllegalStateException( - "Config defined with recipe_enabled condition without a valid field defined! Valid values: \"machineType\", \"generatorType\" (when Mekanism Generators installed) and \"circuitOredict\""); + throw new IllegalStateException("Config defined with recipe_enabled condition without a valid field defined! Valid values: \"machineType\", \"generatorType\" " + + "(when Mekanism Generators installed) and \"circuitOredict\""); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/MultiOredictIngredient.java b/src/main/java/mekanism/common/recipe/MultiOredictIngredient.java index c1bb83b35..2585ab05b 100644 --- a/src/main/java/mekanism/common/recipe/MultiOredictIngredient.java +++ b/src/main/java/mekanism/common/recipe/MultiOredictIngredient.java @@ -49,4 +49,4 @@ public class MultiOredictIngredient extends CompoundIngredient { return new MultiOredictIngredient(ores.toArray(new String[0])); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/RecipeHandler.java b/src/main/java/mekanism/common/recipe/RecipeHandler.java index 28b33fa76..3b83177a3 100644 --- a/src/main/java/mekanism/common/recipe/RecipeHandler.java +++ b/src/main/java/mekanism/common/recipe/RecipeHandler.java @@ -75,15 +75,12 @@ public final class RecipeHandler { public static void removeRecipe(@Nonnull Recipe recipeMap, @Nonnull MachineRecipe recipe) { List toRemove = new ArrayList<>(); - for (Object o : recipeMap.get().keySet()) { MachineInput iterInput = (MachineInput) o; - if (iterInput.testEquality(recipe.getInput())) { toRemove.add(iterInput); } } - for (MachineInput iterInput : toRemove) { recipeMap.get().remove(iterInput); } @@ -92,7 +89,7 @@ public final class RecipeHandler { /** * Add an Enrichment Chamber recipe. * - * @param input - input ItemStack + * @param input - input ItemStack * @param output - output ItemStack */ public static void addEnrichmentChamberRecipe(ItemStack input, ItemStack output) { @@ -102,7 +99,7 @@ public final class RecipeHandler { /** * Add an Osmium Compressor recipe. * - * @param input - input ItemStack + * @param input - input ItemStack * @param output - output ItemStack */ public static void addOsmiumCompressorRecipe(ItemStack input, ItemStack output) { @@ -112,10 +109,10 @@ public final class RecipeHandler { /** * Add a Combiner recipe. * - * @param input - input ItemStack + * @param input - input ItemStack * @param output - output ItemStack - * @deprecated Replaced by {@link #addCombinerRecipe(ItemStack, ItemStack, ItemStack)}. May be removed with - * Minecraft 1.13. + * + * @deprecated Replaced by {@link #addCombinerRecipe(ItemStack, ItemStack, ItemStack)}. May be removed with Minecraft 1.13. */ @Deprecated public static void addCombinerRecipe(ItemStack input, ItemStack output) { @@ -125,8 +122,8 @@ public final class RecipeHandler { /** * Add a Combiner recipe. * - * @param input - input ItemStack - * @param extra - extra ItemStack + * @param input - input ItemStack + * @param extra - extra ItemStack * @param output - output ItemStack */ public static void addCombinerRecipe(ItemStack input, ItemStack extra, ItemStack output) { @@ -136,7 +133,7 @@ public final class RecipeHandler { /** * Add a Crusher recipe. * - * @param input - input ItemStack + * @param input - input ItemStack * @param output - output ItemStack */ public static void addCrusherRecipe(ItemStack input, ItemStack output) { @@ -146,7 +143,7 @@ public final class RecipeHandler { /** * Add a Purification Chamber recipe. * - * @param input - input ItemStack + * @param input - input ItemStack * @param output - output ItemStack */ public static void addPurificationChamberRecipe(ItemStack input, ItemStack output) { @@ -158,20 +155,19 @@ public final class RecipeHandler { * * @param infuse - which Infuse to use * @param amount - how much of the Infuse to use - * @param input - input ItemStack + * @param input - input ItemStack * @param output - output ItemStack */ public static void addMetallurgicInfuserRecipe(InfuseType infuse, int amount, ItemStack input, ItemStack output) { - addRecipe(Recipe.METALLURGIC_INFUSER, - new MetallurgicInfuserRecipe(new InfusionInput(infuse, amount, input), output)); + addRecipe(Recipe.METALLURGIC_INFUSER, new MetallurgicInfuserRecipe(new InfusionInput(infuse, amount, input), output)); } /** * Add a Chemical Infuser recipe. * - * @param leftInput - left GasStack to input + * @param leftInput - left GasStack to input * @param rightInput - right GasStack to input - * @param output - output GasStack + * @param output - output GasStack */ public static void addChemicalInfuserRecipe(GasStack leftInput, GasStack rightInput, GasStack output) { addRecipe(Recipe.CHEMICAL_INFUSER, new ChemicalInfuserRecipe(leftInput, rightInput, output)); @@ -180,7 +176,7 @@ public final class RecipeHandler { /** * Add a Chemical Oxidizer recipe. * - * @param input - input ItemStack + * @param input - input ItemStack * @param output - output GasStack */ public static void addChemicalOxidizerRecipe(ItemStack input, GasStack output) { @@ -190,7 +186,7 @@ public final class RecipeHandler { /** * Add a Chemical Injection Chamber recipe. * - * @param input - input ItemStack + * @param input - input ItemStack * @param output - output ItemStack */ public static void addChemicalInjectionChamberRecipe(ItemStack input, Gas gas, ItemStack output) { @@ -200,32 +196,30 @@ public final class RecipeHandler { /** * Add an Electrolytic Separator recipe. * - * @param fluid - FluidStack to electrolyze - * @param leftOutput - left gas to produce when the fluid is electrolyzed + * @param fluid - FluidStack to electrolyze + * @param leftOutput - left gas to produce when the fluid is electrolyzed * @param rightOutput - right gas to produce when the fluid is electrolyzed */ - public static void addElectrolyticSeparatorRecipe(FluidStack fluid, double energy, GasStack leftOutput, - GasStack rightOutput) { + public static void addElectrolyticSeparatorRecipe(FluidStack fluid, double energy, GasStack leftOutput, GasStack rightOutput) { addRecipe(Recipe.ELECTROLYTIC_SEPARATOR, new SeparatorRecipe(fluid, energy, leftOutput, rightOutput)); } /** * Add a Precision Sawmill recipe. * - * @param input - input ItemStack - * @param primaryOutput - guaranteed output + * @param input - input ItemStack + * @param primaryOutput - guaranteed output * @param secondaryOutput - possible extra output - * @param chance - probability of obtaining extra output + * @param chance - probability of obtaining extra output */ - public static void addPrecisionSawmillRecipe(ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, - double chance) { + public static void addPrecisionSawmillRecipe(ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, double chance) { addRecipe(Recipe.PRECISION_SAWMILL, new SawmillRecipe(input, primaryOutput, secondaryOutput, chance)); } /** * Add a Precision Sawmill recipe with no chance output * - * @param input - input ItemStack + * @param input - input ItemStack * @param primaryOutput - guaranteed output */ public static void addPrecisionSawmillRecipe(ItemStack input, ItemStack primaryOutput) { @@ -235,7 +229,7 @@ public final class RecipeHandler { /** * Add a Chemical Dissolution Chamber recipe. * - * @param input - input ItemStack + * @param input - input ItemStack * @param output - output GasStack */ public static void addChemicalDissolutionChamberRecipe(ItemStack input, GasStack output) { @@ -245,7 +239,7 @@ public final class RecipeHandler { /** * Add a Chemical Washer recipe. * - * @param input - input GasStack + * @param input - input GasStack * @param output - output GasStack */ public static void addChemicalWasherRecipe(GasStack input, GasStack output) { @@ -255,7 +249,7 @@ public final class RecipeHandler { /** * Add a Chemical Crystallizer recipe. * - * @param input - input GasStack + * @param input - input GasStack * @param output - output ItemStack */ public static void addChemicalCrystallizerRecipe(GasStack input, ItemStack output) { @@ -265,18 +259,16 @@ public final class RecipeHandler { /** * Add a Pressurized Reaction Chamber recipe. * - * @param inputSolid - input ItemStack - * @param inputFluid - input FluidStack - * @param inputGas - input GasStack + * @param inputSolid - input ItemStack + * @param inputFluid - input FluidStack + * @param inputGas - input GasStack * @param outputSolid - output ItemStack - * @param outputGas - output GasStack + * @param outputGas - output GasStack * @param extraEnergy - extra energy needed by the recipe - * @param ticks - amount of ticks it takes for this recipe to complete + * @param ticks - amount of ticks it takes for this recipe to complete */ - public static void addPRCRecipe(ItemStack inputSolid, FluidStack inputFluid, GasStack inputGas, - ItemStack outputSolid, GasStack outputGas, double extraEnergy, int ticks) { - addRecipe(Recipe.PRESSURIZED_REACTION_CHAMBER, - new PressurizedRecipe(inputSolid, inputFluid, inputGas, outputSolid, outputGas, extraEnergy, ticks)); + public static void addPRCRecipe(ItemStack inputSolid, FluidStack inputFluid, GasStack inputGas, ItemStack outputSolid, GasStack outputGas, double extraEnergy, int ticks) { + addRecipe(Recipe.PRESSURIZED_REACTION_CHAMBER, new PressurizedRecipe(inputSolid, inputFluid, inputGas, outputSolid, outputGas, extraEnergy, ticks)); } public static void addThermalEvaporationRecipe(FluidStack inputFluid, FluidStack outputFluid) { @@ -295,22 +287,19 @@ public final class RecipeHandler { * Gets the Metallurgic Infuser Recipe for the InfusionInput in the parameters. * * @param input - input Infusion + * * @return MetallurgicInfuserRecipe */ @Nullable public static MetallurgicInfuserRecipe getMetallurgicInfuserRecipe(@Nonnull InfusionInput input) { if (input.isValid()) { Map recipes = Recipe.METALLURGIC_INFUSER.get(); - MetallurgicInfuserRecipe recipe = recipes.get(input); - if (recipe == null) { recipe = recipes.get(input.wildCopy()); } - return recipe == null ? null : recipe.copy(); } - return null; } @@ -318,17 +307,16 @@ public final class RecipeHandler { * Gets the Chemical Infuser Recipe of the ChemicalPairInput in the parameters. * * @param input - the pair of gases to infuse + * * @return ChemicalInfuserRecipe */ @Nullable public static ChemicalInfuserRecipe getChemicalInfuserRecipe(@Nonnull ChemicalPairInput input) { if (input.isValid()) { Map recipes = Recipe.CHEMICAL_INFUSER.get(); - ChemicalInfuserRecipe recipe = recipes.get(input); return recipe == null ? null : recipe.copy(); } - return null; } @@ -336,17 +324,16 @@ public final class RecipeHandler { * Gets the Chemical Crystallizer Recipe for the defined Gas input. * * @param input - GasInput + * * @return CrystallizerRecipe */ @Nullable public static CrystallizerRecipe getChemicalCrystallizerRecipe(@Nonnull GasInput input) { if (input.isValid()) { Map recipes = Recipe.CHEMICAL_CRYSTALLIZER.get(); - CrystallizerRecipe recipe = recipes.get(input); return recipe == null ? null : recipe.copy(); } - return null; } @@ -354,17 +341,16 @@ public final class RecipeHandler { * Gets the Chemical Washer Recipe for the defined Gas input. * * @param input - GasInput + * * @return WasherRecipe */ @Nullable public static WasherRecipe getChemicalWasherRecipe(@Nonnull GasInput input) { if (input.isValid()) { Map recipes = Recipe.CHEMICAL_WASHER.get(); - WasherRecipe recipe = recipes.get(input); return recipe == null ? null : recipe.copy(); } - return null; } @@ -372,17 +358,16 @@ public final class RecipeHandler { * Gets the Chemical Dissolution Chamber of the ItemStackInput in the parameters * * @param input - ItemStackInput + * * @return DissolutionRecipe */ @Nullable public static DissolutionRecipe getDissolutionRecipe(@Nonnull ItemStackInput input) { if (input.isValid()) { Map recipes = Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(); - DissolutionRecipe recipe = getRecipeTryWildcard(input, recipes); return recipe == null ? null : recipe.copy(); } - return null; } @@ -390,76 +375,70 @@ public final class RecipeHandler { * Gets the Chemical Oxidizer Recipe for the ItemStackInput in the parameters. * * @param input - ItemStackInput + * * @return OxidationRecipe */ @Nullable public static OxidationRecipe getOxidizerRecipe(@Nonnull ItemStackInput input) { if (input.isValid()) { Map recipes = Recipe.CHEMICAL_OXIDIZER.get(); - OxidationRecipe recipe = getRecipeTryWildcard(input, recipes); return recipe == null ? null : recipe.copy(); } - return null; } /** * Gets the ChanceMachineRecipe of the ItemStackInput in the parameters, using the map in the parameters. * - * @param input - ItemStackInput + * @param input - ItemStackInput * @param recipes - Map of recipes + * * @return ChanceRecipe */ @Nullable - public static > RECIPE getChanceRecipe(@Nonnull ItemStackInput input, - @Nonnull Map recipes) { + public static > RECIPE getChanceRecipe(@Nonnull ItemStackInput input, @Nonnull Map recipes) { if (input.isValid()) { RECIPE recipe = getRecipeTryWildcard(input, recipes); return recipe == null ? null : recipe.copy(); } - return null; } /** * Gets the BasicMachineRecipe of the ItemStackInput in the parameters, using the map in the parameters. * - * @param input - ItemStackInput + * @param input - ItemStackInput * @param recipes - Map of recipes + * * @return BasicMachineRecipe */ @Nullable - public static > RECIPE getRecipe(@Nonnull ItemStackInput input, - @Nonnull Map recipes) { + public static > RECIPE getRecipe(@Nonnull ItemStackInput input, @Nonnull Map recipes) { if (input.isValid()) { RECIPE recipe = getRecipeTryWildcard(input, recipes); return recipe == null ? null : recipe.copy(); } - return null; } /** * Gets the AdvancedMachineRecipe of the AdvancedInput in the parameters, using the map in the paramaters. * - * @param input - AdvancedInput + * @param input - AdvancedInput * @param recipes - Map of recipes + * * @return AdvancedMachineRecipe */ @Nullable - public static > RECIPE getRecipe(@Nonnull AdvancedMachineInput input, - @Nonnull Map recipes) { + public static > RECIPE getRecipe(@Nonnull AdvancedMachineInput input, @Nonnull Map recipes) { if (input.isValid()) { RECIPE recipe = recipes.get(input); - if (recipe == null) { recipe = recipes.get(input.wildCopy()); } - return recipe == null ? null : recipe.copy(); } - return null; } @@ -467,23 +446,20 @@ public final class RecipeHandler { /** * Gets the DoubleMachineRecipe of the DoubleInput in the parameters, using the map in the paramaters. * - * @param input - DoubleInput + * @param input - DoubleInput * @param recipes - Map of recipes + * * @return DoubleMachineRecipe */ @Nullable - public static > RECIPE getRecipe(@Nonnull DoubleMachineInput input, - @Nonnull Map recipes) { + public static > RECIPE getRecipe(@Nonnull DoubleMachineInput input, @Nonnull Map recipes) { if (input.isValid()) { RECIPE recipe = recipes.get(input); - if (recipe == null) { recipe = recipes.get(input.wildCopy()); } - return recipe == null ? null : recipe.copy(); } - return null; } @@ -491,17 +467,16 @@ public final class RecipeHandler { * Get the Electrolytic Separator Recipe corresponding to electrolysing a given fluid. * * @param input - the FluidInput to electrolyse fluid from + * * @return SeparatorRecipe */ @Nullable public static SeparatorRecipe getElectrolyticSeparatorRecipe(@Nonnull FluidInput input) { if (input.isValid()) { Map recipes = Recipe.ELECTROLYTIC_SEPARATOR.get(); - SeparatorRecipe recipe = recipes.get(input); return recipe == null ? null : recipe.copy(); } - return null; } @@ -509,11 +484,9 @@ public final class RecipeHandler { public static ThermalEvaporationRecipe getThermalEvaporationRecipe(@Nonnull FluidInput input) { if (input.isValid()) { Map recipes = Recipe.THERMAL_EVAPORATION_PLANT.get(); - ThermalEvaporationRecipe recipe = recipes.get(input); return recipe == null ? null : recipe.copy(); } - return null; } @@ -521,11 +494,9 @@ public final class RecipeHandler { public static SolarNeutronRecipe getSolarNeutronRecipe(@Nonnull GasInput input) { if (input.isValid()) { Map recipes = Recipe.SOLAR_NEUTRON_ACTIVATOR.get(); - SolarNeutronRecipe recipe = recipes.get(input); return recipe == null ? null : recipe.copy(); } - return null; } @@ -533,16 +504,12 @@ public final class RecipeHandler { public static PressurizedRecipe getPRCRecipe(@Nonnull PressurizedInput input) { if (input.isValid()) { Map recipes = Recipe.PRESSURIZED_REACTION_CHAMBER.get(); - PressurizedRecipe recipe = recipes.get(input); - if (recipe == null) { recipe = recipes.get(input.wildCopy()); } - return recipe == null ? null : recipe.copy(); } - return null; } @@ -550,7 +517,6 @@ public final class RecipeHandler { public static AmbientGasRecipe getDimensionGas(IntegerInput input) { Map recipes = Recipe.AMBIENT_ACCUMULATOR.get(); AmbientGasRecipe recipe = recipes.get(input); - return recipe == null ? null : recipe.copy(); } @@ -558,23 +524,21 @@ public final class RecipeHandler { * Gets the whether the input ItemStack is in a recipe * * @param itemstack - input ItemStack - * @param recipes - Map of recipes + * @param recipes - Map of recipes + * * @return whether the item can be used in a recipe */ - public static > boolean isInRecipe(@Nonnull ItemStack itemstack, - @Nonnull Map recipes) { + public static > boolean isInRecipe(@Nonnull ItemStack itemstack, @Nonnull Map recipes) { if (!itemstack.isEmpty()) { for (RECIPE recipe : recipes.values()) { ItemStackInput required = recipe.getInput(); NonNullList list = NonNullList.create(); list.add(itemstack); - if (required.useItemStackFromInventory(list, 0, false)) { return true; } } } - return false; } @@ -586,23 +550,18 @@ public final class RecipeHandler { } } } - return false; } - public static > RECIPE getRecipeTryWildcard(ItemStack stack, - @Nonnull Map recipes) { + public static > RECIPE getRecipeTryWildcard(ItemStack stack, @Nonnull Map recipes) { return getRecipeTryWildcard(new ItemStackInput(stack), recipes); } - public static > RECIPE getRecipeTryWildcard( - @Nonnull ItemStackInput input, @Nonnull Map recipes) { + public static > RECIPE getRecipeTryWildcard(@Nonnull ItemStackInput input, @Nonnull Map recipes) { RECIPE recipe = recipes.get(input); - if (recipe == null) { recipe = recipes.get(input.wildCopy()); } - return recipe; } @@ -611,80 +570,61 @@ public final class RecipeHandler { private static List values = new ArrayList<>(); public static final Recipe ENERGIZED_SMELTER = new Recipe<>( - MachineType.ENERGIZED_SMELTER.blockName, "ENERGIZED_SMELTER", ItemStackInput.class, ItemStackOutput.class, - SmeltingRecipe.class); + MachineType.ENERGIZED_SMELTER.blockName, "ENERGIZED_SMELTER", ItemStackInput.class, ItemStackOutput.class, SmeltingRecipe.class); public static final Recipe ENRICHMENT_CHAMBER = new Recipe<>( - MachineType.ENRICHMENT_CHAMBER.blockName, "ENRICHMENT_CHAMBER", ItemStackInput.class, - ItemStackOutput.class, EnrichmentRecipe.class); + MachineType.ENRICHMENT_CHAMBER.blockName, "ENRICHMENT_CHAMBER", ItemStackInput.class, ItemStackOutput.class, EnrichmentRecipe.class); public static final Recipe OSMIUM_COMPRESSOR = new Recipe<>( - MachineType.OSMIUM_COMPRESSOR.blockName, "OSMIUM_COMPRESSOR", AdvancedMachineInput.class, - ItemStackOutput.class, OsmiumCompressorRecipe.class); + MachineType.OSMIUM_COMPRESSOR.blockName, "OSMIUM_COMPRESSOR", AdvancedMachineInput.class, ItemStackOutput.class, OsmiumCompressorRecipe.class); public static final Recipe COMBINER = new Recipe<>( - MachineType.COMBINER.blockName, "COMBINER", DoubleMachineInput.class, ItemStackOutput.class, - CombinerRecipe.class); + MachineType.COMBINER.blockName, "COMBINER", DoubleMachineInput.class, ItemStackOutput.class, CombinerRecipe.class); public static final Recipe CRUSHER = new Recipe<>( - MachineType.CRUSHER.blockName, "CRUSHER", ItemStackInput.class, ItemStackOutput.class, - CrusherRecipe.class); + MachineType.CRUSHER.blockName, "CRUSHER", ItemStackInput.class, ItemStackOutput.class, CrusherRecipe.class); public static final Recipe PURIFICATION_CHAMBER = new Recipe<>( - MachineType.PURIFICATION_CHAMBER.blockName, "PURIFICATION_CHAMBER", AdvancedMachineInput.class, - ItemStackOutput.class, PurificationRecipe.class); + MachineType.PURIFICATION_CHAMBER.blockName, "PURIFICATION_CHAMBER", AdvancedMachineInput.class, ItemStackOutput.class, PurificationRecipe.class); public static final Recipe METALLURGIC_INFUSER = new Recipe<>( - MachineType.METALLURGIC_INFUSER.blockName, "METALLURGIC_INFUSER", InfusionInput.class, - ItemStackOutput.class, MetallurgicInfuserRecipe.class); + MachineType.METALLURGIC_INFUSER.blockName, "METALLURGIC_INFUSER", InfusionInput.class, ItemStackOutput.class, MetallurgicInfuserRecipe.class); public static final Recipe CHEMICAL_INFUSER = new Recipe<>( - MachineType.CHEMICAL_INFUSER.blockName, "CHEMICAL_INFUSER", ChemicalPairInput.class, GasOutput.class, - ChemicalInfuserRecipe.class); + MachineType.CHEMICAL_INFUSER.blockName, "CHEMICAL_INFUSER", ChemicalPairInput.class, GasOutput.class, ChemicalInfuserRecipe.class); public static final Recipe CHEMICAL_OXIDIZER = new Recipe<>( - MachineType.CHEMICAL_OXIDIZER.blockName, "CHEMICAL_OXIDIZER", ItemStackInput.class, GasOutput.class, - OxidationRecipe.class); + MachineType.CHEMICAL_OXIDIZER.blockName, "CHEMICAL_OXIDIZER", ItemStackInput.class, GasOutput.class, OxidationRecipe.class); public static final Recipe CHEMICAL_INJECTION_CHAMBER = new Recipe<>( - MachineType.CHEMICAL_INJECTION_CHAMBER.blockName, "CHEMICAL_INJECTION_CHAMBER", - AdvancedMachineInput.class, ItemStackOutput.class, InjectionRecipe.class); + MachineType.CHEMICAL_INJECTION_CHAMBER.blockName, "CHEMICAL_INJECTION_CHAMBER", AdvancedMachineInput.class, ItemStackOutput.class, InjectionRecipe.class); public static final Recipe ELECTROLYTIC_SEPARATOR = new Recipe<>( - MachineType.ELECTROLYTIC_SEPARATOR.blockName, "ELECTROLYTIC_SEPARATOR", FluidInput.class, - ChemicalPairOutput.class, SeparatorRecipe.class); + MachineType.ELECTROLYTIC_SEPARATOR.blockName, "ELECTROLYTIC_SEPARATOR", FluidInput.class, ChemicalPairOutput.class, SeparatorRecipe.class); public static final Recipe PRECISION_SAWMILL = new Recipe<>( - MachineType.PRECISION_SAWMILL.blockName, "PRECISION_SAWMILL", ItemStackInput.class, ChanceOutput.class, - SawmillRecipe.class); + MachineType.PRECISION_SAWMILL.blockName, "PRECISION_SAWMILL", ItemStackInput.class, ChanceOutput.class, SawmillRecipe.class); public static final Recipe CHEMICAL_DISSOLUTION_CHAMBER = new Recipe<>( - MachineType.CHEMICAL_DISSOLUTION_CHAMBER.blockName, "CHEMICAL_DISSOLUTION_CHAMBER", ItemStackInput.class, - GasOutput.class, DissolutionRecipe.class); + MachineType.CHEMICAL_DISSOLUTION_CHAMBER.blockName, "CHEMICAL_DISSOLUTION_CHAMBER", ItemStackInput.class, GasOutput.class, DissolutionRecipe.class); public static final Recipe CHEMICAL_WASHER = new Recipe<>( - MachineType.CHEMICAL_WASHER.blockName, "CHEMICAL_WASHER", GasInput.class, GasOutput.class, - WasherRecipe.class); + MachineType.CHEMICAL_WASHER.blockName, "CHEMICAL_WASHER", GasInput.class, GasOutput.class, WasherRecipe.class); public static final Recipe CHEMICAL_CRYSTALLIZER = new Recipe<>( - MachineType.CHEMICAL_CRYSTALLIZER.blockName, "CHEMICAL_CRYSTALLIZER", GasInput.class, - ItemStackOutput.class, CrystallizerRecipe.class); + MachineType.CHEMICAL_CRYSTALLIZER.blockName, "CHEMICAL_CRYSTALLIZER", GasInput.class, ItemStackOutput.class, CrystallizerRecipe.class); public static final Recipe PRESSURIZED_REACTION_CHAMBER = new Recipe<>( - MachineType.PRESSURIZED_REACTION_CHAMBER.blockName, "PRESSURIZED_REACTION_CHAMBER", - PressurizedInput.class, PressurizedOutput.class, PressurizedRecipe.class); + MachineType.PRESSURIZED_REACTION_CHAMBER.blockName, "PRESSURIZED_REACTION_CHAMBER", PressurizedInput.class, PressurizedOutput.class, PressurizedRecipe.class); public static final Recipe AMBIENT_ACCUMULATOR = new Recipe<>( - MachineType.AMBIENT_ACCUMULATOR.blockName, "AMBIENT_ACCUMULATOR", IntegerInput.class, GasOutput.class, - AmbientGasRecipe.class); + MachineType.AMBIENT_ACCUMULATOR.blockName, "AMBIENT_ACCUMULATOR", IntegerInput.class, GasOutput.class, AmbientGasRecipe.class); public static final Recipe THERMAL_EVAPORATION_PLANT = new Recipe<>( - "ThermalEvaporationPlant", "THERMAL_EVAPORATION_PLANT", FluidInput.class, FluidOutput.class, - ThermalEvaporationRecipe.class); + "ThermalEvaporationPlant", "THERMAL_EVAPORATION_PLANT", FluidInput.class, FluidOutput.class, ThermalEvaporationRecipe.class); public static final Recipe SOLAR_NEUTRON_ACTIVATOR = new Recipe<>( - MachineType.SOLAR_NEUTRON_ACTIVATOR.blockName, "SOLAR_NEUTRON_ACTIVATOR", GasInput.class, GasOutput.class, - SolarNeutronRecipe.class); + MachineType.SOLAR_NEUTRON_ACTIVATOR.blockName, "SOLAR_NEUTRON_ACTIVATOR", GasInput.class, GasOutput.class, SolarNeutronRecipe.class); static { values = ImmutableList.copyOf(values); @@ -744,7 +684,6 @@ public final class RecipeHandler { try { MachineInput input = inputClass.newInstance(); input.load(nbtTags); - return (INPUT) input; } catch (Exception e) { return null; @@ -756,14 +695,11 @@ public final class RecipeHandler { try { MachineOutput output = outputClass.newInstance(); output.load(nbtTags); - try { - Constructor construct = recipeClass - .getDeclaredConstructor(inputClass, outputClass); + Constructor construct = recipeClass.getDeclaredConstructor(inputClass, outputClass); return (RECIPE) construct.newInstance(input, output); } catch (Exception e) { - Constructor construct = recipeClass - .getDeclaredConstructor(inputClass, outputClass, NBTTagCompound.class); + Constructor construct = recipeClass.getDeclaredConstructor(inputClass, outputClass, NBTTagCompound.class); return (RECIPE) construct.newInstance(input, output, nbtTags); } } catch (Exception e) { @@ -776,7 +712,6 @@ public final class RecipeHandler { for (Entry entry : recipes.entrySet()) { if (entry.getKey() instanceof ItemStackInput) { ItemStack stack = ((ItemStackInput) entry.getKey()).ingredient; - if (StackUtils.equalsWildcard(stack, input)) { return true; } @@ -786,13 +721,11 @@ public final class RecipeHandler { } } else if (entry.getKey() instanceof AdvancedMachineInput) { ItemStack stack = ((AdvancedMachineInput) entry.getKey()).itemStack; - if (StackUtils.equalsWildcard(stack, input)) { return true; } } } - return false; } @@ -805,7 +738,6 @@ public final class RecipeHandler { } } } - return false; } @@ -822,7 +754,6 @@ public final class RecipeHandler { return true; } } - return false; } @@ -845,4 +776,4 @@ public final class RecipeHandler { return null; }*/ } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/ShapedMekanismRecipe.java b/src/main/java/mekanism/common/recipe/ShapedMekanismRecipe.java index ff22d86c5..ab617e219 100644 --- a/src/main/java/mekanism/common/recipe/ShapedMekanismRecipe.java +++ b/src/main/java/mekanism/common/recipe/ShapedMekanismRecipe.java @@ -1,11 +1,11 @@ package mekanism.common.recipe; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; +import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Set; import javax.annotation.Nonnull; @@ -48,38 +48,29 @@ public class ShapedMekanismRecipe extends ShapedOreRecipe { public static ShapedMekanismRecipe create(NBTTagCompound nbtTags) { if (!nbtTags.hasKey("result") || !nbtTags.hasKey("input")) { - Mekanism.logger - .error(Mekanism.LOG_TAG + " Shaped recipe parse error: missing input or result compound tag."); + Mekanism.logger.error(Mekanism.LOG_TAG + " Shaped recipe parse error: missing input or result compound tag."); return null; } - ItemStack result = new ItemStack(nbtTags.getCompoundTag("result")); NBTTagList list = nbtTags.getTagList("input", Constants.NBT.TAG_COMPOUND); - if (result.isEmpty() || list.tagCount() == 0) { - Mekanism.logger - .error(Mekanism.LOG_TAG + " Shaped recipe parse error: invalid result stack or input data list."); + Mekanism.logger.error(Mekanism.LOG_TAG + " Shaped recipe parse error: invalid result stack or input data list."); return null; } Object[] ret = new Object[list.tagCount()]; - for (int i = 0; i < list.tagCount(); i++) { NBTTagCompound compound = list.getCompoundTagAt(i); - if (compound.hasKey("oredict")) { ret[i] = compound.getString("oredict"); } else if (compound.hasKey("pattern")) { ret[i] = compound.getString("pattern"); } else if (compound.hasKey("character")) { String s = compound.getString("character"); - if (s.length() > 1) { - Mekanism.logger - .error(Mekanism.LOG_TAG + " Shaped recipe parse error: invalid pattern character data."); + Mekanism.logger.error(Mekanism.LOG_TAG + " Shaped recipe parse error: invalid pattern character data."); return null; } - ret[i] = compound.getString("character").toCharArray()[0]; } else if (compound.hasKey("itemstack")) { ret[i] = new ItemStack(compound.getCompoundTag("itemstack")); @@ -88,7 +79,6 @@ public class ShapedMekanismRecipe extends ShapedOreRecipe { return null; } } - return new ShapedMekanismRecipe(null, result, ret); //TODO Find out correct value for group } @@ -98,23 +88,20 @@ public class ShapedMekanismRecipe extends ShapedOreRecipe { //if (!group.isEmpty() && group.indexOf(':') == -1) // group = context.getModId() + ":" + group; - Map ingMap = Maps.newHashMap(); + Map ingMap = new HashMap<>(); for (Map.Entry entry : JsonUtils.getJsonObject(json, "key").entrySet()) { if (entry.getKey().length() != 1) { - throw new JsonSyntaxException( - "Invalid key entry: '" + entry.getKey() + "' is an invalid symbol (must be 1 character only)."); + throw new JsonSyntaxException("Invalid key entry: '" + entry.getKey() + "' is an invalid symbol (must be 1 character only)."); } if (" ".equals(entry.getKey())) { throw new JsonSyntaxException("Invalid key entry: ' ' is a reserved symbol."); } - ingMap.put(entry.getKey().toCharArray()[0], CraftingHelper.getIngredient(entry.getValue(), context)); } ingMap.put(' ', Ingredient.EMPTY); JsonArray patternJ = JsonUtils.getJsonArray(json, "pattern"); - if (patternJ.size() == 0) { throw new JsonSyntaxException("Invalid pattern: empty pattern not allowed"); } @@ -134,7 +121,7 @@ public class ShapedMekanismRecipe extends ShapedOreRecipe { primer.mirrored = JsonUtils.getBoolean(json, "mirrored", true); primer.input = NonNullList.withSize(primer.width * primer.height, Ingredient.EMPTY); - Set keys = Sets.newHashSet(ingMap.keySet()); + Set keys = new HashSet<>(ingMap.keySet()); keys.remove(' '); int x = 0; @@ -142,8 +129,7 @@ public class ShapedMekanismRecipe extends ShapedOreRecipe { for (char chr : line.toCharArray()) { Ingredient ing = ingMap.get(chr); if (ing == null) { - throw new JsonSyntaxException( - "Pattern references symbol '" + chr + "' but it's not defined in the key"); + throw new JsonSyntaxException("Pattern references symbol '" + chr + "' but it's not defined in the key"); } primer.input.set(x++, ing); keys.remove(chr); @@ -153,7 +139,6 @@ public class ShapedMekanismRecipe extends ShapedOreRecipe { if (!keys.isEmpty()) { throw new JsonSyntaxException("Key defines symbols that aren't used in pattern: " + keys); } - ItemStack result = CraftingHelper.getItemStack(JsonUtils.getJsonObject(json, "result"), context); return new ShapedMekanismRecipe(group.isEmpty() ? null : new ResourceLocation(group), result, primer); } @@ -172,4 +157,4 @@ public class ShapedMekanismRecipe extends ShapedOreRecipe { return ShapedMekanismRecipe.factory(context, json); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/ShapelessMekanismRecipe.java b/src/main/java/mekanism/common/recipe/ShapelessMekanismRecipe.java index 59a532041..84827266a 100644 --- a/src/main/java/mekanism/common/recipe/ShapelessMekanismRecipe.java +++ b/src/main/java/mekanism/common/recipe/ShapelessMekanismRecipe.java @@ -44,25 +44,20 @@ public class ShapelessMekanismRecipe extends ShapelessOreRecipe { public static ShapelessMekanismRecipe create(NBTTagCompound nbtTags) { if (!nbtTags.hasKey("result") || !nbtTags.hasKey("input")) { - Mekanism.logger - .error(Mekanism.LOG_TAG + " Shapeless recipe parse error: missing input or result compound tag."); + Mekanism.logger.error(Mekanism.LOG_TAG + " Shapeless recipe parse error: missing input or result compound tag."); return null; } ItemStack result = new ItemStack(nbtTags.getCompoundTag("result")); NBTTagList list = nbtTags.getTagList("input", Constants.NBT.TAG_COMPOUND); - if (result.isEmpty() || list.tagCount() == 0) { - Mekanism.logger - .error(Mekanism.LOG_TAG + " Shapeless recipe parse error: invalid result stack or input data list."); + Mekanism.logger.error(Mekanism.LOG_TAG + " Shapeless recipe parse error: invalid result stack or input data list."); return null; } Object[] ret = new Object[list.tagCount()]; - for (int i = 0; i < list.tagCount(); i++) { NBTTagCompound compound = list.getCompoundTagAt(i); - if (compound.hasKey("oredict")) { ret[i] = compound.getString("oredict"); } else if (compound.hasKey("itemstack")) { @@ -72,7 +67,6 @@ public class ShapelessMekanismRecipe extends ShapelessOreRecipe { return null; } } - return new ShapelessMekanismRecipe(null, result, ret); //TODO Find out correct value for group } @@ -84,11 +78,9 @@ public class ShapelessMekanismRecipe extends ShapelessOreRecipe { for (JsonElement ele : JsonUtils.getJsonArray(json, "ingredients")) { ings.add(CraftingHelper.getIngredient(ele, context)); } - if (ings.isEmpty()) { throw new JsonParseException("No ingredients for shapeless recipe"); } - ItemStack itemstack = ShapedRecipes.deserializeItem(JsonUtils.getJsonObject(json, "result"), true); return new ShapelessMekanismRecipe(group.isEmpty() ? null : new ResourceLocation(group), ings, itemstack); } @@ -107,4 +99,4 @@ public class ShapelessMekanismRecipe extends ShapelessOreRecipe { return ShapelessMekanismRecipe.factory(context, json); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/inputs/AdvancedMachineInput.java b/src/main/java/mekanism/common/recipe/inputs/AdvancedMachineInput.java index f3648352c..7516f331b 100644 --- a/src/main/java/mekanism/common/recipe/inputs/AdvancedMachineInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/AdvancedMachineInput.java @@ -43,10 +43,8 @@ public class AdvancedMachineInput extends MachineInput { if (deplete) { inventory.set(index, StackUtils.subtract(inventory.get(index), itemStack)); } - return true; } - return false; } @@ -55,13 +53,11 @@ public class AdvancedMachineInput extends MachineInput { gasTank.draw(amountToUse, deplete); return true; } - return false; } public boolean matches(AdvancedMachineInput input) { - return StackUtils.equalsWildcard(itemStack, input.itemStack) && input.itemStack.getCount() >= itemStack - .getCount(); + return StackUtils.equalsWildcard(itemStack, input.itemStack) && input.itemStack.getCount() >= itemStack.getCount(); } @Override @@ -74,7 +70,6 @@ public class AdvancedMachineInput extends MachineInput { if (!isValid()) { return !other.isValid(); } - return MachineInput.inputItemMatches(itemStack, other.itemStack) && gasType.getID() == other.gasType.getID(); } @@ -84,7 +79,6 @@ public class AdvancedMachineInput extends MachineInput { } public AdvancedMachineInput wildCopy() { - return new AdvancedMachineInput( - new ItemStack(itemStack.getItem(), itemStack.getCount(), OreDictionary.WILDCARD_VALUE), gasType); + return new AdvancedMachineInput(new ItemStack(itemStack.getItem(), itemStack.getCount(), OreDictionary.WILDCARD_VALUE), gasType); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/inputs/ChemicalPairInput.java b/src/main/java/mekanism/common/recipe/inputs/ChemicalPairInput.java index 1e0c9b64b..e632ea997 100644 --- a/src/main/java/mekanism/common/recipe/inputs/ChemicalPairInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/ChemicalPairInput.java @@ -24,7 +24,7 @@ public class ChemicalPairInput extends MachineInput { /** * Creates a chemical input with two defined gasses. * - * @param left - left gas + * @param left - left gas * @param right - right gas */ public ChemicalPairInput(GasStack left, GasStack right) { @@ -44,23 +44,19 @@ public class ChemicalPairInput extends MachineInput { public boolean useGas(GasTank leftTank, GasTank rightTank, boolean deplete, int scale) { int leftAmount = leftGas.amount * scale; int rightAmount = rightGas.amount * scale; - if (leftTank.canDraw(leftGas.getGas()) && rightTank.canDraw(rightGas.getGas())) { if (leftTank.getStored() >= leftAmount && rightTank.getStored() >= rightAmount) { leftTank.draw(leftAmount, deplete); rightTank.draw(rightAmount, deplete); - return true; } } else if (leftTank.canDraw(rightGas.getGas()) && rightTank.canDraw(leftGas.getGas())) { if (leftTank.getStored() >= rightAmount && rightTank.getStored() >= leftAmount) { leftTank.draw(rightAmount, deplete); rightTank.draw(leftAmount, deplete); - return true; } } - return false; } @@ -73,10 +69,10 @@ public class ChemicalPairInput extends MachineInput { } /** - * Whether or not the defined input contains the same gasses and at least the required amount of the defined gasses - * as this input. + * 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 + * * @return if the input meets this input's requirements */ public boolean meetsInput(ChemicalPairInput input) { @@ -95,7 +91,7 @@ public class ChemicalPairInput extends MachineInput { /** * Draws the needed amount of gas from each tank. * - * @param leftTank - left tank to draw from + * @param leftTank - left tank to draw from * @param rightTank - right tank to draw from */ public void draw(GasTank leftTank, GasTank rightTank) { @@ -112,13 +108,13 @@ public class ChemicalPairInput extends MachineInput { * 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 + * * @return if the stack's gas type is contained in this ChemicalInput */ public boolean containsType(GasStack stack) { if (stack == null || stack.amount == 0) { return false; } - return stack.isGasEqual(leftGas) || stack.isGasEqual(rightGas); } @@ -126,17 +122,16 @@ public class ChemicalPairInput extends MachineInput { * Actual implementation of meetsInput(), performs the checks. * * @param input - input to check + * * @return if the input meets this input's requirements */ private boolean meets(ChemicalPairInput input) { if (input == null || !input.isValid()) { 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; } @@ -156,11 +151,11 @@ public class ChemicalPairInput extends MachineInput { return !other.isValid(); } return (other.leftGas.hashCode() == leftGas.hashCode() && other.rightGas.hashCode() == rightGas.hashCode()) - || (other.leftGas.hashCode() == rightGas.hashCode() && other.rightGas.hashCode() == leftGas.hashCode()); + || (other.leftGas.hashCode() == rightGas.hashCode() && other.rightGas.hashCode() == leftGas.hashCode()); } @Override public boolean isInstance(Object other) { return other instanceof ChemicalPairInput; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/inputs/DoubleMachineInput.java b/src/main/java/mekanism/common/recipe/inputs/DoubleMachineInput.java index 14859513a..9513df150 100644 --- a/src/main/java/mekanism/common/recipe/inputs/DoubleMachineInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/DoubleMachineInput.java @@ -40,10 +40,8 @@ public class DoubleMachineInput extends MachineInput { if (deplete) { inventory.set(index, StackUtils.subtract(inventory.get(index), stack)); } - return true; } - return false; } @@ -56,10 +54,8 @@ public class DoubleMachineInput extends MachineInput { } public boolean matches(DoubleMachineInput input) { - return StackUtils.equalsWildcard(itemStack, input.itemStack) && input.itemStack.getCount() >= itemStack - .getCount() - && StackUtils.equalsWildcard(extraStack, input.extraStack) && input.extraStack.getCount() >= extraStack - .getCount(); + return StackUtils.equalsWildcard(itemStack, input.itemStack) && input.itemStack.getCount() >= itemStack.getCount() + && StackUtils.equalsWildcard(extraStack, input.extraStack) && input.extraStack.getCount() >= extraStack.getCount(); } @Override @@ -72,9 +68,7 @@ public class DoubleMachineInput extends MachineInput { if (!isValid()) { return !other.isValid(); } - - return MachineInput.inputItemMatches(itemStack, other.itemStack) && MachineInput - .inputItemMatches(extraStack, other.extraStack); + return MachineInput.inputItemMatches(itemStack, other.itemStack) && MachineInput.inputItemMatches(extraStack, other.extraStack); } @Override @@ -83,8 +77,7 @@ public class DoubleMachineInput extends MachineInput { } public DoubleMachineInput wildCopy() { - return new DoubleMachineInput( - new ItemStack(itemStack.getItem(), itemStack.getCount(), OreDictionary.WILDCARD_VALUE), + return new DoubleMachineInput(new ItemStack(itemStack.getItem(), itemStack.getCount(), OreDictionary.WILDCARD_VALUE), new ItemStack(extraStack.getItem(), extraStack.getCount(), OreDictionary.WILDCARD_VALUE)); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/inputs/FluidInput.java b/src/main/java/mekanism/common/recipe/inputs/FluidInput.java index 21a28b43a..201776104 100644 --- a/src/main/java/mekanism/common/recipe/inputs/FluidInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/FluidInput.java @@ -35,7 +35,6 @@ public class FluidInput extends MachineInput { fluidTank.drain(ingredient.amount * scale, deplete); return true; } - return false; } @@ -49,7 +48,6 @@ public class FluidInput extends MachineInput { if (!isValid()) { return !other.isValid(); } - return ingredient.equals(other.ingredient); } @@ -57,4 +55,4 @@ public class FluidInput extends MachineInput { public boolean isInstance(Object other) { return other instanceof FluidInput; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/inputs/GasInput.java b/src/main/java/mekanism/common/recipe/inputs/GasInput.java index db4303bf9..88e18d106 100644 --- a/src/main/java/mekanism/common/recipe/inputs/GasInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/GasInput.java @@ -33,10 +33,8 @@ public class GasInput extends MachineInput { public boolean useGas(GasTank gasTank, boolean deplete, int scale) { if (gasTank.getGasType() == ingredient.getGas() && gasTank.getStored() >= ingredient.amount * scale) { gasTank.draw(ingredient.amount * scale, deplete); - return true; } - return false; } @@ -50,7 +48,6 @@ public class GasInput extends MachineInput { if (!isValid()) { return !other.isValid(); } - return other.ingredient.hashCode() == ingredient.hashCode(); } @@ -58,4 +55,4 @@ public class GasInput extends MachineInput { public boolean isInstance(Object other) { return other instanceof GasInput; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/inputs/InfusionInput.java b/src/main/java/mekanism/common/recipe/inputs/InfusionInput.java index f1801f02f..3adc2bca9 100644 --- a/src/main/java/mekanism/common/recipe/inputs/InfusionInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/InfusionInput.java @@ -10,8 +10,7 @@ import net.minecraft.util.NonNullList; import net.minecraftforge.oredict.OreDictionary; /** - * An infusion input, containing the type of and amount of infuse the operation requires, as well as the input - * ItemStack. + * An infusion input, containing the type of and amount of infuse the operation requires, as well as the input ItemStack. * * @author AidanBrady */ @@ -61,10 +60,8 @@ public class InfusionInput extends MachineInput { inventory.set(index, StackUtils.subtract(inventory.get(index), inputStack)); infuseStorage.subtract(infuse); } - return true; } - return false; } @@ -78,7 +75,6 @@ public class InfusionInput extends MachineInput { if (!isValid()) { return !other.isValid(); } - return infuse.getType() == other.infuse.getType() && MachineInput.inputItemMatches(inputStack, other.inputStack); } @@ -88,7 +84,6 @@ public class InfusionInput extends MachineInput { } public InfusionInput wildCopy() { - return new InfusionInput(infuse, - new ItemStack(inputStack.getItem(), inputStack.getCount(), OreDictionary.WILDCARD_VALUE)); + return new InfusionInput(infuse, new ItemStack(inputStack.getItem(), inputStack.getCount(), OreDictionary.WILDCARD_VALUE)); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/inputs/IntegerInput.java b/src/main/java/mekanism/common/recipe/inputs/IntegerInput.java index 2b343570f..c32a3aa91 100644 --- a/src/main/java/mekanism/common/recipe/inputs/IntegerInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/IntegerInput.java @@ -42,4 +42,4 @@ public class IntegerInput extends MachineInput { public boolean isInstance(Object other) { return other instanceof IntegerInput; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/inputs/ItemStackInput.java b/src/main/java/mekanism/common/recipe/inputs/ItemStackInput.java index 65e308d2b..8e70cc695 100644 --- a/src/main/java/mekanism/common/recipe/inputs/ItemStackInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/ItemStackInput.java @@ -40,8 +40,7 @@ public class ItemStackInput extends MachineInput { public ItemStackInput wildCopy() { if (wildVersion == null) { if (ingredient.getMetadata() != OreDictionary.WILDCARD_VALUE) { - this.wildVersion = new ItemStackInput( - new ItemStack(ingredient.getItem(), ingredient.getCount(), OreDictionary.WILDCARD_VALUE)); + this.wildVersion = new ItemStackInput(new ItemStack(ingredient.getItem(), ingredient.getCount(), OreDictionary.WILDCARD_VALUE)); } else { this.wildVersion = this; } @@ -54,10 +53,8 @@ public class ItemStackInput extends MachineInput { if (deplete) { inventory.set(index, StackUtils.subtract(inventory.get(index), ingredient)); } - return true; } - return false; } @@ -80,4 +77,4 @@ public class ItemStackInput extends MachineInput { public int hashCode() { return ingredientHash; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/inputs/MachineInput.java b/src/main/java/mekanism/common/recipe/inputs/MachineInput.java index 894ac1efa..4e2045ff9 100644 --- a/src/main/java/mekanism/common/recipe/inputs/MachineInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/MachineInput.java @@ -21,7 +21,6 @@ public abstract class MachineInput> { if (!container.isEmpty() && container.getCount() >= contained.getCount()) { return inputItemMatches(container, contained); } - return false; } @@ -34,24 +33,22 @@ public abstract class MachineInput> { public abstract void load(NBTTagCompound nbtTags); /** - * Test equality to another input. This should return true if the input matches this one, IGNORING AMOUNTS. Allows - * usage of HashMap optimisation to get recipes. + * Test equality to another input. This should return true if the input matches this one, IGNORING AMOUNTS. Allows usage of HashMap optimisation to get recipes. * * @param other The other input to check + * * @return True if input matches this one, IGNORING AMOUNTS! */ public abstract boolean testEquality(INPUT other); public static boolean inputItemMatches(ItemStack container, ItemStack contained) { - return ITEM_MATCHER_OVERRIDES.getOrDefault(container.getItem().getClass(), DEFAULT_MATCHER) - .test(container, contained); + return ITEM_MATCHER_OVERRIDES.getOrDefault(container.getItem().getClass(), DEFAULT_MATCHER).test(container, contained); } private static boolean inputItemMatchesDefault(ItemStack container, ItemStack contained) { if (OreDictCache.getOreDictName(container).contains("treeSapling")) { return StackUtils.equalsWildcard(contained, container); } - return StackUtils.equalsWildcardWithNBT(contained, container) && container.getCount() >= contained.getCount(); } @@ -65,7 +62,6 @@ public abstract class MachineInput> { if (isInstance(other)) { return testEquality((INPUT) other); } - return false; } @@ -78,9 +74,10 @@ public abstract class MachineInput> { * Test equality to another input. This should return true if the input matches this one, IGNORING AMOUNTS. * * @param definition The ingredient stored in the ItemStackInput - * @param test The other input to check + * @param test The other input to check + * * @return True if input matches this one, IGNORING AMOUNTS! */ boolean test(ItemStack definition, ItemStack test); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/inputs/PressurizedInput.java b/src/main/java/mekanism/common/recipe/inputs/PressurizedInput.java index b9cb6239d..9cacfe14d 100644 --- a/src/main/java/mekanism/common/recipe/inputs/PressurizedInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/PressurizedInput.java @@ -43,48 +43,43 @@ public class PressurizedInput extends MachineInput { return !theSolid.isEmpty() && theFluid != null && theGas != null; } - public boolean use(NonNullList inventory, int index, FluidTank fluidTank, GasTank gasTank, - boolean deplete) { + public boolean use(NonNullList inventory, int index, FluidTank fluidTank, GasTank gasTank, boolean deplete) { if (meets(new PressurizedInput(inventory.get(index), fluidTank.getFluid(), gasTank.getGas()))) { if (deplete) { inventory.set(index, StackUtils.subtract(inventory.get(index), theSolid)); fluidTank.drain(theFluid.amount, true); gasTank.draw(theGas.amount, true); } - return true; } - return false; } /** - * Whether or not this PressurizedReactants's ItemStack entry's item type is equal to the item type of the given - * item. + * Whether or not this PressurizedReactants's ItemStack entry's item type is equal to the item type of the given item. * * @param stack - stack to check + * * @return if the stack's item type is contained in this PressurizedReactants */ public boolean containsType(ItemStack stack) { if (stack.isEmpty() || stack.getCount() == 0) { return false; } - return MachineInput.inputItemMatches(stack, theSolid); } /** - * Whether or not this PressurizedReactants's FluidStack entry's fluid type is equal to the fluid type of the given - * fluid. + * Whether or not this PressurizedReactants's FluidStack entry's fluid type is equal to the fluid type of the given fluid. * * @param stack - stack to check + * * @return if the stack's fluid type is contained in this PressurizedReactants */ public boolean containsType(FluidStack stack) { if (stack == null || stack.amount == 0) { return false; } - return stack.isFluidEqual(theFluid); } @@ -92,13 +87,13 @@ public class PressurizedInput extends MachineInput { * Whether or not this PressurizedReactants's GasStack entry's gas type is equal to the gas type of the given gas. * * @param stack - stack to check + * * @return if the stack's gas type is contained in this PressurizedReactants */ public boolean containsType(GasStack stack) { if (stack == null || stack.amount == 0) { return false; } - return stack.isGasEqual(theGas); } @@ -106,20 +101,17 @@ public class PressurizedInput extends MachineInput { * Actual implementation of meetsInput(), performs the checks. * * @param input - input to check + * * @return if the input meets this input's requirements */ public boolean meets(PressurizedInput input) { if (input == null || !input.isValid()) { return false; } - - if (!(StackUtils.equalsWildcard(input.theSolid, theSolid) && input.theFluid.isFluidEqual(theFluid) - && input.theGas.isGasEqual(theGas))) { + if (!(StackUtils.equalsWildcard(input.theSolid, theSolid) && input.theFluid.isFluidEqual(theFluid) && input.theGas.isGasEqual(theGas))) { return false; } - - return input.theSolid.getCount() >= theSolid.getCount() && input.theFluid.amount >= theFluid.amount - && input.theGas.amount >= theGas.amount; + return input.theSolid.getCount() >= theSolid.getCount() && input.theFluid.amount >= theFluid.amount && input.theGas.amount >= theGas.amount; } @Override @@ -141,8 +133,7 @@ public class PressurizedInput extends MachineInput { @Override public int hashIngredients() { - return StackUtils.hashItemStack(theSolid) << 16 - | (theFluid.getFluid() != null ? theFluid.getFluid().hashCode() : 0) << 8 | theGas.hashCode(); + return StackUtils.hashItemStack(theSolid) << 16 | (theFluid.getFluid() != null ? theFluid.getFluid().hashCode() : 0) << 8 | theGas.hashCode(); } @Override @@ -156,7 +147,6 @@ public class PressurizedInput extends MachineInput { } public PressurizedInput wildCopy() { - return new PressurizedInput( - new ItemStack(theSolid.getItem(), theSolid.getCount(), OreDictionary.WILDCARD_VALUE), theFluid, theGas); + return new PressurizedInput(new ItemStack(theSolid.getItem(), theSolid.getCount(), OreDictionary.WILDCARD_VALUE), theFluid, theGas); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/machines/AdvancedMachineRecipe.java b/src/main/java/mekanism/common/recipe/machines/AdvancedMachineRecipe.java index ff4a78594..b850c12b1 100644 --- a/src/main/java/mekanism/common/recipe/machines/AdvancedMachineRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/AdvancedMachineRecipe.java @@ -7,8 +7,7 @@ import mekanism.common.recipe.outputs.ItemStackOutput; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; -public abstract class AdvancedMachineRecipe> extends - MachineRecipe { +public abstract class AdvancedMachineRecipe> extends MachineRecipe { public AdvancedMachineRecipe(AdvancedMachineInput input, ItemStackOutput output) { super(input, output); @@ -22,16 +21,13 @@ public abstract class AdvancedMachineRecipe inventory, int inputIndex, int outputIndex, GasTank gasTank, - int amount) { - return inputMatches(inventory, inputIndex, gasTank, amount) && getOutput() - .applyOutputs(inventory, outputIndex, false); + public boolean canOperate(NonNullList inventory, int inputIndex, int outputIndex, GasTank gasTank, int amount) { + return inputMatches(inventory, inputIndex, gasTank, amount) && getOutput().applyOutputs(inventory, outputIndex, false); } - public void operate(NonNullList inventory, int inputIndex, int outputIndex, GasTank gasTank, - int needed) { + public void operate(NonNullList inventory, int inputIndex, int outputIndex, GasTank gasTank, int needed) { if (getInput().useItem(inventory, inputIndex, true) && getInput().useSecondary(gasTank, needed, true)) { getOutput().applyOutputs(inventory, outputIndex, true); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/machines/AmbientGasRecipe.java b/src/main/java/mekanism/common/recipe/machines/AmbientGasRecipe.java index e6f660c20..186f05dcb 100644 --- a/src/main/java/mekanism/common/recipe/machines/AmbientGasRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/AmbientGasRecipe.java @@ -18,4 +18,4 @@ public class AmbientGasRecipe extends MachineRecipe> extends - MachineRecipe { +public abstract class BasicMachineRecipe> extends MachineRecipe { public BasicMachineRecipe(ItemStackInput input, ItemStackOutput output) { super(input, output); @@ -29,4 +28,4 @@ public abstract class BasicMachineRecipe> extends - MachineRecipe { +public abstract class ChanceMachineRecipe> extends MachineRecipe { public ChanceMachineRecipe(ItemStackInput input, ChanceOutput output) { super(input, output); @@ -17,8 +16,7 @@ public abstract class ChanceMachineRecipe inventory, int inputIndex, int primaryIndex, int secondaryIndex) { - return inputMatches(inventory, inputIndex) && getOutput() - .applyOutputs(inventory, primaryIndex, secondaryIndex, false); + return inputMatches(inventory, inputIndex) && getOutput().applyOutputs(inventory, primaryIndex, secondaryIndex, false); } public void operate(NonNullList inventory, int inputIndex, int primaryIndex, int secondaryIndex) { @@ -26,4 +24,4 @@ public abstract class ChanceMachineRecipe { } /** - * @deprecated Replaced by {@link #CombinerRecipe(ItemStack, ItemStack, ItemStack)}. May be removed with Minecraft - * 1.13. + * @deprecated Replaced by {@link #CombinerRecipe(ItemStack, ItemStack, ItemStack)}. May be removed with Minecraft 1.13. */ @Deprecated public CombinerRecipe(ItemStack input, ItemStack output) { @@ -28,4 +27,4 @@ public class CombinerRecipe extends DoubleMachineRecipe { public CombinerRecipe copy() { return new CombinerRecipe(getInput().copy(), getOutput().copy()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/machines/CrusherRecipe.java b/src/main/java/mekanism/common/recipe/machines/CrusherRecipe.java index e99bb8d66..a577df3be 100644 --- a/src/main/java/mekanism/common/recipe/machines/CrusherRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/CrusherRecipe.java @@ -18,4 +18,4 @@ public class CrusherRecipe extends BasicMachineRecipe { public CrusherRecipe copy() { return new CrusherRecipe(getInput().copy(), getOutput().copy()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/machines/CrystallizerRecipe.java b/src/main/java/mekanism/common/recipe/machines/CrystallizerRecipe.java index 612c42553..8f2c8bea4 100644 --- a/src/main/java/mekanism/common/recipe/machines/CrystallizerRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/CrystallizerRecipe.java @@ -31,4 +31,4 @@ public class CrystallizerRecipe extends MachineRecipe inventory, GasTank outputTank) { - return getInput().useItemStackFromInventory(inventory, 1, false) && getOutput() - .applyOutputs(outputTank, false, 1); + return getInput().useItemStackFromInventory(inventory, 1, false) && getOutput().applyOutputs(outputTank, false, 1); } public void operate(NonNullList inventory, GasTank outputTank) { @@ -32,4 +31,4 @@ public class DissolutionRecipe extends MachineRecipe> extends - MachineRecipe { +public abstract class DoubleMachineRecipe> extends MachineRecipe { public DoubleMachineRecipe(DoubleMachineInput input, ItemStackOutput output) { super(input, output); @@ -21,8 +20,7 @@ public abstract class DoubleMachineRecipe inventory, int inputIndex, int extraIndex, int outputIndex) { - return inputMatches(inventory, inputIndex, extraIndex) && getOutput() - .applyOutputs(inventory, outputIndex, false); + return inputMatches(inventory, inputIndex, extraIndex) && getOutput().applyOutputs(inventory, outputIndex, false); } public void operate(NonNullList inventory, int inputIndex, int extraIndex, int outputIndex) { @@ -30,4 +28,4 @@ public abstract class DoubleMachineRecipe { public EnrichmentRecipe copy() { return new EnrichmentRecipe(getInput().copy(), getOutput().copy()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/machines/GasCentrifugeRecipe.java b/src/main/java/mekanism/common/recipe/machines/GasCentrifugeRecipe.java index e351b63ac..1e17fcfcd 100644 --- a/src/main/java/mekanism/common/recipe/machines/GasCentrifugeRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/GasCentrifugeRecipe.java @@ -29,4 +29,4 @@ public class GasCentrifugeRecipe extends MachineRecipe { public InjectionRecipe copy() { return new InjectionRecipe(getInput().copy(), getOutput().copy()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/machines/MachineRecipe.java b/src/main/java/mekanism/common/recipe/machines/MachineRecipe.java index 0d701cea3..fcb432d64 100644 --- a/src/main/java/mekanism/common/recipe/machines/MachineRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/MachineRecipe.java @@ -22,4 +22,4 @@ public abstract class MachineRecipe inventory, GasTank outputTank) { - return getInput().useItemStackFromInventory(inventory, 0, false) && getOutput() - .applyOutputs(outputTank, false, 1); + return getInput().useItemStackFromInventory(inventory, 0, false) && getOutput().applyOutputs(outputTank, false, 1); } public void operate(NonNullList inventory, GasTank outputTank) { @@ -32,4 +31,4 @@ public class OxidationRecipe extends MachineRecipe inventory, FluidTank inputFluidTank, GasTank inputGasTank, - GasTank outputGasTank) { - return getInput().use(inventory, 0, inputFluidTank, inputGasTank, false) && getOutput() - .applyOutputs(inventory, 2, outputGasTank, false); + public boolean canOperate(NonNullList inventory, FluidTank inputFluidTank, GasTank inputGasTank, GasTank outputGasTank) { + return getInput().use(inventory, 0, inputFluidTank, inputGasTank, false) && getOutput().applyOutputs(inventory, 2, outputGasTank, false); } - public void operate(NonNullList inventory, FluidTank inputFluidTank, GasTank inputGasTank, - GasTank outputGasTank) { + public void operate(NonNullList inventory, FluidTank inputFluidTank, GasTank inputGasTank, GasTank outputGasTank) { if (getInput().use(inventory, 0, inputFluidTank, inputGasTank, true)) { getOutput().applyOutputs(inventory, 2, outputGasTank, true); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/machines/PurificationRecipe.java b/src/main/java/mekanism/common/recipe/machines/PurificationRecipe.java index 430112ca6..5d3732970 100644 --- a/src/main/java/mekanism/common/recipe/machines/PurificationRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/PurificationRecipe.java @@ -19,4 +19,4 @@ public class PurificationRecipe extends AdvancedMachineRecipe { public SawmillRecipe copy() { return new SawmillRecipe(getInput().copy(), getOutput().copy()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/machines/SeparatorRecipe.java b/src/main/java/mekanism/common/recipe/machines/SeparatorRecipe.java index 37382637b..73c2b2a12 100644 --- a/src/main/java/mekanism/common/recipe/machines/SeparatorRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/SeparatorRecipe.java @@ -40,4 +40,4 @@ public class SeparatorRecipe extends MachineRecipe { public SmeltingRecipe copy() { return new SmeltingRecipe(getInput().copy(), getOutput().copy()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/machines/SolarNeutronRecipe.java b/src/main/java/mekanism/common/recipe/machines/SolarNeutronRecipe.java index b5cf6991f..54b6ac203 100644 --- a/src/main/java/mekanism/common/recipe/machines/SolarNeutronRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/SolarNeutronRecipe.java @@ -29,4 +29,4 @@ public class SolarNeutronRecipe extends MachineRecipe { - public FluidInput waterInput = new FluidInput( - new FluidStack(FluidRegistry.WATER, TileEntityChemicalWasher.WATER_USAGE)); + public FluidInput waterInput = new FluidInput(new FluidStack(FluidRegistry.WATER, TileEntityChemicalWasher.WATER_USAGE)); public WasherRecipe(GasInput input, GasOutput output) { super(input, output); @@ -29,8 +28,7 @@ public class WasherRecipe extends MachineRecipe { return !secondaryOutput.isEmpty(); } - public boolean applyOutputs(NonNullList inventory, int primaryIndex, int secondaryIndex, - boolean doEmit) { + public boolean applyOutputs(NonNullList inventory, int primaryIndex, int secondaryIndex, boolean doEmit) { if (hasPrimary()) { - if (inventory.get(primaryIndex).isEmpty()) { + ItemStack primaryStack = inventory.get(primaryIndex); + if (primaryStack.isEmpty()) { if (doEmit) { inventory.set(primaryIndex, primaryOutput.copy()); } - } else if (inventory.get(primaryIndex).isItemEqual(primaryOutput) - && inventory.get(primaryIndex).getCount() + primaryOutput.getCount() <= inventory.get(primaryIndex) - .getMaxStackSize()) { + } else if (primaryStack.isItemEqual(primaryOutput) && primaryStack.getCount() + primaryOutput.getCount() <= primaryStack.getMaxStackSize()) { if (doEmit) { - inventory.get(primaryIndex).grow(primaryOutput.getCount()); + primaryStack.grow(primaryOutput.getCount()); } } else { return false; @@ -66,25 +64,19 @@ public class ChanceOutput extends MachineOutput { } if (hasSecondary() && (!doEmit || checkSecondary())) { - if (inventory.get(secondaryIndex).isEmpty()) { + ItemStack secondaryStack = inventory.get(secondaryIndex); + if (secondaryStack.isEmpty()) { if (doEmit) { inventory.set(secondaryIndex, secondaryOutput.copy()); } - - return true; - } else if (inventory.get(secondaryIndex).isItemEqual(secondaryOutput) - && inventory.get(secondaryIndex).getCount() + primaryOutput.getCount() <= inventory - .get(secondaryIndex).getMaxStackSize()) { + } else if (secondaryStack.isItemEqual(secondaryOutput) && secondaryStack.getCount() + primaryOutput.getCount() <= secondaryStack.getMaxStackSize()) { if (doEmit) { - inventory.get(secondaryIndex).grow(secondaryOutput.getCount()); + secondaryStack.grow(secondaryOutput.getCount()); } - - return true; } else { return false; } } - return true; } @@ -92,4 +84,4 @@ public class ChanceOutput extends MachineOutput { public ChanceOutput copy() { return new ChanceOutput(primaryOutput.copy(), secondaryOutput.copy(), secondaryChance); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/outputs/ChemicalPairOutput.java b/src/main/java/mekanism/common/recipe/outputs/ChemicalPairOutput.java index 8aa194bf7..cb416664b 100644 --- a/src/main/java/mekanism/common/recipe/outputs/ChemicalPairOutput.java +++ b/src/main/java/mekanism/common/recipe/outputs/ChemicalPairOutput.java @@ -24,7 +24,7 @@ public class ChemicalPairOutput extends MachineOutput { /** * Creates a chemical input with two defined gasses. * - * @param left - left gas + * @param left - left gas * @param right - right gas */ public ChemicalPairOutput(GasStack left, GasStack right) { @@ -49,10 +49,10 @@ public class ChemicalPairOutput extends MachineOutput { } /** - * Whether or not the defined input contains the same gasses and at least the required amount of the defined gasses - * as this input. + * 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 + * * @return if the input meets this input's requirements */ public boolean meetsInput(ChemicalPairOutput input) { @@ -73,25 +73,22 @@ public class ChemicalPairOutput extends MachineOutput { if (leftTank.getNeeded() >= leftGas.amount * scale && rightTank.getNeeded() >= rightGas.amount * scale) { leftTank.receive(leftGas.copy().withAmount(leftGas.amount * scale), doEmit); rightTank.receive(rightGas.copy().withAmount(rightGas.amount * scale), doEmit); - return true; } } else if (leftTank.canReceive(rightGas.getGas()) && rightTank.canReceive(leftGas.getGas())) { if (leftTank.getNeeded() >= rightGas.amount * scale && rightTank.getNeeded() >= leftGas.amount * scale) { leftTank.receive(rightGas.copy().withAmount(rightGas.amount * scale), doEmit); rightTank.receive(leftGas.copy().withAmount(leftGas.amount * scale), doEmit); - return true; } } - return false; } /** * Draws the needed amount of gas from each tank. * - * @param leftTank - left tank to draw from + * @param leftTank - left tank to draw from * @param rightTank - right tank to draw from */ public void draw(GasTank leftTank, GasTank rightTank) { @@ -108,13 +105,13 @@ public class ChemicalPairOutput extends MachineOutput { * 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 + * * @return if the stack's gas type is contained in this ChemicalInput */ public boolean containsType(GasStack stack) { if (stack == null || stack.amount == 0) { return false; } - return stack.isGasEqual(leftGas) || stack.isGasEqual(rightGas); } @@ -122,17 +119,16 @@ public class ChemicalPairOutput extends MachineOutput { * Actual implementation of meetsInput(), performs the checks. * * @param input - input to check + * * @return if the input meets this input's requirements */ private boolean meets(ChemicalPairOutput input) { if (input == null || !input.isValid()) { 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; } @@ -140,4 +136,4 @@ public class ChemicalPairOutput extends MachineOutput { public ChemicalPairOutput copy() { return new ChemicalPairOutput(leftGas.copy(), rightGas.copy()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/outputs/FluidOutput.java b/src/main/java/mekanism/common/recipe/outputs/FluidOutput.java index 466f7e4f9..6312258b0 100644 --- a/src/main/java/mekanism/common/recipe/outputs/FluidOutput.java +++ b/src/main/java/mekanism/common/recipe/outputs/FluidOutput.java @@ -28,10 +28,8 @@ public class FluidOutput extends MachineOutput { public boolean applyOutputs(FluidTank fluidTank, boolean doEmit) { if (fluidTank.fill(output, false) > 0) { fluidTank.fill(output, doEmit); - return true; } - return false; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/outputs/GasOutput.java b/src/main/java/mekanism/common/recipe/outputs/GasOutput.java index 5a552a992..0685bc5b7 100644 --- a/src/main/java/mekanism/common/recipe/outputs/GasOutput.java +++ b/src/main/java/mekanism/common/recipe/outputs/GasOutput.java @@ -28,10 +28,8 @@ public class GasOutput extends MachineOutput { public boolean applyOutputs(GasTank gasTank, boolean doEmit, int scale) { if (gasTank.canReceive(output.getGas()) && gasTank.getNeeded() >= output.amount * scale) { gasTank.receive(output.copy().withAmount(output.amount * scale), doEmit); - return true; } - return false; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/outputs/ItemStackOutput.java b/src/main/java/mekanism/common/recipe/outputs/ItemStackOutput.java index 7b45cd5df..21a0bc154 100644 --- a/src/main/java/mekanism/common/recipe/outputs/ItemStackOutput.java +++ b/src/main/java/mekanism/common/recipe/outputs/ItemStackOutput.java @@ -21,21 +21,18 @@ public class ItemStackOutput extends MachineOutput { } public boolean applyOutputs(NonNullList inventory, int index, boolean doEmit) { - if (inventory.get(index).isEmpty()) { + ItemStack stack = inventory.get(index); + if (stack.isEmpty()) { if (doEmit) { inventory.set(index, output.copy()); } - return true; - } else if (inventory.get(index).isItemEqual(output) - && inventory.get(index).getCount() + output.getCount() <= inventory.get(index).getMaxStackSize()) { + } else if (stack.isItemEqual(output) && stack.getCount() + output.getCount() <= stack.getMaxStackSize()) { if (doEmit) { - inventory.get(index).grow(output.getCount()); + stack.grow(output.getCount()); } - return true; } - return false; } @@ -43,4 +40,4 @@ public class ItemStackOutput extends MachineOutput { public ItemStackOutput copy() { return new ItemStackOutput(output.copy()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/outputs/MachineOutput.java b/src/main/java/mekanism/common/recipe/outputs/MachineOutput.java index d117e4ee9..c8f039708 100644 --- a/src/main/java/mekanism/common/recipe/outputs/MachineOutput.java +++ b/src/main/java/mekanism/common/recipe/outputs/MachineOutput.java @@ -7,4 +7,4 @@ public abstract class MachineOutput> { public abstract OUTPUT copy(); public abstract void load(NBTTagCompound nbtTags); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/recipe/outputs/PressurizedOutput.java b/src/main/java/mekanism/common/recipe/outputs/PressurizedOutput.java index 3870b31e0..5d8bf462a 100644 --- a/src/main/java/mekanism/common/recipe/outputs/PressurizedOutput.java +++ b/src/main/java/mekanism/common/recipe/outputs/PressurizedOutput.java @@ -30,8 +30,8 @@ public class PressurizedOutput extends MachineOutput { } public boolean canAddProducts(NonNullList inventory, int index) { - return inventory.get(index).isEmpty() || (inventory.get(index).isItemEqual(itemOutput) - && inventory.get(index).getCount() + itemOutput.getCount() <= inventory.get(index).getMaxStackSize()); + return inventory.get(index).isEmpty() || + (inventory.get(index).isItemEqual(itemOutput) && inventory.get(index).getCount() + itemOutput.getCount() <= inventory.get(index).getMaxStackSize()); } public void fillTank(GasTank tank) { @@ -52,10 +52,8 @@ public class PressurizedOutput extends MachineOutput { fillTank(tank); addProducts(inventory, index); } - return true; } - return false; } @@ -71,4 +69,4 @@ public class PressurizedOutput extends MachineOutput { public PressurizedOutput copy() { return new PressurizedOutput(itemOutput.copy(), gasOutput.copy()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/security/IOwnerItem.java b/src/main/java/mekanism/common/security/IOwnerItem.java index 222243396..2f145b716 100644 --- a/src/main/java/mekanism/common/security/IOwnerItem.java +++ b/src/main/java/mekanism/common/security/IOwnerItem.java @@ -10,4 +10,4 @@ public interface IOwnerItem { void setOwnerUUID(ItemStack stack, UUID owner); boolean hasOwner(ItemStack stack); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/security/ISecurityItem.java b/src/main/java/mekanism/common/security/ISecurityItem.java index e44b508d7..6d63abfd2 100644 --- a/src/main/java/mekanism/common/security/ISecurityItem.java +++ b/src/main/java/mekanism/common/security/ISecurityItem.java @@ -10,4 +10,4 @@ public interface ISecurityItem extends IOwnerItem { void setSecurity(ItemStack stack, SecurityMode mode); boolean hasSecurity(ItemStack stack); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/security/ISecurityTile.java b/src/main/java/mekanism/common/security/ISecurityTile.java index 0a6d6340e..b34183690 100644 --- a/src/main/java/mekanism/common/security/ISecurityTile.java +++ b/src/main/java/mekanism/common/security/ISecurityTile.java @@ -25,4 +25,4 @@ public interface ISecurityTile { return color + LangUtils.localize(display); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/security/SecurityData.java b/src/main/java/mekanism/common/security/SecurityData.java index ce12a091a..27bdb521d 100644 --- a/src/main/java/mekanism/common/security/SecurityData.java +++ b/src/main/java/mekanism/common/security/SecurityData.java @@ -18,10 +18,8 @@ public class SecurityData { public static SecurityData read(ByteBuf dataStream) { SecurityData data = new SecurityData(); - data.mode = SecurityMode.values()[dataStream.readInt()]; data.override = dataStream.readBoolean(); - return data; } @@ -29,4 +27,4 @@ public class SecurityData { dataStream.writeInt(mode.ordinal()); dataStream.writeBoolean(override); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/security/SecurityFrequency.java b/src/main/java/mekanism/common/security/SecurityFrequency.java index 48b8a53a1..47dde2cae 100644 --- a/src/main/java/mekanism/common/security/SecurityFrequency.java +++ b/src/main/java/mekanism/common/security/SecurityFrequency.java @@ -2,9 +2,9 @@ package mekanism.common.security; import io.netty.buffer.ByteBuf; import java.util.UUID; +import mekanism.api.TileNetworkList; import mekanism.common.HashList; import mekanism.common.PacketHandler; -import mekanism.api.TileNetworkList; import mekanism.common.frequency.Frequency; import mekanism.common.security.ISecurityTile.SecurityMode; import net.minecraft.nbt.NBTTagCompound; @@ -24,7 +24,6 @@ public class SecurityFrequency extends Frequency { public SecurityFrequency(UUID uuid) { super("Security", uuid); - trusted = new HashList<>(); securityMode = SecurityMode.PUBLIC; } @@ -40,17 +39,14 @@ public class SecurityFrequency extends Frequency { @Override public void write(NBTTagCompound nbtTags) { super.write(nbtTags); - nbtTags.setBoolean("override", override); nbtTags.setInteger("securityMode", securityMode.ordinal()); if (!trusted.isEmpty()) { NBTTagList trustedList = new NBTTagList(); - for (String s : trusted) { trustedList.appendTag(new NBTTagString(s)); } - nbtTags.setTag("trusted", trustedList); } } @@ -67,7 +63,6 @@ public class SecurityFrequency extends Frequency { if (nbtTags.hasKey("trusted")) { NBTTagList trustedList = nbtTags.getTagList("trusted", NBT.TAG_STRING); - for (int i = 0; i < trustedList.tagCount(); i++) { trusted.add(trustedList.getStringTagAt(i)); } @@ -82,7 +77,6 @@ public class SecurityFrequency extends Frequency { data.add(securityMode.ordinal()); data.add(trusted.size()); - for (String s : trusted) { data.add(s); } @@ -104,4 +98,4 @@ public class SecurityFrequency extends Frequency { trusted.add(PacketHandler.readString(dataStream)); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tier/CableTier.java b/src/main/java/mekanism/common/tier/CableTier.java index 03c78dd27..86d87c7f9 100644 --- a/src/main/java/mekanism/common/tier/CableTier.java +++ b/src/main/java/mekanism/common/tier/CableTier.java @@ -22,7 +22,6 @@ public enum CableTier implements ITier { return transmitter; } } - return BASIC; } diff --git a/src/main/java/mekanism/common/tier/ConductorTier.java b/src/main/java/mekanism/common/tier/ConductorTier.java index d33a00670..c8a7ea8e3 100644 --- a/src/main/java/mekanism/common/tier/ConductorTier.java +++ b/src/main/java/mekanism/common/tier/ConductorTier.java @@ -30,7 +30,6 @@ public enum ConductorTier implements ITier { return transmitter; } } - return BASIC; } diff --git a/src/main/java/mekanism/common/tier/ITier.java b/src/main/java/mekanism/common/tier/ITier.java index c8582096a..ea23425b6 100644 --- a/src/main/java/mekanism/common/tier/ITier.java +++ b/src/main/java/mekanism/common/tier/ITier.java @@ -3,4 +3,4 @@ package mekanism.common.tier; public interface ITier { BaseTier getBaseTier(); -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tier/PipeTier.java b/src/main/java/mekanism/common/tier/PipeTier.java index 16bae2de2..7eabd843a 100644 --- a/src/main/java/mekanism/common/tier/PipeTier.java +++ b/src/main/java/mekanism/common/tier/PipeTier.java @@ -24,7 +24,6 @@ public enum PipeTier implements ITier { return transmitter; } } - return BASIC; } diff --git a/src/main/java/mekanism/common/tier/TransporterTier.java b/src/main/java/mekanism/common/tier/TransporterTier.java index 639f71f9b..e4a9f71a5 100644 --- a/src/main/java/mekanism/common/tier/TransporterTier.java +++ b/src/main/java/mekanism/common/tier/TransporterTier.java @@ -24,7 +24,6 @@ public enum TransporterTier implements ITier { return transmitter; } } - return BASIC; } diff --git a/src/main/java/mekanism/common/tier/TubeTier.java b/src/main/java/mekanism/common/tier/TubeTier.java index 1e67dddae..8279a0ab7 100644 --- a/src/main/java/mekanism/common/tier/TubeTier.java +++ b/src/main/java/mekanism/common/tier/TubeTier.java @@ -24,7 +24,6 @@ public enum TubeTier implements ITier { return transmitter; } } - return BASIC; } diff --git a/src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java b/src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java index ad4409d67..b943b12f0 100644 --- a/src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java @@ -32,8 +32,8 @@ import net.minecraftforge.fml.common.Optional.Method; @Interface(iface = "cofh.redstoneflux.api.IEnergyReceiver", modid = MekanismHooks.REDSTONEFLUX_MOD_ID), @Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = MekanismHooks.IC2_MOD_ID) }) -public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock implements ISidedInventory, IEnergySink, - IStrictEnergyAcceptor, IEnergyReceiver, IEnergyProvider, IComputerIntegration, ISpecialConfigData { +public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock implements ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IEnergyReceiver, + IEnergyProvider, IComputerIntegration, ISpecialConfigData { @Override public boolean isEmpty() { @@ -41,7 +41,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return true; } - return inv.isEmpty(); } @@ -51,7 +50,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return 0; } - return inv.getSizeInventory(); } @@ -62,7 +60,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return ItemStack.EMPTY; } - return inv.getStackInSlot(i); } @@ -73,7 +70,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return ItemStack.EMPTY; } - return inv.decrStackSize(i, j); } @@ -84,7 +80,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return ItemStack.EMPTY; } - return inv.removeStackFromSlot(i); } @@ -94,7 +89,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return; } - inv.setInventorySlotContents(i, itemstack); } @@ -105,7 +99,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return "null"; } - return inv.getName(); } @@ -115,7 +108,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return false; } - return inv.hasCustomName(); } @@ -131,7 +123,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return 0; } - return inv.getInventoryStackLimit(); } @@ -141,7 +132,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return false; } - return inv.isUsableByPlayer(entityplayer); } @@ -151,7 +141,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return; } - inv.openInventory(player); } @@ -161,7 +150,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return; } - inv.closeInventory(player); } @@ -171,7 +159,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return false; } - return inv.isItemValidForSlot(i, itemstack); } @@ -182,7 +169,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp @Override public void setField(int id, int value) { - } @Override @@ -201,7 +187,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return InventoryUtils.EMPTY; } - return inv.getSlotsForFace(side); } @@ -211,7 +196,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return false; } - return inv.canInsertItem(i, itemstack, side); } @@ -221,7 +205,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return false; } - return inv.canExtractItem(i, itemstack, side); } @@ -232,7 +215,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return false; } - return inv.acceptsEnergyFrom(emitter, direction); } @@ -243,7 +225,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null || !canReceiveEnergy(from)) { return 0; } - return inv.receiveEnergy(from, maxReceive, simulate); } @@ -254,7 +235,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return 0; } - return inv.extractEnergy(from, maxExtract, simulate); } @@ -271,7 +251,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return 0; } - return inv.getEnergyStored(from); } @@ -282,7 +261,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return 0; } - return inv.getMaxEnergyStored(from); } @@ -292,7 +270,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null || !canReceiveEnergy(side)) { return 0; } - return inv.acceptEnergy(side, amount, simulate); } @@ -302,7 +279,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return false; } - return inv.canBoundReceiveEnergy(getPos(), side); } @@ -320,7 +296,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null || !canReceiveEnergy(directionFrom)) { return amount; } - return inv.injectEnergy(directionFrom, amount, voltage); } @@ -331,7 +306,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return 0; } - return inv.getSinkTier(); } @@ -353,14 +327,12 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp //world.setBlockToAir(mainPos); return null; } - return (IAdvancedBoundingBlock) tile; } @Override public void onPower() { super.onPower(); - IAdvancedBoundingBlock inv = getInv(); if (inv != null) { inv.onPower(); @@ -370,7 +342,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp @Override public void onNoPower() { super.onNoPower(); - IAdvancedBoundingBlock inv = getInv(); if (inv != null) { inv.onNoPower(); @@ -383,7 +354,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return new String[]{}; } - return inv.getMethods(); } @@ -393,7 +363,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return new Object[]{}; } - return inv.invoke(method, arguments); } @@ -403,7 +372,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return new NBTTagCompound(); } - return inv.getConfigurationData(nbtTags); } @@ -413,7 +381,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return; } - inv.setConfigurationData(nbtTags); } @@ -423,7 +390,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (inv == null) { return "null"; } - return inv.getDataType(); } @@ -432,12 +398,10 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (capability == Capabilities.TILE_NETWORK_CAPABILITY) { return super.hasCapability(capability, facing); } - IAdvancedBoundingBlock inv = getInv(); if (inv == null) { return super.hasCapability(capability, facing); } - return inv.hasOffsetCapability(capability, facing, pos.subtract(mainPos)); } @@ -446,12 +410,10 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp if (capability == Capabilities.TILE_NETWORK_CAPABILITY) { return super.getCapability(capability, facing); } - IAdvancedBoundingBlock inv = getInv(); if (inv == null) { return super.getCapability(capability, facing); } - return inv.getOffsetCapability(capability, facing, pos.subtract(mainPos)); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityAdvancedFactory.java b/src/main/java/mekanism/common/tile/TileEntityAdvancedFactory.java index 9cb89b77a..4d17ab4d3 100644 --- a/src/main/java/mekanism/common/tile/TileEntityAdvancedFactory.java +++ b/src/main/java/mekanism/common/tile/TileEntityAdvancedFactory.java @@ -14,14 +14,11 @@ public class TileEntityAdvancedFactory extends TileEntityFactory { public TileEntityAdvancedFactory() { super(FactoryTier.ADVANCED, MachineType.ADVANCED_FACTORY); - configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY, - TransmissionType.GAS); + configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY, TransmissionType.GAS); configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); - configComponent - .addOutput(TransmissionType.ITEM, new SideData("Input", EnumColor.DARK_RED, new int[]{5, 6, 7, 8, 9})); - configComponent.addOutput(TransmissionType.ITEM, - new SideData("Output", EnumColor.DARK_BLUE, new int[]{10, 11, 12, 13, 14})); + configComponent.addOutput(TransmissionType.ITEM, new SideData("Input", EnumColor.DARK_RED, new int[]{5, 6, 7, 8, 9})); + configComponent.addOutput(TransmissionType.ITEM, new SideData("Output", EnumColor.DARK_BLUE, new int[]{10, 11, 12, 13, 14})); configComponent.addOutput(TransmissionType.ITEM, new SideData("Energy", EnumColor.DARK_GREEN, new int[]{1})); configComponent.addOutput(TransmissionType.ITEM, new SideData("Extra", EnumColor.PURPLE, new int[]{4})); configComponent.setConfig(TransmissionType.ITEM, new byte[]{4, 0, 0, 3, 1, 2}); @@ -36,4 +33,4 @@ public class TileEntityAdvancedFactory extends TileEntityFactory { ejectorComponent = new TileComponentEjector(this); ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(2)); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityAmbientAccumulator.java b/src/main/java/mekanism/common/tile/TileEntityAmbientAccumulator.java index 3c4bac027..9cad6190a 100644 --- a/src/main/java/mekanism/common/tile/TileEntityAmbientAccumulator.java +++ b/src/main/java/mekanism/common/tile/TileEntityAmbientAccumulator.java @@ -41,15 +41,12 @@ public class TileEntityAmbientAccumulator extends TileEntityContainerBlock imple cachedDimensionId = world.provider.getDimension(); cachedRecipe = RecipeHandler.getDimensionGas(new IntegerInput(cachedDimensionId)); } - - if (cachedRecipe != null && gasRand.nextDouble() < 0.05 && cachedRecipe.getOutput() - .applyOutputs(collectedGas, false, 1)) { + if (cachedRecipe != null && gasRand.nextDouble() < 0.05 && cachedRecipe.getOutput().applyOutputs(collectedGas, false, 1)) { cachedRecipe.getOutput().applyOutputs(collectedGas, true, 1); } } } - @Override public int receiveGas(EnumFacing side, GasStack stack, boolean doTransfer) { return 0; @@ -106,7 +103,6 @@ public class TileEntityAmbientAccumulator extends TileEntityContainerBlock imple if (capability == Capabilities.GAS_HANDLER_CAPABILITY) { return Capabilities.GAS_HANDLER_CAPABILITY.cast(this); } - return super.getCapability(capability, side); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityBin.java b/src/main/java/mekanism/common/tile/TileEntityBin.java index c63802ea2..20cee5ee4 100644 --- a/src/main/java/mekanism/common/tile/TileEntityBin.java +++ b/src/main/java/mekanism/common/tile/TileEntityBin.java @@ -8,8 +8,6 @@ import mekanism.api.Range4D; import mekanism.api.TileNetworkList; import mekanism.common.Mekanism; import mekanism.common.PacketHandler; -import mekanism.common.tier.BaseTier; -import mekanism.common.tier.BinTier; import mekanism.common.base.IActiveState; import mekanism.common.base.ILogisticalTransporter; import mekanism.common.base.ITierUpgradeable; @@ -18,6 +16,8 @@ import mekanism.common.content.transporter.TransitRequest; import mekanism.common.content.transporter.TransitRequest.TransitResponse; import mekanism.common.item.ItemBlockBasic; import mekanism.common.network.PacketTileEntity.TileEntityMessage; +import mekanism.common.tier.BaseTier; +import mekanism.common.tier.BinTier; import mekanism.common.tile.prefab.TileEntityBasicBlock; import mekanism.common.util.CapabilityUtils; import mekanism.common.util.InventoryUtils; @@ -42,8 +42,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; -public class TileEntityBin extends TileEntityBasicBlock implements ISidedInventory, IActiveState, IConfigurable, - ITierUpgradeable { +public class TileEntityBin extends TileEntityBasicBlock implements ISidedInventory, IActiveState, IConfigurable, ITierUpgradeable { private static final int[] UPSLOTS = {1}; private static final int[] DOWNSLOTS = {0}; @@ -79,14 +78,9 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento if (upgradeTier.ordinal() != tier.ordinal() + 1) { return false; } - tier = BinTier.values()[upgradeTier.ordinal()]; - - Mekanism.packetHandler - .sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); markDirty(); - return true; } @@ -96,7 +90,6 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento topStack = ItemStack.EMPTY; bottomStack = ItemStack.EMPTY; cacheCount = 0; - return; } @@ -111,12 +104,9 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento } count -= topStack.getCount(); - bottomStack = itemType.copy(); bottomStack.setCount(Math.min(itemType.getMaxStackSize(), count)); - count -= bottomStack.getCount(); - cacheCount = count; } @@ -124,15 +114,12 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento if (stack.isEmpty() || stack.getCount() <= 0) { return false; } - if (stack.getItem() instanceof ItemBlockBasic && stack.getItemDamage() == 6) { return false; } - if (itemType.isEmpty()) { return true; } - return stack.isItemEqual(itemType) && ItemStack.areItemStackTagsEqual(stack, itemType); } @@ -141,31 +128,24 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento if (itemType.isEmpty() && !simulate) { setItemType(stack); } - if (tier != BinTier.CREATIVE) { if (getItemCount() + stack.getCount() <= tier.getStorage()) { if (!simulate) { setItemCount(getItemCount() + stack.getCount()); } - return ItemStack.EMPTY; } else { ItemStack rejects = stack.copy(); rejects.setCount((getItemCount() + stack.getCount()) - tier.getStorage()); - if (!simulate) { setItemCount(tier.getStorage()); } - return rejects; } - } else { - if (!simulate) { - setItemCount(Integer.MAX_VALUE); - } + } else if (!simulate) { + setItemCount(Integer.MAX_VALUE); } } - return stack; } @@ -177,7 +157,6 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento if (getItemCount() == 0) { return ItemStack.EMPTY; } - return remove(bottomStack.getCount()); } @@ -185,14 +164,11 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento if (getItemCount() == 0) { return ItemStack.EMPTY; } - ItemStack ret = itemType.copy(); ret.setCount(Math.min(Math.min(amount, itemType.getMaxStackSize()), getItemCount())); - if (tier != BinTier.CREATIVE && !simulate) { setItemCount(getItemCount() - ret.getCount()); } - return ret; } @@ -208,11 +184,9 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento cacheCount = Math.max(0, count); topStack = ItemStack.EMPTY; bottomStack = ItemStack.EMPTY; - if (count == 0) { setItemType(ItemStack.EMPTY); } - markDirty(); } @@ -221,9 +195,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento if (!world.isRemote) { addTicks = Math.max(0, addTicks - 1); delayTicks = Math.max(0, delayTicks - 1); - sortStacks(); - if (getItemCount() != prevCount) { markDirty(); MekanismUtils.saveChunk(this); @@ -232,29 +204,20 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento if (delayTicks == 0) { if (!bottomStack.isEmpty() && isActive) { TileEntity tile = Coord4D.get(this).offset(EnumFacing.DOWN).getTileEntity(world); - - if (CapabilityUtils - .hasCapability(tile, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, EnumFacing.UP)) { - ILogisticalTransporter transporter = CapabilityUtils - .getCapability(tile, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, EnumFacing.UP); - TransitResponse response = TransporterUtils - .insert(this, transporter, TransitRequest.getFromStack(bottomStack), null, true, 0); - + if (CapabilityUtils.hasCapability(tile, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, EnumFacing.UP)) { + ILogisticalTransporter transporter = CapabilityUtils.getCapability(tile, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, EnumFacing.UP); + TransitResponse response = TransporterUtils.insert(this, transporter, TransitRequest.getFromStack(bottomStack), null, true, 0); if (!response.isEmpty()) { bottomStack.shrink(response.getStack().getCount()); setInventorySlotContents(0, bottomStack); } } else { - TransitResponse response = InventoryUtils - .putStackInInventory(tile, TransitRequest.getFromStack(bottomStack), EnumFacing.DOWN, - false); - + TransitResponse response = InventoryUtils.putStackInInventory(tile, TransitRequest.getFromStack(bottomStack), EnumFacing.DOWN, false); if (!response.isEmpty()) { bottomStack.shrink(response.getStack().getCount()); setInventorySlotContents(0, bottomStack); } } - delayTicks = 10; } } else { @@ -267,37 +230,29 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setBoolean("isActive", isActive); nbtTags.setInteger("itemCount", cacheCount); nbtTags.setInteger("tier", tier.ordinal()); - if (!bottomStack.isEmpty()) { nbtTags.setTag("bottomStack", bottomStack.writeToNBT(new NBTTagCompound())); } - if (!topStack.isEmpty()) { nbtTags.setTag("topStack", topStack.writeToNBT(new NBTTagCompound())); } - if (getItemCount() > 0) { nbtTags.setTag("itemType", itemType.writeToNBT(new NBTTagCompound())); } - return nbtTags; } @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - clientActive = isActive = nbtTags.getBoolean("isActive"); cacheCount = nbtTags.getInteger("itemCount"); tier = BinTier.values()[nbtTags.getInteger("tier")]; - bottomStack = new ItemStack(nbtTags.getCompoundTag("bottomStack")); topStack = new ItemStack(nbtTags.getCompoundTag("topStack")); - if (getItemCount() > 0) { itemType = new ItemStack(nbtTags.getCompoundTag("itemType")); } @@ -306,33 +261,27 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(isActive); data.add(getItemCount()); data.add(tier.ordinal()); - if (getItemCount() > 0) { data.add(itemType); } - return data; } @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { clientActive = isActive = dataStream.readBoolean(); clientAmount = dataStream.readInt(); tier = BinTier.values()[dataStream.readInt()]; - if (clientAmount > 0) { itemType = PacketHandler.readStack(dataStream); } else { itemType = ItemStack.EMPTY; } - MekanismUtils.updateBlock(world, getPos()); } } @@ -342,9 +291,8 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento public ItemStack getStackInSlot(int slotID) { if (slotID == 1) { return topStack; - } else { - return bottomStack; } + return bottomStack; } @Nonnull @@ -364,7 +312,6 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento return ret; } } - return ItemStack.EMPTY; } @@ -385,7 +332,6 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento if (getItemCount() == 0) { return; } - if (tier != BinTier.CREATIVE) { if (itemstack.isEmpty()) { setItemCount(getItemCount() - bottomStack.getCount()); @@ -396,11 +342,8 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento } else if (i == 1) { if (itemstack.isEmpty()) { topStack = ItemStack.EMPTY; - } else { - if (isValid(itemstack) && itemstack.getCount() > topStack.getCount() - && tier != BinTier.CREATIVE) { - add(StackUtils.size(itemstack, itemstack.getCount() - topStack.getCount())); - } + } else if (isValid(itemstack) && itemstack.getCount() > topStack.getCount() && tier != BinTier.CREATIVE) { + add(StackUtils.size(itemstack, itemstack.getCount() - topStack.getCount())); } } } @@ -408,12 +351,9 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento @Override public void markDirty() { super.markDirty(); - if (!world.isRemote) { MekanismUtils.saveChunk(this); - Mekanism.packetHandler - .sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); prevCount = getItemCount(); sortStacks(); } @@ -427,7 +367,6 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento bottomStack = ItemStack.EMPTY; return; } - ItemStack ret = stack.copy(); ret.setCount(1); itemType = ret; @@ -436,8 +375,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento @Nonnull @Override public String getName() { - return LangUtils - .localize(getBlockType().getTranslationKey() + ".Bin" + tier.getBaseTier().getSimpleName() + ".name"); + return LangUtils.localize(getBlockType().getTranslationKey() + ".Bin" + tier.getBaseTier().getSimpleName() + ".name"); } @Override @@ -486,7 +424,6 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento @Override public void setField(int id, int value) { - } @Override @@ -508,7 +445,6 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento } else if (side == EnumFacing.DOWN) { return DOWNSLOTS; } - return InventoryUtils.EMPTY; } @@ -535,12 +471,8 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento @Override public void setActive(boolean active) { isActive = active; - if (clientActive != active) { - Mekanism.packetHandler - .sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); - + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); clientActive = active; } } @@ -560,41 +492,6 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento return MathHelper.floor((float) (fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0); } - // @Override -// public ItemStack getStoredItemType() -// { -// if(itemType == null) -// { -// return ItemStack.EMPTY; -// } -// -// return MekanismUtils.size(itemType, getItemCount()); -// } -// -// @Override -// public void setStoredItemCount(int amount) -// { -// if(amount == 0) -// { -// setStoredItemType(ItemStack.EMPTY, 0); -// } -// -// setItemCount(amount); -// } -// -// @Override -// public void setStoredItemType(ItemStack type, int amount) -// { -// itemType = type; -// cacheCount = amount; -// -// topStack = ItemStack.EMPTY; -// bottomStack = ItemStack.EMPTY; -// -// markDirty(); -// } -// -// @Override public int getMaxStoredCount() { return tier.getStorage(); } @@ -602,9 +499,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento @Override public EnumActionResult onSneakRightClick(EntityPlayer player, EnumFacing side) { setActive(!getActive()); - world.playSound(null, getPos().getX(), getPos().getY(), getPos().getZ(), SoundEvents.UI_BUTTON_CLICK, - SoundCategory.BLOCKS, 0.3F, 1); - + world.playSound(null, getPos().getX(), getPos().getY(), getPos().getZ(), SoundEvents.UI_BUTTON_CLICK, SoundCategory.BLOCKS, 0.3F, 1); return EnumActionResult.SUCCESS; } @@ -615,8 +510,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento @Override public boolean hasCapability(@Nonnull Capability capability, EnumFacing side) { - return capability == Capabilities.CONFIGURABLE_CAPABILITY - || capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, side); + return capability == Capabilities.CONFIGURABLE_CAPABILITY || capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, side); } @Override @@ -626,7 +520,6 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento } else if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(myItemHandler); } - return super.getCapability(capability, side); } @@ -643,7 +536,6 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento if (slot != 0) { return 0; } - return tier.getStorage(); } @@ -663,7 +555,6 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento if (slot != 0 || tileEntityBin.itemType.isEmpty()) { return ItemStack.EMPTY; } - return StackUtils.size(tileEntityBin.itemType, tileEntityBin.getItemCount()); } @@ -673,7 +564,6 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento if (slot != 0) { return ItemStack.EMPTY; } - return tileEntityBin.add(stack, simulate); } @@ -682,8 +572,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento if (slot != 0) { return ItemStack.EMPTY; } - return tileEntityBin.remove(amount, simulate); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityBoilerCasing.java b/src/main/java/mekanism/common/tile/TileEntityBoilerCasing.java index 6a19cc57f..150b057a8 100644 --- a/src/main/java/mekanism/common/tile/TileEntityBoilerCasing.java +++ b/src/main/java/mekanism/common/tile/TileEntityBoilerCasing.java @@ -33,11 +33,10 @@ import net.minecraftforge.items.CapabilityItemHandler; public class TileEntityBoilerCasing extends TileEntityMultiblock implements IHeatTransfer { - protected static final int[] INV_SLOTS = {0,1}; + protected static final int[] INV_SLOTS = {0, 1}; /** - * A client-sided set of valves on this tank's structure that are currently active, used on the client for rendering - * fluids. + * A client-sided set of valves on this tank's structure that are currently active, used on the client for rendering fluids. */ public Set valveViewing = new HashSet<>(); @@ -61,26 +60,20 @@ public class TileEntityBoilerCasing extends TileEntityMultiblock 0.01) { prevWaterScale = (9 * prevWaterScale + targetScale) / 10; } } - if (!clientHasStructure || !isRendering) { for (ValveData data : valveViewing) { TileEntityBoilerCasing tileEntity = (TileEntityBoilerCasing) data.location.getTileEntity(world); - if (tileEntity != null) { tileEntity.clientHasStructure = false; } } - valveViewing.clear(); } } @@ -91,30 +84,24 @@ public class TileEntityBoilerCasing extends TileEntityMultiblock 0) { data.activeTicks--; } - if (data.activeTicks > 0 != data.prevActive) { needsValveUpdate = true; } - data.prevActive = data.activeTicks > 0; } boolean needsHotUpdate = false; boolean newHot = structure.temperature >= SynchronizedBoilerData.BASE_BOIL_TEMP - 0.01F; - if (newHot != structure.clientHot) { needsHotUpdate = true; structure.clientHot = newHot; @@ -123,41 +110,32 @@ public class TileEntityBoilerCasing extends TileEntityMultiblock= SynchronizedBoilerData.BASE_BOIL_TEMP - && structure.waterStored != null) { + if (structure.temperature >= SynchronizedBoilerData.BASE_BOIL_TEMP && structure.waterStored != null) { int steamAmount = structure.steamStored != null ? structure.steamStored.amount : 0; double heatAvailable = structure.getHeatAvailable(); - structure.lastMaxBoil = (int) Math - .floor(heatAvailable / SynchronizedBoilerData.getHeatEnthalpy()); + structure.lastMaxBoil = (int) Math.floor(heatAvailable / SynchronizedBoilerData.getHeatEnthalpy()); int amountToBoil = Math.min(structure.lastMaxBoil, structure.waterStored.amount); - amountToBoil = Math.min(amountToBoil, - (structure.steamVolume * BoilerUpdateProtocol.STEAM_PER_TANK) - steamAmount); + amountToBoil = Math.min(amountToBoil, (structure.steamVolume * BoilerUpdateProtocol.STEAM_PER_TANK) - steamAmount); structure.waterStored.amount -= amountToBoil; - if (structure.steamStored == null) { structure.steamStored = new FluidStack(FluidRegistry.getFluid("steam"), amountToBoil); } else { structure.steamStored.amount += amountToBoil; } - structure.temperature -= - (amountToBoil * SynchronizedBoilerData.getHeatEnthalpy()) / structure.locations.size(); + structure.temperature -= (amountToBoil * SynchronizedBoilerData.getHeatEnthalpy()) / structure.locations.size(); structure.lastBoilRate = amountToBoil; } else { structure.lastBoilRate = 0; structure.lastMaxBoil = 0; } - if (needsValveUpdate || structure.needsRenderUpdate() || needsHotUpdate) { sendPacketToRenderer(); } - structure.prevWater = structure.waterStored != null ? structure.waterStored.copy() : null; structure.prevSteam = structure.steamStored != null ? structure.steamStored.copy() : null; - MekanismUtils.saveChunk(this); } } @@ -167,14 +145,10 @@ public class TileEntityBoilerCasing extends TileEntityMultiblock toSend = new HashSet<>(); - for (ValveData valveData : structure.valves) { if (valveData.activeTicks > 0) { toSend.add(valveData); } } - data.add(toSend.size()); - for (ValveData valveData : toSend) { valveData.location.write(data); data.add(valveData.side.ordinal()); } } } - return data; } @@ -243,7 +212,6 @@ public class TileEntityBoilerCasing extends TileEntityMultiblock= structure.upperRenderLocation.y - 1) { + if (structure != null && structure.upperRenderLocation != null && getPos().getY() >= structure.upperRenderLocation.y - 1) { if (structure.steamStored != null && structure.steamStored.amount > 0) { for (EnumFacing side : EnumFacing.values()) { TileEntity tile = Coord4D.get(this).offset(side).getTileEntity(world); - - if (tile != null && !(tile instanceof TileEntityBoilerValve) && CapabilityUtils - .hasCapability(tile, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, - side.getOpposite())) { - IFluidHandler handler = CapabilityUtils - .getCapability(tile, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, - side.getOpposite()); - + if (tile != null && !(tile instanceof TileEntityBoilerValve) && + CapabilityUtils.hasCapability(tile, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite())) { + IFluidHandler handler = CapabilityUtils.getCapability(tile, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite()); if (PipeUtils.canFill(handler, structure.steamStored)) { structure.steamStored.amount -= handler.fill(structure.steamStored, true); - if (structure.steamStored.amount <= 0) { structure.steamStored = null; } @@ -71,11 +60,9 @@ public class TileEntityBoilerValve extends TileEntityBoilerCasing implements IFl if ((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) { if (structure.upperRenderLocation != null && getPos().getY() >= structure.upperRenderLocation.y - 1) { return new FluidTankInfo[]{steamTank.getInfo()}; - } else { - return new FluidTankInfo[]{waterTank.getInfo()}; } + return new FluidTankInfo[]{waterTank.getInfo()}; } - return PipeUtils.EMPTY; } @@ -86,35 +73,29 @@ public class TileEntityBoilerValve extends TileEntityBoilerCasing implements IFl @Override public int fill(EnumFacing from, @Nullable FluidStack resource, boolean doFill) { - if (structure != null && structure.upperRenderLocation != null - && getPos().getY() < structure.upperRenderLocation.y - 1) { + if (structure != null && structure.upperRenderLocation != null && getPos().getY() < structure.upperRenderLocation.y - 1) { return waterTank.fill(resource, doFill); } - return 0; } @Override public FluidStack drain(EnumFacing from, @Nullable FluidStack resource, boolean doDrain) { - if (structure != null && structure.upperRenderLocation != null - && getPos().getY() >= structure.upperRenderLocation.y - 1) { + if (structure != null && structure.upperRenderLocation != null && getPos().getY() >= structure.upperRenderLocation.y - 1) { if (structure.steamStored != null) { if (resource != null && resource.getFluid() == structure.steamStored.getFluid()) { return steamTank.drain(resource.amount, doDrain); } } } - return null; } @Override public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) { - if (structure != null && structure.upperRenderLocation != null - && getPos().getY() >= structure.upperRenderLocation.y - 1) { + if (structure != null && structure.upperRenderLocation != null && getPos().getY() >= structure.upperRenderLocation.y - 1) { return steamTank.drain(maxDrain, doDrain); } - return null; } @@ -123,7 +104,6 @@ public class TileEntityBoilerValve extends TileEntityBoilerCasing implements IFl if ((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) { return structure.upperRenderLocation != null && getPos().getY() < structure.upperRenderLocation.y - 1; } - return false; } @@ -132,7 +112,6 @@ public class TileEntityBoilerValve extends TileEntityBoilerCasing implements IFl if ((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) { return structure.upperRenderLocation != null && getPos().getY() >= structure.upperRenderLocation.y - 1; } - return false; } @@ -149,7 +128,6 @@ public class TileEntityBoilerValve extends TileEntityBoilerCasing implements IFl if (structure == null) { return new Object[]{"Unformed"}; } - switch (method) { case 1: return new Object[]{structure.steamStored != null ? structure.steamStored.amount : 0}; @@ -163,7 +141,6 @@ public class TileEntityBoilerValve extends TileEntityBoilerCasing implements IFl return new Object[]{structure.temperature}; } } - throw new NoSuchMethodException(); } @@ -174,7 +151,6 @@ public class TileEntityBoilerValve extends TileEntityBoilerCasing implements IFl return true; } } - return super.hasCapability(capability, side); } @@ -185,7 +161,6 @@ public class TileEntityBoilerValve extends TileEntityBoilerCasing implements IFl return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(new FluidHandlerWrapper(this, side)); } } - return super.getCapability(capability, side); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityBoundingBlock.java b/src/main/java/mekanism/common/tile/TileEntityBoundingBlock.java index cbabf19a6..5f4cfcb62 100644 --- a/src/main/java/mekanism/common/tile/TileEntityBoundingBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityBoundingBlock.java @@ -4,9 +4,9 @@ import io.netty.buffer.ByteBuf; import javax.annotation.Nonnull; import mekanism.api.Coord4D; import mekanism.api.Range4D; +import mekanism.api.TileNetworkList; import mekanism.common.Mekanism; import mekanism.common.base.ITileNetwork; -import mekanism.api.TileNetworkList; import mekanism.common.capabilities.Capabilities; import mekanism.common.network.PacketDataRequest.DataRequestMessage; import mekanism.common.network.PacketTileEntity.TileEntityMessage; @@ -28,20 +28,15 @@ public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork public void setMainLocation(BlockPos pos) { receivedCoords = true; - if (!world.isRemote) { mainPos = pos; - - Mekanism.packetHandler - .sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); } } @Override public void validate() { super.validate(); - if (world.isRemote) { Mekanism.packetHandler.sendToServer(new DataRequestMessage(Coord4D.get(this))); } @@ -49,22 +44,17 @@ public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork public void onNeighborChange(Block block) { TileEntity tile = world.getTileEntity(mainPos); - if (tile instanceof TileEntityBasicBlock) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock) tile; - int power = world.getRedstonePowerFromNeighbors(getPos()); - if (prevPower != power) { if (power > 0) { onPower(); } else { onNoPower(); } - prevPower = power; - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), - tileEntity.getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); } } } @@ -86,7 +76,6 @@ public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - mainPos = new BlockPos(nbtTags.getInteger("mainX"), nbtTags.getInteger("mainY"), nbtTags.getInteger("mainZ")); prevPower = nbtTags.getInteger("prevPower"); receivedCoords = nbtTags.getBoolean("receivedCoords"); @@ -96,13 +85,11 @@ public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setInteger("mainX", mainPos.getX()); nbtTags.setInteger("mainY", mainPos.getY()); nbtTags.setInteger("mainZ", mainPos.getZ()); nbtTags.setInteger("prevPower", prevPower); nbtTags.setBoolean("receivedCoords", receivedCoords); - return nbtTags; } @@ -112,7 +99,6 @@ public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork data.add(mainPos.getY()); data.add(mainPos.getZ()); data.add(prevPower); - return data; } @@ -126,7 +112,6 @@ public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork if (capability == Capabilities.TILE_NETWORK_CAPABILITY) { return Capabilities.TILE_NETWORK_CAPABILITY.cast(this); } - return super.getCapability(capability, facing); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityCardboardBox.java b/src/main/java/mekanism/common/tile/TileEntityCardboardBox.java index 371036022..61613af8d 100644 --- a/src/main/java/mekanism/common/tile/TileEntityCardboardBox.java +++ b/src/main/java/mekanism/common/tile/TileEntityCardboardBox.java @@ -12,7 +12,6 @@ public class TileEntityCardboardBox extends TileEntity { @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - if (nbtTags.hasKey("storedData")) { storedData = BlockData.read(nbtTags.getCompoundTag("storedData")); } @@ -22,11 +21,9 @@ public class TileEntityCardboardBox extends TileEntity { @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - if (storedData != null) { nbtTags.setTag("storedData", storedData.write(new NBTTagCompound())); } - return nbtTags; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityChanceMachine.java b/src/main/java/mekanism/common/tile/TileEntityChanceMachine.java index 8ef4058a7..83c4a6591 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChanceMachine.java +++ b/src/main/java/mekanism/common/tile/TileEntityChanceMachine.java @@ -21,16 +21,12 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; -public abstract class TileEntityChanceMachine> extends - TileEntityUpgradeableMachine { +public abstract class TileEntityChanceMachine> extends TileEntityUpgradeableMachine { - private static final String[] methods = new String[]{"getEnergy", "getProgress", "isActive", "facing", "canOperate", - "getMaxEnergy", "getEnergyNeeded"}; + private static final String[] methods = new String[]{"getEnergy", "getProgress", "isActive", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"}; - public TileEntityChanceMachine(String soundPath, String name, double baseMaxEnergy, double baseEnergyUsage, - int ticksRequired, ResourceLocation location) { + public TileEntityChanceMachine(String soundPath, String name, double baseMaxEnergy, double baseEnergyUsage, int ticksRequired, ResourceLocation location) { super(soundPath, name, baseMaxEnergy, baseEnergyUsage, 3, ticksRequired, location); - configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY); configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); @@ -61,34 +57,24 @@ public abstract class TileEntityChanceMachine= energyPerTick) { setActive(true); - electricityStored -= energyPerTick; - if ((operatingTicks + 1) < ticksRequired) { operatingTicks++; } else { operate(recipe); - operatingTicks = 0; } - } else { - if (prevEnergy >= getEnergy()) { - setActive(false); - } + } else if (prevEnergy >= getEnergy()) { + setActive(false); } - if (!canOperate(recipe)) { operatingTicks = 0; } - prevEnergy = getEnergy(); } } @@ -96,14 +82,12 @@ public abstract class TileEntityChanceMachine entities = world.getEntitiesWithinAABB(EntityLivingBase.class, - new AxisAlignedBB(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX() + 1, - getPos().getY() + 0.2, getPos().getZ() + 1)); + new AxisAlignedBB(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX() + 1, getPos().getY() + 0.2, getPos().getZ() + 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) { ChargeUtils.charge(itemstack, this); - if (prevEnergy != getEnergy()) { break; } } - for (ItemStack itemstack : player.inventory.mainInventory) { ChargeUtils.charge(itemstack, this); - if (prevEnergy != getEnergy()) { break; } @@ -97,12 +87,11 @@ public class TileEntityChargepad extends TileEntityEffectsBlock { world.playSound(null, getPos().getX() + 0.5, getPos().getY() + 0.1, getPos().getZ() + 0.5, SoundEvents.BLOCK_STONE_PRESSPLATE_CLICK_OFF, SoundCategory.BLOCKS, 0.3F, 0.7F); } - setActive(isActive); } } else if (isActive) { - world.spawnParticle(EnumParticleTypes.REDSTONE, getPos().getX() + random.nextDouble(), - getPos().getY() + 0.15, getPos().getZ() + random.nextDouble(), 0, 0, 0); + world.spawnParticle(EnumParticleTypes.REDSTONE, getPos().getX() + random.nextDouble(), getPos().getY() + 0.15, + getPos().getZ() + random.nextDouble(), 0, 0, 0); } } @@ -119,20 +108,15 @@ public class TileEntityChargepad extends TileEntityEffectsBlock { @Override public void setActive(boolean active) { isActive = active; - if (clientActive != active) { - Mekanism.packetHandler - .sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); } - clientActive = active; } @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - clientActive = isActive = nbtTags.getBoolean("isActive"); } @@ -140,19 +124,15 @@ public class TileEntityChargepad extends TileEntityEffectsBlock { @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setBoolean("isActive", isActive); - return nbtTags; } @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { clientActive = dataStream.readBoolean(); - if (clientActive != isActive) { isActive = clientActive; MekanismUtils.updateBlock(world, getPos()); @@ -195,4 +175,4 @@ public class TileEntityChargepad extends TileEntityEffectsBlock { } return super.isCapabilityDisabled(capability, side); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java b/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java index bca43f8fb..ccabee6ad 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java @@ -36,8 +36,7 @@ import net.minecraft.util.NonNullList; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.FMLCommonHandler; -public class TileEntityChemicalCrystallizer extends TileEntityOperationalMachine implements IGasHandler, - ISideConfiguration, ISustainedData, ITankManager, IConfigCardAccess { +public class TileEntityChemicalCrystallizer extends TileEntityOperationalMachine implements IGasHandler, ISideConfiguration, ISustainedData, ITankManager, IConfigCardAccess { public static final int MAX_GAS = 10000; @@ -49,12 +48,8 @@ public class TileEntityChemicalCrystallizer extends TileEntityOperationalMachine public TileComponentConfig configComponent; public TileEntityChemicalCrystallizer() { - super("machine.crystallizer", "ChemicalCrystallizer", - MachineType.CHEMICAL_CRYSTALLIZER.getStorage(), - MachineType.CHEMICAL_CRYSTALLIZER.getUsage(), 3, 200); - - configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY, - TransmissionType.GAS); + super("machine.crystallizer", "ChemicalCrystallizer", MachineType.CHEMICAL_CRYSTALLIZER.getStorage(), MachineType.CHEMICAL_CRYSTALLIZER.getUsage(), 3, 200); + configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY, TransmissionType.GAS); configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); configComponent.addOutput(TransmissionType.ITEM, new SideData("Gas", EnumColor.PURPLE, new int[]{0})); @@ -78,33 +73,25 @@ public class TileEntityChemicalCrystallizer extends TileEntityOperationalMachine @Override public void onUpdate() { super.onUpdate(); - if (!world.isRemote) { ChargeUtils.discharge(2, this); TileUtils.receiveGas(inventory.get(0), inputTank); CrystallizerRecipe recipe = getRecipe(); - if (canOperate(recipe) && MekanismUtils.canFunction(this) && getEnergy() >= energyPerTick) { setActive(true); - setEnergy(getEnergy() - energyPerTick); - if ((operatingTicks + 1) < ticksRequired) { operatingTicks++; } else { operate(recipe); operatingTicks = 0; } - } else { - if (prevEnergy >= getEnergy()) { - setActive(false); - } + } else if (prevEnergy >= getEnergy()) { + setActive(false); } - if (!canOperate(recipe)) { operatingTicks = 0; } - prevEnergy = getEnergy(); } } @@ -115,11 +102,9 @@ public class TileEntityChemicalCrystallizer extends TileEntityOperationalMachine public CrystallizerRecipe getRecipe() { GasInput input = getInput(); - if (cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) { cachedRecipe = RecipeHandler.getChemicalCrystallizerRecipe(getInput()); } - return cachedRecipe; } @@ -129,7 +114,6 @@ public class TileEntityChemicalCrystallizer extends TileEntityOperationalMachine public void operate(CrystallizerRecipe recipe) { recipe.operate(inputTank, inventory); - markDirty(); ejectorComponent.outputItems(); } @@ -137,7 +121,6 @@ public class TileEntityChemicalCrystallizer extends TileEntityOperationalMachine @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { TileUtils.readTankData(dataStream, inputTank); } @@ -153,7 +136,6 @@ public class TileEntityChemicalCrystallizer extends TileEntityOperationalMachine @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - inputTank.read(nbtTags.getCompoundTag("rightTank")); } @@ -161,11 +143,8 @@ public class TileEntityChemicalCrystallizer extends TileEntityOperationalMachine @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setTag("rightTank", inputTank.write(new NBTTagCompound())); - nbtTags.setBoolean("sideDataStored", true); - return nbtTags; } @@ -177,7 +156,7 @@ public class TileEntityChemicalCrystallizer extends TileEntityOperationalMachine @Override public boolean canReceiveGas(EnumFacing side, Gas type) { return configComponent.getOutput(TransmissionType.GAS, side, facing).hasSlot(0) && inputTank.canReceive(type) && - RecipeHandler.Recipe.CHEMICAL_CRYSTALLIZER.containsRecipe(type); + RecipeHandler.Recipe.CHEMICAL_CRYSTALLIZER.containsRecipe(type); } @Override @@ -185,7 +164,6 @@ public class TileEntityChemicalCrystallizer extends TileEntityOperationalMachine if (canReceiveGas(side, stack.getGas())) { return inputTank.receive(stack, doTransfer); } - return 0; } @@ -210,8 +188,7 @@ public class TileEntityChemicalCrystallizer extends TileEntityOperationalMachine if (isCapabilityDisabled(capability, side)) { return false; } - return capability == Capabilities.GAS_HANDLER_CAPABILITY - || capability == Capabilities.CONFIG_CARD_CAPABILITY || super.hasCapability(capability, side); + return capability == Capabilities.GAS_HANDLER_CAPABILITY || capability == Capabilities.CONFIG_CARD_CAPABILITY || super.hasCapability(capability, side); } @Override @@ -222,41 +199,34 @@ public class TileEntityChemicalCrystallizer extends TileEntityOperationalMachine if (capability == Capabilities.GAS_HANDLER_CAPABILITY || capability == Capabilities.CONFIG_CARD_CAPABILITY) { return (T) this; } - return super.getCapability(capability, side); } @Override public boolean isCapabilityDisabled(@Nonnull Capability capability, EnumFacing side) { - return configComponent.isCapabilityDisabled(capability, side, facing) || super - .isCapabilityDisabled(capability, side); + return configComponent.isCapabilityDisabled(capability, side, facing) || super.isCapabilityDisabled(capability, side); } @Override public boolean isItemValidForSlot(int slotID, @Nonnull ItemStack itemstack) { if (slotID == 0) { - return !itemstack.isEmpty() && itemstack.getItem() instanceof IGasItem - && ((IGasItem) itemstack.getItem()).getGas(itemstack) != null && - RecipeHandler.Recipe.CHEMICAL_CRYSTALLIZER - .containsRecipe(((IGasItem) itemstack.getItem()).getGas(itemstack).getGas()); + return !itemstack.isEmpty() && itemstack.getItem() instanceof IGasItem && ((IGasItem) itemstack.getItem()).getGas(itemstack) != null && + RecipeHandler.Recipe.CHEMICAL_CRYSTALLIZER.containsRecipe(((IGasItem) itemstack.getItem()).getGas(itemstack).getGas()); } else if (slotID == 2) { return ChargeUtils.canBeDischarged(itemstack); } - return false; } @Override public boolean canExtractItem(int slotID, @Nonnull ItemStack itemstack, @Nonnull EnumFacing side) { if (slotID == 0) { - return !itemstack.isEmpty() && itemstack.getItem() instanceof IGasItem - && ((IGasItem) itemstack.getItem()).getGas(itemstack) == null; + return !itemstack.isEmpty() && itemstack.getItem() instanceof IGasItem && ((IGasItem) itemstack.getItem()).getGas(itemstack) == null; } else if (slotID == 1) { return true; } else if (slotID == 2) { return ChargeUtils.canBeOutputted(itemstack, false); } - return false; } @@ -297,4 +267,4 @@ public class TileEntityChemicalCrystallizer extends TileEntityOperationalMachine public Object[] getTanks() { return new Object[]{inputTank}; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java b/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java index 47323eaa9..2446931ff 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java @@ -35,8 +35,7 @@ import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.items.CapabilityItemHandler; -public class TileEntityChemicalDissolutionChamber extends TileEntityMachine implements IGasHandler, ISustainedData, - ITankManager { +public class TileEntityChemicalDissolutionChamber extends TileEntityMachine implements IGasHandler, ISustainedData, ITankManager { public static final int MAX_GAS = 10000; public static final int BASE_INJECT_USAGE = 1; @@ -52,10 +51,7 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityMachine impl public DissolutionRecipe cachedRecipe; public TileEntityChemicalDissolutionChamber() { - super("machine.dissolution", "ChemicalDissolutionChamber", - MachineType.CHEMICAL_DISSOLUTION_CHAMBER.getStorage(), - MachineType.CHEMICAL_DISSOLUTION_CHAMBER.getUsage(), 4); - + super("machine.dissolution", "ChemicalDissolutionChamber", MachineType.CHEMICAL_DISSOLUTION_CHAMBER.getStorage(), MachineType.CHEMICAL_DISSOLUTION_CHAMBER.getUsage(), 4); inventory = NonNullList.withSize(5, ItemStack.EMPTY); upgradeComponent.setSupported(Upgrade.GAS); } @@ -65,7 +61,6 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityMachine impl if (!world.isRemote) { ChargeUtils.discharge(3, this); ItemStack itemStack = inventory.get(0); - if (!itemStack.isEmpty() && injectTank.getNeeded() > 0 && itemStack.getItem() instanceof IGasItem) { //TODO: Maybe make this use GasUtils.getItemGas. This only currently accepts IGasItems here though IGasItem item = (IGasItem) itemStack.getItem(); @@ -78,40 +73,28 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityMachine impl } } } - TileUtils.drawGas(inventory.get(2), outputTank); - boolean changed = false; - DissolutionRecipe recipe = getRecipe(); - injectUsageThisTick = Math.max(BASE_INJECT_USAGE, StatUtils.inversePoisson(injectUsage)); - - if (canOperate(recipe) && getEnergy() >= energyPerTick && injectTank.getStored() >= injectUsageThisTick - && MekanismUtils.canFunction(this)) { + if (canOperate(recipe) && getEnergy() >= energyPerTick && injectTank.getStored() >= injectUsageThisTick && MekanismUtils.canFunction(this)) { setActive(true); setEnergy(getEnergy() - energyPerTick); minorOperate(); - if ((operatingTicks + 1) < ticksRequired) { operatingTicks++; } else { operate(recipe); operatingTicks = 0; } - } else { - if (prevEnergy >= getEnergy()) { - changed = true; - setActive(false); - } + } else if (prevEnergy >= getEnergy()) { + changed = true; + setActive(false); } - if (changed && !canOperate(recipe)) { operatingTicks = 0; } - prevEnergy = getEnergy(); - TileUtils.emitGas(this, outputTank, gasOutput, MekanismUtils.getRight(facing)); } } @@ -123,17 +106,14 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityMachine impl } else if (slotID == 3) { return ChargeUtils.canBeDischarged(itemstack); } - return false; } @Override public boolean canExtractItem(int slotID, @Nonnull ItemStack itemstack, @Nonnull EnumFacing side) { if (slotID == 2) { - return !itemstack.isEmpty() && itemstack.getItem() instanceof IGasItem && ((IGasItem) itemstack.getItem()) - .canProvideGas(itemstack, null); + return !itemstack.isEmpty() && itemstack.getItem() instanceof IGasItem && ((IGasItem) itemstack.getItem()).canProvideGas(itemstack, null); } - return false; } @@ -147,21 +127,18 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityMachine impl } else if (side == MekanismUtils.getRight(facing)) { return new int[]{2}; } - return InventoryUtils.EMPTY; } public double getScaledProgress() { - return ((double) operatingTicks) / ((double) ticksRequired); + return (double) operatingTicks / (double) ticksRequired; } public DissolutionRecipe getRecipe() { ItemStackInput input = getInput(); - if (cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) { cachedRecipe = RecipeHandler.getDissolutionRecipe(getInput()); } - return cachedRecipe; } @@ -175,7 +152,6 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityMachine impl public void operate(DissolutionRecipe recipe) { recipe.operate(inventory, outputTank); - markDirty(); } @@ -186,7 +162,6 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityMachine impl @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { operatingTicks = dataStream.readInt(); TileUtils.readTankData(dataStream, injectTank); @@ -206,7 +181,6 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityMachine impl @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - operatingTicks = nbtTags.getInteger("operatingTicks"); injectTank.read(nbtTags.getCompoundTag("injectTank")); outputTank.read(nbtTags.getCompoundTag("gasTank")); @@ -216,11 +190,9 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityMachine impl @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setInteger("operatingTicks", operatingTicks); nbtTags.setTag("injectTank", injectTank.write(new NBTTagCompound())); nbtTags.setTag("gasTank", outputTank.write(new NBTTagCompound())); - return nbtTags; } @@ -234,7 +206,6 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityMachine impl if (canReceiveGas(side, stack.getGas())) { return injectTank.receive(stack, doTransfer); } - return 0; } @@ -279,7 +250,6 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityMachine impl } else if (capability == Capabilities.GAS_HANDLER_CAPABILITY) { return Capabilities.GAS_HANDLER_CAPABILITY.cast(this); } - return super.getCapability(capability, side); } @@ -303,7 +273,6 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityMachine impl if (injectTank.getGas() != null) { ItemDataUtils.setCompound(itemStack, "injectTank", injectTank.getGas().write(new NBTTagCompound())); } - if (outputTank.getGas() != null) { ItemDataUtils.setCompound(itemStack, "outputTank", outputTank.getGas().write(new NBTTagCompound())); } @@ -318,11 +287,9 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityMachine impl @Override public void recalculateUpgradables(Upgrade upgrade) { super.recalculateUpgradables(upgrade); - switch (upgrade) { case ENERGY: - energyPerTick = MekanismUtils - .getEnergyPerTick(this, BASE_ENERGY_PER_TICK); // incorporate speed upgrades + energyPerTick = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK); // incorporate speed upgrades break; case GAS: injectUsage = MekanismUtils.getSecondaryEnergyPerTickMean(this, BASE_INJECT_USAGE); @@ -341,4 +308,4 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityMachine impl public Object[] getTanks() { return new Object[]{injectTank, outputTank}; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java b/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java index 7a98153df..d75d0f9c1 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java @@ -36,8 +36,8 @@ import net.minecraft.util.NonNullList; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.FMLCommonHandler; -public class TileEntityChemicalInfuser extends TileEntityMachine implements IGasHandler, IRedstoneControl, - ISustainedData, IUpgradeTile, IUpgradeInfoHandler, ITankManager, ISecurityTile { +public class TileEntityChemicalInfuser extends TileEntityMachine implements IGasHandler, IRedstoneControl, ISustainedData, IUpgradeTile, IUpgradeInfoHandler, + ITankManager, ISecurityTile { public static final int MAX_GAS = 10000; public GasTank leftTank = new GasTank(MAX_GAS); @@ -50,31 +50,23 @@ public class TileEntityChemicalInfuser extends TileEntityMachine implements IGas public double clientEnergyUsed; public TileEntityChemicalInfuser() { - super("machine.cheminfuser", "ChemicalInfuser", - MachineType.CHEMICAL_INFUSER.getStorage(), - MachineType.CHEMICAL_INFUSER.getUsage(), 4); - + super("machine.cheminfuser", "ChemicalInfuser", MachineType.CHEMICAL_INFUSER.getStorage(), MachineType.CHEMICAL_INFUSER.getUsage(), 4); inventory = NonNullList.withSize(5, ItemStack.EMPTY); } @Override public void onUpdate() { super.onUpdate(); - if (!world.isRemote) { ChargeUtils.discharge(3, this); TileUtils.receiveGas(inventory.get(0), leftTank); TileUtils.receiveGas(inventory.get(1), rightTank); TileUtils.drawGas(inventory.get(2), centerTank); - ChemicalInfuserRecipe recipe = getRecipe(); - if (canOperate(recipe) && getEnergy() >= energyPerTick && MekanismUtils.canFunction(this)) { setActive(true); - int operations = operate(recipe); double prev = getEnergy(); - setEnergy(getEnergy() - energyPerTick * operations); clientEnergyUsed = prev - getEnergy(); } else { @@ -89,7 +81,6 @@ public class TileEntityChemicalInfuser extends TileEntityMachine implements IGas public int getUpgradedUsage(ChemicalInfuserRecipe recipe) { int possibleProcess = (int) Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)); - if (leftTank.getGasType() == recipe.recipeInput.leftGas.getGas()) { possibleProcess = Math.min(leftTank.getStored() / recipe.recipeInput.leftGas.amount, possibleProcess); possibleProcess = Math.min(rightTank.getStored() / recipe.recipeInput.rightGas.amount, possibleProcess); @@ -97,10 +88,8 @@ public class TileEntityChemicalInfuser extends TileEntityMachine implements IGas possibleProcess = Math.min(leftTank.getStored() / recipe.recipeInput.rightGas.amount, possibleProcess); possibleProcess = Math.min(rightTank.getStored() / recipe.recipeInput.leftGas.amount, possibleProcess); } - possibleProcess = Math.min(centerTank.getNeeded() / recipe.recipeOutput.output.amount, possibleProcess); possibleProcess = Math.min((int) (getEnergy() / energyPerTick), possibleProcess); - return possibleProcess; } @@ -110,11 +99,9 @@ public class TileEntityChemicalInfuser extends TileEntityMachine implements IGas public ChemicalInfuserRecipe getRecipe() { ChemicalPairInput input = getInput(); - if (cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) { cachedRecipe = RecipeHandler.getChemicalInfuserRecipe(getInput()); } - return cachedRecipe; } @@ -124,17 +111,14 @@ public class TileEntityChemicalInfuser extends TileEntityMachine implements IGas public int operate(ChemicalInfuserRecipe recipe) { int operations = getUpgradedUsage(recipe); - recipe.operate(leftTank, rightTank, centerTank, operations); markDirty(); - return operations; } @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { clientEnergyUsed = dataStream.readDouble(); TileUtils.readTankData(dataStream, leftTank); @@ -156,7 +140,6 @@ public class TileEntityChemicalInfuser extends TileEntityMachine implements IGas @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - leftTank.read(nbtTags.getCompoundTag("leftTank")); rightTank.read(nbtTags.getCompoundTag("rightTank")); centerTank.read(nbtTags.getCompoundTag("centerTank")); @@ -166,11 +149,9 @@ public class TileEntityChemicalInfuser extends TileEntityMachine implements IGas @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setTag("leftTank", leftTank.write(new NBTTagCompound())); nbtTags.setTag("rightTank", rightTank.write(new NBTTagCompound())); nbtTags.setTag("centerTank", centerTank.write(new NBTTagCompound())); - return nbtTags; } @@ -187,7 +168,6 @@ public class TileEntityChemicalInfuser extends TileEntityMachine implements IGas } else if (side == facing) { return centerTank; } - return null; } @@ -199,7 +179,7 @@ public class TileEntityChemicalInfuser extends TileEntityMachine implements IGas @Override public boolean canReceiveGas(EnumFacing side, Gas type) { - return (getTank(side) != null && getTank(side) != centerTank) && getTank(side).canReceive(type); + return getTank(side) != null && getTank(side) != centerTank && getTank(side).canReceive(type); } @Override @@ -207,7 +187,6 @@ public class TileEntityChemicalInfuser extends TileEntityMachine implements IGas if (canReceiveGas(side, stack != null ? stack.getGas() : null)) { return getTank(side).receive(stack, doTransfer); } - return 0; } @@ -216,13 +195,12 @@ public class TileEntityChemicalInfuser extends TileEntityMachine implements IGas if (canDrawGas(side, null)) { return getTank(side).draw(amount, doTransfer); } - return null; } @Override public boolean canDrawGas(EnumFacing side, Gas type) { - return (getTank(side) != null && getTank(side) == centerTank) && getTank(side).canDraw(type); + return getTank(side) != null && getTank(side) == centerTank && getTank(side).canDraw(type); } @Override @@ -240,7 +218,6 @@ public class TileEntityChemicalInfuser extends TileEntityMachine implements IGas } else if (capability == Capabilities.GAS_HANDLER_CAPABILITY) { return Capabilities.GAS_HANDLER_CAPABILITY.cast(this); } - return super.getCapability(capability, side); } @@ -260,15 +237,12 @@ public class TileEntityChemicalInfuser extends TileEntityMachine implements IGas @Override public boolean canExtractItem(int slotID, @Nonnull ItemStack itemstack, @Nonnull EnumFacing side) { if (slotID == 0 || slotID == 2) { - return !itemstack.isEmpty() && itemstack.getItem() instanceof IGasItem && ((IGasItem) itemstack.getItem()) - .canReceiveGas(itemstack, null); + return !itemstack.isEmpty() && itemstack.getItem() instanceof IGasItem && ((IGasItem) itemstack.getItem()).canReceiveGas(itemstack, null); } else if (slotID == 1) { - return !itemstack.isEmpty() && itemstack.getItem() instanceof IGasItem && ((IGasItem) itemstack.getItem()) - .canProvideGas(itemstack, null); + return !itemstack.isEmpty() && itemstack.getItem() instanceof IGasItem && ((IGasItem) itemstack.getItem()).canProvideGas(itemstack, null); } else if (slotID == 3) { return ChargeUtils.canBeOutputted(itemstack, false); } - return false; } @@ -284,7 +258,6 @@ public class TileEntityChemicalInfuser extends TileEntityMachine implements IGas } else if (side.getAxis() == Axis.Y) { return new int[3]; } - return InventoryUtils.EMPTY; } @@ -293,11 +266,9 @@ public class TileEntityChemicalInfuser extends TileEntityMachine implements IGas if (leftTank.getGas() != null) { ItemDataUtils.setCompound(itemStack, "leftTank", leftTank.getGas().write(new NBTTagCompound())); } - if (rightTank.getGas() != null) { ItemDataUtils.setCompound(itemStack, "rightTank", rightTank.getGas().write(new NBTTagCompound())); } - if (centerTank.getGas() != null) { ItemDataUtils.setCompound(itemStack, "centerTank", centerTank.getGas().write(new NBTTagCompound())); } @@ -319,4 +290,4 @@ public class TileEntityChemicalInfuser extends TileEntityMachine implements IGas public Object[] getTanks() { return new Object[]{leftTank, rightTank, centerTank}; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalInjectionChamber.java b/src/main/java/mekanism/common/tile/TileEntityChemicalInjectionChamber.java index 25c8dff9c..b2143e97d 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalInjectionChamber.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalInjectionChamber.java @@ -19,10 +19,8 @@ import net.minecraft.util.EnumFacing; public class TileEntityChemicalInjectionChamber extends TileEntityAdvancedElectricMachine { public TileEntityChemicalInjectionChamber() { - super("injection", "ChemicalInjectionChamber", - MachineType.CHEMICAL_INJECTION_CHAMBER.getStorage(), - MachineType.CHEMICAL_INJECTION_CHAMBER.getUsage(), BASE_TICKS_REQUIRED, BASE_GAS_PER_TICK); - + super("injection", "ChemicalInjectionChamber", MachineType.CHEMICAL_INJECTION_CHAMBER.getStorage(), + MachineType.CHEMICAL_INJECTION_CHAMBER.getUsage(), BASE_TICKS_REQUIRED, BASE_GAS_PER_TICK); configComponent.addSupported(TransmissionType.GAS); configComponent.addOutput(TransmissionType.GAS, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); configComponent.addOutput(TransmissionType.GAS, new SideData("Gas", EnumColor.DARK_RED, new int[]{0})); @@ -40,14 +38,12 @@ public class TileEntityChemicalInjectionChamber extends TileEntityAdvancedElectr if (canReceiveGas(side, stack.getGas())) { return gasTank.receive(stack, doTransfer); } - return 0; } @Override public boolean canReceiveGas(EnumFacing side, Gas type) { - return configComponent.getOutput(TransmissionType.GAS, side, facing).hasSlot(0) && gasTank.canReceive(type) - && isValidGas(type); + return configComponent.getOutput(TransmissionType.GAS, side, facing).hasSlot(0) && gasTank.canReceive(type) && isValidGas(type); } @@ -55,15 +51,12 @@ public class TileEntityChemicalInjectionChamber extends TileEntityAdvancedElectr public void handleSecondaryFuel() { if (!inventory.get(1).isEmpty() && gasTank.getNeeded() > 0 && inventory.get(1).getItem() instanceof IGasItem) { GasStack gas = ((IGasItem) inventory.get(1).getItem()).getGas(inventory.get(1)); - if (gas != null && isValidGas(gas.getGas())) { GasStack removed = GasUtils.removeGas(inventory.get(1), gasTank.getGasType(), gasTank.getNeeded()); gasTank.receive(removed, true); } - return; } - super.handleSecondaryFuel(); } @@ -81,4 +74,4 @@ public class TileEntityChemicalInjectionChamber extends TileEntityAdvancedElectr public boolean useStatisticalMechanics() { return true; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java b/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java index e41db6f38..8d2c5ef2c 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java @@ -31,8 +31,7 @@ import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.items.CapabilityItemHandler; -public class TileEntityChemicalOxidizer extends TileEntityOperationalMachine implements ISustainedData, ITankManager, - IGasHandler { +public class TileEntityChemicalOxidizer extends TileEntityOperationalMachine implements ISustainedData, ITankManager, IGasHandler { public static final int MAX_GAS = 10000; public GasTank gasTank = new GasTank(MAX_GAS); @@ -41,43 +40,31 @@ public class TileEntityChemicalOxidizer extends TileEntityOperationalMachine imp public OxidationRecipe cachedRecipe; public TileEntityChemicalOxidizer() { - super("machine.oxidizer", "ChemicalOxidizer", - MachineType.CHEMICAL_OXIDIZER.getStorage(), - MachineType.CHEMICAL_OXIDIZER.getUsage(), 3, 100); - + super("machine.oxidizer", "ChemicalOxidizer", MachineType.CHEMICAL_OXIDIZER.getStorage(), MachineType.CHEMICAL_OXIDIZER.getUsage(), 3, 100); inventory = NonNullList.withSize(4, ItemStack.EMPTY); } @Override public void onUpdate() { super.onUpdate(); - if (!world.isRemote) { ChargeUtils.discharge(1, this); TileUtils.drawGas(inventory.get(2), gasTank); - OxidationRecipe recipe = getRecipe(); - if (canOperate(recipe) && getEnergy() >= energyPerTick && MekanismUtils.canFunction(this)) { setActive(true); setEnergy(getEnergy() - energyPerTick); - if (operatingTicks < ticksRequired) { operatingTicks++; } else { operate(recipe); - operatingTicks = 0; markDirty(); } - } else { - if (prevEnergy >= getEnergy()) { - setActive(false); - } + } else if (prevEnergy >= getEnergy()) { + setActive(false); } - prevEnergy = getEnergy(); - TileUtils.emitGas(this, gasTank, gasOutput, MekanismUtils.getRight(facing)); } } @@ -89,17 +76,14 @@ public class TileEntityChemicalOxidizer extends TileEntityOperationalMachine imp } else if (slotID == 1) { return ChargeUtils.canBeDischarged(itemstack); } - return false; } @Override public boolean canExtractItem(int slotID, @Nonnull ItemStack itemstack, @Nonnull EnumFacing side) { if (slotID == 2) { - return !itemstack.isEmpty() && itemstack.getItem() instanceof IGasItem && ((IGasItem) itemstack.getItem()) - .canProvideGas(itemstack, null); + return !itemstack.isEmpty() && itemstack.getItem() instanceof IGasItem && ((IGasItem) itemstack.getItem()).canProvideGas(itemstack, null); } - return false; } @@ -113,17 +97,14 @@ public class TileEntityChemicalOxidizer extends TileEntityOperationalMachine imp } else if (side == MekanismUtils.getRight(facing)) { return new int[]{2}; } - return InventoryUtils.EMPTY; } public OxidationRecipe getRecipe() { ItemStackInput input = getInput(); - if (cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) { cachedRecipe = RecipeHandler.getOxidizerRecipe(getInput()); } - return cachedRecipe; } @@ -137,14 +118,12 @@ public class TileEntityChemicalOxidizer extends TileEntityOperationalMachine imp public void operate(OxidationRecipe recipe) { recipe.operate(inventory, gasTank); - markDirty(); } @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { TileUtils.readTankData(dataStream, gasTank); } @@ -160,7 +139,6 @@ public class TileEntityChemicalOxidizer extends TileEntityOperationalMachine imp @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - gasTank.read(nbtTags.getCompoundTag("gasTank")); } @@ -168,9 +146,7 @@ public class TileEntityChemicalOxidizer extends TileEntityOperationalMachine imp @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setTag("gasTank", gasTank.write(new NBTTagCompound())); - return nbtTags; } @@ -194,7 +170,6 @@ public class TileEntityChemicalOxidizer extends TileEntityOperationalMachine imp } else if (capability == Capabilities.GAS_HANDLER_CAPABILITY) { return Capabilities.GAS_HANDLER_CAPABILITY.cast(this); } - return super.getCapability(capability, side); } @@ -254,4 +229,4 @@ public class TileEntityChemicalOxidizer extends TileEntityOperationalMachine imp public GasTankInfo[] getTankInfo() { return new GasTankInfo[]{gasTank}; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java b/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java index bbc994b5a..39fe63496 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java @@ -46,8 +46,7 @@ import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.items.CapabilityItemHandler; -public class TileEntityChemicalWasher extends TileEntityMachine implements IGasHandler, IFluidHandlerWrapper, - ISustainedData, IUpgradeInfoHandler, ITankManager { +public class TileEntityChemicalWasher extends TileEntityMachine implements IGasHandler, IFluidHandlerWrapper, ISustainedData, IUpgradeInfoHandler, ITankManager { public static final int MAX_GAS = 10000; public static final int MAX_FLUID = 10000; @@ -62,50 +61,37 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH public double clientEnergyUsed; public TileEntityChemicalWasher() { - super("machine.washer", "ChemicalWasher", - MachineType.CHEMICAL_WASHER.getStorage(), - MachineType.CHEMICAL_WASHER.getUsage(), 4); + super("machine.washer", "ChemicalWasher", MachineType.CHEMICAL_WASHER.getStorage(), MachineType.CHEMICAL_WASHER.getUsage(), 4); inventory = NonNullList.withSize(5, ItemStack.EMPTY); } @Override public void onUpdate() { super.onUpdate(); - if (!world.isRemote) { ChargeUtils.discharge(3, this); manageBuckets(); TileUtils.drawGas(inventory.get(2), outputTank); - WasherRecipe recipe = getRecipe(); - if (canOperate(recipe) && getEnergy() >= energyPerTick && MekanismUtils.canFunction(this)) { setActive(true); - int operations = operate(recipe); double prev = getEnergy(); - setEnergy(getEnergy() - energyPerTick * operations); clientEnergyUsed = prev - getEnergy(); - } else { - if (prevEnergy >= getEnergy()) { - setActive(false); - } + } else if (prevEnergy >= getEnergy()) { + setActive(false); } - TileUtils.emitGas(this, outputTank, gasOutput, MekanismUtils.getRight(facing)); - prevEnergy = getEnergy(); } } public WasherRecipe getRecipe() { GasInput input = getInput(); - if (cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) { cachedRecipe = RecipeHandler.getChemicalWasherRecipe(getInput()); } - return cachedRecipe; } @@ -119,16 +105,13 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH public int operate(WasherRecipe recipe) { int operations = getUpgradedUsage(); - recipe.operate(inputTank, fluidTank, outputTank, operations); - return operations; } private void manageBuckets() { if (FluidContainerUtils.isFluidContainer(inventory.get(0))) { - FluidContainerUtils - .handleContainerItemEmpty(this, fluidTank, 0, 1, FluidChecker.check(FluidRegistry.WATER)); + FluidContainerUtils.handleContainerItemEmpty(this, fluidTank, 0, 1, FluidChecker.check(FluidRegistry.WATER)); } } @@ -136,14 +119,12 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH int possibleProcess = (int) Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)); possibleProcess = Math.min(Math.min(inputTank.getStored(), outputTank.getNeeded()), possibleProcess); possibleProcess = Math.min((int) (getEnergy() / energyPerTick), possibleProcess); - return Math.min(fluidTank.getFluidAmount() / WATER_USAGE, possibleProcess); } @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { clientEnergyUsed = dataStream.readDouble(); TileUtils.readTankData(dataStream, fluidTank); @@ -155,7 +136,6 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(clientEnergyUsed); TileUtils.addTankData(data, fluidTank); TileUtils.addTankData(data, inputTank); @@ -166,7 +146,6 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - fluidTank.readFromNBT(nbtTags.getCompoundTag("leftTank")); inputTank.read(nbtTags.getCompoundTag("rightTank")); outputTank.read(nbtTags.getCompoundTag("centerTank")); @@ -176,11 +155,9 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setTag("leftTank", fluidTank.writeToNBT(new NBTTagCompound())); nbtTags.setTag("rightTank", inputTank.write(new NBTTagCompound())); nbtTags.setTag("centerTank", outputTank.write(new NBTTagCompound())); - return nbtTags; } @@ -195,7 +172,6 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH } else if (side == MekanismUtils.getRight(facing)) { return outputTank; } - return null; } @@ -204,7 +180,6 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH if (getTank(side) == inputTank) { return getTank(side).canReceive(type) && RecipeHandler.Recipe.CHEMICAL_WASHER.containsRecipe(type); } - return false; } @@ -214,7 +189,6 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH if (canReceiveGas(side, stack != null ? stack.getGas() : null)) { return getTank(side).receive(stack, doTransfer); } - return 0; } @@ -223,7 +197,6 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH if (canDrawGas(side, null)) { return getTank(side).draw(amount, doTransfer); } - return null; } @@ -241,24 +214,20 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH @Override public boolean isItemValidForSlot(int slotID, @Nonnull ItemStack itemstack) { if (slotID == 0) { - return FluidUtil.getFluidContained(itemstack) != null - && FluidUtil.getFluidContained(itemstack).getFluid() == FluidRegistry.WATER; + return FluidUtil.getFluidContained(itemstack) != null && FluidUtil.getFluidContained(itemstack).getFluid() == FluidRegistry.WATER; } else if (slotID == 2) { return ChargeUtils.canBeDischarged(itemstack); } - return false; } @Override public boolean canExtractItem(int slotID, @Nonnull ItemStack itemstack, @Nonnull EnumFacing side) { if (slotID == 1) { - return !itemstack.isEmpty() && itemstack.getItem() instanceof IGasItem && ((IGasItem) itemstack.getItem()) - .canProvideGas(itemstack, null); + return !itemstack.isEmpty() && itemstack.getItem() instanceof IGasItem && ((IGasItem) itemstack.getItem()).canProvideGas(itemstack, null); } else if (slotID == 2) { return ChargeUtils.canBeOutputted(itemstack, false); } - return false; } @@ -272,7 +241,6 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH } else if (side.getAxis() == Axis.Y) { return new int[2]; } - return InventoryUtils.EMPTY; } @@ -281,8 +249,7 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH if (isCapabilityDisabled(capability, side)) { return false; } - return capability == Capabilities.GAS_HANDLER_CAPABILITY - || capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, side); + return capability == Capabilities.GAS_HANDLER_CAPABILITY || capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, side); } @Override @@ -294,7 +261,6 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH } else if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(new FluidHandlerWrapper(this, side)); } - return super.getCapability(capability, side); } @@ -313,7 +279,6 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH if (canFill(from, resource)) { return fluidTank.fill(resource, doFill); } - return 0; } @@ -342,7 +307,6 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH if (from == EnumFacing.UP) { return new FluidTankInfo[]{fluidTank.getInfo()}; } - return PipeUtils.EMPTY; } @@ -356,11 +320,9 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH if (fluidTank.getFluid() != null) { ItemDataUtils.setCompound(itemStack, "fluidTank", fluidTank.getFluid().writeToNBT(new NBTTagCompound())); } - if (inputTank.getGas() != null) { ItemDataUtils.setCompound(itemStack, "inputTank", inputTank.getGas().write(new NBTTagCompound())); } - if (outputTank.getGas() != null) { ItemDataUtils.setCompound(itemStack, "outputTank", outputTank.getGas().write(new NBTTagCompound())); } @@ -382,4 +344,4 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH public Object[] getTanks() { return new Object[]{fluidTank, inputTank, outputTank}; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityCombiner.java b/src/main/java/mekanism/common/tile/TileEntityCombiner.java index 7e83b9e03..cea3dce41 100644 --- a/src/main/java/mekanism/common/tile/TileEntityCombiner.java +++ b/src/main/java/mekanism/common/tile/TileEntityCombiner.java @@ -10,13 +10,11 @@ import mekanism.common.tile.prefab.TileEntityDoubleElectricMachine; public class TileEntityCombiner extends TileEntityDoubleElectricMachine { public TileEntityCombiner() { - super("combiner", "Combiner", - MachineType.COMBINER.getStorage(), - MachineType.COMBINER.getUsage(), 200); + super("combiner", "Combiner", MachineType.COMBINER.getStorage(), MachineType.COMBINER.getUsage(), 200); } @Override public Map getRecipes() { return Recipe.COMBINER.get(); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityCrusher.java b/src/main/java/mekanism/common/tile/TileEntityCrusher.java index fafbb74bc..1793e3db1 100644 --- a/src/main/java/mekanism/common/tile/TileEntityCrusher.java +++ b/src/main/java/mekanism/common/tile/TileEntityCrusher.java @@ -10,13 +10,11 @@ import mekanism.common.tile.prefab.TileEntityElectricMachine; public class TileEntityCrusher extends TileEntityElectricMachine { public TileEntityCrusher() { - super("crusher", "Crusher", - MachineType.CRUSHER.getStorage(), - MachineType.CRUSHER.getUsage(), 200); + super("crusher", "Crusher", MachineType.CRUSHER.getStorage(), MachineType.CRUSHER.getUsage(), 200); } @Override public Map getRecipes() { return Recipe.CRUSHER.get(); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java b/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java index 1964f17d0..cea1aa008 100644 --- a/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java +++ b/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java @@ -53,7 +53,6 @@ import mekanism.common.util.StackUtils; import mekanism.common.util.TransporterUtils; import net.minecraft.block.Block; import net.minecraft.block.BlockBush; -import net.minecraft.block.BlockShulkerBox; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -64,7 +63,6 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityShulkerBox; import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; import net.minecraft.util.NonNullList; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; @@ -83,8 +81,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.ItemHandlerHelper; -public class TileEntityDigitalMiner extends TileEntityElectricBlock implements IUpgradeTile, IRedstoneControl, - IActiveState, ISustainedData, IChunkLoader, IAdvancedBoundingBlock { +public class TileEntityDigitalMiner extends TileEntityElectricBlock implements IUpgradeTile, IRedstoneControl, IActiveState, ISustainedData, IChunkLoader, IAdvancedBoundingBlock { private static final int[] INV_SLOTS = IntStream.range(0, 28).toArray(); @@ -143,21 +140,18 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, INV_SLOTS.length); public TileComponentSecurity securityComponent = new TileComponentSecurity(this); public TileComponentChunkLoader chunkLoaderComponent = new TileComponentChunkLoader(this); - public String[] methods = {"setRadius", "setMin", "setMax", "addFilter", "removeFilter", "addOreFilter", - "removeOreFilter", "reset", "start", "stop", "getToMine"}; + public String[] methods = {"setRadius", "setMin", "setMax", "addFilter", "removeFilter", "addOreFilter", "removeOreFilter", "reset", "start", "stop", "getToMine"}; public TileEntityDigitalMiner() { super("DigitalMiner", MachineType.DIGITAL_MINER.getStorage()); inventory = NonNullList.withSize(INV_SLOTS.length + 1, ItemStack.EMPTY); radius = 10; - upgradeComponent.setSupported(Upgrade.ANCHOR); } @Override public void onUpdate() { super.onUpdate(); - if (getActive()) { for (EntityPlayer player : new HashSet<>(playersUsing)) { if (player.openContainer instanceof ContainerNull || player.openContainer instanceof ContainerFilter) { @@ -170,40 +164,30 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if (!initCalc) { if (searcher.state == State.FINISHED) { boolean prevRunning = running; - reset(); start(); - running = prevRunning; } - initCalc = true; } ChargeUtils.discharge(27, this); - if (MekanismUtils.canFunction(this) && running && getEnergy() >= getPerTick() - && searcher.state == State.FINISHED && oresToMine.size() > 0) { + if (MekanismUtils.canFunction(this) && running && getEnergy() >= getPerTick() && searcher.state == State.FINISHED && oresToMine.size() > 0) { setActive(true); - if (delay > 0) { delay--; } - setEnergy(getEnergy() - getPerTick()); - if (delay == 0) { boolean did = false; - for (Iterator it = oresToMine.keySet().iterator(); it.hasNext(); ) { Chunk3D chunk = it.next(); BitSet set = oresToMine.get(chunk); int next = 0; - while (!did) { int index = set.nextSetBit(next); Coord4D coord = getCoordFromIndex(index); - if (index == -1) { it.remove(); break; @@ -211,12 +195,10 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if (!coord.exists(world)) { set.clear(index); - if (set.cardinality() == 0) { it.remove(); break; } - next = index + 1; continue; } @@ -227,19 +209,16 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if (coord.isAirBlock(world)) { set.clear(index); - if (set.cardinality() == 0) { it.remove(); break; } - next = index + 1; continue; } boolean hasFilter = false; ItemStack is = new ItemStack(block, 1, meta); - for (MinerFilter filter : filters) { if (filter.canFilter(is)) { hasFilter = true; @@ -249,64 +228,49 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if (inverse == hasFilter || !canMine(coord)) { set.clear(index); - if (set.cardinality() == 0) { it.remove(); break; } - next = index + 1; continue; } List drops = MinerUtils.getDrops(world, coord, silkTouch, this.pos); - if (canInsert(drops) && setReplace(coord, index)) { did = true; add(drops); set.clear(index); - if (set.cardinality() == 0) { it.remove(); } - - world.playEvent(WorldEvents.BREAK_BLOCK_EFFECTS, coord.getPos(), - Block.getStateId(state)); - + world.playEvent(WorldEvents.BREAK_BLOCK_EFFECTS, coord.getPos(), Block.getStateId(state)); missingStack = ItemStack.EMPTY; } - break; } } - delay = getDelay(); } - } else { - if (prevEnergy >= getEnergy()) { - setActive(false); - } + } else if (prevEnergy >= getEnergy()) { + setActive(false); } TransitRequest ejectMap = getEjectItemMap(); - if (doEject && delayTicks == 0 && !ejectMap.isEmpty()) { TileEntity ejectInv = getEjectInv(); TileEntity ejectTile = getEjectTile(); if (ejectInv != null && ejectTile != null) { TransitResponse response; - if (CapabilityUtils.hasCapability(ejectInv, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, - facing.getOpposite())) { - response = TransporterUtils.insert(ejectTile, CapabilityUtils - .getCapability(ejectInv, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, - facing.getOpposite()), ejectMap, null, true, 0); + if (CapabilityUtils.hasCapability(ejectInv, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, facing.getOpposite())) { + response = TransporterUtils.insert(ejectTile, CapabilityUtils.getCapability(ejectInv, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, facing.getOpposite()), + ejectMap, null, true, 0); } else { response = InventoryUtils.putStackInInventory(ejectInv, ejectMap, facing.getOpposite(), false); } if (!response.isEmpty()) { response.getInvStack(ejectTile, facing.getOpposite()).use(); } - delayTicks = 10; } } else if (delayTicks > 0) { @@ -315,29 +279,22 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if (playersUsing.size() > 0) { for (EntityPlayer player : playersUsing) { - Mekanism.packetHandler - .sendTo(new TileEntityMessage(Coord4D.get(this), getSmallPacket(new TileNetworkList())), - (EntityPlayerMP) player); + Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getSmallPacket(new TileNetworkList())), (EntityPlayerMP) player); } } - prevEnergy = getEnergy(); } } public double getPerTick() { double ret = energyUsage; - if (silkTouch) { ret *= MekanismConfig.current().general.minerSilkMultiplier.val(); } - 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)); - + ret *= 1 + ((float) baseRad / 22F); + int baseHeight = Math.max(maxY - minY - 60, 0); + ret *= 1 + ((float) baseHeight / 195F); return ret; } @@ -350,9 +307,8 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I } public void setRadius(int newRadius) { - boolean changed = (radius != newRadius); + boolean changed = radius != newRadius; radius = newRadius; - // If the radius changed and we're on the server, go ahead and refresh // the chunk set if (changed && hasWorld() && world.isRemote) { @@ -379,24 +335,18 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if (!stack.isEmpty()) { world.setBlockState(pos, StackUtils.getStateForPlacement(stack, world, pos, fakePlayer), 3); - IBlockState s = obj.getBlockState(world); - if (s.getBlock() instanceof BlockBush && !((BlockBush) s.getBlock()) - .canBlockStay(world, pos, s)) { + if (s.getBlock() instanceof BlockBush && !((BlockBush) s.getBlock()).canBlockStay(world, pos, s)) { s.getBlock().dropBlockAsItem(world, pos, s, 1); world.setBlockToAir(pos); } - return true; } else { MinerFilter filter = replaceMap.get(index); - - if (filter == null || (filter.replaceStack.isEmpty() || !filter.requireStack)) { + if (filter == null || filter.replaceStack.isEmpty() || !filter.requireStack) { world.setBlockToAir(pos); - return true; } - missingStack = filter.replaceStack; // something failed, so put that thing back where it came from @@ -404,76 +354,61 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I tileEntityShulkerBox.validate(); world.setTileEntity(pos, tileEntityShulkerBox); } - return false; } } private boolean canMine(Coord4D coord) { IBlockState state = coord.getBlockState(world); - EntityPlayer dummy = Objects.requireNonNull(Mekanism.proxy.getDummyPlayer((WorldServer) world, pos).get()); BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, coord.getPos(), state, dummy); MinecraftForge.EVENT_BUS.post(event); - return !event.isCanceled(); } public ItemStack getReplace(int index) { MinerFilter filter = replaceMap.get(index); - if (filter == null || filter.replaceStack.isEmpty()) { return ItemStack.EMPTY; } - for (int i = 0; i < 27; i++) { if (!inventory.get(i).isEmpty() && inventory.get(i).isItemEqual(filter.replaceStack)) { inventory.get(i).shrink(1); - return StackUtils.size(filter.replaceStack, 1); } } if (doPull && getPullInv() != null) { - InvStack stack = InventoryUtils - .takeDefinedItem(getPullInv(), EnumFacing.UP, filter.replaceStack.copy(), 1, 1); - + InvStack stack = InventoryUtils.takeDefinedItem(getPullInv(), EnumFacing.UP, filter.replaceStack.copy(), 1, 1); if (stack != null) { stack.use(); return StackUtils.size(filter.replaceStack, 1); } } - return ItemStack.EMPTY; } public NonNullList copy(NonNullList stacks) { NonNullList toReturn = NonNullList.withSize(stacks.size(), ItemStack.EMPTY); - for (int i = 0; i < stacks.size(); i++) { toReturn.set(i, !stacks.get(i).isEmpty() ? stacks.get(i).copy() : ItemStack.EMPTY); } - return toReturn; } public TransitRequest getEjectItemMap() { TransitRequest request = new TransitRequest(); - for (int i = 27 - 1; i >= 0; i--) { ItemStack stack = inventory.get(i); - if (!stack.isEmpty()) { if (isReplaceStack(stack)) { continue; } - if (!request.hasType(stack)) { request.addItem(stack, i); } } } - return request; } @@ -481,37 +416,28 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if (stacks.isEmpty()) { return true; } - NonNullList testInv = copy(inventory); - int added = 0; stacks: for (ItemStack stack : stacks) { stack = stack.copy(); - if (stack.isEmpty()) { continue; } - for (int i = 0; i < 27; i++) { ItemStack existingStack = testInv.get(i); if (existingStack.isEmpty()) { testInv.set(i, stack); added++; - continue stacks; - } else if (ItemHandlerHelper.canItemStacksStack(existingStack, stack) - && existingStack.getCount() + stack.getCount() <= stack - .getMaxStackSize()) { + } else if (ItemHandlerHelper.canItemStacksStack(existingStack, stack) && existingStack.getCount() + stack.getCount() <= stack.getMaxStackSize()) { existingStack.grow(stack.getCount()); added++; - continue stacks; } } } - return added == stacks.size(); } @@ -522,7 +448,6 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I public TileEntity getEjectInv() { EnumFacing side = facing.getOpposite(); - return world.getTileEntity(getPos().up().offset(side, 2)); } @@ -536,12 +461,9 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I for (int i = 0; i < 27; i++) { if (inventory.get(i).isEmpty()) { inventory.set(i, stack); - continue stacks; - } else if (inventory.get(i).isItemEqual(stack) - && inventory.get(i).getCount() + stack.getCount() <= stack.getMaxStackSize()) { + } else if (inventory.get(i).isItemEqual(stack) && inventory.get(i).getCount() + stack.getCount() <= stack.getMaxStackSize()) { inventory.get(i).grow(stack.getCount()); - continue stacks; } } @@ -552,9 +474,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if (searcher.state == State.IDLE) { searcher.start(); } - running = true; - MekanismUtils.saveChunk(this); } @@ -562,12 +482,10 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if (searcher.state == State.SEARCHING) { searcher.interrupt(); reset(); - return; } else if (searcher.state == State.FINISHED) { running = false; } - MekanismUtils.saveChunk(this); } @@ -578,7 +496,6 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I replaceMap.clear(); missingStack = ItemStack.EMPTY; setActive(false); - MekanismUtils.saveChunk(this); } @@ -588,35 +505,28 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I return true; } } - return false; } public int getSize() { int size = 0; - for (Chunk3D chunk : oresToMine.keySet()) { size += oresToMine.get(chunk).cardinality(); } - return size; } @Override public void openInventory(@Nonnull EntityPlayer player) { super.openInventory(player); - if (!world.isRemote) { - Mekanism.packetHandler - .sendTo(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - (EntityPlayerMP) player); + Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), (EntityPlayerMP) player); } } @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - clientActive = isActive = nbtTags.getBoolean("isActive"); running = nbtTags.getBoolean("running"); delay = nbtTags.getInteger("delay"); @@ -630,11 +540,9 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - if (searcher.state == State.SEARCHING) { reset(); } - nbtTags.setBoolean("isActive", isActive); nbtTags.setBoolean("running", running); nbtTags.setInteger("delay", delay); @@ -658,7 +566,6 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I clientToMine = dataStream.readInt(); controlType = RedstoneControl.values()[dataStream.readInt()]; inverse = dataStream.readBoolean(); - if (dataStream.readBoolean()) { missingStack = new ItemStack(Item.getItemById(dataStream.readInt()), 1, dataStream.readInt()); } else { @@ -670,7 +577,6 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I public void handlePacketData(ByteBuf dataStream) { if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { int type = dataStream.readInt(); - switch (type) { case 0: doEject = !doEject; @@ -688,8 +594,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I reset(); break; case 6: - setRadius( - Math.min(dataStream.readInt(), MekanismConfig.current().general.digitalMinerMaxRadius.val())); + setRadius(Math.min(dataStream.readInt(), MekanismConfig.current().general.digitalMinerMaxRadius.val())); break; case 7: minY = dataStream.readInt(); @@ -707,34 +612,26 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I // Move filter up int filterIndex = dataStream.readInt(); filters.swap(filterIndex, filterIndex - 1); - for (EntityPlayer player : playersUsing) { openInventory(player); } - break; } case 12: { // Move filter down int filterIndex = dataStream.readInt(); filters.swap(filterIndex, filterIndex + 1); - for (EntityPlayer player : playersUsing) { openInventory(player); } - break; } } MekanismUtils.saveChunk(this); - for (EntityPlayer player : playersUsing) { - Mekanism.packetHandler - .sendTo(new TileEntityMessage(Coord4D.get(this), getGenericPacket(new TileNetworkList())), - (EntityPlayerMP) player); + Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getGenericPacket(new TileNetworkList())), (EntityPlayerMP) player); } - return; } @@ -742,14 +639,10 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { int type = dataStream.readInt(); - if (type == 0) { readBasicData(dataStream); - filters.clear(); - int amount = dataStream.readInt(); - for (int i = 0; i < amount; i++) { filters.add(MinerFilter.readFromPacket(dataStream)); } @@ -757,9 +650,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I readBasicData(dataStream); } else if (type == 2) { filters.clear(); - int amount = dataStream.readInt(); - for (int i = 0; i < amount; i++) { filters.add(MinerFilter.readFromPacket(dataStream)); } @@ -767,14 +658,12 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I clientActive = dataStream.readBoolean(); running = dataStream.readBoolean(); clientToMine = dataStream.readInt(); - if (dataStream.readBoolean()) { missingStack = new ItemStack(Item.getItemById(dataStream.readInt()), 1, dataStream.readInt()); } else { missingStack = ItemStack.EMPTY; } } - if (clientActive != isActive) { isActive = clientActive; MekanismUtils.updateBlock(world, getPos()); @@ -802,7 +691,6 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I data.add(controlType.ordinal()); data.add(inverse); - if (!missingStack.isEmpty()) { data.add(true); data.add(MekanismUtils.getID(missingStack)); @@ -818,11 +706,9 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I data.add(0); addBasicData(data); data.add(filters.size()); - for (MinerFilter filter : filters) { filter.write(data); } - return data; } @@ -839,7 +725,6 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I } else { data.add(getSize()); } - if (!missingStack.isEmpty()) { data.add(true); data.add(MekanismUtils.getID(missingStack)); @@ -847,7 +732,6 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I } else { data.add(false); } - return data; } @@ -860,15 +744,11 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I public TileNetworkList getFilterPacket(TileNetworkList data) { super.getNetworkedData(data); - data.add(2); - data.add(filters.size()); - for (MinerFilter filter : filters) { filter.write(data); } - return data; } @@ -887,11 +767,9 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I public Coord4D getCoordFromIndex(int index) { int diameter = getDiameter(); Coord4D start = getStartingCoord(); - int x = start.x + index % diameter; int y = start.y + (index / diameter / diameter); int z = start.z + (index / diameter) % diameter; - return new Coord4D(x, y, z, world.provider.getDimension()); } @@ -929,13 +807,8 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I @Override public void setActive(boolean active) { isActive = active; - if (clientActive != active) { - Mekanism.packetHandler - .sendToReceivers( - new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); - + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); clientActive = active; } } @@ -965,7 +838,6 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if (x == 0 && y == 0 && z == 0) { continue; } - BlockPos pos1 = getPos().add(x, y, z); MekanismUtils.makeAdvancedBoundingBlock(world, pos1, Coord4D.get(this)); world.notifyNeighborsOfStateChange(pos1, getBlockType(), true); @@ -1012,11 +884,9 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if (side == EnumFacing.UP) { if (slotID == 27) { return ChargeUtils.canBeDischarged(itemstack); - } else { - return !itemstack.isEmpty() && isReplaceStack(itemstack); } + return !itemstack.isEmpty() && isReplaceStack(itemstack); } - return false; } @@ -1025,11 +895,9 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if (side == facing.getOpposite()) { if (slotID == 27) { return !ChargeUtils.canBeDischarged(itemstack); - } else { - return itemstack.isEmpty() || !isReplaceStack(itemstack); } + return itemstack.isEmpty() || !isReplaceStack(itemstack); } - return false; } @@ -1054,49 +922,38 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if (arguments.length != 1 || !(arguments[0] instanceof Double)) { return new Object[]{"Invalid parameters."}; } - - setRadius(Math.min(((Double) arguments[0]).intValue(), - MekanismConfig.current().general.digitalMinerMaxRadius.val())); + setRadius(Math.min(((Double) arguments[0]).intValue(), MekanismConfig.current().general.digitalMinerMaxRadius.val())); } else if (method == 1) { if (arguments.length != 1 || !(arguments[0] instanceof Double)) { return new Object[]{"Invalid parameters."}; } - minY = ((Double) arguments[0]).intValue(); } else if (method == 2) { if (arguments.length != 1 || !(arguments[0] instanceof Double)) { return new Object[]{"Invalid parameters."}; } - maxY = ((Double) arguments[0]).intValue(); } else if (method == 3) { if (arguments.length < 1 || !(arguments[0] instanceof Double)) { return new Object[]{"Invalid parameters."}; } - int id = ((Double) arguments[0]).intValue(); int meta = 0; - if (arguments.length > 1) { if (arguments[1] instanceof Double) { meta = ((Double) arguments[1]).intValue(); } } - filters.add(new MItemStackFilter(new ItemStack(Item.getItemById(id), 1, meta))); - return new Object[]{"Added filter."}; } else if (method == 4) { if (arguments.length < 1 || !(arguments[0] instanceof Double)) { return new Object[]{"Invalid parameters."}; } - int id = ((Double) arguments[0]).intValue(); Iterator iter = filters.iterator(); - while (iter.hasNext()) { MinerFilter filter = iter.next(); - if (filter instanceof MItemStackFilter) { if (MekanismUtils.getID(((MItemStackFilter) filter).itemType) == id) { iter.remove(); @@ -1104,31 +961,24 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I } } } - return new Object[]{"Couldn't find filter."}; } else if (method == 5) { if (arguments.length < 1 || !(arguments[0] instanceof String)) { return new Object[]{"Invalid parameters."}; } - String ore = (String) arguments[0]; MOreDictFilter filter = new MOreDictFilter(); - filter.setOreDictName(ore); filters.add(filter); - return new Object[]{"Added filter."}; } else if (method == 6) { if (arguments.length < 1 || !(arguments[0] instanceof String)) { return new Object[]{"Invalid parameters."}; } - String ore = (String) arguments[0]; Iterator iter = filters.iterator(); - while (iter.hasNext()) { MinerFilter filter = iter.next(); - if (filter instanceof MOreDictFilter) { if (((MOreDictFilter) filter).getOreDictName().equals(ore)) { iter.remove(); @@ -1136,7 +986,6 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I } } } - return new Object[]{"Couldn't find filter."}; } else if (method == 7) { reset(); @@ -1150,13 +999,9 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I } else if (method == 10) { return new Object[]{searcher != null ? searcher.found : 0}; } - for (EntityPlayer player : playersUsing) { - Mekanism.packetHandler - .sendTo(new TileEntityMessage(Coord4D.get(this), getGenericPacket(new TileNetworkList())), - (EntityPlayerMP) player); + Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getGenericPacket(new TileNetworkList())), (EntityPlayerMP) player); } - return null; } @@ -1169,17 +1014,13 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I nbtTags.setBoolean("doPull", doPull); nbtTags.setBoolean("silkTouch", silkTouch); nbtTags.setBoolean("inverse", inverse); - NBTTagList filterTags = new NBTTagList(); - for (MinerFilter filter : filters) { filterTags.appendTag(filter.write(new NBTTagCompound())); } - if (filterTags.tagCount() != 0) { nbtTags.setTag("filters", filterTags); } - return nbtTags; } @@ -1192,10 +1033,8 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I doPull = nbtTags.getBoolean("doPull"); silkTouch = nbtTags.getBoolean("silkTouch"); inverse = nbtTags.getBoolean("inverse"); - if (nbtTags.hasKey("filters")) { NBTTagList tagList = nbtTags.getTagList("filters", NBT.TAG_COMPOUND); - for (int i = 0; i < tagList.tagCount(); i++) { filters.add(MinerFilter.readFromNBT(tagList.getCompoundTagAt(i))); } @@ -1232,8 +1071,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I @Override public void readSustainedData(ItemStack itemStack) { if (ItemDataUtils.hasData(itemStack, "hasMinerConfig")) { - setRadius(Math.min(ItemDataUtils.getInt(itemStack, "radius"), - MekanismConfig.current().general.digitalMinerMaxRadius.val())); + setRadius(Math.min(ItemDataUtils.getInt(itemStack, "radius"), MekanismConfig.current().general.digitalMinerMaxRadius.val())); minY = ItemDataUtils.getInt(itemStack, "minY"); maxY = ItemDataUtils.getInt(itemStack, "maxY"); doEject = ItemDataUtils.getBoolean(itemStack, "doEject"); @@ -1243,7 +1081,6 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if (ItemDataUtils.hasData(itemStack, "filters")) { NBTTagList tagList = ItemDataUtils.getList(itemStack, "filters"); - for (int i = 0; i < tagList.tagCount(); i++) { filters.add(MinerFilter.readFromNBT(tagList.getCompoundTagAt(i))); } @@ -1254,7 +1091,6 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I @Override public void recalculateUpgradables(Upgrade upgrade) { super.recalculateUpgradables(upgrade); - switch (upgrade) { case SPEED: delayLength = MekanismUtils.getTicks(this, BASE_DELAY); @@ -1271,20 +1107,17 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I public boolean canBoundReceiveEnergy(BlockPos coord, EnumFacing side) { EnumFacing left = MekanismUtils.getLeft(facing); EnumFacing right = MekanismUtils.getRight(facing); - if (coord.equals(getPos().offset(left))) { return side == left; } else if (coord.equals(getPos().offset(right))) { return side == right; } - return false; } @Override public boolean sideIsConsumer(EnumFacing side) { - return side == MekanismUtils.getLeft(facing) || side == MekanismUtils.getRight(facing) - || side == EnumFacing.DOWN; + return side == MekanismUtils.getLeft(facing) || side == MekanismUtils.getRight(facing) || side == EnumFacing.DOWN; } @Override @@ -1294,19 +1127,15 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I @Override public boolean hasCapability(@Nonnull Capability capability, EnumFacing side) { - return capability == Capabilities.CONFIG_CARD_CAPABILITY - || capability == Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY - || super.hasCapability(capability, side); + return capability == Capabilities.CONFIG_CARD_CAPABILITY || capability == Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY || super.hasCapability(capability, side); } @Override @SuppressWarnings("unchecked") public T getCapability(@Nonnull Capability capability, EnumFacing side) { - if (capability == Capabilities.CONFIG_CARD_CAPABILITY - || capability == Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY) { + if (capability == Capabilities.CONFIG_CARD_CAPABILITY || capability == Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY) { return (T) this; } - return super.getCapability(capability, side); } @@ -1394,11 +1223,8 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I @Override public Set getChunkSet() { if (chunkSet == null) { - chunkSet = new Range4D(Coord4D.get(this)).expandFromCenter(radius). - getIntersectingChunks().stream(). - map(Chunk3D::getPos).collect(Collectors.toSet()); - + chunkSet = new Range4D(Coord4D.get(this)).expandFromCenter(radius).getIntersectingChunks().stream().map(Chunk3D::getPos).collect(Collectors.toSet()); } return chunkSet; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityDynamicTank.java b/src/main/java/mekanism/common/tile/TileEntityDynamicTank.java index 4506a8ea0..b8502e2ea 100644 --- a/src/main/java/mekanism/common/tile/TileEntityDynamicTank.java +++ b/src/main/java/mekanism/common/tile/TileEntityDynamicTank.java @@ -29,14 +29,12 @@ import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.items.CapabilityItemHandler; -public class TileEntityDynamicTank extends TileEntityMultiblock implements - IFluidContainerManager { +public class TileEntityDynamicTank extends TileEntityMultiblock implements IFluidContainerManager { - protected static final int[] SLOTS = {0,1}; + protected static final int[] SLOTS = {0, 1}; /** - * A client-sided set of valves on this tank's structure that are currently active, used on the client for rendering - * fluids. + * A client-sided set of valves on this tank's structure that are currently active, used on the client for rendering fluids. */ public Set valveViewing = new HashSet<>(); @@ -59,12 +57,9 @@ public class TileEntityDynamicTank extends TileEntityMultiblock 0.01) { prevScale = (9 * prevScale + targetScale) / 10; } @@ -73,12 +68,10 @@ public class TileEntityDynamicTank extends TileEntityMultiblock 0) { data.activeTicks--; } - if (data.activeTicks > 0 != data.prevActive) { needsValveUpdate = true; } - data.prevActive = data.activeTicks > 0; } - if (needsValveUpdate || structure.needsRenderUpdate()) { sendPacketToRenderer(); } - structure.prevFluid = structure.fluidStored != null ? structure.fluidStored.copy() : null; - manageInventory(); } } @@ -118,17 +104,10 @@ public class TileEntityDynamicTank extends TileEntityMultiblock capability, EnumFacing side) { - return capability == Capabilities.CONFIGURABLE_CAPABILITY - || capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY - || super.hasCapability(capability, side); + return capability == Capabilities.CONFIGURABLE_CAPABILITY || capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, side); } @Override @@ -470,11 +417,9 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I if (capability == Capabilities.CONFIGURABLE_CAPABILITY) { return Capabilities.CONFIGURABLE_CAPABILITY.cast(this); } - if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(new FluidHandlerWrapper(this, side)); } - return super.getCapability(capability, side); } @@ -526,7 +471,6 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I @Override public void recalculateUpgradables(Upgrade upgrade) { super.recalculateUpgradables(upgrade); - switch (upgrade) { case SPEED: ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED); @@ -538,4 +482,4 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I break; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java b/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java index cb3ad74b7..13108dc44 100644 --- a/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java +++ b/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java @@ -50,11 +50,11 @@ import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.items.CapabilityItemHandler; -public class TileEntityElectrolyticSeparator extends TileEntityMachine implements IFluidHandlerWrapper, - IComputerIntegration, ISustainedData, IGasHandler, IUpgradeInfoHandler, ITankManager { +public class TileEntityElectrolyticSeparator extends TileEntityMachine implements IFluidHandlerWrapper, IComputerIntegration, ISustainedData, IGasHandler, + IUpgradeInfoHandler, ITankManager { - private static final String[] methods = new String[]{"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", - "getWater", "getWaterNeeded", "getHydrogen", "getHydrogenNeeded", "getOxygen", "getOxygenNeeded"}; + private static final String[] methods = new String[]{"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getWater", "getWaterNeeded", "getHydrogen", + "getHydrogenNeeded", "getOxygen", "getOxygenNeeded"}; /** * This separator's water slot. */ @@ -92,18 +92,15 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement public RedstoneControl controlType = RedstoneControl.DISABLED; public TileEntityElectrolyticSeparator() { - super("machine.electrolyticseparator", "ElectrolyticSeparator", - MachineType.ELECTROLYTIC_SEPARATOR.getStorage(), 0, 4); + super("machine.electrolyticseparator", "ElectrolyticSeparator", MachineType.ELECTROLYTIC_SEPARATOR.getStorage(), 0, 4); inventory = NonNullList.withSize(5, ItemStack.EMPTY); } @Override public void onUpdate() { super.onUpdate(); - if (!world.isRemote) { ChargeUtils.discharge(3, this); - if (!inventory.get(0).isEmpty()) { if (RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(inventory.get(0))) { if (FluidContainerUtils.isFluidContainer(inventory.get(0))) { @@ -116,36 +113,26 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement leftTank.draw(GasUtils.addGas(inventory.get(1), leftTank.getGas()), true); MekanismUtils.saveChunk(this); } - if (!inventory.get(2).isEmpty() && rightTank.getStored() > 0) { rightTank.draw(GasUtils.addGas(inventory.get(2), rightTank.getGas()), true); MekanismUtils.saveChunk(this); } - SeparatorRecipe recipe = getRecipe(); if (canOperate(recipe) && getEnergy() >= energyPerTick && MekanismUtils.canFunction(this)) { setActive(true); - boolean update = BASE_ENERGY_PER_TICK != recipe.energyUsage; - BASE_ENERGY_PER_TICK = recipe.energyUsage; - if (update) { recalculateUpgradables(Upgrade.ENERGY); } - int operations = operate(recipe); double prev = getEnergy(); - setEnergy(getEnergy() - energyPerTick * operations); clientEnergyUsed = prev - getEnergy(); - } else { - if (prevEnergy >= getEnergy()) { - setActive(false); - } + } else if (prevEnergy >= getEnergy()) { + setActive(false); } - int dumpAmount = 8 * (int) Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)); handleTank(leftTank, dumpLeft, MekanismUtils.getLeft(facing), dumpAmount); handleTank(rightTank, dumpRight, MekanismUtils.getRight(facing), dumpAmount); @@ -161,7 +148,6 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement } else { tank.draw(dumpAmount, true); } - if (mode == GasMode.DUMPING_EXCESS && tank.getNeeded() < output) { tank.draw(output - tank.getNeeded(), true); } @@ -170,7 +156,6 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement public int getUpgradedUsage(SeparatorRecipe recipe) { int possibleProcess; - if (leftTank.getGasType() == recipe.recipeOutput.leftGas.getGas()) { possibleProcess = leftTank.getNeeded() / recipe.recipeOutput.leftGas.amount; possibleProcess = Math.min(rightTank.getNeeded() / recipe.recipeOutput.rightGas.amount, possibleProcess); @@ -178,20 +163,16 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement possibleProcess = leftTank.getNeeded() / recipe.recipeOutput.rightGas.amount; possibleProcess = Math.min(rightTank.getNeeded() / recipe.recipeOutput.leftGas.amount, possibleProcess); } - possibleProcess = Math.min((int) Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)), possibleProcess); possibleProcess = Math.min((int) (getEnergy() / energyPerTick), possibleProcess); - return Math.min(fluidTank.getFluidAmount() / recipe.recipeInput.ingredient.amount, possibleProcess); } public SeparatorRecipe getRecipe() { FluidInput input = getInput(); - if (cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) { cachedRecipe = RecipeHandler.getElectrolyticSeparatorRecipe(getInput()); } - return cachedRecipe; } @@ -205,15 +186,13 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement public int operate(SeparatorRecipe recipe) { int operations = getUpgradedUsage(recipe); - recipe.operate(fluidTank, leftTank, rightTank, operations); - return operations; } public boolean canFill(ChemicalPairOutput gases) { - return (leftTank.canReceive(gases.leftGas.getGas()) && leftTank.getNeeded() >= gases.leftGas.amount - && rightTank.canReceive(gases.rightGas.getGas()) && rightTank.getNeeded() >= gases.rightGas.amount); + return leftTank.canReceive(gases.leftGas.getGas()) && leftTank.getNeeded() >= gases.leftGas.amount + && rightTank.canReceive(gases.rightGas.getGas()) && rightTank.getNeeded() >= gases.rightGas.amount; } @Override @@ -224,11 +203,8 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement return FluidUtil.getFluidContained(itemstack) == null; } else if (slotID == 1 || slotID == 2) { return itemstack.getItem() instanceof IGasItem && ((IGasItem) itemstack.getItem()).getGas(itemstack) != null - && - ((IGasItem) itemstack.getItem()).getGas(itemstack).amount == ((IGasItem) itemstack.getItem()) - .getMaxGas(itemstack); + && ((IGasItem) itemstack.getItem()).getGas(itemstack).amount == ((IGasItem) itemstack.getItem()).getMaxGas(itemstack); } - return false; } @@ -237,17 +213,14 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement if (slotID == 0) { return Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(itemstack); } else if (slotID == 1) { - return itemstack.getItem() instanceof IGasItem && ( - ((IGasItem) itemstack.getItem()).getGas(itemstack) == null - || ((IGasItem) itemstack.getItem()).getGas(itemstack).getGas() == MekanismFluids.Hydrogen); + return itemstack.getItem() instanceof IGasItem && + (((IGasItem) itemstack.getItem()).getGas(itemstack) == null || ((IGasItem) itemstack.getItem()).getGas(itemstack).getGas() == MekanismFluids.Hydrogen); } else if (slotID == 2) { - return itemstack.getItem() instanceof IGasItem && ( - ((IGasItem) itemstack.getItem()).getGas(itemstack) == null - || ((IGasItem) itemstack.getItem()).getGas(itemstack).getGas() == MekanismFluids.Oxygen); + return itemstack.getItem() instanceof IGasItem && + (((IGasItem) itemstack.getItem()).getGas(itemstack) == null || ((IGasItem) itemstack.getItem()).getGas(itemstack).getGas() == MekanismFluids.Oxygen); } else if (slotID == 3) { return ChargeUtils.canBeDischarged(itemstack); } - return true; } @@ -259,7 +232,6 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement } else if (side == facing || side == facing.getOpposite()) { return new int[]{1, 2}; } - return InventoryUtils.EMPTY; } @@ -267,15 +239,11 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement public void handlePacketData(ByteBuf dataStream) { if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { byte type = dataStream.readByte(); - if (type == 0) { - dumpLeft = GasMode.values()[dumpLeft.ordinal() == GasMode.values().length - 1 ? 0 - : dumpLeft.ordinal() + 1]; + dumpLeft = GasMode.values()[dumpLeft.ordinal() == GasMode.values().length - 1 ? 0 : dumpLeft.ordinal() + 1]; } else if (type == 1) { - dumpRight = GasMode.values()[dumpRight.ordinal() == GasMode.values().length - 1 ? 0 - : dumpRight.ordinal() + 1]; + dumpRight = GasMode.values()[dumpRight.ordinal() == GasMode.values().length - 1 ? 0 : dumpRight.ordinal() + 1]; } - return; } @@ -297,11 +265,9 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement TileUtils.addTankData(data, fluidTank); TileUtils.addTankData(data, leftTank); TileUtils.addTankData(data, rightTank); - data.add(dumpLeft.ordinal()); data.add(dumpRight.ordinal()); data.add(clientEnergyUsed); - return data; } @@ -313,14 +279,11 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - if (nbtTags.hasKey("fluidTank")) { fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank")); } - leftTank.read(nbtTags.getCompoundTag("leftTank")); rightTank.read(nbtTags.getCompoundTag("rightTank")); - dumpLeft = GasMode.values()[nbtTags.getInteger("dumpLeft")]; dumpRight = GasMode.values()[nbtTags.getInteger("dumpRight")]; } @@ -329,17 +292,13 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - if (fluidTank.getFluid() != null) { nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound())); } - nbtTags.setTag("leftTank", leftTank.write(new NBTTagCompound())); nbtTags.setTag("rightTank", rightTank.write(new NBTTagCompound())); - nbtTags.setInteger("dumpLeft", dumpLeft.ordinal()); nbtTags.setInteger("dumpRight", dumpRight.ordinal()); - return nbtTags; } @@ -358,12 +317,11 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement case 2: return new Object[]{BASE_MAX_ENERGY}; case 3: - return new Object[]{(BASE_MAX_ENERGY - electricityStored)}; + return new Object[]{BASE_MAX_ENERGY - electricityStored}; case 4: return new Object[]{fluidTank.getFluid() != null ? fluidTank.getFluid().amount : 0}; case 5: - return new Object[]{ - fluidTank.getFluid() != null ? (fluidTank.getCapacity() - fluidTank.getFluid().amount) : 0}; + return new Object[]{fluidTank.getFluid() != null ? (fluidTank.getCapacity() - fluidTank.getFluid().amount) : 0}; case 6: return new Object[]{leftTank.getStored()}; case 7: @@ -382,11 +340,9 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement if (fluidTank.getFluid() != null) { ItemDataUtils.setCompound(itemStack, "fluidTank", fluidTank.getFluid().writeToNBT(new NBTTagCompound())); } - if (leftTank.getGas() != null) { ItemDataUtils.setCompound(itemStack, "leftTank", leftTank.getGas().write(new NBTTagCompound())); } - if (rightTank.getGas() != null) { ItemDataUtils.setCompound(itemStack, "rightTank", rightTank.getGas().write(new NBTTagCompound())); } @@ -419,7 +375,6 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement if (resource != null && Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(resource.getFluid())) { return fluidTank.fill(resource, doFill); } - return 0; } @@ -450,7 +405,6 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement } else if (side == MekanismUtils.getRight(facing)) { return rightTank.draw(amount, doTransfer); } - return null; } @@ -466,7 +420,6 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement } else if (side == MekanismUtils.getRight(facing)) { return rightTank.getGas() != null && rightTank.getGas().getGas() == type; } - return false; } @@ -481,8 +434,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement if (isCapabilityDisabled(capability, side)) { return false; } - return capability == Capabilities.GAS_HANDLER_CAPABILITY - || capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, side); + return capability == Capabilities.GAS_HANDLER_CAPABILITY || capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, side); } @Override @@ -494,7 +446,6 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement } else if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(new FluidHandlerWrapper(this, side)); } - return super.getCapability(capability, side); } @@ -521,11 +472,10 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement @Override public void recalculateUpgradables(Upgrade upgrade) { super.recalculateUpgradables(upgrade); - if (upgrade == Upgrade.ENERGY) { maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); energyPerTick = MachineType.ELECTROLYTIC_SEPARATOR.getUsage(); setEnergy(Math.min(getMaxEnergy(), getEnergy())); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityEliteFactory.java b/src/main/java/mekanism/common/tile/TileEntityEliteFactory.java index b45723230..ed9f46215 100644 --- a/src/main/java/mekanism/common/tile/TileEntityEliteFactory.java +++ b/src/main/java/mekanism/common/tile/TileEntityEliteFactory.java @@ -13,15 +13,11 @@ public class TileEntityEliteFactory extends TileEntityFactory { public TileEntityEliteFactory() { super(FactoryTier.ELITE, MachineType.ELITE_FACTORY); - - configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY, - TransmissionType.GAS); + configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY, TransmissionType.GAS); configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); - configComponent.addOutput(TransmissionType.ITEM, - new SideData("Input", EnumColor.DARK_RED, new int[]{5, 6, 7, 8, 9, 10, 11})); - configComponent.addOutput(TransmissionType.ITEM, - new SideData("Output", EnumColor.DARK_BLUE, new int[]{12, 13, 14, 15, 16, 17, 18})); + configComponent.addOutput(TransmissionType.ITEM, new SideData("Input", EnumColor.DARK_RED, new int[]{5, 6, 7, 8, 9, 10, 11})); + configComponent.addOutput(TransmissionType.ITEM, new SideData("Output", EnumColor.DARK_BLUE, new int[]{12, 13, 14, 15, 16, 17, 18})); configComponent.addOutput(TransmissionType.ITEM, new SideData("Energy", EnumColor.DARK_GREEN, new int[]{1})); configComponent.addOutput(TransmissionType.ITEM, new SideData("Extra", EnumColor.PURPLE, new int[]{4})); configComponent.setConfig(TransmissionType.ITEM, new byte[]{4, 0, 0, 3, 1, 2}); @@ -36,4 +32,4 @@ public class TileEntityEliteFactory extends TileEntityFactory { ejectorComponent = new TileComponentEjector(this); ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(2)); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityEnergizedSmelter.java b/src/main/java/mekanism/common/tile/TileEntityEnergizedSmelter.java index 9282e3985..4324a580b 100644 --- a/src/main/java/mekanism/common/tile/TileEntityEnergizedSmelter.java +++ b/src/main/java/mekanism/common/tile/TileEntityEnergizedSmelter.java @@ -9,16 +9,12 @@ import mekanism.common.tile.prefab.TileEntityElectricMachine; public class TileEntityEnergizedSmelter extends TileEntityElectricMachine { - private static Map cachedRecipes; - public TileEntityEnergizedSmelter() { - super("smelter", "EnergizedSmelter", - MachineType.ENERGIZED_SMELTER.getStorage(), - MachineType.ENERGIZED_SMELTER.getUsage(), 200); + super("smelter", "EnergizedSmelter", MachineType.ENERGIZED_SMELTER.getStorage(), MachineType.ENERGIZED_SMELTER.getUsage(), 200); } @Override public Map getRecipes() { return Recipe.ENERGIZED_SMELTER.get(); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java b/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java index 297ace768..263d4d8b0 100644 --- a/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java +++ b/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java @@ -10,8 +10,6 @@ import mekanism.api.TileNetworkList; import mekanism.api.transmitters.TransmissionType; import mekanism.common.Mekanism; import mekanism.common.SideData; -import mekanism.common.tier.BaseTier; -import mekanism.common.tier.EnergyCubeTier; import mekanism.common.base.IRedstoneControl; import mekanism.common.base.ISideConfiguration; import mekanism.common.base.ITierUpgradeable; @@ -19,6 +17,8 @@ import mekanism.common.capabilities.Capabilities; import mekanism.common.integration.computer.IComputerIntegration; import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.security.ISecurityTile; +import mekanism.common.tier.BaseTier; +import mekanism.common.tier.EnergyCubeTier; import mekanism.common.tile.component.TileComponentConfig; import mekanism.common.tile.component.TileComponentEjector; import mekanism.common.tile.component.TileComponentSecurity; @@ -36,8 +36,8 @@ import net.minecraft.util.math.MathHelper; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.FMLCommonHandler; -public class TileEntityEnergyCube extends TileEntityElectricBlock implements IComputerIntegration, IRedstoneControl, - ISideConfiguration, ISecurityTile, ITierUpgradeable, IConfigCardAccess { +public class TileEntityEnergyCube extends TileEntityElectricBlock implements IComputerIntegration, IRedstoneControl, ISideConfiguration, ISecurityTile, ITierUpgradeable, + IConfigCardAccess { private static final String[] methods = new String[]{"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded"}; /** @@ -62,7 +62,6 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo */ public TileEntityEnergyCube() { super("EnergyCube", 0); - configComponent = new TileComponentConfig(this, TransmissionType.ENERGY, TransmissionType.ITEM); configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); @@ -85,23 +84,17 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo @Override public void onUpdate() { super.onUpdate(); - if (!world.isRemote) { ChargeUtils.charge(0, this); ChargeUtils.discharge(1, this); - if (MekanismUtils.canFunction(this) && configComponent.isEjecting(TransmissionType.ENERGY)) { CableUtils.emit(this); } int newScale = getScaledEnergyLevel(20); - if (newScale != prevScale) { - Mekanism.packetHandler.sendToReceivers( - new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); } - prevScale = newScale; } } @@ -111,14 +104,9 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo if (upgradeTier.ordinal() != tier.ordinal() + 1) { return false; } - tier = EnergyCubeTier.values()[upgradeTier.ordinal()]; - - Mekanism.packetHandler - .sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); markDirty(); - return true; } @@ -133,7 +121,6 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo if (tier == EnergyCubeTier.CREATIVE) { return Integer.MAX_VALUE; } - return tier.getOutput(); } @@ -144,7 +131,6 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo } else if (slotID == 1) { return ChargeUtils.canBeDischarged(itemstack); } - return true; } @@ -181,7 +167,6 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo } else if (slotID == 0) { return ChargeUtils.canBeOutputted(itemstack, true); } - return false; } @@ -200,7 +185,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo case 2: return new Object[]{getMaxEnergy()}; case 3: - return new Object[]{(getMaxEnergy() - getEnergy())}; + return new Object[]{getMaxEnergy() - getEnergy()}; default: throw new NoSuchMethodException(); } @@ -209,13 +194,10 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { EnergyCubeTier prevTier = tier; - tier = EnergyCubeTier.values()[dataStream.readInt()]; controlType = RedstoneControl.values()[dataStream.readInt()]; - if (prevTier != tier) { MekanismUtils.updateBlock(world, getPos()); } @@ -225,17 +207,14 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(tier.ordinal()); data.add(controlType.ordinal()); - return data; } @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - tier = EnergyCubeTier.values()[nbtTags.getInteger("tier")]; controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; } @@ -244,10 +223,8 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setInteger("tier", tier.ordinal()); nbtTags.setInteger("controlType", controlType.ordinal()); - return nbtTags; } @@ -256,11 +233,8 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo if (tier == EnergyCubeTier.CREATIVE && energy != Double.MAX_VALUE) { return; } - super.setEnergy(energy); - int newRedstoneLevel = getRedstoneLevel(); - if (newRedstoneLevel != currentRedstoneLevel) { markDirty(); currentRedstoneLevel = newRedstoneLevel; @@ -318,7 +292,6 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo if (capability == Capabilities.CONFIG_CARD_CAPABILITY) { return Capabilities.CONFIG_CARD_CAPABILITY.cast(this); } - return super.getCapability(capability, side); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityEnrichmentChamber.java b/src/main/java/mekanism/common/tile/TileEntityEnrichmentChamber.java index d1c68881b..578fae2d4 100644 --- a/src/main/java/mekanism/common/tile/TileEntityEnrichmentChamber.java +++ b/src/main/java/mekanism/common/tile/TileEntityEnrichmentChamber.java @@ -10,13 +10,11 @@ import mekanism.common.tile.prefab.TileEntityElectricMachine; public class TileEntityEnrichmentChamber extends TileEntityElectricMachine { public TileEntityEnrichmentChamber() { - super("enrichment", "EnrichmentChamber", - MachineType.ENRICHMENT_CHAMBER.getStorage(), - MachineType.ENRICHMENT_CHAMBER.getUsage(), 200); + super("enrichment", "EnrichmentChamber", MachineType.ENRICHMENT_CHAMBER.getStorage(), MachineType.ENRICHMENT_CHAMBER.getUsage(), 200); } @Override public Map getRecipes() { return Recipe.ENRICHMENT_CHAMBER.get(); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityFactory.java b/src/main/java/mekanism/common/tile/TileEntityFactory.java index 00b0230d6..5bfdd3af4 100644 --- a/src/main/java/mekanism/common/tile/TileEntityFactory.java +++ b/src/main/java/mekanism/common/tile/TileEntityFactory.java @@ -68,11 +68,9 @@ import net.minecraft.util.text.translation.I18n; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.FMLCommonHandler; -public class TileEntityFactory extends TileEntityMachine implements IComputerIntegration, ISideConfiguration, - IGasHandler, ISpecialConfigData, ITierUpgradeable, ISustainedData { +public class TileEntityFactory extends TileEntityMachine implements IComputerIntegration, ISideConfiguration, IGasHandler, ISpecialConfigData, ITierUpgradeable, ISustainedData { - private static final String[] methods = new String[]{"getEnergy", "getProgress", "facing", "canOperate", - "getMaxEnergy", "getEnergyNeeded"}; + private static final String[] methods = new String[]{"getEnergy", "getProgress", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"}; private final MachineRecipe[] cachedRecipe; /** * This Factory's tier. @@ -132,14 +130,11 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt public TileEntityFactory() { this(FactoryTier.BASIC, MachineType.BASIC_FACTORY); - - configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY, - TransmissionType.GAS); + configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY, TransmissionType.GAS); configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); configComponent.addOutput(TransmissionType.ITEM, new SideData("Input", EnumColor.DARK_RED, new int[]{5, 6, 7})); - configComponent - .addOutput(TransmissionType.ITEM, new SideData("Output", EnumColor.DARK_BLUE, new int[]{8, 9, 10})); + configComponent.addOutput(TransmissionType.ITEM, new SideData("Output", EnumColor.DARK_BLUE, new int[]{8, 9, 10})); configComponent.addOutput(TransmissionType.ITEM, new SideData("Energy", EnumColor.DARK_GREEN, new int[]{1})); configComponent.addOutput(TransmissionType.ITEM, new SideData("Extra", EnumColor.PURPLE, new int[]{4})); @@ -158,16 +153,13 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt public TileEntityFactory(FactoryTier type, MachineType machine) { super("null", machine.blockName, 0, 0, 0); - tier = type; inventory = NonNullList.withSize(5 + type.processes * 2, ItemStack.EMPTY); progress = new int[type.processes]; isActive = false; cachedRecipe = new MachineRecipe[tier.processes]; - gasTank = new GasTank(TileEntityAdvancedElectricMachine.MAX_GAS * tier.processes); maxInfuse = BASE_MAX_INFUSE * tier.processes; - setRecipeType(recipeType); } @@ -205,8 +197,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt factory.upgradeComponent.readFrom(upgradeComponent); factory.ejectorComponent.readFrom(ejectorComponent); factory.configComponent.readFrom(configComponent); - factory.ejectorComponent - .setOutputData(TransmissionType.ITEM, factory.configComponent.getOutputs(TransmissionType.ITEM).get(2)); + factory.ejectorComponent.setOutputData(TransmissionType.ITEM, factory.configComponent.getOutputs(TransmissionType.ITEM).get(2)); factory.setRecipeType(recipeType); factory.upgradeComponent.setSupported(Upgrade.GAS, recipeType.fuelEnergyUpgrades()); factory.securityComponent.readFrom(securityComponent); @@ -218,10 +209,8 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt for (int i = 0; i < tier.processes; i++) { int output = getOutputSlot(i); - if (!inventory.get(output).isEmpty()) { int newOutput = 5 + factory.tier.processes + i; - factory.inventory.set(newOutput, inventory.get(output)); } } @@ -231,29 +220,22 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt } factory.upgraded = true; - factory.markDirty(); - Mekanism.packetHandler.sendToReceivers( - new TileEntityMessage(Coord4D.get(factory), factory.getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(factory))); - + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(factory), factory.getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(factory))); return true; } @Override public void onUpdate() { super.onUpdate(); - if (!world.isRemote) { if (ticker == 1) { world.notifyNeighborsOfStateChange(getPos(), getBlockType(), true); } - ChargeUtils.discharge(1, this); handleSecondaryFuel(); sortInventory(); - if (!inventory.get(2).isEmpty() && inventory.get(3).isEmpty()) { RecipeType toSet = null; @@ -263,13 +245,11 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt break; } } - if (toSet != null && recipeType != toSet) { if (recipeTicks < RECIPE_TICKS_REQUIRED) { recipeTicks++; } else { recipeTicks = 0; - ItemStack returnStack = getMachineStack(); upgradeComponent.write(ItemDataUtils.getDataMap(returnStack)); @@ -281,11 +261,8 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt setRecipeType(toSet); gasTank.setGas(null); - secondaryEnergyPerTick = getSecondaryEnergyPerTick(recipeType); - world.notifyNeighborsOfStateChange(getPos(), getBlockType(), true); - MekanismUtils.saveChunk(this); } } else { @@ -296,20 +273,17 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt } double prev = getEnergy(); - - secondaryEnergyThisTick = recipeType.fuelEnergyUpgrades() ? StatUtils.inversePoisson(secondaryEnergyPerTick) - : (int) Math.ceil(secondaryEnergyPerTick); + secondaryEnergyThisTick = recipeType.fuelEnergyUpgrades() ? StatUtils.inversePoisson(secondaryEnergyPerTick) : (int) Math.ceil(secondaryEnergyPerTick); for (int process = 0; process < tier.processes; process++) { if (MekanismUtils.canFunction(this) && canOperate(getInputSlot(process), getOutputSlot(process)) - && getEnergy() >= energyPerTick && gasTank.getStored() >= secondaryEnergyThisTick) { + && getEnergy() >= energyPerTick && gasTank.getStored() >= secondaryEnergyThisTick) { if ((progress[process] + 1) < ticksRequired) { progress[process]++; gasTank.draw(secondaryEnergyThisTick, true); electricityStored -= energyPerTick; } else if ((progress[process] + 1) >= ticksRequired) { operate(getInputSlot(process), getOutputSlot(process)); - progress[process] = 0; gasTank.draw(secondaryEnergyThisTick, true); electricityStored -= energyPerTick; @@ -317,8 +291,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt } if (!canOperate(getInputSlot(process), getOutputSlot(process))) { - if (!(recipeType.getFuelType() == MachineFuelType.ADVANCED && recipeType - .hasRecipe(inventory.get(getInputSlot(process))))) { + if (!(recipeType.getFuelType() == MachineFuelType.ADVANCED && recipeType.hasRecipe(inventory.get(getInputSlot(process))))) { progress[process] = 0; } } @@ -333,15 +306,11 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt } } - if (MekanismUtils.canFunction(this) && hasOperation && getEnergy() >= energyPerTick - && gasTank.getStored() >= secondaryEnergyThisTick) { + if (MekanismUtils.canFunction(this) && hasOperation && getEnergy() >= energyPerTick && gasTank.getStored() >= secondaryEnergyThisTick) { setActive(true); - } else { - if (prevEnergy >= getEnergy()) { - setActive(false); - } + } else if (prevEnergy >= getEnergy()) { + setActive(false); } - lastUsage = prev - getEnergy(); prevEnergy = getEnergy(); } @@ -353,8 +322,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt public void setRecipeType(RecipeType type) { recipeType = type; - BASE_MAX_ENERGY = maxEnergy = tier.processes * - Math.max(0.5D * recipeType.getEnergyStorage(), recipeType.getEnergyUsage()); + BASE_MAX_ENERGY = maxEnergy = tier.processes * Math.max(0.5D * recipeType.getEnergyStorage(), recipeType.getEnergyUsage()); BASE_ENERGY_PER_TICK = energyPerTick = recipeType.getEnergyUsage(); upgradeComponent.setSupported(Upgrade.GAS, recipeType.fuelEnergyUpgrades()); secondaryEnergyPerTick = getSecondaryEnergyPerTick(recipeType); @@ -364,15 +332,12 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt //Append the "extra" slot to the available slots data.availableSlots = Arrays.copyOf(data.availableSlots, data.availableSlots.length + 1); data.availableSlots[data.availableSlots.length - 1] = 4; - - ejectorComponent.trackers.put(TransmissionType.ITEM, - Arrays.copyOf(ejectorComponent.trackers.get(TransmissionType.ITEM), data.availableSlots.length)); + ejectorComponent.trackers.put(TransmissionType.ITEM, Arrays.copyOf(ejectorComponent.trackers.get(TransmissionType.ITEM), data.availableSlots.length)); } for (Upgrade upgrade : upgradeComponent.getSupportedTypes()) { recalculateUpgradables(upgrade); } - if (hasWorld() && world.isRemote) { setSoundEvent(type.getSound()); } @@ -396,7 +361,6 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt //If something went wrong finding the tier don't sort it return; } - for (int i = 0; i < inputSlots.length; i++) { int slotID = inputSlots[i]; ItemStack stack = inventory.get(slotID); @@ -406,14 +370,13 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt int checkSlotID = inputSlots[j]; ItemStack checkStack = inventory.get(checkSlotID); if (Math.abs(count - checkStack.getCount()) < 2 || - !InventoryUtils.areItemsStackable(stack, checkStack)) { + !InventoryUtils.areItemsStackable(stack, checkStack)) { continue; } //Output/Input will not match // Only check if the input spot is empty otherwise assume it works if (stack.isEmpty() && !inputProducesOutput(checkSlotID, checkStack, output, true) || - checkStack.isEmpty() && !inputProducesOutput(slotID, stack, - inventory.get(tier.processes + checkSlotID), true)) { + checkStack.isEmpty() && !inputProducesOutput(slotID, stack, inventory.get(tier.processes + checkSlotID), true)) { continue; } @@ -431,13 +394,13 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt } /** - * Checks if the cached recipe (or recipe for current factory if the cache is out of date) can produce a specific - * output. + * Checks if the cached recipe (or recipe for current factory if the cache is out of date) can produce a specific output. * - * @param slotID Slot ID to grab the cached recipe of. + * @param slotID Slot ID to grab the cached recipe of. * @param fallbackInput Used if the cached recipe is null or to validate the cached recipe is not out of date. - * @param output The output we want. - * @param updateCache True to make the cached recipe get updated if it is out of date. + * @param output The output we want. + * @param updateCache True to make the cached recipe get updated if it is out of date. + * * @return True if the recipe produces the given output. */ public boolean inputProducesOutput(int slotID, ItemStack fallbackInput, ItemStack output, boolean updateCache) { @@ -512,22 +475,17 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt if (recipeType.getFuelType() == MachineFuelType.ADVANCED && gasTank.getNeeded() > 0) { if (inventory.get(4).getItem() instanceof IGasItem) { GasStack gas = ((IGasItem) inventory.get(4).getItem()).getGas(inventory.get(4)); - if (gas != null && recipeType.isValidGas(gas.getGas())) { - GasStack removed = GasUtils - .removeGas(inventory.get(4), gasTank.getGasType(), gasTank.getNeeded()); + GasStack removed = GasUtils.removeGas(inventory.get(4), gasTank.getGasType(), gasTank.getNeeded()); gasTank.receive(removed, true); } - return; } GasStack stack = recipeType.getItemGas(inventory.get(4)); int gasNeeded = gasTank.getNeeded(); - if (stack != null && stack.amount <= gasNeeded) { gasTank.receive(stack, true); - inventory.get(4).shrink(1); } } else if (recipeType == RecipeType.INFUSING) { @@ -576,8 +534,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt } private boolean isInputSlot(int slotID) { - return slotID >= 5 && (tier == FactoryTier.BASIC ? slotID <= 7 - : tier == FactoryTier.ADVANCED ? slotID <= 9 : tier == FactoryTier.ELITE && slotID <= 11); + return slotID >= 5 && (tier == FactoryTier.BASIC ? slotID <= 7 : tier == FactoryTier.ADVANCED ? slotID <= 9 : tier == FactoryTier.ELITE && slotID <= 11); } @Override @@ -603,8 +560,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt } if (slotID == 0) { - return itemstack.getItem() == MekanismItems.SpeedUpgrade - || itemstack.getItem() == MekanismItems.EnergyUpgrade; + return itemstack.getItem() == MekanismItems.SpeedUpgrade || itemstack.getItem() == MekanismItems.EnergyUpgrade; } else if (slotID == 1) { return ChargeUtils.canBeDischarged(itemstack); } else if (slotID == 4) { @@ -613,11 +569,9 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt } else if (recipeType.getFuelType() == MachineFuelType.DOUBLE) { return recipeType.hasRecipeForExtra(itemstack); } else if (recipeType == RecipeType.INFUSING) { - return InfuseRegistry.getObject(itemstack) != null && (infuseStored.getType() == null - || infuseStored.getType() == InfuseRegistry.getObject(itemstack).type); + return InfuseRegistry.getObject(itemstack) != null && (infuseStored.getType() == null || infuseStored.getType() == InfuseRegistry.getObject(itemstack).type); } } - return false; } @@ -646,63 +600,46 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt if (recipeType.getFuelType() == MachineFuelType.ADVANCED) { if (cachedRecipe[process] instanceof AdvancedMachineRecipe && - ((AdvancedMachineRecipe) cachedRecipe[process]) - .inputMatches(inventory, inputSlot, gasTank, secondaryEnergyThisTick)) { - return ((AdvancedMachineRecipe) cachedRecipe[process]) - .canOperate(inventory, inputSlot, outputSlot, gasTank, secondaryEnergyThisTick); + ((AdvancedMachineRecipe) cachedRecipe[process]).inputMatches(inventory, inputSlot, gasTank, secondaryEnergyThisTick)) { + return ((AdvancedMachineRecipe) cachedRecipe[process]).canOperate(inventory, inputSlot, outputSlot, gasTank, secondaryEnergyThisTick); } - AdvancedMachineRecipe recipe = recipeType.getRecipe(inventory.get(inputSlot), gasTank.getGasType()); cachedRecipe[process] = recipe; - - return recipe != null && recipe - .canOperate(inventory, inputSlot, outputSlot, gasTank, secondaryEnergyThisTick); - + return recipe != null && recipe.canOperate(inventory, inputSlot, outputSlot, gasTank, secondaryEnergyThisTick); } else if (recipeType.getFuelType() == MachineFuelType.DOUBLE) { - if (cachedRecipe[process] instanceof DoubleMachineRecipe && - ((DoubleMachineRecipe) cachedRecipe[process]).inputMatches(inventory, inputSlot, 4)) { + if (cachedRecipe[process] instanceof DoubleMachineRecipe && ((DoubleMachineRecipe) cachedRecipe[process]).inputMatches(inventory, inputSlot, 4)) { return ((DoubleMachineRecipe) cachedRecipe[process]).canOperate(inventory, inputSlot, 4, outputSlot); } DoubleMachineRecipe recipe = recipeType.getRecipe(inventory.get(inputSlot), inventory.get(4)); cachedRecipe[process] = recipe; - return recipe != null && recipe.canOperate(inventory, inputSlot, 4, outputSlot); } else if (recipeType.getFuelType() == MachineFuelType.CHANCE) { - if (cachedRecipe[process] instanceof ChanceMachineRecipe && ((ChanceMachineRecipe) cachedRecipe[process]) - .inputMatches(inventory, inputSlot)) { + if (cachedRecipe[process] instanceof ChanceMachineRecipe && ((ChanceMachineRecipe) cachedRecipe[process]).inputMatches(inventory, inputSlot)) { return ((ChanceMachineRecipe) cachedRecipe[process]).canOperate(inventory, inputSlot, outputSlot, 4); } ChanceMachineRecipe recipe = recipeType.getChanceRecipe(inventory.get(inputSlot)); cachedRecipe[process] = recipe; - return recipe != null && recipe.canOperate(inventory, inputSlot, outputSlot, 4); } if (recipeType == RecipeType.INFUSING) { - if (cachedRecipe[process] instanceof MetallurgicInfuserRecipe && - ((MetallurgicInfuserRecipe) cachedRecipe[process]).inputMatches(inventory, inputSlot, infuseStored)) { - return ((MetallurgicInfuserRecipe) cachedRecipe[process]) - .canOperate(inventory, inputSlot, outputSlot, infuseStored); + if (cachedRecipe[process] instanceof MetallurgicInfuserRecipe && ((MetallurgicInfuserRecipe) cachedRecipe[process]).inputMatches(inventory, inputSlot, infuseStored)) { + return ((MetallurgicInfuserRecipe) cachedRecipe[process]).canOperate(inventory, inputSlot, outputSlot, infuseStored); } InfusionInput input = new InfusionInput(infuseStored, inventory.get(inputSlot)); MetallurgicInfuserRecipe recipe = RecipeHandler.getMetallurgicInfuserRecipe(input); cachedRecipe[process] = recipe; - if (recipe == null) { return false; } - return recipe.canOperate(inventory, inputSlot, outputSlot, infuseStored); } - if (cachedRecipe[process] instanceof BasicMachineRecipe && ((BasicMachineRecipe) cachedRecipe[process]) - .inputMatches(inventory, inputSlot)) { - return (((BasicMachineRecipe) cachedRecipe[process]).canOperate(inventory, inputSlot, outputSlot)); + if (cachedRecipe[process] instanceof BasicMachineRecipe && ((BasicMachineRecipe) cachedRecipe[process]).inputMatches(inventory, inputSlot)) { + return ((BasicMachineRecipe) cachedRecipe[process]).canOperate(inventory, inputSlot, outputSlot); } - BasicMachineRecipe recipe = recipeType.getRecipe(inventory.get(inputSlot)); cachedRecipe[process] = recipe; - return recipe != null && recipe.canOperate(inventory, inputSlot, outputSlot); } @@ -711,37 +648,26 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt if (!canOperate(inputSlot, outputSlot)) { return; } - int process = getOperation(inputSlot); - if (cachedRecipe[process] == null) {//should never happen, but cant be too sure. - Mekanism.logger - .debug("cachedRecipe was null, but we were asked to operate anyway?! {} @ {}", this, this.pos); + Mekanism.logger.debug("cachedRecipe was null, but we were asked to operate anyway?! {} @ {}", this, this.pos); return; } - if (recipeType.getFuelType() == MachineFuelType.ADVANCED - && cachedRecipe[process] instanceof AdvancedMachineRecipe) { + if (recipeType.getFuelType() == MachineFuelType.ADVANCED && cachedRecipe[process] instanceof AdvancedMachineRecipe) { AdvancedMachineRecipe recipe = (AdvancedMachineRecipe) cachedRecipe[process]; - recipe.operate(inventory, inputSlot, outputSlot, gasTank, secondaryEnergyThisTick); - } else if (recipeType.getFuelType() == MachineFuelType.DOUBLE - && cachedRecipe[process] instanceof DoubleMachineRecipe) { + } else if (recipeType.getFuelType() == MachineFuelType.DOUBLE && cachedRecipe[process] instanceof DoubleMachineRecipe) { DoubleMachineRecipe recipe = (DoubleMachineRecipe) cachedRecipe[process]; - recipe.operate(inventory, inputSlot, 4, outputSlot); - } else if (recipeType.getFuelType() == MachineFuelType.CHANCE - && cachedRecipe[process] instanceof ChanceMachineRecipe) { + } else if (recipeType.getFuelType() == MachineFuelType.CHANCE && cachedRecipe[process] instanceof ChanceMachineRecipe) { ChanceMachineRecipe recipe = (ChanceMachineRecipe) cachedRecipe[process]; - recipe.operate(inventory, inputSlot, outputSlot, 4); } else if (recipeType == RecipeType.INFUSING && cachedRecipe[process] instanceof MetallurgicInfuserRecipe) { MetallurgicInfuserRecipe recipe = (MetallurgicInfuserRecipe) cachedRecipe[process]; - recipe.output(inventory, inputSlot, outputSlot, infuseStored); } else { BasicMachineRecipe recipe = (BasicMachineRecipe) cachedRecipe[process]; - recipe.operate(inventory, inputSlot, outputSlot); } @@ -753,14 +679,12 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt public void handlePacketData(ByteBuf dataStream) { if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { int type = dataStream.readInt(); - if (type == 0) { sorting = !sorting; } else if (type == 1) { gasTank.setGas(null); infuseStored.setEmpty(); } - return; } @@ -784,7 +708,6 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt if (recipeType != oldRecipe) { setRecipeType(recipeType); - if (!upgraded) { MekanismUtils.updateBlock(world, getPos()); } @@ -793,7 +716,6 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt for (int i = 0; i < tier.processes; i++) { progress[i] = dataStream.readInt(); } - TileUtils.readTankData(dataStream, gasTank); if (upgraded) { markDirty(); @@ -806,7 +728,6 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - setRecipeType(RecipeType.values()[nbtTags.getInteger("recipeType")]); upgradeComponent.setSupported(Upgrade.GAS, recipeType.fuelEnergyUpgrades()); recipeTicks = nbtTags.getInteger("recipeTicks"); @@ -816,11 +737,9 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt infuseStored.setAmount(amount); infuseStored.setType(InfuseRegistry.get(nbtTags.getString("type"))); } - for (int i = 0; i < tier.processes; i++) { progress[i] = nbtTags.getInteger("progress" + i); } - gasTank.read(nbtTags.getCompoundTag("gasTank")); } @@ -828,7 +747,6 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setInteger("recipeType", recipeType.ordinal()); nbtTags.setInteger("recipeTicks", recipeTicks); nbtTags.setBoolean("sorting", sorting); @@ -838,13 +756,10 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt } else { nbtTags.setString("type", "null"); } - for (int i = 0; i < tier.processes; i++) { nbtTags.setInteger("progress" + i, progress[i]); } - nbtTags.setTag("gasTank", gasTank.write(new NBTTagCompound())); - return nbtTags; } @@ -865,9 +780,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt data.add(progress); TileUtils.addTankData(data, gasTank); - upgraded = false; - return data; } @@ -888,10 +801,8 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt @Override public String getName() { if (I18n.canTranslate("tile." + tier.getBaseTier().getName() + recipeType.getTranslationKey() + "Factory")) { - return LangUtils - .localize("tile." + tier.getBaseTier().getName() + recipeType.getTranslationKey() + "Factory"); + return LangUtils.localize("tile." + tier.getBaseTier().getName() + recipeType.getTranslationKey() + "Factory"); } - return tier.getBaseTier().getLocalizedName() + " " + recipeType.getLocalizedName() + " " + super.getName(); } @@ -909,15 +820,12 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt if (arguments[0] == null) { 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}; @@ -925,15 +833,12 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt if (arguments[0] == null) { 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: @@ -976,7 +881,6 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt if (canReceiveGas(side, stack.getGas())) { return gasTank.receive(stack, doTransfer); } - return 0; } @@ -985,7 +889,6 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt if (configComponent.getOutput(TransmissionType.GAS, side, facing).hasSlot(0)) { return recipeType.canReceiveGas(side, type); } - return false; } @@ -1010,10 +913,8 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt if (isCapabilityDisabled(capability, side)) { return false; } - return capability == Capabilities.GAS_HANDLER_CAPABILITY - || capability == Capabilities.CONFIG_CARD_CAPABILITY - || capability == Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY - || super.hasCapability(capability, side); + return capability == Capabilities.GAS_HANDLER_CAPABILITY || capability == Capabilities.CONFIG_CARD_CAPABILITY + || capability == Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY || super.hasCapability(capability, side); } @Override @@ -1022,10 +923,9 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt return null; } if (capability == Capabilities.GAS_HANDLER_CAPABILITY || capability == Capabilities.CONFIG_CARD_CAPABILITY - || capability == Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY) { + || capability == Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY) { return (T) this; } - return super.getCapability(capability, side); } @@ -1043,11 +943,9 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt @Override public void recalculateUpgradables(Upgrade upgrade) { super.recalculateUpgradables(upgrade); - switch (upgrade) { case ENERGY: - energyPerTick = MekanismUtils - .getEnergyPerTick(this, BASE_ENERGY_PER_TICK); // incorporate speed upgrades + energyPerTick = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK); // incorporate speed upgrades break; case GAS: secondaryEnergyPerTick = getSecondaryEnergyPerTick(recipeType); @@ -1065,7 +963,6 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt @Override public NBTTagCompound getConfigurationData(NBTTagCompound nbtTags) { nbtTags.setBoolean("sorting", sorting); - return nbtTags; } @@ -1090,4 +987,4 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt infuseStored.readSustainedData(itemStack); GasUtils.readSustainedData(gasTank, itemStack); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityFluidTank.java b/src/main/java/mekanism/common/tile/TileEntityFluidTank.java index 1fb21380a..74ea65b15 100644 --- a/src/main/java/mekanism/common/tile/TileEntityFluidTank.java +++ b/src/main/java/mekanism/common/tile/TileEntityFluidTank.java @@ -51,9 +51,8 @@ import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.items.CapabilityItemHandler; -public class TileEntityFluidTank extends TileEntityContainerBlock implements IActiveState, IConfigurable, - IFluidHandlerWrapper, ISustainedTank, IFluidContainerManager, ITankManager, ISecurityTile, ITierUpgradeable, - ITieredTile { +public class TileEntityFluidTank extends TileEntityContainerBlock implements IActiveState, IConfigurable, IFluidHandlerWrapper, ISustainedTank, IFluidContainerManager, + ITankManager, ISecurityTile, ITierUpgradeable, ITieredTile { public boolean isActive; @@ -82,7 +81,6 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc public TileEntityFluidTank() { super("FluidTank"); - fluidTank = new FluidTank(tier.getStorage()); inventory = NonNullList.withSize(2, ItemStack.EMPTY); } @@ -92,15 +90,10 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc if (upgradeTier.ordinal() != tier.ordinal() + 1) { return false; } - tier = FluidTankTier.values()[upgradeTier.ordinal()]; fluidTank.setCapacity(tier.getStorage()); - - Mekanism.packetHandler - .sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); markDirty(); - return true; } @@ -114,23 +107,19 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc if (world.isRemote) { if (updateDelay > 0) { updateDelay--; - if (updateDelay == 0 && clientActive != isActive) { isActive = clientActive; MekanismUtils.updateBlock(world, getPos()); } } - float targetScale = - (float) (fluidTank.getFluid() != null ? fluidTank.getFluid().amount : 0) / fluidTank.getCapacity(); - + float targetScale = (float) (fluidTank.getFluid() != null ? fluidTank.getFluid().amount : 0) / fluidTank.getCapacity(); if (Math.abs(prevScale - targetScale) > 0.01) { prevScale = (9 * prevScale + targetScale) / 10; } } else { if (updateDelay > 0) { updateDelay--; - if (updateDelay == 0 && clientActive != isActive) { needsPacket = true; } @@ -138,7 +127,6 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc if (valve > 0) { valve--; - if (valve == 0) { valveFluid = null; needsPacket = true; @@ -151,28 +139,22 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc } prevAmount = fluidTank.getFluidAmount(); - if (!inventory.get(0).isEmpty()) { manageInventory(); } - if (isActive) { activeEmit(); } int newRedstoneLevel = getRedstoneLevel(); - if (newRedstoneLevel != currentRedstoneLevel) { markDirty(); currentRedstoneLevel = newRedstoneLevel; } - if (needsPacket) { - Mekanism.packetHandler.sendToAllAround( - new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), + Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), Coord4D.get(this).getTargetPoint(50)); } - needsPacket = false; } } @@ -186,13 +168,9 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc private void activeEmit() { if (fluidTank.getFluid() != null) { TileEntity tileEntity = Coord4D.get(this).offset(EnumFacing.DOWN).getTileEntity(world); - - if (CapabilityUtils - .hasCapability(tileEntity, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.UP)) { - IFluidHandler handler = CapabilityUtils - .getCapability(tileEntity, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.UP); - FluidStack toDrain = new FluidStack(fluidTank.getFluid(), - Math.min(tier.getOutput(), fluidTank.getFluidAmount())); + if (CapabilityUtils.hasCapability(tileEntity, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.UP)) { + IFluidHandler handler = CapabilityUtils.getCapability(tileEntity, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.UP); + FluidStack toDrain = new FluidStack(fluidTank.getFluid(), Math.min(tier.getOutput(), fluidTank.getFluidAmount())); fluidTank.drain(handler.fill(toDrain, true), tier != FluidTankTier.CREATIVE); } } @@ -200,12 +178,10 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc private void manageInventory() { if (FluidContainerUtils.isFluidContainer(inventory.get(0))) { - FluidStack ret = FluidContainerUtils - .handleContainerItem(this, inventory, editMode, fluidTank.getFluid(), getCurrentNeeded(), 0, 1, null); + FluidStack ret = FluidContainerUtils.handleContainerItem(this, inventory, editMode, fluidTank.getFluid(), getCurrentNeeded(), 0, 1, null); if (ret != null) { fluidTank.setFluid(PipeUtils.copy(ret, Math.min(fluidTank.getCapacity(), ret.amount))); - if (tier == FluidTankTier.CREATIVE) { FluidStack fluid = fluidTank.getFluid(); if (fluid != null) { @@ -213,15 +189,12 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc } } else { int rejects = Math.max(0, ret.amount - fluidTank.getCapacity()); - if (rejects > 0) { pushUp(PipeUtils.copy(ret, rejects), true); } } - } else { - if (tier != FluidTankTier.CREATIVE) { - fluidTank.setFluid(null); - } + } else if (tier != FluidTankTier.CREATIVE) { + fluidTank.setFluid(null); } } } @@ -230,14 +203,11 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc Coord4D up = Coord4D.get(this).offset(EnumFacing.UP); TileEntity tileEntity = up.getTileEntity(world); if (tileEntity instanceof TileEntityFluidTank) { - IFluidHandler handler = CapabilityUtils - .getCapability(tileEntity, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.DOWN); - + IFluidHandler handler = CapabilityUtils.getCapability(tileEntity, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.DOWN); if (PipeUtils.canFill(handler, fluid)) { return handler.fill(fluid, doFill); } } - return 0; } @@ -251,7 +221,6 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc if (slotID == 0) { return FluidContainerUtils.isFluidContainer(itemstack); } - return false; } @@ -263,7 +232,6 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc } else if (side == EnumFacing.UP) { return new int[]{0}; } - return InventoryUtils.EMPTY; } @@ -271,28 +239,23 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setInteger("tier", tier.ordinal()); nbtTags.setBoolean("isActive", isActive); nbtTags.setInteger("editMode", editMode.ordinal()); - if (fluidTank.getFluid() != null) { nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound())); } - return nbtTags; } @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - tier = FluidTankTier.values()[nbtTags.getInteger("tier")]; clientActive = isActive = nbtTags.getBoolean("isActive"); editMode = ContainerEditMode.values()[nbtTags.getInteger("editMode")]; //Needs to be outside the hasKey check because this is just based on the tier which is known information fluidTank.setCapacity(tier.getStorage()); - if (nbtTags.hasKey("fluidTank")) { fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank")); } @@ -301,17 +264,14 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { FluidTankTier prevTier = tier; - tier = FluidTankTier.values()[dataStream.readInt()]; fluidTank.setCapacity(tier.getStorage()); clientActive = dataStream.readBoolean(); valve = dataStream.readInt(); editMode = ContainerEditMode.values()[dataStream.readInt()]; - if (valve > 0) { valveFluid = TileUtils.readFluidStack(dataStream); } else { @@ -319,7 +279,6 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc } TileUtils.readTankData(dataStream, fluidTank); - if (prevTier != tier || (updateDelay == 0 && clientActive != isActive)) { updateDelay = MekanismConfig.current().general.UPDATE_DELAY.val(); isActive = clientActive; @@ -335,44 +294,34 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc public int getCurrentNeeded() { int needed = fluidTank.getCapacity() - fluidTank.getFluidAmount(); - if (tier == FluidTankTier.CREATIVE) { return Integer.MAX_VALUE; } - Coord4D top = Coord4D.get(this).offset(EnumFacing.UP); TileEntity topTile = top.getTileEntity(world); - if (topTile instanceof TileEntityFluidTank) { TileEntityFluidTank topTank = (TileEntityFluidTank) topTile; - if (fluidTank.getFluid() != null && topTank.fluidTank.getFluid() != null) { if (fluidTank.getFluid().getFluid() != topTank.fluidTank.getFluid().getFluid()) { return needed; } } - needed += topTank.getCurrentNeeded(); } - return needed; } @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(tier.ordinal()); data.add(isActive); data.add(valve); data.add(editMode.ordinal()); - if (valve > 0) { TileUtils.addFluidStack(data, valveFluid); } - TileUtils.addTankData(data, fluidTank); - return data; } @@ -384,12 +333,8 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc @Override public void setActive(boolean active) { isActive = active; - if (clientActive != active && updateDelay == 0) { - Mekanism.packetHandler - .sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); - + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); updateDelay = 10; clientActive = active; } @@ -409,10 +354,8 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc public EnumActionResult onSneakRightClick(EntityPlayer player, EnumFacing side) { if (!world.isRemote) { setActive(!getActive()); - world.playSound(null, getPos().getX(), getPos().getY(), getPos().getZ(), SoundEvents.UI_BUTTON_CLICK, - SoundCategory.BLOCKS, 0.3F, 1); + world.playSound(null, getPos().getX(), getPos().getY(), getPos().getZ(), SoundEvents.UI_BUTTON_CLICK, SoundCategory.BLOCKS, 0.3F, 1); } - return EnumActionResult.SUCCESS; } @@ -426,9 +369,7 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc if (isCapabilityDisabled(capability, side)) { return false; } - return capability == Capabilities.CONFIGURABLE_CAPABILITY - || capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY - || super.hasCapability(capability, side); + return capability == Capabilities.CONFIGURABLE_CAPABILITY || capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, side); } @Override @@ -440,7 +381,6 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc } else if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(new FluidHandlerWrapper(this, side)); } - return super.getCapability(capability, side); } @@ -457,23 +397,18 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc if (tier == FluidTankTier.CREATIVE) { return resource != null ? resource.amount : 0; } - if (resource != null && canFill(from, resource)) { int filled = fluidTank.fill(resource, doFill); - if (filled < resource.amount && !isActive) { filled += pushUp(PipeUtils.copy(resource, resource.amount - filled), doFill); } - if (filled > 0 && from == EnumFacing.UP) { if (valve == 0) { needsPacket = true; } - valve = 20; valveFluid = new FluidStack(resource, 1); } - return filled; } @@ -485,7 +420,6 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc if (resource != null && canDrain(from, resource)) { return fluidTank.drain(resource.amount, tier != FluidTankTier.CREATIVE && doDrain); } - return null; } @@ -494,7 +428,6 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc if (canDrain(from, null)) { return fluidTank.drain(maxDrain, tier != FluidTankTier.CREATIVE && doDrain); } - return null; } @@ -506,17 +439,14 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc return false; } } - if (tier == FluidTankTier.CREATIVE) { return true; } - if (isActive && tile instanceof TileEntityFluidTank) // Only fill if tanks underneath have same fluid. - { + if (isActive && tile instanceof TileEntityFluidTank) { // Only fill if tanks underneath have same fluid. return (fluidTank.getFluid() == null && ((TileEntityFluidTank) tile).canFill(EnumFacing.UP, fluid)) || - (fluidTank.getFluid() != null && fluidTank.getFluid().isFluidEqual(fluid)); + (fluidTank.getFluid() != null && fluidTank.getFluid().isFluidEqual(fluid)); } - return fluidTank.getFluid() == null || fluidTank.getFluid().isFluidEqual(fluid); } @@ -525,10 +455,8 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc if (fluidTank != null) { if (fluid == null || fluidTank.getFluid() != null && fluidTank.getFluid().isFluidEqual(fluid)) { return !(isActive && from == EnumFacing.DOWN); - } } - return false; } @@ -581,4 +509,4 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc public BaseTier getTier() { return tier.getBaseTier(); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityFluidicPlenisher.java b/src/main/java/mekanism/common/tile/TileEntityFluidicPlenisher.java index 29f5d08f2..03587859a 100644 --- a/src/main/java/mekanism/common/tile/TileEntityFluidicPlenisher.java +++ b/src/main/java/mekanism/common/tile/TileEntityFluidicPlenisher.java @@ -51,8 +51,8 @@ import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fml.common.FMLCommonHandler; -public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implements IComputerIntegration, IConfigurable, - IFluidHandlerWrapper, ISustainedTank, IUpgradeTile, IRedstoneControl, ISecurityTile { +public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implements IComputerIntegration, IConfigurable, IFluidHandlerWrapper, ISustainedTank, + IUpgradeTile, IRedstoneControl, ISecurityTile { private static final String[] methods = new String[]{"reset"}; private static EnumSet dirs = EnumSet.complementOf(EnumSet.of(EnumFacing.UP)); @@ -87,7 +87,6 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen public void onUpdate() { if (!world.isRemote) { ChargeUtils.discharge(2, this); - if (FluidContainerUtils.isFluidContainer(inventory.get(0))) { FluidContainerUtils.handleContainerItemEmpty(this, fluidTank, 0, 1, new FluidChecker() { @Override @@ -97,12 +96,10 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen }); } - if (MekanismUtils.canFunction(this) && getEnergy() >= energyPerTick && fluidTank.getFluid() != null - && fluidTank.getFluid().getFluid().canBePlacedInWorld()) { + if (MekanismUtils.canFunction(this) && getEnergy() >= energyPerTick && fluidTank.getFluid() != null && fluidTank.getFluid().getFluid().canBePlacedInWorld()) { if (!finishedCalc) { setEnergy(getEnergy() - energyPerTick); } - if ((operatingTicks + 1) < ticksRequired) { operatingTicks++; } else { @@ -113,16 +110,12 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen if (canReplace(below, false, false) && fluidTank.getFluidAmount() >= Fluid.BUCKET_VOLUME) { if (fluidTank.getFluid().getFluid().canBePlacedInWorld()) { - world.setBlockState(below.getPos(), - MekanismUtils.getFlowingBlock(fluidTank.getFluid().getFluid()).getDefaultState(), - 3); - + world.setBlockState(below.getPos(), MekanismUtils.getFlowingBlock(fluidTank.getFluid().getFluid()).getDefaultState(), 3); setEnergy(getEnergy() - energyPerTick); fluidTank.drain(Fluid.BUCKET_VOLUME, true); } } } - operatingTicks = 0; } } @@ -134,16 +127,13 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen finishedCalc = true; return; } - if (activeNodes.isEmpty()) { if (usedNodes.isEmpty()) { Coord4D below = Coord4D.get(this).offset(EnumFacing.DOWN); - if (!canReplace(below, true, true)) { finishedCalc = true; return; } - activeNodes.add(below); } else { finishedCalc = true; @@ -152,32 +142,26 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen } Set toRemove = new HashSet<>(); - for (Coord4D coord : activeNodes) { if (coord.exists(world)) { FluidStack fluid = fluidTank.getFluid(); if (canReplace(coord, true, false) && fluid != null) { - world.setBlockState(coord.getPos(), - MekanismUtils.getFlowingBlock(fluid.getFluid()).getDefaultState(), 3); - + world.setBlockState(coord.getPos(), MekanismUtils.getFlowingBlock(fluid.getFluid()).getDefaultState(), 3); fluidTank.drain(Fluid.BUCKET_VOLUME, true); } for (EnumFacing dir : dirs) { Coord4D sideCoord = coord.offset(dir); - if (sideCoord.exists(world) && canReplace(sideCoord, true, true)) { activeNodes.add(sideCoord); } } - toRemove.add(coord); break; } else { toRemove.add(coord); } } - usedNodes.addAll(toRemove); activeNodes.removeAll(toRemove); } @@ -186,26 +170,21 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen if (checkNodes && usedNodes.contains(coord)) { return false; } - if (coord.isAirBlock(world) || MekanismUtils.isDeadFluid(world, coord)) { return true; } - if (MekanismUtils.isFluid(world, coord)) { return isPathfinding; } - return coord.getBlock(world).isReplaceable(world, coord.getPos()); } @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { finishedCalc = dataStream.readBoolean(); controlType = RedstoneControl.values()[dataStream.readInt()]; - TileUtils.readTankData(dataStream, fluidTank); } } @@ -213,12 +192,9 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(finishedCalc); data.add(controlType.ordinal()); - TileUtils.addTankData(data, fluidTank); - return data; } @@ -226,7 +202,6 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setInteger("operatingTicks", operatingTicks); nbtTags.setBoolean("finishedCalc", finishedCalc); nbtTags.setInteger("controlType", controlType.ordinal()); @@ -236,34 +211,28 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen } NBTTagList activeList = new NBTTagList(); - for (Coord4D wrapper : activeNodes) { NBTTagCompound tagCompound = new NBTTagCompound(); wrapper.write(tagCompound); activeList.appendTag(tagCompound); } - if (activeList.tagCount() != 0) { nbtTags.setTag("activeNodes", activeList); } NBTTagList usedList = new NBTTagList(); - for (Coord4D obj : usedNodes) { activeList.appendTag(obj.write(new NBTTagCompound())); } - if (activeList.tagCount() != 0) { nbtTags.setTag("usedNodes", usedList); } - return nbtTags; } @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - operatingTicks = nbtTags.getInteger("operatingTicks"); finishedCalc = nbtTags.getBoolean("finishedCalc"); controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; @@ -279,7 +248,6 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen activeNodes.add(Coord4D.read(tagList.getCompoundTagAt(i))); } } - if (nbtTags.hasKey("usedNodes")) { NBTTagList tagList = nbtTags.getTagList("usedNodes", NBT.TAG_COMPOUND); @@ -299,7 +267,6 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen } else if (slotID == 2) { return ChargeUtils.canBeDischarged(itemstack); } - return false; } @@ -307,10 +274,8 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen public boolean canExtractItem(int slotID, @Nonnull ItemStack itemstack, @Nonnull EnumFacing side) { if (slotID == 2) { return ChargeUtils.canBeOutputted(itemstack, false); - } else { - return slotID == 1; } - + return slotID == 1; } @Override @@ -330,9 +295,8 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen return new int[]{0}; } else if (side == EnumFacing.DOWN) { return new int[]{1}; - } else { - return new int[]{2}; } + return new int[]{2}; } @Override @@ -340,7 +304,6 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen if (direction == EnumFacing.UP) { return new FluidTankInfo[]{fluidTank.getInfo()}; } - return PipeUtils.EMPTY; } @@ -366,11 +329,9 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen @Override public FluidStack drain(EnumFacing from, @Nullable FluidStack resource, boolean doDrain) { - if (resource != null && fluidTank.getFluid() != null && fluidTank.getFluid().getFluid() == resource.getFluid() - && from == EnumFacing.UP) { + if (resource != null && fluidTank.getFluid() != null && fluidTank.getFluid().getFluid() == resource.getFluid() && from == EnumFacing.UP) { return drain(from, resource.amount, doDrain); } - return null; } @@ -379,7 +340,6 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen if (from == EnumFacing.UP && resource != null && resource.getFluid().canBePlacedInWorld()) { return fluidTank.fill(resource, true); } - return 0; } @@ -403,10 +363,8 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen activeNodes.clear(); usedNodes.clear(); finishedCalc = false; - - player.sendMessage( - new TextComponentString(EnumColor.DARK_BLUE + Mekanism.LOG_TAG + " " + EnumColor.GREY + LangUtils - .localize("tooltip.configurator.plenisherReset"))); + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + Mekanism.LOG_TAG + " " + EnumColor.GREY + + LangUtils.localize("tooltip.configurator.plenisherReset"))); return EnumActionResult.SUCCESS; } @@ -418,9 +376,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen @Override public boolean hasCapability(@Nonnull Capability capability, EnumFacing side) { - return capability == Capabilities.CONFIGURABLE_CAPABILITY - || capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY - || super.hasCapability(capability, side); + return capability == Capabilities.CONFIGURABLE_CAPABILITY || capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, side); } @Override @@ -428,11 +384,9 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen if (capability == Capabilities.CONFIGURABLE_CAPABILITY) { return Capabilities.CONFIGURABLE_CAPABILITY.cast(this); } - if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(new FluidHandlerWrapper(this, side)); } - return super.getCapability(capability, side); } @@ -447,7 +401,6 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen activeNodes.clear(); usedNodes.clear(); finishedCalc = false; - return new Object[]{"Plenisher calculation reset."}; } throw new NoSuchMethodException(); @@ -461,7 +414,6 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen @Override public void recalculateUpgradables(Upgrade upgrade) { super.recalculateUpgradables(upgrade); - switch (upgrade) { case SPEED: ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED); @@ -493,4 +445,4 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen public TileComponentSecurity getSecurity() { return securityComponent; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityFormulaicAssemblicator.java b/src/main/java/mekanism/common/tile/TileEntityFormulaicAssemblicator.java index 2119f815a..0c9b2f2bf 100644 --- a/src/main/java/mekanism/common/tile/TileEntityFormulaicAssemblicator.java +++ b/src/main/java/mekanism/common/tile/TileEntityFormulaicAssemblicator.java @@ -35,8 +35,7 @@ import net.minecraft.util.NonNullList; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.FMLCommonHandler; -public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock implements ISideConfiguration, - IUpgradeTile, IRedstoneControl, IConfigCardAccess, ISecurityTile { +public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock implements ISideConfiguration, IUpgradeTile, IRedstoneControl, IConfigCardAccess, ISecurityTile { public InventoryCrafting dummyInv = MekanismUtils.getDummyCraftingInv(); @@ -74,14 +73,12 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im public TileEntityFormulaicAssemblicator() { super("FormulaicAssemblicator", MachineType.FORMULAIC_ASSEMBLICATOR.getStorage()); - configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY); configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Input", EnumColor.DARK_RED, - new int[]{3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20})); - configComponent.addOutput(TransmissionType.ITEM, - new SideData("Output", EnumColor.DARK_BLUE, new int[]{21, 22, 23, 24, 25, 26})); + configComponent.addOutput(TransmissionType.ITEM, new SideData("Input", EnumColor.DARK_RED, new int[]{3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20})); + configComponent.addOutput(TransmissionType.ITEM, new SideData("Output", EnumColor.DARK_BLUE, new int[]{21, 22, 23, 24, 25, 26})); configComponent.addOutput(TransmissionType.ITEM, new SideData("Energy", EnumColor.DARK_GREEN, new int[]{1})); configComponent.setConfig(TransmissionType.ITEM, new byte[]{0, 0, 0, 3, 1, 2}); @@ -100,69 +97,53 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im @Override public void onUpdate() { super.onUpdate(); - if (!world.isRemote) { if (formula != null && stockControl && needsOrganize) { needsOrganize = false; organizeStock(); } - ChargeUtils.discharge(1, this); - if (controlType != RedstoneControl.PULSE) { pulseOperations = 0; } else if (MekanismUtils.canFunction(this)) { pulseOperations++; } - RecipeFormula prev = formula; - if (!inventory.get(2).isEmpty() && inventory.get(2).getItem() instanceof ItemCraftingFormula) { ItemCraftingFormula item = (ItemCraftingFormula) inventory.get(2).getItem(); - if (formula == null || lastFormulaStack != inventory.get(2)) { loadFormula(); } } else { formula = null; } - if (prev != formula) { needsFormulaUpdate = true; } lastFormulaStack = inventory.get(2); - if (autoMode && formula == null) { toggleAutoMode(); } - if (autoMode && formula != null && ((controlType == RedstoneControl.PULSE && pulseOperations > 0) - || MekanismUtils.canFunction(this))) { + if (autoMode && formula != null && ((controlType == RedstoneControl.PULSE && pulseOperations > 0) || MekanismUtils.canFunction(this))) { boolean canOperate = true; - if (!isRecipe) { canOperate = moveItemsToGrid(); } - if (canOperate) { isRecipe = true; - if (operatingTicks >= ticksRequired) { if (doSingleCraft()) { operatingTicks = 0; - if (pulseOperations > 0) { pulseOperations--; } - ejectorComponent.outputItems(); } - } else { - if (getEnergy() >= energyPerTick) { - operatingTicks++; - setEnergy(getEnergy() - energyPerTick); - } + } else if (getEnergy() >= energyPerTick) { + operatingTicks++; + setEnergy(getEnergy() - energyPerTick); } } else { operatingTicks = 0; @@ -175,10 +156,8 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im public void loadFormula() { ItemCraftingFormula item = (ItemCraftingFormula) inventory.get(2).getItem(); - if (item.getInventory(inventory.get(2)) != null && !item.isInvalid(inventory.get(2))) { RecipeFormula itemFormula = new RecipeFormula(world, item.getInventory(inventory.get(2))); - if (itemFormula.isValidFormula(world)) { if (formula != null && !formula.isFormulaEqual(world, itemFormula)) { formula = itemFormula; @@ -204,14 +183,12 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im for (int i = 0; i < 9; i++) { dummyInv.setInventorySlotContents(i, inventory.get(27 + i)); } - lastOutputStack = MekanismUtils.findMatchingRecipe(dummyInv, world); isRecipe = !lastOutputStack.isEmpty(); } else { isRecipe = formula.matches(world, inventory, 27); lastOutputStack = isRecipe ? formula.recipe.getRecipeOutput() : ItemStack.EMPTY; } - needsOrganize = true; } } @@ -229,96 +206,74 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im for (int i = 27; i <= 35; i++) { if (!inventory.get(i).isEmpty()) { ItemStack stack = inventory.get(i).copy(); - inventory.get(i).shrink(1); - if (inventory.get(i).getCount() == 0 && stack.getItem().hasContainerItem(stack)) { ItemStack container = stack.getItem().getContainerItem(stack); - - if (!container.isEmpty() && container.isItemStackDamageable() - && container.getItemDamage() > container.getMaxDamage()) { + if (!container.isEmpty() && container.isItemStackDamageable() && container.getItemDamage() > container.getMaxDamage()) { container = ItemStack.EMPTY; } - if (!container.isEmpty()) { boolean move = tryMoveToOutput(container.copy(), false); - if (move) { tryMoveToOutput(container.copy(), true); } - inventory.set(i, move ? ItemStack.EMPTY : container.copy()); } } } } - if (formula != null) { moveItemsToGrid(); } - markDirty(); - return true; } - return false; } private boolean craftSingle() { if (formula != null) { boolean canOperate = true; - if (!formula.matches(world, inventory, 27)) { canOperate = moveItemsToGrid(); } - if (canOperate) { return doSingleCraft(); } } else { return doSingleCraft(); } - return false; } private boolean moveItemsToGrid() { boolean ret = true; - for (int i = 27; i <= 35; i++) { if (formula.isIngredientInPos(world, inventory.get(i), i - 27)) { continue; } - if (!inventory.get(i).isEmpty()) { inventory.set(i, tryMoveToInput(inventory.get(i))); markDirty(); - if (!inventory.get(i).isEmpty()) { ret = false; } } else { boolean found = false; - for (int j = 20; j >= 3; j--) { if (!inventory.get(j).isEmpty() && formula.isIngredientInPos(world, inventory.get(j), i - 27)) { inventory.set(i, StackUtils.size(inventory.get(j), 1)); inventory.get(j).shrink(1); - markDirty(); found = true; - break; } } - if (!found) { ret = false; } } } - return ret; } @@ -329,12 +284,10 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im private void moveItemsToInput(boolean forcePush) { for (int i = 27; i <= 35; i++) { - if (!inventory.get(i).isEmpty() && (forcePush || (formula != null && !formula - .isIngredientInPos(world, inventory.get(i), i - 27)))) { + if (!inventory.get(i).isEmpty() && (forcePush || (formula != null && !formula.isIngredientInPos(world, inventory.get(i), i - 27)))) { inventory.set(i, tryMoveToInput(inventory.get(i))); } } - markDirty(); } @@ -346,14 +299,12 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im moveItemsToInput(false); autoMode = true; } - markDirty(); } private void toggleStockControl() { if (!world.isRemote && formula != null) { stockControl = !stockControl; - if (stockControl) { organizeStock(); } @@ -385,66 +336,49 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im private ItemStack tryMoveToInput(ItemStack stack) { stack = stack.copy(); - for (int i = 3; i <= 20; i++) { if (inventory.get(i).isEmpty()) { inventory.set(i, stack); - return ItemStack.EMPTY; - } else if (InventoryUtils.areItemsStackable(stack, inventory.get(i)) - && inventory.get(i).getCount() < inventory.get(i).getMaxStackSize()) { - int toUse = Math - .min(stack.getCount(), inventory.get(i).getMaxStackSize() - inventory.get(i).getCount()); - + } else if (InventoryUtils.areItemsStackable(stack, inventory.get(i)) && inventory.get(i).getCount() < inventory.get(i).getMaxStackSize()) { + int toUse = Math.min(stack.getCount(), inventory.get(i).getMaxStackSize() - inventory.get(i).getCount()); inventory.get(i).grow(toUse); stack.shrink(toUse); - if (stack.getCount() == 0) { return ItemStack.EMPTY; } } } - return stack; } private boolean tryMoveToOutput(ItemStack stack, boolean doMove) { stack = stack.copy(); - for (int i = 21; i <= 26; i++) { if (inventory.get(i).isEmpty()) { if (doMove) { inventory.set(i, stack); } - return true; - } else if (InventoryUtils.areItemsStackable(stack, inventory.get(i)) - && inventory.get(i).getCount() < inventory.get(i).getMaxStackSize()) { - int toUse = Math - .min(stack.getCount(), inventory.get(i).getMaxStackSize() - inventory.get(i).getCount()); - + } else if (InventoryUtils.areItemsStackable(stack, inventory.get(i)) && inventory.get(i).getCount() < inventory.get(i).getMaxStackSize()) { + int toUse = Math.min(stack.getCount(), inventory.get(i).getMaxStackSize() - inventory.get(i).getCount()); if (doMove) { inventory.get(i).grow(toUse); } - stack.shrink(toUse); - if (stack.getCount() == 0) { return true; } } } - return false; } private void encodeFormula() { if (!inventory.get(2).isEmpty() && inventory.get(2).getItem() instanceof ItemCraftingFormula) { ItemCraftingFormula item = (ItemCraftingFormula) inventory.get(2).getItem(); - if (item.getInventory(inventory.get(2)) == null) { RecipeFormula formula = new RecipeFormula(world, inventory, 27); - if (formula.isValidFormula(world)) { item.setInventory(inventory.get(2), formula.input); markDirty(); @@ -468,9 +402,8 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im public boolean canExtractItem(int slotID, @Nonnull ItemStack itemstack, @Nonnull EnumFacing side) { if (slotID == 1) { return ChargeUtils.canBeOutputted(itemstack, false); - } else { - return slotID >= 21 && slotID <= 26; } + return slotID >= 21 && slotID <= 26; } @@ -479,38 +412,31 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im if (slotID >= 3 && slotID <= 20) { if (formula == null) { return true; - } else { - List indices = formula.getIngredientIndices(world, itemstack); - - if (indices.size() > 0) { - if (stockControl) { - int filled = 0; - - for (int i = 3; i < 20; i++) { - if (!inventory.get(i).isEmpty()) { - if (formula.isIngredientInPos(world, inventory.get(i), indices.get(0))) { - filled++; - } + } + List indices = formula.getIngredientIndices(world, itemstack); + if (indices.size() > 0) { + if (stockControl) { + int filled = 0; + for (int i = 3; i < 20; i++) { + if (!inventory.get(i).isEmpty()) { + if (formula.isIngredientInPos(world, inventory.get(i), indices.get(0))) { + filled++; } } - - return filled < indices.size() * 2; - } else { - return true; } + return filled < indices.size() * 2; } + return true; } } else if (slotID == 1) { return ChargeUtils.canBeDischarged(itemstack); } - return false; } @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - autoMode = nbtTags.getBoolean("autoMode"); operatingTicks = nbtTags.getInteger("operatingTicks"); controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; @@ -522,13 +448,11 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setBoolean("autoMode", autoMode); nbtTags.setInteger("operatingTicks", operatingTicks); nbtTags.setInteger("controlType", controlType.ordinal()); nbtTags.setInteger("pulseOperations", pulseOperations); nbtTags.setBoolean("stockControl", stockControl); - return nbtTags; } @@ -536,7 +460,6 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im public void handlePacketData(ByteBuf dataStream) { if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { int type = dataStream.readInt(); - if (type == 0) { toggleAutoMode(); } else if (type == 1) { @@ -554,7 +477,6 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im } else if (type == 5) { toggleStockControl(); } - return; } @@ -566,17 +488,14 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im controlType = RedstoneControl.values()[dataStream.readInt()]; isRecipe = dataStream.readBoolean(); stockControl = dataStream.readBoolean(); - if (dataStream.readBoolean()) { if (dataStream.readBoolean()) { NonNullList inv = NonNullList.withSize(9, ItemStack.EMPTY); - for (int i = 0; i < 9; i++) { if (dataStream.readBoolean()) { inv.set(i, PacketHandler.readStack(dataStream)); } } - formula = new RecipeFormula(world, inv); } else { formula = null; @@ -588,19 +507,15 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(autoMode); data.add(operatingTicks); data.add(controlType.ordinal()); data.add(isRecipe); data.add(stockControl); - if (needsFormulaUpdate) { data.add(true); - if (formula != null) { data.add(true); - for (int i = 0; i < 9; i++) { if (!formula.input.get(i).isEmpty()) { data.add(true); @@ -615,9 +530,7 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im } else { data.add(false); } - needsFormulaUpdate = false; - return data; } @@ -665,7 +578,6 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im @Override public void recalculateUpgradables(Upgrade upgrade) { super.recalculateUpgradables(upgrade); - switch (upgrade) { case SPEED: ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED); @@ -697,13 +609,11 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im if (capability == Capabilities.CONFIG_CARD_CAPABILITY) { return Capabilities.CONFIG_CARD_CAPABILITY.cast(this); } - return super.getCapability(capability, side); } @Override public boolean isCapabilityDisabled(@Nonnull Capability capability, EnumFacing side) { - return configComponent.isCapabilityDisabled(capability, side, facing) || super - .isCapabilityDisabled(capability, side); + return configComponent.isCapabilityDisabled(capability, side, facing) || super.isCapabilityDisabled(capability, side); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityFuelwoodHeater.java b/src/main/java/mekanism/common/tile/TileEntityFuelwoodHeater.java index 250e7f70b..205956ea3 100644 --- a/src/main/java/mekanism/common/tile/TileEntityFuelwoodHeater.java +++ b/src/main/java/mekanism/common/tile/TileEntityFuelwoodHeater.java @@ -26,8 +26,7 @@ import net.minecraft.util.NonNullList; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.FMLCommonHandler; -public class TileEntityFuelwoodHeater extends TileEntityContainerBlock implements IHeatTransfer, ISecurityTile, - IActiveState { +public class TileEntityFuelwoodHeater extends TileEntityContainerBlock implements IHeatTransfer, ISecurityTile, IActiveState { public double temperature; public double heatToAbsorb = 0; @@ -63,7 +62,6 @@ public class TileEntityFuelwoodHeater extends TileEntityContainerBlock implement public void onUpdate() { if (world.isRemote && updateDelay > 0) { updateDelay--; - if (updateDelay == 0 && clientActive != isActive) { isActive = clientActive; MekanismUtils.updateBlock(world, getPos()); @@ -73,45 +71,34 @@ public class TileEntityFuelwoodHeater extends TileEntityContainerBlock implement if (!world.isRemote) { if (updateDelay > 0) { updateDelay--; - if (updateDelay == 0 && clientActive != isActive) { - Mekanism.packetHandler.sendToReceivers( - new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); } } boolean burning = false; - if (burnTime > 0) { burnTime--; burning = true; } else { if (!inventory.get(0).isEmpty()) { maxBurnTime = burnTime = TileEntityFurnace.getItemBurnTime(inventory.get(0)) / 2; - if (burnTime > 0) { ItemStack preShrunk = inventory.get(0).copy(); inventory.get(0).shrink(1); - if (inventory.get(0).getCount() == 0) { inventory.set(0, preShrunk.getItem().getContainerItem(preShrunk)); } - burning = true; } } } - if (burning) { heatToAbsorb += MekanismConfig.current().general.heatPerFuelTick.val(); } - double[] loss = simulateHeat(); applyTemperatureChange(); - lastEnvironmentLoss = loss[1]; - setActive(burning); } } @@ -119,7 +106,6 @@ public class TileEntityFuelwoodHeater extends TileEntityContainerBlock implement @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - temperature = nbtTags.getDouble("temperature"); clientActive = isActive = nbtTags.getBoolean("isActive"); burnTime = nbtTags.getInteger("burnTime"); @@ -130,27 +116,22 @@ public class TileEntityFuelwoodHeater extends TileEntityContainerBlock implement @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setDouble("temperature", temperature); nbtTags.setBoolean("isActive", isActive); nbtTags.setInteger("burnTime", burnTime); nbtTags.setInteger("maxBurnTime", maxBurnTime); - return nbtTags; } @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { temperature = dataStream.readDouble(); clientActive = dataStream.readBoolean(); burnTime = dataStream.readInt(); maxBurnTime = dataStream.readInt(); - lastEnvironmentLoss = dataStream.readDouble(); - if (updateDelay == 0 && clientActive != isActive) { updateDelay = MekanismConfig.current().general.UPDATE_DELAY.val(); isActive = clientActive; @@ -162,14 +143,11 @@ public class TileEntityFuelwoodHeater extends TileEntityContainerBlock implement @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(temperature); data.add(isActive); data.add(burnTime); data.add(maxBurnTime); - data.add(lastEnvironmentLoss); - return data; } @@ -197,12 +175,8 @@ public class TileEntityFuelwoodHeater extends TileEntityContainerBlock implement @Override public void setActive(boolean active) { isActive = active; - if (clientActive != active && updateDelay == 0) { - Mekanism.packetHandler - .sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); - + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); updateDelay = 10; clientActive = active; } @@ -247,7 +221,6 @@ public class TileEntityFuelwoodHeater extends TileEntityContainerBlock implement public double applyTemperatureChange() { temperature += heatToAbsorb; heatToAbsorb = 0; - return temperature; } @@ -259,11 +232,9 @@ public class TileEntityFuelwoodHeater extends TileEntityContainerBlock implement @Override public IHeatTransfer getAdjacent(EnumFacing side) { TileEntity adj = Coord4D.get(this).offset(side).getTileEntity(world); - if (CapabilityUtils.hasCapability(adj, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite())) { return CapabilityUtils.getCapability(adj, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite()); } - return null; } @@ -277,7 +248,6 @@ public class TileEntityFuelwoodHeater extends TileEntityContainerBlock implement if (capability == Capabilities.HEAT_TRANSFER_CAPABILITY) { return Capabilities.HEAT_TRANSFER_CAPABILITY.cast(this); } - return super.getCapability(capability, side); } @@ -285,4 +255,4 @@ public class TileEntityFuelwoodHeater extends TileEntityContainerBlock implement public TileComponentSecurity getSecurity() { return securityComponent; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityGasTank.java b/src/main/java/mekanism/common/tile/TileEntityGasTank.java index bda512337..ad177e9f3 100644 --- a/src/main/java/mekanism/common/tile/TileEntityGasTank.java +++ b/src/main/java/mekanism/common/tile/TileEntityGasTank.java @@ -15,8 +15,6 @@ import mekanism.api.gas.IGasItem; import mekanism.api.transmitters.TransmissionType; import mekanism.common.Mekanism; import mekanism.common.SideData; -import mekanism.common.tier.BaseTier; -import mekanism.common.tier.GasTankTier; import mekanism.common.base.IRedstoneControl; import mekanism.common.base.ISideConfiguration; import mekanism.common.base.ITierUpgradeable; @@ -24,6 +22,8 @@ import mekanism.common.capabilities.Capabilities; import mekanism.common.integration.computer.IComputerIntegration; import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.security.ISecurityTile; +import mekanism.common.tier.BaseTier; +import mekanism.common.tier.GasTankTier; import mekanism.common.tile.component.TileComponentConfig; import mekanism.common.tile.component.TileComponentEjector; import mekanism.common.tile.component.TileComponentSecurity; @@ -43,8 +43,8 @@ import net.minecraft.util.math.MathHelper; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.FMLCommonHandler; -public class TileEntityGasTank extends TileEntityContainerBlock implements IGasHandler, IRedstoneControl, - ISideConfiguration, ISecurityTile, ITierUpgradeable, IComputerIntegration { +public class TileEntityGasTank extends TileEntityContainerBlock implements IGasHandler, IRedstoneControl, ISideConfiguration, ISecurityTile, ITierUpgradeable, + IComputerIntegration { private static final String[] methods = new String[]{"getMaxGas", "getStoredGas", "getGas"}; /** @@ -71,7 +71,6 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH public TileEntityGasTank() { super("GasTank"); - configComponent = new TileComponentConfig(this, TransmissionType.GAS, TransmissionType.ITEM); configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); @@ -97,20 +96,13 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH public void onUpdate() { if (!world.isRemote) { TileUtils.drawGas(inventory.get(0), gasTank, tier != GasTankTier.CREATIVE); - - if (TileUtils.receiveGas(inventory.get(1), gasTank) && tier == GasTankTier.CREATIVE - && gasTank.getGas() != null) { + if (TileUtils.receiveGas(inventory.get(1), gasTank) && tier == GasTankTier.CREATIVE && gasTank.getGas() != null) { gasTank.getGas().amount = Integer.MAX_VALUE; } - - if (gasTank.getGas() != null && MekanismUtils.canFunction(this) && (tier == GasTankTier.CREATIVE - || dumping != GasMode.DUMPING)) { + if (gasTank.getGas() != null && MekanismUtils.canFunction(this) && (tier == GasTankTier.CREATIVE || dumping != GasMode.DUMPING)) { if (configComponent.isEjecting(TransmissionType.GAS)) { - GasStack toSend = new GasStack(gasTank.getGas().getGas(), - Math.min(gasTank.getStored(), tier.getOutput())); - gasTank.draw(GasUtils - .emit(toSend, this, configComponent.getSidesForData(TransmissionType.GAS, facing, 2)), - tier != GasTankTier.CREATIVE); + GasStack toSend = new GasStack(gasTank.getGas().getGas(), Math.min(gasTank.getStored(), tier.getOutput())); + gasTank.draw(GasUtils.emit(toSend, this, configComponent.getSidesForData(TransmissionType.GAS, facing, 2)), tier != GasTankTier.CREATIVE); } } @@ -118,22 +110,17 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH if (dumping == GasMode.DUMPING) { gasTank.draw(tier.getStorage() / 400, true); } - if (dumping == GasMode.DUMPING_EXCESS && gasTank.getNeeded() < tier.getOutput()) { gasTank.draw(tier.getOutput() - gasTank.getNeeded(), true); } } int newGasAmount = gasTank.getStored(); - if (newGasAmount != currentGasAmount) { MekanismUtils.saveChunk(this); } - currentGasAmount = newGasAmount; - int newRedstoneLevel = getRedstoneLevel(); - if (newRedstoneLevel != currentRedstoneLevel) { markDirty(); currentRedstoneLevel = newRedstoneLevel; @@ -146,15 +133,10 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH if (upgradeTier.ordinal() != tier.ordinal() + 1) { return false; } - tier = GasTankTier.values()[upgradeTier.ordinal()]; gasTank.setMaxGas(tier.getStorage()); - - Mekanism.packetHandler - .sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); markDirty(); - return true; } @@ -167,28 +149,21 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH @Override public boolean canExtractItem(int slotID, @Nonnull ItemStack itemstack, @Nonnull EnumFacing side) { if (slotID == 1) { - return (itemstack.getItem() instanceof IGasItem - && ((IGasItem) itemstack.getItem()).getGas(itemstack) == null); + return itemstack.getItem() instanceof IGasItem && ((IGasItem) itemstack.getItem()).getGas(itemstack) == null; } else if (slotID == 0) { - return (itemstack.getItem() instanceof IGasItem - && ((IGasItem) itemstack.getItem()).getGas(itemstack) != null && - ((IGasItem) itemstack.getItem()).getGas(itemstack).amount == ((IGasItem) itemstack.getItem()) - .getMaxGas(itemstack)); + 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, @Nonnull ItemStack itemstack) { if (slotID == 0) { - return itemstack.getItem() instanceof IGasItem && (gasTank.getGas() == null || ((IGasItem) itemstack - .getItem()).canReceiveGas(itemstack, gasTank.getGas().getGas())); + return itemstack.getItem() instanceof IGasItem && (gasTank.getGas() == null || ((IGasItem) itemstack.getItem()).canReceiveGas(itemstack, gasTank.getGas().getGas())); } else if (slotID == 1) { - return itemstack.getItem() instanceof IGasItem && (gasTank.getGas() == null || ((IGasItem) itemstack - .getItem()).canProvideGas(itemstack, gasTank.getGas().getGas())); + return itemstack.getItem() instanceof IGasItem && (gasTank.getGas() == null || ((IGasItem) itemstack.getItem()).canProvideGas(itemstack, gasTank.getGas().getGas())); } - return false; } @@ -203,7 +178,6 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH if (tier == GasTankTier.CREATIVE) { return stack != null ? stack.amount : 0; } - return gasTank.receive(stack, doTransfer); } @@ -212,7 +186,6 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH if (canDrawGas(side, null)) { return gasTank.draw(amount, doTransfer); } - return null; } @@ -229,7 +202,6 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH if (configComponent.hasSideForData(TransmissionType.GAS, facing, 1, side)) { return gasTank.canReceive(type); } - return false; } @@ -254,47 +226,36 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH } else if (capability == Capabilities.GAS_HANDLER_CAPABILITY) { return Capabilities.GAS_HANDLER_CAPABILITY.cast(this); } - return super.getCapability(capability, side); } @Override public boolean isCapabilityDisabled(@Nonnull Capability capability, EnumFacing side) { - return configComponent.isCapabilityDisabled(capability, side, facing) || super - .isCapabilityDisabled(capability, side); + return configComponent.isCapabilityDisabled(capability, side, facing) || super.isCapabilityDisabled(capability, side); } @Override public void handlePacketData(ByteBuf dataStream) { if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { int type = dataStream.readInt(); - if (type == 0) { int index = (dumping.ordinal() + 1) % GasMode.values().length; dumping = GasMode.values()[index]; } - for (EntityPlayer player : playersUsing) { - Mekanism.packetHandler - .sendTo(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - (EntityPlayerMP) player); + Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), (EntityPlayerMP) player); } return; } - super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { GasTankTier prevTier = tier; - tier = GasTankTier.values()[dataStream.readInt()]; gasTank.setMaxGas(tier.getStorage()); TileUtils.readTankData(dataStream, gasTank); - dumping = GasMode.values()[dataStream.readInt()]; controlType = RedstoneControl.values()[dataStream.readInt()]; - if (prevTier != tier) { MekanismUtils.updateBlock(world, getPos()); } @@ -304,11 +265,9 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - tier = GasTankTier.values()[nbtTags.getInteger("tier")]; gasTank.read(nbtTags.getCompoundTag("gasTank")); dumping = GasMode.values()[nbtTags.getInteger("dumping")]; - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; } @@ -316,25 +275,20 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setInteger("tier", tier.ordinal()); nbtTags.setTag("gasTank", gasTank.write(new NBTTagCompound())); nbtTags.setInteger("dumping", dumping.ordinal()); nbtTags.setInteger("controlType", controlType.ordinal()); - return nbtTags; } @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(tier.ordinal()); TileUtils.addTankData(data, gasTank); - data.add(dumping.ordinal()); data.add(controlType.ordinal()); - return data; } @@ -407,4 +361,4 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH DUMPING_EXCESS, DUMPING } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityGlowPanel.java b/src/main/java/mekanism/common/tile/TileEntityGlowPanel.java index 255e6d257..f5de7a863 100644 --- a/src/main/java/mekanism/common/tile/TileEntityGlowPanel.java +++ b/src/main/java/mekanism/common/tile/TileEntityGlowPanel.java @@ -4,9 +4,9 @@ import io.netty.buffer.ByteBuf; import javax.annotation.Nonnull; import mekanism.api.Coord4D; import mekanism.api.EnumColor; +import mekanism.api.TileNetworkList; import mekanism.common.Mekanism; import mekanism.common.base.ITileNetwork; -import mekanism.api.TileNetworkList; import mekanism.common.block.property.PropertyColor; import mekanism.common.block.states.BlockStateFacing; import mekanism.common.capabilities.Capabilities; @@ -30,7 +30,6 @@ public class TileEntityGlowPanel extends TileEntity implements ITileNetwork { EnumColor color = propColor != null ? propColor.color : EnumColor.WHITE; hash = 31 * hash + color.ordinal(); hash = 31 * hash + state.getValue(BlockStateFacing.facingProperty).ordinal(); - return hash; } @@ -46,7 +45,6 @@ public class TileEntityGlowPanel extends TileEntity implements ITileNetwork { public void handlePacketData(ByteBuf dataStream) { side = EnumFacing.byIndex(dataStream.readInt()); colour = EnumColor.DYES[dataStream.readInt()]; - MekanismUtils.updateBlock(world, pos); } @@ -55,17 +53,14 @@ public class TileEntityGlowPanel extends TileEntity implements ITileNetwork { if (Mekanism.hooks.MCMPLoaded) { MultipartTileNetworkJoiner.addMultipartHeader(this, data, side); } - data.add(side.ordinal()); data.add(colour.getMetaValue()); - return data; } @Override public void validate() { super.validate(); - if (world.isRemote) { Mekanism.packetHandler.sendToServer(new DataRequestMessage(Coord4D.get(this))); } @@ -75,10 +70,8 @@ public class TileEntityGlowPanel extends TileEntity implements ITileNetwork { @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); - nbt.setInteger("side", side.ordinal()); nbt.setInteger("colour", colour.getMetaValue()); - return nbt; } @@ -91,7 +84,6 @@ public class TileEntityGlowPanel extends TileEntity implements ITileNetwork { @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); - side = EnumFacing.byIndex(nbt.getInteger("side")); colour = EnumColor.DYES[nbt.getInteger("colour")]; } @@ -108,4 +100,4 @@ public class TileEntityGlowPanel extends TileEntity implements ITileNetwork { } return super.getCapability(capability, facing); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityInductionCasing.java b/src/main/java/mekanism/common/tile/TileEntityInductionCasing.java index a8189aa73..026b1c906 100644 --- a/src/main/java/mekanism/common/tile/TileEntityInductionCasing.java +++ b/src/main/java/mekanism/common/tile/TileEntityInductionCasing.java @@ -27,14 +27,12 @@ import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.items.CapabilityItemHandler; -public class TileEntityInductionCasing extends TileEntityMultiblock implements - IStrictEnergyStorage, IComputerIntegration { +public class TileEntityInductionCasing extends TileEntityMultiblock implements IStrictEnergyStorage, IComputerIntegration { protected static final int[] CHARGE_SLOT = {0}; protected static final int[] DISCHARGE_SLOT = {1}; - public static final String[] methods = new String[]{"getEnergy", "getMaxEnergy", "getInput", "getOutput", - "getTransferCap"}; + public static final String[] methods = new String[]{"getEnergy", "getMaxEnergy", "getInput", "getOutput", "getTransferCap"}; public int clientCells; public int clientProviders; @@ -68,14 +66,10 @@ public class TileEntityInductionCasing extends TileEntityMultiblock capability, - net.minecraft.util.EnumFacing facing) { + public boolean hasCapability(@Nonnull net.minecraftforge.common.capabilities.Capability capability, EnumFacing facing) { return capability == Capabilities.ENERGY_STORAGE_CAPABILITY || super.hasCapability(capability, facing); } @Override - public T getCapability(@Nonnull Capability capability, net.minecraft.util.EnumFacing facing) { + public T getCapability(@Nonnull Capability capability, EnumFacing facing) { if (capability == Capabilities.ENERGY_STORAGE_CAPABILITY) { return Capabilities.ENERGY_STORAGE_CAPABILITY.cast(this); } diff --git a/src/main/java/mekanism/common/tile/TileEntityInductionPort.java b/src/main/java/mekanism/common/tile/TileEntityInductionPort.java index 2f88fe195..4697396d8 100644 --- a/src/main/java/mekanism/common/tile/TileEntityInductionPort.java +++ b/src/main/java/mekanism/common/tile/TileEntityInductionPort.java @@ -51,8 +51,7 @@ import net.minecraftforge.items.CapabilityItemHandler; @Interface(iface = "ic2.api.energy.tile.IEnergySource", modid = MekanismHooks.IC2_MOD_ID), @Interface(iface = "ic2.api.tile.IEnergyStorage", modid = MekanismHooks.IC2_MOD_ID) }) -public class TileEntityInductionPort extends TileEntityInductionCasing implements IEnergyWrapper, IConfigurable, - IActiveState { +public class TileEntityInductionPort extends TileEntityInductionCasing implements IEnergyWrapper, IConfigurable, IActiveState { public boolean ic2Registered = false; @@ -60,10 +59,8 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement * false = input, true = output */ public boolean mode; - private CapabilityWrapperManager teslaManager = new CapabilityWrapperManager<>( - IEnergyWrapper.class, TeslaIntegration.class); - private CapabilityWrapperManager forgeEnergyManager = new CapabilityWrapperManager<>( - IEnergyWrapper.class, ForgeEnergyIntegration.class); + private CapabilityWrapperManager teslaManager = new CapabilityWrapperManager<>(IEnergyWrapper.class, TeslaIntegration.class); + private CapabilityWrapperManager forgeEnergyManager = new CapabilityWrapperManager<>(IEnergyWrapper.class, ForgeEnergyIntegration.class); public TileEntityInductionPort() { super("InductionPort"); @@ -81,7 +78,7 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement if (structure != null && mode) { double prev = getEnergy(); CableUtils.emit(this); - structure.remainingOutput -= (prev - getEnergy()); + structure.remainingOutput -= prev - getEnergy(); } } } @@ -97,7 +94,7 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement @Override public boolean sideIsConsumer(EnumFacing side) { - return (structure != null && !mode); + return structure != null && !mode; } @Method(modid = MekanismHooks.IC2_MOD_ID) @@ -362,7 +359,7 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement } return amount - acceptEnergy(direction, amount * MekanismConfig.current().general.FROM_IC2.val(), false) - * MekanismConfig.current().general.TO_IC2.val(); + * MekanismConfig.current().general.TO_IC2.val(); } @Override @@ -410,18 +407,12 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement public EnumActionResult onSneakRightClick(EntityPlayer player, EnumFacing side) { if (!world.isRemote) { mode = !mode; - String modeText = - " " + (mode ? EnumColor.DARK_RED : EnumColor.DARK_GREEN) + LangUtils.transOutputInput(mode) + "."; - player.sendMessage( - new TextComponentString(EnumColor.DARK_BLUE + Mekanism.LOG_TAG + " " + EnumColor.GREY + LangUtils - .localize("tooltip.configurator.inductionPortMode") + modeText)); - - Mekanism.packetHandler - .sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); + String modeText = " " + (mode ? EnumColor.DARK_RED : EnumColor.DARK_GREEN) + LangUtils.transOutputInput(mode) + "."; + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + Mekanism.LOG_TAG + " " + EnumColor.GREY + + LangUtils.localize("tooltip.configurator.inductionPortMode") + modeText)); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); markDirty(); } - return EnumActionResult.SUCCESS; } @@ -453,28 +444,28 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement @Override public boolean hasCapability(@Nonnull Capability capability, EnumFacing facing) { return capability == Capabilities.ENERGY_STORAGE_CAPABILITY - || capability == Capabilities.ENERGY_ACCEPTOR_CAPABILITY - || capability == Capabilities.ENERGY_OUTPUTTER_CAPABILITY - || capability == Capabilities.TESLA_HOLDER_CAPABILITY - || capability == Capabilities.CONFIGURABLE_CAPABILITY - || (capability == Capabilities.TESLA_CONSUMER_CAPABILITY && sideIsConsumer(facing)) - || (capability == Capabilities.TESLA_PRODUCER_CAPABILITY && sideIsOutput(facing)) - || capability == CapabilityEnergy.ENERGY - || super.hasCapability(capability, facing); + || capability == Capabilities.ENERGY_ACCEPTOR_CAPABILITY + || capability == Capabilities.ENERGY_OUTPUTTER_CAPABILITY + || capability == Capabilities.TESLA_HOLDER_CAPABILITY + || capability == Capabilities.CONFIGURABLE_CAPABILITY + || (capability == Capabilities.TESLA_CONSUMER_CAPABILITY && sideIsConsumer(facing)) + || (capability == Capabilities.TESLA_PRODUCER_CAPABILITY && sideIsOutput(facing)) + || capability == CapabilityEnergy.ENERGY + || super.hasCapability(capability, facing); } @Override public T getCapability(@Nonnull Capability capability, EnumFacing facing) { if (capability == Capabilities.ENERGY_STORAGE_CAPABILITY - || capability == Capabilities.ENERGY_ACCEPTOR_CAPABILITY || - capability == Capabilities.ENERGY_OUTPUTTER_CAPABILITY - || capability == Capabilities.CONFIGURABLE_CAPABILITY) { + || capability == Capabilities.ENERGY_ACCEPTOR_CAPABILITY || + capability == Capabilities.ENERGY_OUTPUTTER_CAPABILITY + || capability == Capabilities.CONFIGURABLE_CAPABILITY) { return (T) this; } if (capability == Capabilities.TESLA_HOLDER_CAPABILITY - || (capability == Capabilities.TESLA_CONSUMER_CAPABILITY && sideIsConsumer(facing)) - || (capability == Capabilities.TESLA_PRODUCER_CAPABILITY && sideIsOutput(facing))) { + || (capability == Capabilities.TESLA_CONSUMER_CAPABILITY && sideIsConsumer(facing)) + || (capability == Capabilities.TESLA_PRODUCER_CAPABILITY && sideIsOutput(facing))) { return (T) teslaManager.getWrapper(this, facing); } @@ -490,7 +481,7 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement public int[] getSlotsForFace(@Nonnull EnumFacing side) { //Inserting into input make it draw power from the item inserted return (!world.isRemote && structure != null) || (world.isRemote && clientHasStructure) ? mode ? CHARGE_SLOT - : DISCHARGE_SLOT : InventoryUtils.EMPTY; + : DISCHARGE_SLOT : InventoryUtils.EMPTY; } @Override @@ -510,4 +501,4 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement } return super.isCapabilityDisabled(capability, side); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityInductionProvider.java b/src/main/java/mekanism/common/tile/TileEntityInductionProvider.java index 681576e22..df9ccb4ea 100644 --- a/src/main/java/mekanism/common/tile/TileEntityInductionProvider.java +++ b/src/main/java/mekanism/common/tile/TileEntityInductionProvider.java @@ -2,8 +2,8 @@ package mekanism.common.tile; import io.netty.buffer.ByteBuf; import javax.annotation.Nonnull; -import mekanism.common.tier.InductionProviderTier; import mekanism.api.TileNetworkList; +import mekanism.common.tier.InductionProviderTier; import mekanism.common.tile.prefab.TileEntityBasicBlock; import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; @@ -19,18 +19,15 @@ public class TileEntityInductionProvider extends TileEntityBasicBlock { } public String getName() { - return LangUtils.localize( - getBlockType().getTranslationKey() + ".InductionProvider" + tier.getBaseTier().getSimpleName() + ".name"); + return LangUtils.localize(getBlockType().getTranslationKey() + ".InductionProvider" + tier.getBaseTier().getSimpleName() + ".name"); } @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { InductionProviderTier prevTier = tier; tier = InductionProviderTier.values()[dataStream.readInt()]; - if (prevTier != tier) { MekanismUtils.updateBlock(world, getPos()); } @@ -40,16 +37,13 @@ public class TileEntityInductionProvider extends TileEntityBasicBlock { @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(tier.ordinal()); - return data; } @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - tier = InductionProviderTier.values()[nbtTags.getInteger("tier")]; } @@ -57,9 +51,7 @@ public class TileEntityInductionProvider extends TileEntityBasicBlock { @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setInteger("tier", tier.ordinal()); - return nbtTags; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityLaser.java b/src/main/java/mekanism/common/tile/TileEntityLaser.java index 59e9fbf47..3b750ba37 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLaser.java +++ b/src/main/java/mekanism/common/tile/TileEntityLaser.java @@ -30,29 +30,21 @@ public class TileEntityLaser extends TileEntityEffectsBlock { @Override public void onUpdate() { super.onUpdate(); - if (world.isRemote) { if (isActive) { - RayTraceResult mop = LaserManager - .fireLaserClient(this, facing, MekanismConfig.current().usage.laser.val(), world); + RayTraceResult mop = LaserManager.fireLaserClient(this, facing, MekanismConfig.current().usage.laser.val(), world); Coord4D hitCoord = mop == null ? null : new Coord4D(mop, world); - if (hitCoord == null || !hitCoord.equals(digging)) { digging = hitCoord; diggingProgress = 0; } - if (hitCoord != null) { IBlockState blockHit = hitCoord.getBlockState(world); TileEntity tileHit = hitCoord.getTileEntity(world); float hardness = blockHit.getBlockHardness(world, hitCoord.getPos()); - - if (!(hardness < 0 || (LaserManager.isReceptor(tileHit, mop.sideHit) && !(LaserManager - .getReceptor(tileHit, mop.sideHit).canLasersDig())))) { + if (!(hardness < 0 || (LaserManager.isReceptor(tileHit, mop.sideHit) && !LaserManager.getReceptor(tileHit, mop.sideHit).canLasersDig()))) { diggingProgress += MekanismConfig.current().usage.laser.val(); - - if (diggingProgress < hardness * MekanismConfig.current().general.laserEnergyNeededPerHardness - .val()) { + if (diggingProgress < hardness * MekanismConfig.current().general.laserEnergyNeededPerHardness.val()) { Mekanism.proxy.addHitEffects(hitCoord, mop); } } @@ -61,33 +53,25 @@ public class TileEntityLaser extends TileEntityEffectsBlock { } else { if (getEnergy() >= MekanismConfig.current().usage.laser.val()) { setActive(true); - - LaserInfo info = LaserManager - .fireLaser(this, facing, MekanismConfig.current().usage.laser.val(), world); + LaserInfo info = LaserManager.fireLaser(this, facing, MekanismConfig.current().usage.laser.val(), world); Coord4D hitCoord = info.movingPos == null ? null : new Coord4D(info.movingPos, world); if (hitCoord == null || !hitCoord.equals(digging)) { digging = hitCoord; diggingProgress = 0; } - if (hitCoord != null) { IBlockState blockHit = hitCoord.getBlockState(world); TileEntity tileHit = hitCoord.getTileEntity(world); float hardness = blockHit.getBlockHardness(world, hitCoord.getPos()); - - if (!(hardness < 0 || (LaserManager.isReceptor(tileHit, info.movingPos.sideHit) && !(LaserManager - .getReceptor(tileHit, info.movingPos.sideHit).canLasersDig())))) { + if (!(hardness < 0 || (LaserManager.isReceptor(tileHit, info.movingPos.sideHit) && !LaserManager.getReceptor(tileHit, info.movingPos.sideHit).canLasersDig()))) { diggingProgress += MekanismConfig.current().usage.laser.val(); - - if (diggingProgress >= hardness * MekanismConfig.current().general.laserEnergyNeededPerHardness - .val()) { + if (diggingProgress >= hardness * MekanismConfig.current().general.laserEnergyNeededPerHardness.val()) { LaserManager.breakBlock(hitCoord, true, world, pos); diggingProgress = 0; } } } - setEnergy(getEnergy() - MekanismConfig.current().usage.laser.val()); } else { setActive(false); @@ -124,4 +108,4 @@ public class TileEntityLaser extends TileEntityEffectsBlock { } return super.isCapabilityDisabled(capability, side); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityLaserAmplifier.java b/src/main/java/mekanism/common/tile/TileEntityLaserAmplifier.java index cd91b246e..4b01e8a6d 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLaserAmplifier.java +++ b/src/main/java/mekanism/common/tile/TileEntityLaserAmplifier.java @@ -33,8 +33,8 @@ import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.items.CapabilityItemHandler; -public class TileEntityLaserAmplifier extends TileEntityContainerBlock implements ILaserReceptor, IRedstoneControl, - IStrictEnergyOutputter, IStrictEnergyStorage, IComputerIntegration, ISecurityTile { +public class TileEntityLaserAmplifier extends TileEntityContainerBlock implements ILaserReceptor, IRedstoneControl, IStrictEnergyOutputter, IStrictEnergyStorage, + IComputerIntegration, ISecurityTile { public static final double MAX_ENERGY = 5E9; private static final String[] methods = new String[]{"getEnergy", "getMaxEnergy"}; @@ -74,7 +74,6 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement if (on) { RayTraceResult mop = LaserManager.fireLaserClient(this, facing, lastFired, world); Coord4D hitCoord = mop == null ? null : new Coord4D(mop, world); - if (hitCoord == null || !hitCoord.equals(digging)) { digging = hitCoord; diggingProgress = 0; @@ -85,12 +84,9 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement TileEntity tileHit = hitCoord.getTileEntity(world); float hardness = blockHit.getBlockHardness(world, hitCoord.getPos()); - if (!(hardness < 0 || (LaserManager.isReceptor(tileHit, mop.sideHit) && !(LaserManager - .getReceptor(tileHit, mop.sideHit).canLasersDig())))) { + if (!(hardness < 0 || (LaserManager.isReceptor(tileHit, mop.sideHit) && !LaserManager.getReceptor(tileHit, mop.sideHit).canLasersDig()))) { diggingProgress += lastFired; - - if (diggingProgress < hardness * MekanismConfig.current().general.laserEnergyNeededPerHardness - .val()) { + if (diggingProgress < hardness * MekanismConfig.current().general.laserEnergyNeededPerHardness.val()) { Mekanism.proxy.addHitEffects(hitCoord, mop); } } @@ -99,9 +95,7 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement } } else { boolean prevRedstone = emittingRedstone; - emittingRedstone = false; - if (ticks < time) { ticks++; } else { @@ -110,12 +104,10 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement if (toFire() > 0) { double firing = toFire(); - if (!on || firing != lastFired) { on = true; lastFired = firing; - Mekanism.packetHandler.sendToAllAround( - new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), + Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), Coord4D.get(this).getTargetPoint(50D)); } @@ -131,41 +123,31 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement IBlockState blockHit = hitCoord.getBlockState(world); TileEntity tileHit = hitCoord.getTileEntity(world); float hardness = blockHit.getBlockHardness(world, hitCoord.getPos()); - - if (!(hardness < 0 || (LaserManager.isReceptor(tileHit, info.movingPos.sideHit) && !(LaserManager - .getReceptor(tileHit, info.movingPos.sideHit).canLasersDig())))) { + if (!(hardness < 0 || (LaserManager.isReceptor(tileHit, info.movingPos.sideHit) && !LaserManager.getReceptor(tileHit, info.movingPos.sideHit).canLasersDig()))) { diggingProgress += firing; - - if (diggingProgress >= hardness * MekanismConfig.current().general.laserEnergyNeededPerHardness - .val()) { + if (diggingProgress >= hardness * MekanismConfig.current().general.laserEnergyNeededPerHardness.val()) { LaserManager.breakBlock(hitCoord, true, world, pos); diggingProgress = 0; } } } - emittingRedstone = info.foundEntity; - setEnergy(getEnergy() - firing); } else if (on) { on = false; diggingProgress = 0; - Mekanism.packetHandler.sendToAllAround( - new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), + Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), Coord4D.get(this).getTargetPoint(50D)); } if (outputMode != RedstoneOutput.ENTITY_DETECTION) { emittingRedstone = false; } - int newRedstoneLevel = getRedstoneLevel(); - if (newRedstoneLevel != currentRedstoneLevel) { markDirty(); currentRedstoneLevel = newRedstoneLevel; } - if (emittingRedstone != prevRedstone) { world.notifyNeighborsOfStateChange(getPos(), getBlockType(), true); } @@ -175,15 +157,12 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement @Override public double pullEnergy(EnumFacing side, double amount, boolean simulate) { double toGive = Math.min(getEnergy(), amount); - if (toGive < 0.0001) { return 0; } - if (!simulate) { setEnergy(getEnergy() - toGive); } - return toGive; } @@ -209,7 +188,6 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement if (outputMode != RedstoneOutput.ENERGY_CONTENTS) { return 0; } - double fractionFull = getEnergy() / getMaxEnergy(); return MathHelper.floor((float) (fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0); } @@ -217,7 +195,6 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(on); data.add(minThreshold); data.add(maxThreshold); @@ -227,7 +204,6 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement data.add(controlType.ordinal()); data.add(emittingRedstone); data.add(outputMode.ordinal()); - return data; } @@ -245,11 +221,9 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement time = dataStream.readInt(); break; case 3: - outputMode = RedstoneOutput.values()[outputMode.ordinal() == RedstoneOutput.values().length - 1 ? 0 - : outputMode.ordinal() + 1]; + outputMode = RedstoneOutput.values()[outputMode.ordinal() == RedstoneOutput.values().length - 1 ? 0 : outputMode.ordinal() + 1]; break; } - return; } @@ -271,7 +245,6 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - on = nbtTags.getBoolean("on"); minThreshold = nbtTags.getDouble("minThreshold"); maxThreshold = nbtTags.getDouble("maxThreshold"); @@ -286,7 +259,6 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setBoolean("on", on); nbtTags.setDouble("minThreshold", minThreshold); nbtTags.setDouble("maxThreshold", maxThreshold); @@ -295,7 +267,6 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement nbtTags.setDouble("lastFired", lastFired); nbtTags.setInteger("controlType", controlType.ordinal()); nbtTags.setInteger("outputMode", outputMode.ordinal()); - return nbtTags; } @@ -348,10 +319,8 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement @Override public boolean hasCapability(@Nonnull Capability capability, EnumFacing facing) { - return capability == Capabilities.ENERGY_STORAGE_CAPABILITY - || capability == Capabilities.ENERGY_OUTPUTTER_CAPABILITY - || capability == Capabilities.LASER_RECEPTOR_CAPABILITY - || super.hasCapability(capability, facing); + return capability == Capabilities.ENERGY_STORAGE_CAPABILITY || capability == Capabilities.ENERGY_OUTPUTTER_CAPABILITY + || capability == Capabilities.LASER_RECEPTOR_CAPABILITY || super.hasCapability(capability, facing); } @Override @@ -397,4 +366,4 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement return LangUtils.localize("gui." + unlocalizedName); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityLaserTractorBeam.java b/src/main/java/mekanism/common/tile/TileEntityLaserTractorBeam.java index 0c95f0f92..91f6975dc 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLaserTractorBeam.java +++ b/src/main/java/mekanism/common/tile/TileEntityLaserTractorBeam.java @@ -59,7 +59,6 @@ public class TileEntityLaserTractorBeam extends TileEntityContainerBlock impleme if (on) { RayTraceResult mop = LaserManager.fireLaserClient(this, facing, lastFired, world); Coord4D hitCoord = mop == null ? null : new Coord4D(mop, world); - if (hitCoord == null || !hitCoord.equals(digging)) { digging = hitCoord; diggingProgress = 0; @@ -69,67 +68,54 @@ public class TileEntityLaserTractorBeam extends TileEntityContainerBlock impleme IBlockState blockHit = hitCoord.getBlockState(world); TileEntity tileHit = hitCoord.getTileEntity(world); float hardness = blockHit.getBlockHardness(world, hitCoord.getPos()); - - if (!(hardness < 0 || (LaserManager.isReceptor(tileHit, mop.sideHit) && !(LaserManager - .getReceptor(tileHit, mop.sideHit).canLasersDig())))) { + if (!(hardness < 0 || (LaserManager.isReceptor(tileHit, mop.sideHit) && !LaserManager.getReceptor(tileHit, mop.sideHit).canLasersDig()))) { diggingProgress += lastFired; - - if (diggingProgress < hardness * MekanismConfig.current().general.laserEnergyNeededPerHardness - .val()) { + if (diggingProgress < hardness * MekanismConfig.current().general.laserEnergyNeededPerHardness.val()) { Mekanism.proxy.addHitEffects(hitCoord, mop); } } } } - } else { - if (collectedEnergy > 0) { - double firing = collectedEnergy; - - if (!on || firing != lastFired) { - on = true; - lastFired = firing; - Mekanism.packetHandler.sendToAllAround( - new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - Coord4D.get(this).getTargetPoint(50D)); - } - - LaserInfo info = LaserManager.fireLaser(this, facing, firing, world); - Coord4D hitCoord = info.movingPos == null ? null : new Coord4D(info.movingPos, world); - - if (hitCoord == null || !hitCoord.equals(digging)) { - digging = hitCoord; - diggingProgress = 0; - } - - if (hitCoord != null) { - IBlockState blockHit = hitCoord.getBlockState(world); - TileEntity tileHit = hitCoord.getTileEntity(world); - float hardness = blockHit.getBlockHardness(world, hitCoord.getPos()); - - if (!(hardness < 0 || (LaserManager.isReceptor(tileHit, info.movingPos.sideHit) && !(LaserManager - .getReceptor(tileHit, info.movingPos.sideHit).canLasersDig())))) { - diggingProgress += firing; - - if (diggingProgress >= hardness * MekanismConfig.current().general.laserEnergyNeededPerHardness - .val()) { - List drops = LaserManager.breakBlock(hitCoord, false, world, pos); - if (drops != null) { - receiveDrops(drops); - } - diggingProgress = 0; - } - } - } - - setEnergy(getEnergy() - firing); - } else if (on) { - on = false; - diggingProgress = 0; - Mekanism.packetHandler.sendToAllAround( - new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), + } else if (collectedEnergy > 0) { + double firing = collectedEnergy; + if (!on || firing != lastFired) { + on = true; + lastFired = firing; + Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), Coord4D.get(this).getTargetPoint(50D)); } + + LaserInfo info = LaserManager.fireLaser(this, facing, firing, world); + Coord4D hitCoord = info.movingPos == null ? null : new Coord4D(info.movingPos, world); + + if (hitCoord == null || !hitCoord.equals(digging)) { + digging = hitCoord; + diggingProgress = 0; + } + + if (hitCoord != null) { + IBlockState blockHit = hitCoord.getBlockState(world); + TileEntity tileHit = hitCoord.getTileEntity(world); + float hardness = blockHit.getBlockHardness(world, hitCoord.getPos()); + + if (!(hardness < 0 || (LaserManager.isReceptor(tileHit, info.movingPos.sideHit) && !LaserManager.getReceptor(tileHit, info.movingPos.sideHit).canLasersDig()))) { + diggingProgress += firing; + if (diggingProgress >= hardness * MekanismConfig.current().general.laserEnergyNeededPerHardness.val()) { + List drops = LaserManager.breakBlock(hitCoord, false, world, pos); + if (drops != null) { + receiveDrops(drops); + } + diggingProgress = 0; + } + } + } + setEnergy(getEnergy() - firing); + } else if (on) { + on = false; + diggingProgress = 0; + Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), + Coord4D.get(this).getTargetPoint(50D)); } } @@ -149,9 +135,7 @@ public class TileEntityLaserTractorBeam extends TileEntityContainerBlock impleme inventory.set(i, drop); continue outer; } - ItemStack slot = inventory.get(i); - if (StackUtils.equalsWildcardWithNBT(slot, drop)) { int change = Math.min(drop.getCount(), slot.getMaxStackSize() - slot.getCount()); slot.grow(change); @@ -161,7 +145,6 @@ public class TileEntityLaserTractorBeam extends TileEntityContainerBlock impleme } } } - Block.spawnAsEntity(world, pos, drop); } } @@ -180,18 +163,15 @@ public class TileEntityLaserTractorBeam extends TileEntityContainerBlock impleme @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(on); data.add(collectedEnergy); data.add(lastFired); - return data; } @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { on = dataStream.readBoolean(); collectedEnergy = dataStream.readDouble(); @@ -214,7 +194,6 @@ public class TileEntityLaserTractorBeam extends TileEntityContainerBlock impleme if (capability == Capabilities.LASER_RECEPTOR_CAPABILITY) { return Capabilities.LASER_RECEPTOR_CAPABILITY.cast(this); } - return super.getCapability(capability, side); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java b/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java index 12b0ca0b7..520a832f0 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java +++ b/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java @@ -51,8 +51,8 @@ import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.items.CapabilityItemHandler; -public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implements IRedstoneControl, - ISpecialConfigData, ISustainedData, ISecurityTile, IComputerIntegration, IUpgradeTile { +public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implements IRedstoneControl, ISpecialConfigData, ISustainedData, ISecurityTile, + IComputerIntegration, IUpgradeTile { public HashList filters = new HashList<>(); public RedstoneControl controlType = RedstoneControl.DISABLED; @@ -64,15 +64,12 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement public int delayTicks; public TileComponentUpgrade upgradeComponent; public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - public String[] methods = {"setDefaultColor", "setRoundRobin", "setAutoEject", "addFilter", "removeFilter", - "addOreFilter", "removeOreFilter", "setSingleItem"}; + public String[] methods = {"setDefaultColor", "setRoundRobin", "setAutoEject", "addFilter", "removeFilter", "addOreFilter", "removeOreFilter", "setSingleItem"}; public TileEntityLogisticalSorter() { - super("machine.logisticalsorter", "LogisticalSorter", - MachineType.LOGISTICAL_SORTER.getStorage(), 3); + super("machine.logisticalsorter", "LogisticalSorter", MachineType.LOGISTICAL_SORTER.getStorage(), 3); inventory = NonNullList.withSize(2, ItemStack.EMPTY); doAutoSync = false; - upgradeComponent = new TileComponentUpgrade(this, 1); upgradeComponent.clearSupportedTypes(); upgradeComponent.setSupported(Upgrade.MUFFLING); @@ -81,10 +78,8 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement @Override public void onUpdate() { super.onUpdate(); - if (!world.isRemote) { delayTicks = Math.max(0, delayTicks - 1); - if (delayTicks == 6) { setActive(false); } @@ -92,7 +87,6 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement if (MekanismUtils.canFunction(this) && delayTicks == 0) { TileEntity back = Coord4D.get(this).offset(facing.getOpposite()).getTileEntity(world); TileEntity front = Coord4D.get(this).offset(facing).getTileEntity(world); - boolean sentItems = false; int min = 0; @@ -100,17 +94,13 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement for (TransporterFilter filter : filters) { for (StackSearcher search = new StackSearcher(back, facing.getOpposite()); search.getSlotCount() >= 0; ) { InvStack invStack = filter.getStackFromInventory(search, singleItem); - if (invStack == null) { break; } - ItemStack itemStack = invStack.getStack(); - if (filter.canFilter(itemStack, !singleItem)) { if (!singleItem && filter instanceof TItemStackFilter) { TItemStackFilter itemFilter = (TItemStackFilter) filter; - if (itemFilter.sizeMode) { min = itemFilter.min; } @@ -118,13 +108,11 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement TransitRequest request = TransitRequest.getFromStack(itemStack); TransitResponse response = emitItemToTransporter(front, request, filter.color, min); - if (!response.isEmpty()) { invStack.use(response.getStack().getCount()); back.markDirty(); setActive(true); sentItems = true; - break outer; } } @@ -132,10 +120,8 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement } if (!sentItems && autoEject) { - TransitRequest request = TransitRequest - .buildInventoryMap(back, facing.getOpposite(), singleItem ? 1 : 64, new StrictFilterFinder()); + TransitRequest request = TransitRequest.buildInventoryMap(back, facing.getOpposite(), singleItem ? 1 : 64, new StrictFilterFinder()); TransitResponse response = emitItemToTransporter(front, request, color, 0); - if (!response.isEmpty()) { response.getInvStack(back, facing).use(response.getStack().getCount()); back.markDirty(); @@ -145,39 +131,29 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement delayTicks = 10; } - if (playersUsing.size() > 0) { for (EntityPlayer player : playersUsing) { - Mekanism.packetHandler - .sendTo(new TileEntityMessage(Coord4D.get(this), getGenericPacket(new TileNetworkList())), - (EntityPlayerMP) player); + Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getGenericPacket(new TileNetworkList())), (EntityPlayerMP) player); } } } } - public TransitResponse emitItemToTransporter(TileEntity front, TransitRequest request, EnumColor filterColor, - int min) { - if (CapabilityUtils - .hasCapability(front, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, facing.getOpposite())) { - ILogisticalTransporter transporter = CapabilityUtils - .getCapability(front, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, facing.getOpposite()); - - if (!roundRobin) { - return TransporterUtils.insert(this, transporter, request, filterColor, true, min); - } else { + public TransitResponse emitItemToTransporter(TileEntity front, TransitRequest request, EnumColor filterColor, int min) { + if (CapabilityUtils.hasCapability(front, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, facing.getOpposite())) { + ILogisticalTransporter transporter = CapabilityUtils.getCapability(front, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, facing.getOpposite()); + if (roundRobin) { return TransporterUtils.insertRR(this, transporter, request, filterColor, true, min); } - } else { - return InventoryUtils.putStackInInventory(front, request, facing, false); + return TransporterUtils.insert(this, transporter, request, filterColor, true, min); } + return InventoryUtils.putStackInInventory(front, request, facing, false); } @Nonnull @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setInteger("controlType", controlType.ordinal()); if (color != null) { @@ -197,20 +173,16 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement filter.write(tagCompound); filterTags.appendTag(tagCompound); } - if (filterTags.tagCount() != 0) { nbtTags.setTag("filters", filterTags); } - return nbtTags; } @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")); } @@ -223,7 +195,6 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement if (nbtTags.hasKey("filters")) { NBTTagList tagList = nbtTags.getTagList("filters", NBT.TAG_COMPOUND); - for (int i = 0; i < tagList.tagCount(); i++) { filters.add(TransporterFilter.readFromNBT(tagList.getCompoundTagAt(i))); } @@ -234,10 +205,8 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement public void handlePacketData(ByteBuf dataStream) { if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { int type = dataStream.readInt(); - if (type == 0) { int clickType = dataStream.readInt(); - if (clickType == 0) { color = TransporterUtils.increment(color); } else if (clickType == 1) { @@ -299,15 +268,12 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement private void readState(ByteBuf dataStream) { controlType = RedstoneControl.values()[dataStream.readInt()]; - int c = dataStream.readInt(); - if (c != -1) { color = TransporterUtils.colors.get(c); } else { color = null; } - autoEject = dataStream.readBoolean(); roundRobin = dataStream.readBoolean(); singleItem = dataStream.readBoolean(); @@ -315,9 +281,7 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement private void readFilters(ByteBuf dataStream) { filters.clear(); - int amount = dataStream.readInt(); - for (int i = 0; i < amount; i++) { filters.add(TransporterFilter.readFromPacket(dataStream)); } @@ -326,11 +290,8 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(0); - data.add(controlType.ordinal()); - if (color != null) { data.add(TransporterUtils.colors.indexOf(color)); } else { @@ -342,21 +303,16 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement data.add(singleItem); data.add(filters.size()); - for (TransporterFilter filter : filters) { filter.write(data); } - return data; } public TileNetworkList getGenericPacket(TileNetworkList data) { super.getNetworkedData(data); - data.add(1); - data.add(controlType.ordinal()); - if (color != null) { data.add(TransporterUtils.colors.indexOf(color)); } else { @@ -366,22 +322,16 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement data.add(autoEject); data.add(roundRobin); data.add(singleItem); - return data; - } public TileNetworkList getFilterPacket(TileNetworkList data) { super.getNetworkedData(data); - data.add(2); - data.add(filters.size()); - for (TransporterFilter filter : filters) { filter.write(data); } - return data; } @@ -421,16 +371,13 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement if (side == facing || side == facing.getOpposite()) { return new int[]{0}; } - return InventoryUtils.EMPTY; } @Override public void openInventory(@Nonnull EntityPlayer player) { if (!world.isRemote) { - Mekanism.packetHandler - .sendToReceivers(new TileEntityMessage(Coord4D.get(this), getFilterPacket(new TileNetworkList())), - new Range4D(Coord4D.get(this))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getFilterPacket(new TileNetworkList())), new Range4D(Coord4D.get(this))); } } @@ -479,25 +426,20 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement if (color != null) { nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color)); } - nbtTags.setBoolean("autoEject", autoEject); nbtTags.setBoolean("roundRobin", roundRobin); nbtTags.setBoolean("singleItem", singleItem); - 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); } - return nbtTags; } @@ -506,16 +448,13 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement if (nbtTags.hasKey("color")) { color = TransporterUtils.colors.get(nbtTags.getInteger("color")); } - autoEject = nbtTags.getBoolean("autoEject"); roundRobin = nbtTags.getBoolean("roundRobin"); singleItem = nbtTags.getBoolean("singleItem"); - rrIndex = nbtTags.getInteger("rrIndex"); if (nbtTags.hasKey("filters")) { NBTTagList tagList = nbtTags.getTagList("filters", NBT.TAG_COMPOUND); - for (int i = 0; i < tagList.tagCount(); i++) { filters.add(TransporterFilter.readFromNBT(tagList.getCompoundTagAt(i))); } @@ -530,7 +469,6 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement @Override public void writeSustainedData(ItemStack itemStack) { ItemDataUtils.setBoolean(itemStack, "hasSorterConfig", true); - if (color != null) { ItemDataUtils.setInt(itemStack, "color", TransporterUtils.colors.indexOf(color)); } @@ -540,13 +478,11 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement ItemDataUtils.setBoolean(itemStack, "singleItem", singleItem); NBTTagList filterTags = new NBTTagList(); - for (TransporterFilter filter : filters) { NBTTagCompound tagCompound = new NBTTagCompound(); filter.write(tagCompound); filterTags.appendTag(tagCompound); } - if (filterTags.tagCount() != 0) { ItemDataUtils.setList(itemStack, "filters", filterTags); } @@ -558,14 +494,11 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement if (ItemDataUtils.hasData(itemStack, "color")) { color = TransporterUtils.colors.get(ItemDataUtils.getInt(itemStack, "color")); } - autoEject = ItemDataUtils.getBoolean(itemStack, "autoEject"); roundRobin = ItemDataUtils.getBoolean(itemStack, "roundRobin"); singleItem = ItemDataUtils.getBoolean(itemStack, "singleItem"); - if (ItemDataUtils.hasData(itemStack, "filters")) { NBTTagList tagList = ItemDataUtils.getList(itemStack, "filters"); - for (int i = 0; i < tagList.tagCount(); i++) { filters.add(TransporterFilter.readFromNBT(tagList.getCompoundTagAt(i))); } @@ -585,60 +518,45 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement if (!(arguments[0] instanceof String)) { return new Object[]{"Invalid parameters."}; } - color = EnumColor.getFromDyeName((String) arguments[0]); - if (color == null) { return new Object[]{"Default color set to null"}; - } else { - return new Object[]{"Default color set to " + color.dyeName}; } + return new Object[]{"Default color set to " + color.dyeName}; } else if (method == 1) { if (!(arguments[0] instanceof Boolean)) { return new Object[]{"Invalid parameters."}; } - roundRobin = (Boolean) arguments[0]; - return new Object[]{"Round-robin mode set to " + roundRobin}; } else if (method == 2) { if (!(arguments[0] instanceof Boolean)) { return new Object[]{"Invalid parameters."}; } - autoEject = (Boolean) arguments[0]; - return new Object[]{"Auto-eject mode set to " + autoEject}; } else if (method == 3) { if (arguments.length != 6 || !(arguments[0] instanceof String) || !(arguments[1] instanceof Double) || - !(arguments[2] instanceof String) || !(arguments[3] instanceof Boolean) || - !(arguments[4] instanceof Double) || !(arguments[5] instanceof Double)) { + !(arguments[2] instanceof String) || !(arguments[3] instanceof Boolean) || + !(arguments[4] instanceof Double) || !(arguments[5] instanceof Double)) { return new Object[]{"Invalid parameters."}; } - TItemStackFilter filter = new TItemStackFilter(); - filter.itemType = new ItemStack(Item.getByNameOrId((String) arguments[0]), 1, - ((Double) arguments[1]).intValue()); - + filter.itemType = new ItemStack(Item.getByNameOrId((String) arguments[0]), 1, ((Double) arguments[1]).intValue()); filter.color = EnumColor.getFromDyeName((String) arguments[2]); filter.sizeMode = (Boolean) arguments[3]; filter.min = ((Double) arguments[4]).intValue(); filter.max = ((Double) arguments[5]).intValue(); filters.add(filter); - return new Object[]{"Added filter."}; } else if (method == 4) { if (arguments.length != 2 || !(arguments[0] instanceof String) || !(arguments[1] instanceof Double)) { return new Object[]{"Invalid parameters."}; } - - ItemStack stack = new ItemStack(Item.getByNameOrId((String) arguments[0]), 1, - ((Double) arguments[1]).intValue()); + ItemStack stack = new ItemStack(Item.getByNameOrId((String) arguments[0]), 1, ((Double) arguments[1]).intValue()); Iterator iter = filters.iterator(); - while (iter.hasNext()) { TransporterFilter filter = iter.next(); - if (filter instanceof TItemStackFilter) { if (StackUtils.equalsWildcard(((TItemStackFilter) filter).itemType, stack)) { iter.remove(); @@ -646,30 +564,24 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement } } } - return new Object[]{"Couldn't find filter."}; } else if (method == 5) { if (arguments.length != 2 || !(arguments[0] instanceof String) || !(arguments[1] instanceof String)) { return new Object[]{"Invalid parameters."}; } - TOreDictFilter filter = new TOreDictFilter(); filter.setOreDictName((String) arguments[0]); filter.color = EnumColor.getFromDyeName((String) arguments[1]); filters.add(filter); - return new Object[]{"Added filter."}; } else if (method == 6) { if (arguments.length != 1 || !(arguments[0] instanceof String)) { return new Object[]{"Invalid parameters."}; } - String ore = (String) arguments[0]; Iterator iter = filters.iterator(); - while (iter.hasNext()) { TransporterFilter filter = iter.next(); - if (filter instanceof TOreDictFilter) { if (((TOreDictFilter) filter).getOreDictName().equals(ore)) { iter.remove(); @@ -677,25 +589,19 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement } } } - return new Object[]{"Couldn't find filter."}; } else if (method == 7) { if (!(arguments[0] instanceof Boolean)) { return new Object[]{"Invalid parameters."}; } - singleItem = (Boolean) arguments[0]; - return new Object[]{"Single-item mode set to " + singleItem}; } } for (EntityPlayer player : playersUsing) { - Mekanism.packetHandler - .sendTo(new TileEntityMessage(Coord4D.get(this), getGenericPacket(new TileNetworkList())), - (EntityPlayerMP) player); + Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getGenericPacket(new TileNetworkList())), (EntityPlayerMP) player); } - return null; } @@ -704,9 +610,7 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement if (isCapabilityDisabled(capability, side)) { return false; } - return capability == Capabilities.CONFIG_CARD_CAPABILITY - || capability == Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY - || super.hasCapability(capability, side); + return capability == Capabilities.CONFIG_CARD_CAPABILITY || capability == Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY || super.hasCapability(capability, side); } @Override @@ -714,11 +618,9 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement if (isCapabilityDisabled(capability, side)) { return null; } - if (capability == Capabilities.CONFIG_CARD_CAPABILITY - || capability == Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY) { + if (capability == Capabilities.CONFIG_CARD_CAPABILITY || capability == Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY) { return (T) this; } - return super.getCapability(capability, side); } @@ -744,8 +646,7 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement return false; } } - return true; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java b/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java index 69f59e9a6..e6a1baf87 100644 --- a/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java +++ b/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java @@ -18,7 +18,6 @@ import mekanism.common.base.IFactory.RecipeType; import mekanism.common.base.ISideConfiguration; import mekanism.common.base.ISustainedData; import mekanism.common.base.ITierUpgradeable; -import mekanism.common.block.states.BlockStateMachine.MachineType; import mekanism.common.capabilities.Capabilities; import mekanism.common.config.MekanismConfig; import mekanism.common.integration.computer.IComputerIntegration; @@ -41,11 +40,11 @@ import net.minecraft.util.NonNullList; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.FMLCommonHandler; -public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine implements IComputerIntegration, - ISideConfiguration, IConfigCardAccess, ITierUpgradeable, ISustainedData { +public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine implements IComputerIntegration, ISideConfiguration, IConfigCardAccess, ITierUpgradeable, + ISustainedData { - private static final String[] methods = new String[]{"getEnergy", "getProgress", "facing", "canOperate", - "getMaxEnergy", "getEnergyNeeded", "getInfuse", "getInfuseNeeded"}; + private static final String[] methods = new String[]{"getEnergy", "getProgress", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded", "getInfuse", + "getInfuseNeeded"}; /** * The maxiumum amount of infuse this machine can store. */ @@ -58,10 +57,8 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i public TileComponentConfig configComponent; public TileEntityMetallurgicInfuser() { - super("machine.metalinfuser", "MetallurgicInfuser", - MekanismConfig.current().storage.metallurgicInfuser.val(), + super("machine.metalinfuser", "MetallurgicInfuser", MekanismConfig.current().storage.metallurgicInfuser.val(), MekanismConfig.current().usage.metallurgicInfuser.val(), 0, 200); - configComponent = new TileComponentConfig(this, TransmissionType.ITEM); configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); @@ -83,10 +80,8 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i @Override public void onUpdate() { super.onUpdate(); - if (!world.isRemote) { ChargeUtils.discharge(4, this); - if (!inventory.get(1).isEmpty()) { InfuseObject pendingInfuseInput = InfuseRegistry.getObject(inventory.get(1)); if (pendingInfuseInput != null) { @@ -100,27 +95,21 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i } MetallurgicInfuserRecipe recipe = RecipeHandler.getMetallurgicInfuserRecipe(getInput()); - if (canOperate(recipe) && MekanismUtils.canFunction(this) && getEnergy() >= energyPerTick) { setActive(true); setEnergy(getEnergy() - energyPerTick); - if ((operatingTicks + 1) < ticksRequired) { operatingTicks++; } else { operate(recipe); operatingTicks = 0; } - } else { - if (prevEnergy >= getEnergy()) { - setActive(false); - } + } else if (prevEnergy >= getEnergy()) { + setActive(false); } - if (!canOperate(recipe)) { operatingTicks = 0; } - prevEnergy = getEnergy(); } } @@ -156,8 +145,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i factory.upgradeComponent.readFrom(upgradeComponent); factory.upgradeComponent.setUpgradeSlot(0); factory.ejectorComponent.readFrom(ejectorComponent); - factory.ejectorComponent - .setOutputData(TransmissionType.ITEM, factory.configComponent.getOutputs(TransmissionType.ITEM).get(2)); + factory.ejectorComponent.setOutputData(TransmissionType.ITEM, factory.configComponent.getOutputs(TransmissionType.ITEM).get(2)); factory.setRecipeType(type); factory.upgradeComponent.setSupported(Upgrade.GAS, type.fuelEnergyUpgrades()); factory.securityComponent.readFrom(securityComponent); @@ -179,10 +167,8 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i for (Upgrade upgrade : factory.upgradeComponent.getSupportedTypes()) { factory.recalculateUpgradables(upgrade); } - factory.upgraded = true; factory.markDirty(); - return true; } @@ -190,10 +176,8 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i public boolean canExtractItem(int slotID, @Nonnull ItemStack itemstack, @Nonnull EnumFacing side) { if (slotID == 4) { return ChargeUtils.canBeOutputted(itemstack, false); - } else { - return slotID == 3; } - + return slotID == 3; } @Override @@ -201,22 +185,17 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i if (slotID == 3) { return false; } else if (slotID == 1) { - return InfuseRegistry.getObject(itemstack) != null && (infuseStored.getType() == null - || infuseStored.getType() == InfuseRegistry.getObject(itemstack).type); + return InfuseRegistry.getObject(itemstack) != null && (infuseStored.getType() == null || infuseStored.getType() == InfuseRegistry.getObject(itemstack).type); } else if (slotID == 0) { - return itemstack.getItem() == MekanismItems.SpeedUpgrade - || itemstack.getItem() == MekanismItems.EnergyUpgrade; + return itemstack.getItem() == MekanismItems.SpeedUpgrade || itemstack.getItem() == MekanismItems.EnergyUpgrade; } else if (slotID == 2) { if (infuseStored.getType() != null) { return RecipeHandler.getMetallurgicInfuserRecipe(new InfusionInput(infuseStored, itemstack)) != null; - } else { - return Recipe.METALLURGIC_INFUSER.get().keySet().stream() - .anyMatch(input -> input.inputStack.isItemEqual(itemstack)); } + return Recipe.METALLURGIC_INFUSER.get().keySet().stream().anyMatch(input -> input.inputStack.isItemEqual(itemstack)); } else if (slotID == 4) { return ChargeUtils.canBeDischarged(itemstack); } - return false; } @@ -226,7 +205,6 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i public void operate(MetallurgicInfuserRecipe recipe) { recipe.output(inventory, 2, 3, infuseStored); - markDirty(); ejectorComponent.outputItems(); } @@ -242,7 +220,6 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - int amount = nbtTags.getInteger("infuseStored"); if (amount != 0) { infuseStored.setAmount(amount); @@ -254,16 +231,13 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - if (infuseStored.getType() != null) { nbtTags.setString("type", infuseStored.getType().name); nbtTags.setInteger("infuseStored", infuseStored.getAmount()); } else { nbtTags.setString("type", "null"); } - nbtTags.setBoolean("sideDataStored", true); - return nbtTags; } @@ -280,7 +254,6 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i } super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { int amount = dataStream.readInt(); if (amount > 0) { @@ -295,12 +268,10 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(infuseStored.getAmount()); if (infuseStored.getAmount() > 0) { data.add(infuseStored.getType().name); } - return data; } @@ -375,14 +346,12 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i if (capability == Capabilities.CONFIG_CARD_CAPABILITY) { return Capabilities.CONFIG_CARD_CAPABILITY.cast(this); } - return super.getCapability(capability, side); } @Override public boolean isCapabilityDisabled(@Nonnull Capability capability, EnumFacing side) { - return configComponent.isCapabilityDisabled(capability, side, facing) || super - .isCapabilityDisabled(capability, side); + return configComponent.isCapabilityDisabled(capability, side, facing) || super.isCapabilityDisabled(capability, side); } @Override @@ -394,4 +363,4 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i public void readSustainedData(ItemStack itemStack) { infuseStored.readSustainedData(itemStack); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityMultiblock.java b/src/main/java/mekanism/common/tile/TileEntityMultiblock.java index 43d2a2dd3..49f281af5 100644 --- a/src/main/java/mekanism/common/tile/TileEntityMultiblock.java +++ b/src/main/java/mekanism/common/tile/TileEntityMultiblock.java @@ -4,9 +4,9 @@ import io.netty.buffer.ByteBuf; import javax.annotation.Nonnull; import mekanism.api.Coord4D; import mekanism.api.Range4D; +import mekanism.api.TileNetworkList; import mekanism.common.Mekanism; import mekanism.common.PacketHandler; -import mekanism.api.TileNetworkList; import mekanism.common.multiblock.IMultiblock; import mekanism.common.multiblock.IStructuralMultiblock; import mekanism.common.multiblock.MultiblockCache; @@ -28,8 +28,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public abstract class TileEntityMultiblock> extends TileEntityContainerBlock implements - IMultiblock { +public abstract class TileEntityMultiblock> extends TileEntityContainerBlock implements IMultiblock { /** * The multiblock data for this structure. @@ -76,44 +75,35 @@ public abstract class TileEntityMultiblock> extend if (structure == null) { structure = getNewStructure(); } - if (structure != null && structure.renderLocation != null && clientHasStructure && isRendering) { if (!prevStructure) { Mekanism.proxy.doMultiblockSparkle(this, structure.renderLocation.getPos(), structure.volLength, structure.volWidth, structure.volHeight, tile -> MultiblockManager.areEqual(this, tile)); } } - prevStructure = clientHasStructure; } - - if (playersUsing.size() > 0 && ((world.isRemote && !clientHasStructure) || (!world.isRemote - && structure == null))) { + if (playersUsing.size() > 0 && ((world.isRemote && !clientHasStructure) || (!world.isRemote && structure == null))) { for (EntityPlayer player : playersUsing) { player.closeScreen(); } } - if (!world.isRemote) { if (structure == null) { isRendering = false; - if (cachedID != null) { getManager().updateCache(this); } } - if (structure == null && ticker == 5) { doUpdate(); } - if (prevStructure == (structure == null)) { if (structure != null && !getSynchronizedData().hasRenderer) { getSynchronizedData().hasRenderer = true; isRendering = true; sendStructure = true; } - for (EnumFacing side : EnumFacing.VALUES) { Coord4D obj = Coord4D.get(this).offset(side); if (structure != null && (structure.locations.contains(obj) || structure.internalLocations @@ -121,23 +111,19 @@ public abstract class TileEntityMultiblock> extend continue; } TileEntity tile = obj.getTileEntity(world); - - if (!obj.isAirBlock(world) && (tile == null || tile.getClass() != getClass()) && !( - tile instanceof IStructuralMultiblock || tile instanceof IMultiblock)) { + if (!obj.isAirBlock(world) && (tile == null || tile.getClass() != getClass()) && + !(tile instanceof IStructuralMultiblock || tile instanceof IMultiblock)) { MekanismUtils.notifyNeighborofChange(world, obj, getPos()); } } - Mekanism.packetHandler.sendToReceivers( - new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); } prevStructure = structure != null; if (structure != null) { getSynchronizedData().didTick = false; - if (getSynchronizedData().inventoryID != null) { cachedData.sync(getSynchronizedData()); cachedID = getSynchronizedData().inventoryID; @@ -151,7 +137,6 @@ public abstract class TileEntityMultiblock> extend public void doUpdate() { if (!world.isRemote && (structure == null || !getSynchronizedData().didTick)) { getProtocol().doUpdate(); - if (structure != null) { getSynchronizedData().didTick = true; } @@ -162,7 +147,6 @@ public abstract class TileEntityMultiblock> extend if (structure != null) { for (Coord4D obj : getSynchronizedData().locations) { TileEntityMultiblock tileEntity = (TileEntityMultiblock) obj.getTileEntity(world); - if (tileEntity != null && tileEntity.isRendering) { Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(tileEntity))); @@ -212,7 +196,6 @@ public abstract class TileEntityMultiblock> extend @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { if (structure == null) { structure = getNewStructure(); @@ -226,7 +209,6 @@ public abstract class TileEntityMultiblock> extend getSynchronizedData().volHeight = dataStream.readInt(); getSynchronizedData().volWidth = dataStream.readInt(); getSynchronizedData().volLength = dataStream.readInt(); - getSynchronizedData().renderLocation = Coord4D.read(dataStream); if (dataStream.readBoolean()) { getSynchronizedData().inventoryID = PacketHandler.readString(dataStream); @@ -241,7 +223,6 @@ public abstract class TileEntityMultiblock> extend @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - if (structure == null) { if (nbtTags.hasKey("cachedID")) { cachedID = nbtTags.getString("cachedID"); @@ -254,12 +235,10 @@ public abstract class TileEntityMultiblock> extend @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - if (cachedID != null) { nbtTags.setString("cachedID", cachedID); cachedData.save(nbtTags); } - return nbtTags; } @@ -289,4 +268,4 @@ public abstract class TileEntityMultiblock> extend public T getSynchronizedData() { return structure; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityObsidianTNT.java b/src/main/java/mekanism/common/tile/TileEntityObsidianTNT.java deleted file mode 100644 index 8a69ce2ee..000000000 --- a/src/main/java/mekanism/common/tile/TileEntityObsidianTNT.java +++ /dev/null @@ -1,8 +0,0 @@ -package mekanism.common.tile; - -import net.minecraft.tileentity.TileEntity; - -@Deprecated //Don't need this any more? -public class TileEntityObsidianTNT extends TileEntity { - -} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityOredictionificator.java b/src/main/java/mekanism/common/tile/TileEntityOredictionificator.java index a96d6e508..b23d96e15 100644 --- a/src/main/java/mekanism/common/tile/TileEntityOredictionificator.java +++ b/src/main/java/mekanism/common/tile/TileEntityOredictionificator.java @@ -37,8 +37,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.oredict.OreDictionary; -public class TileEntityOredictionificator extends TileEntityContainerBlock implements IRedstoneControl, - ISpecialConfigData, ISustainedData, ISecurityTile { +public class TileEntityOredictionificator extends TileEntityContainerBlock implements IRedstoneControl, ISpecialConfigData, ISustainedData, ISecurityTile { public static final int MAX_LENGTH = 24; private static final int[] SLOTS = {0, 1}; @@ -52,7 +51,6 @@ public class TileEntityOredictionificator extends TileEntityContainerBlock imple public TileEntityOredictionificator() { super(MachineType.OREDICTIONIFICATOR.blockName); - inventory = NonNullList.withSize(2, ItemStack.EMPTY); doAutoSync = false; } @@ -62,40 +60,29 @@ public class TileEntityOredictionificator extends TileEntityContainerBlock imple if (!world.isRemote) { if (playersUsing.size() > 0) { for (EntityPlayer player : playersUsing) { - Mekanism.packetHandler - .sendTo(new TileEntityMessage(Coord4D.get(this), getGenericPacket(new TileNetworkList())), - (EntityPlayerMP) player); + Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getGenericPacket(new TileNetworkList())), (EntityPlayerMP) player); } } didProcess = false; - - if (MekanismUtils.canFunction(this) && !inventory.get(0).isEmpty() - && getValidName(inventory.get(0)) != null) { + if (MekanismUtils.canFunction(this) && !inventory.get(0).isEmpty() && getValidName(inventory.get(0)) != null) { ItemStack result = getResult(inventory.get(0)); - if (!result.isEmpty()) { if (inventory.get(1).isEmpty()) { inventory.get(0).shrink(1); - if (inventory.get(0).getCount() <= 0) { inventory.set(0, ItemStack.EMPTY); } - inventory.set(1, result); didProcess = true; - } else if (inventory.get(1).isItemEqual(result) && inventory.get(1).getCount() < inventory.get(1) - .getMaxStackSize()) { + } else if (inventory.get(1).isItemEqual(result) && inventory.get(1).getCount() < inventory.get(1).getMaxStackSize()) { inventory.get(0).shrink(1); - if (inventory.get(0).getCount() <= 0) { inventory.set(0, ItemStack.EMPTY); } - inventory.get(1).grow(1); didProcess = true; } - markDirty(); } } @@ -104,7 +91,6 @@ public class TileEntityOredictionificator extends TileEntityContainerBlock imple public String getValidName(ItemStack stack) { List def = OreDictCache.getOreDictName(stack); - for (String s : def) { for (String pre : possibleFilters) { if (s.startsWith(pre)) { @@ -112,29 +98,23 @@ public class TileEntityOredictionificator extends TileEntityContainerBlock imple } } } - return null; } public ItemStack getResult(ItemStack stack) { String s = getValidName(stack); - if (s == null) { return ItemStack.EMPTY; } - List ores = OreDictionary.getOres(s); - for (OredictionificatorFilter filter : filters) { if (filter.filter.equals(s)) { if (ores.size() - 1 >= filter.index) { return StackUtils.size(ores.get(filter.index), 1); - } else { - return ItemStack.EMPTY; } + return ItemStack.EMPTY; } } - return ItemStack.EMPTY; } @@ -162,33 +142,25 @@ public class TileEntityOredictionificator extends TileEntityContainerBlock imple @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setInteger("controlType", controlType.ordinal()); - NBTTagList filterTags = new NBTTagList(); - for (OredictionificatorFilter filter : filters) { NBTTagCompound tagCompound = new NBTTagCompound(); filter.write(tagCompound); filterTags.appendTag(tagCompound); } - if (filterTags.tagCount() != 0) { nbtTags.setTag("filters", filterTags); } - return nbtTags; } @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - if (nbtTags.hasKey("filters")) { NBTTagList tagList = nbtTags.getTagList("filters", NBT.TAG_COMPOUND); - for (int i = 0; i < tagList.tagCount(); i++) { filters.add(OredictionificatorFilter.readFromNBT(tagList.getCompoundTagAt(i))); } @@ -203,18 +175,14 @@ public class TileEntityOredictionificator extends TileEntityContainerBlock imple @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { int type = dataStream.readInt(); - if (type == 0) { controlType = RedstoneControl.values()[dataStream.readInt()]; didProcess = dataStream.readBoolean(); - filters.clear(); int amount = dataStream.readInt(); - for (int i = 0; i < amount; i++) { filters.add(OredictionificatorFilter.readFromPacket(dataStream)); } @@ -223,9 +191,7 @@ public class TileEntityOredictionificator extends TileEntityContainerBlock imple didProcess = dataStream.readBoolean(); } else if (type == 2) { filters.clear(); - int amount = dataStream.readInt(); - for (int i = 0; i < amount; i++) { filters.add(OredictionificatorFilter.readFromPacket(dataStream)); } @@ -236,70 +202,52 @@ public class TileEntityOredictionificator extends TileEntityContainerBlock imple @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(0); - data.add(controlType.ordinal()); data.add(didProcess); - data.add(filters.size()); - for (OredictionificatorFilter filter : filters) { filter.write(data); } - return data; } public TileNetworkList getGenericPacket(TileNetworkList data) { super.getNetworkedData(data); - data.add(1); - data.add(controlType.ordinal()); data.add(didProcess); - return data; - } public TileNetworkList getFilterPacket(TileNetworkList data) { super.getNetworkedData(data); - data.add(2); - data.add(filters.size()); - for (OredictionificatorFilter filter : filters) { filter.write(data); } - return data; } @Override public void openInventory(@Nonnull EntityPlayer player) { if (!world.isRemote) { - Mekanism.packetHandler - .sendToReceivers(new TileEntityMessage(Coord4D.get(this), getFilterPacket(new TileNetworkList())), - new Range4D(Coord4D.get(this))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getFilterPacket(new TileNetworkList())), new Range4D(Coord4D.get(this))); } } @Override public NBTTagCompound getConfigurationData(NBTTagCompound nbtTags) { NBTTagList filterTags = new NBTTagList(); - for (OredictionificatorFilter filter : filters) { NBTTagCompound tagCompound = new NBTTagCompound(); filter.write(tagCompound); filterTags.appendTag(tagCompound); } - if (filterTags.tagCount() != 0) { nbtTags.setTag("filters", filterTags); } - return nbtTags; } @@ -307,7 +255,6 @@ public class TileEntityOredictionificator extends TileEntityContainerBlock imple public void setConfigurationData(NBTTagCompound nbtTags) { if (nbtTags.hasKey("filters")) { NBTTagList tagList = nbtTags.getTagList("filters", NBT.TAG_COMPOUND); - for (int i = 0; i < tagList.tagCount(); i++) { filters.add(OredictionificatorFilter.readFromNBT(tagList.getCompoundTagAt(i))); } @@ -322,15 +269,12 @@ public class TileEntityOredictionificator extends TileEntityContainerBlock imple @Override public void writeSustainedData(ItemStack itemStack) { ItemDataUtils.setBoolean(itemStack, "hasOredictionificatorConfig", true); - NBTTagList filterTags = new NBTTagList(); - for (OredictionificatorFilter filter : filters) { NBTTagCompound tagCompound = new NBTTagCompound(); filter.write(tagCompound); filterTags.appendTag(tagCompound); } - if (filterTags.tagCount() != 0) { ItemDataUtils.setList(itemStack, "filters", filterTags); } @@ -341,7 +285,6 @@ public class TileEntityOredictionificator extends TileEntityContainerBlock imple if (ItemDataUtils.hasData(itemStack, "hasOredictionificatorConfig")) { if (ItemDataUtils.hasData(itemStack, "filters")) { NBTTagList tagList = ItemDataUtils.getList(itemStack, "filters"); - for (int i = 0; i < tagList.tagCount(); i++) { filters.add(OredictionificatorFilter.readFromNBT(tagList.getCompoundTagAt(i))); } @@ -374,20 +317,16 @@ public class TileEntityOredictionificator extends TileEntityContainerBlock imple if (isCapabilityDisabled(capability, side)) { return false; } - return capability == Capabilities.CONFIG_CARD_CAPABILITY - || capability == Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY - || super.hasCapability(capability, side); + return capability == Capabilities.CONFIG_CARD_CAPABILITY || capability == Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY || super.hasCapability(capability, side); } @Override public T getCapability(@Nonnull Capability capability, EnumFacing side) { if (isCapabilityDisabled(capability, side)) { return null; - } else if (capability == Capabilities.CONFIG_CARD_CAPABILITY - || capability == Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY) { + } else if (capability == Capabilities.CONFIG_CARD_CAPABILITY || capability == Capabilities.SPECIAL_CONFIG_DATA_CAPABILITY) { return (T) this; } - return super.getCapability(capability, side); } @@ -411,17 +350,13 @@ public class TileEntityOredictionificator extends TileEntityContainerBlock imple public static OredictionificatorFilter readFromNBT(NBTTagCompound nbtTags) { OredictionificatorFilter filter = new OredictionificatorFilter(); - filter.read(nbtTags); - return filter; } public static OredictionificatorFilter readFromPacket(ByteBuf dataStream) { OredictionificatorFilter filter = new OredictionificatorFilter(); - filter.read(dataStream); - return filter; } @@ -450,7 +385,6 @@ public class TileEntityOredictionificator extends TileEntityContainerBlock imple OredictionificatorFilter newFilter = new OredictionificatorFilter(); newFilter.filter = filter; newFilter.index = index; - return newFilter; } @@ -466,4 +400,4 @@ public class TileEntityOredictionificator extends TileEntityContainerBlock imple return obj instanceof OredictionificatorFilter && ((OredictionificatorFilter) obj).filter.equals(filter); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityOsmiumCompressor.java b/src/main/java/mekanism/common/tile/TileEntityOsmiumCompressor.java index 17dbf81d8..85d36b775 100644 --- a/src/main/java/mekanism/common/tile/TileEntityOsmiumCompressor.java +++ b/src/main/java/mekanism/common/tile/TileEntityOsmiumCompressor.java @@ -13,9 +13,8 @@ import net.minecraft.util.EnumFacing; public class TileEntityOsmiumCompressor extends TileEntityAdvancedElectricMachine { public TileEntityOsmiumCompressor() { - super("compressor", "OsmiumCompressor", - MachineType.OSMIUM_COMPRESSOR.getStorage(), - MachineType.OSMIUM_COMPRESSOR.getUsage(), BASE_TICKS_REQUIRED, BASE_GAS_PER_TICK); + super("compressor", "OsmiumCompressor", MachineType.OSMIUM_COMPRESSOR.getStorage(), MachineType.OSMIUM_COMPRESSOR.getUsage(), + BASE_TICKS_REQUIRED, BASE_GAS_PER_TICK); } @Override @@ -40,4 +39,4 @@ public class TileEntityOsmiumCompressor extends TileEntityAdvancedElectricMachin public boolean canReceiveGas(EnumFacing side, Gas type) { return gasTank.canReceive(type) && isValidGas(type); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityPRC.java b/src/main/java/mekanism/common/tile/TileEntityPRC.java index ed402513f..fce225196 100644 --- a/src/main/java/mekanism/common/tile/TileEntityPRC.java +++ b/src/main/java/mekanism/common/tile/TileEntityPRC.java @@ -46,24 +46,19 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fml.common.FMLCommonHandler; -public class TileEntityPRC extends - TileEntityBasicMachine implements IFluidHandlerWrapper, - IGasHandler, ISustainedData, ITankManager { +public class TileEntityPRC extends TileEntityBasicMachine implements IFluidHandlerWrapper, IGasHandler, + ISustainedData, ITankManager { - private static final String[] methods = new String[]{"getEnergy", "getProgress", "isActive", "facing", "canOperate", - "getMaxEnergy", "getEnergyNeeded", "getFluidStored", "getGasStored"}; + private static final String[] methods = new String[]{"getEnergy", "getProgress", "isActive", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded", + "getFluidStored", "getGasStored"}; public FluidTank inputFluidTank = new FluidTank(10000); public GasTank inputGasTank = new GasTank(10000); public GasTank outputGasTank = new GasTank(10000); public TileEntityPRC() { - super("prc", MachineType.PRESSURIZED_REACTION_CHAMBER.blockName, - MachineType.PRESSURIZED_REACTION_CHAMBER.getStorage(), - MachineType.PRESSURIZED_REACTION_CHAMBER.getUsage(), 3, 100, - new ResourceLocation("mekanism", "gui/GuiPRC.png")); - - configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY, - TransmissionType.FLUID, TransmissionType.GAS); + super("prc", MachineType.PRESSURIZED_REACTION_CHAMBER.blockName, MachineType.PRESSURIZED_REACTION_CHAMBER.getStorage(), + MachineType.PRESSURIZED_REACTION_CHAMBER.getUsage(), 3, 100, new ResourceLocation("mekanism", "gui/GuiPRC.png")); + configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY, TransmissionType.FLUID, TransmissionType.GAS); configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); configComponent.addOutput(TransmissionType.ITEM, new SideData("Input", EnumColor.DARK_RED, new int[]{0})); @@ -96,36 +91,25 @@ public class TileEntityPRC extends if (!world.isRemote) { PressurizedRecipe recipe = getRecipe(); - ChargeUtils.discharge(1, this); - - if (canOperate(recipe) && MekanismUtils.canFunction(this) && getEnergy() >= MekanismUtils - .getEnergyPerTick(this, BASE_ENERGY_PER_TICK + recipe.extraEnergy)) { + if (canOperate(recipe) && MekanismUtils.canFunction(this) && + getEnergy() >= MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK + recipe.extraEnergy)) { boolean update = BASE_TICKS_REQUIRED != recipe.ticks; - BASE_TICKS_REQUIRED = recipe.ticks; - if (update) { recalculateUpgradables(Upgrade.SPEED); } - setActive(true); - if ((operatingTicks + 1) < ticksRequired) { operatingTicks++; - electricityStored -= MekanismUtils - .getEnergyPerTick(this, BASE_ENERGY_PER_TICK + recipe.extraEnergy); - } else if ((operatingTicks + 1) >= ticksRequired && getEnergy() >= MekanismUtils - .getEnergyPerTick(this, BASE_ENERGY_PER_TICK + recipe.extraEnergy)) { + electricityStored -= MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK + recipe.extraEnergy); + } else if ((operatingTicks + 1) >= ticksRequired && getEnergy() >= MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK + recipe.extraEnergy)) { operate(recipe); - operatingTicks = 0; - electricityStored -= MekanismUtils - .getEnergyPerTick(this, BASE_ENERGY_PER_TICK + recipe.extraEnergy); + electricityStored -= MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK + recipe.extraEnergy); } } else { BASE_TICKS_REQUIRED = 100; - if (prevEnergy >= getEnergy()) { setActive(false); } @@ -134,7 +118,6 @@ public class TileEntityPRC extends if (!canOperate(recipe)) { operatingTicks = 0; } - prevEnergy = getEnergy(); } } @@ -148,18 +131,15 @@ public class TileEntityPRC extends } else if (slotID == 3) { return itemstack.getItem() instanceof ItemUpgrade; } - return false; } @Override public PressurizedRecipe getRecipe() { PressurizedInput input = getInput(); - if (cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) { cachedRecipe = RecipeHandler.getPRCRecipe(input); } - return cachedRecipe; } @@ -171,7 +151,6 @@ public class TileEntityPRC extends @Override public void operate(PressurizedRecipe recipe) { recipe.operate(inventory, inputFluidTank, inputGasTank, outputGasTank); - markDirty(); ejectorComponent.outputItems(); } @@ -185,10 +164,8 @@ public class TileEntityPRC extends public boolean canExtractItem(int slotID, @Nonnull ItemStack itemstack, @Nonnull EnumFacing side) { if (slotID == 1) { return ChargeUtils.canBeOutputted(itemstack, false); - } else { - return slotID == 2 || slotID == 4; } - + return slotID == 2 || slotID == 4; } @Override @@ -203,7 +180,6 @@ public class TileEntityPRC extends @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { TileUtils.readTankData(dataStream, inputFluidTank); TileUtils.readTankData(dataStream, inputGasTank); @@ -214,7 +190,6 @@ public class TileEntityPRC extends @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - inputFluidTank.readFromNBT(nbtTags.getCompoundTag("inputFluidTank")); inputGasTank.read(nbtTags.getCompoundTag("inputGasTank")); outputGasTank.read(nbtTags.getCompoundTag("outputGasTank")); @@ -224,11 +199,9 @@ public class TileEntityPRC extends @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setTag("inputFluidTank", inputFluidTank.writeToNBT(new NBTTagCompound())); nbtTags.setTag("inputGasTank", inputGasTank.write(new NBTTagCompound())); nbtTags.setTag("outputGasTank", outputGasTank.write(new NBTTagCompound())); - return nbtTags; } @@ -279,7 +252,6 @@ public class TileEntityPRC extends if (canFill(from, resource)) { return inputFluidTank.fill(resource, doFill); } - return 0; } @@ -296,11 +268,9 @@ public class TileEntityPRC extends @Override public boolean canFill(EnumFacing from, @Nullable FluidStack fluid) { SideData data = configComponent.getOutput(TransmissionType.FLUID, from, facing); - if (data.hasSlot(0)) { return inputFluidTank.getFluid() == null || inputFluidTank.getFluid().isFluidEqual(fluid); } - return false; } @@ -312,7 +282,6 @@ public class TileEntityPRC extends @Override public FluidTankInfo[] getTankInfo(EnumFacing from) { SideData data = configComponent.getOutput(TransmissionType.FLUID, from, facing); - return data.getFluidTankInfo(this); } @@ -326,7 +295,6 @@ public class TileEntityPRC extends if (canReceiveGas(side, stack.getGas())) { return inputGasTank.receive(stack, doTransfer); } - return 0; } @@ -335,14 +303,12 @@ public class TileEntityPRC extends if (canDrawGas(side, null)) { return outputGasTank.draw(amount, doTransfer); } - return null; } @Override public boolean canReceiveGas(EnumFacing side, Gas type) { - return configComponent.getOutput(TransmissionType.GAS, side, facing).hasSlot(1) && inputGasTank - .canReceive(type); + return configComponent.getOutput(TransmissionType.GAS, side, facing).hasSlot(1) && inputGasTank.canReceive(type); } @Override @@ -361,8 +327,7 @@ public class TileEntityPRC extends if (isCapabilityDisabled(capability, side)) { return false; } - return capability == Capabilities.GAS_HANDLER_CAPABILITY - || capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, side); + return capability == Capabilities.GAS_HANDLER_CAPABILITY || capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, side); } @Override @@ -374,27 +339,22 @@ public class TileEntityPRC extends } else if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(new FluidHandlerWrapper(this, side)); } - return super.getCapability(capability, side); } @Override public boolean isCapabilityDisabled(@Nonnull Capability capability, EnumFacing side) { - return configComponent.isCapabilityDisabled(capability, side, facing) || super - .isCapabilityDisabled(capability, side); + return configComponent.isCapabilityDisabled(capability, side, facing) || super.isCapabilityDisabled(capability, side); } @Override public void writeSustainedData(ItemStack itemStack) { if (inputFluidTank.getFluid() != null) { - ItemDataUtils - .setCompound(itemStack, "inputFluidTank", inputFluidTank.getFluid().writeToNBT(new NBTTagCompound())); + ItemDataUtils.setCompound(itemStack, "inputFluidTank", inputFluidTank.getFluid().writeToNBT(new NBTTagCompound())); } - if (inputGasTank.getGas() != null) { ItemDataUtils.setCompound(itemStack, "inputGasTank", inputGasTank.getGas().write(new NBTTagCompound())); } - if (outputGasTank.getGas() != null) { ItemDataUtils.setCompound(itemStack, "outputGasTank", outputGasTank.getGas().write(new NBTTagCompound())); } @@ -402,8 +362,7 @@ public class TileEntityPRC extends @Override public void readSustainedData(ItemStack itemStack) { - inputFluidTank - .setFluid(FluidStack.loadFluidStackFromNBT(ItemDataUtils.getCompound(itemStack, "inputFluidTank"))); + inputFluidTank.setFluid(FluidStack.loadFluidStackFromNBT(ItemDataUtils.getCompound(itemStack, "inputFluidTank"))); inputGasTank.setGas(GasStack.readFromNBT(ItemDataUtils.getCompound(itemStack, "inputGasTank"))); outputGasTank.setGas(GasStack.readFromNBT(ItemDataUtils.getCompound(itemStack, "outputGasTank"))); } @@ -412,4 +371,4 @@ public class TileEntityPRC extends public Object[] getTanks() { return new Object[]{inputFluidTank, inputGasTank, outputGasTank}; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityPersonalChest.java b/src/main/java/mekanism/common/tile/TileEntityPersonalChest.java index a652c2007..62060bb5a 100644 --- a/src/main/java/mekanism/common/tile/TileEntityPersonalChest.java +++ b/src/main/java/mekanism/common/tile/TileEntityPersonalChest.java @@ -28,7 +28,6 @@ public class TileEntityPersonalChest extends TileEntityContainerBlock implements public TileEntityPersonalChest() { super("PersonalChest"); inventory = NonNullList.withSize(54, ItemStack.EMPTY); - securityComponent = new TileComponentSecurity(this); } @@ -36,7 +35,6 @@ public class TileEntityPersonalChest extends TileEntityContainerBlock implements public void onUpdate() { prevLidAngle = lidAngle; float increment = 0.1F; - if ((playersUsing.size() > 0) && (lidAngle == 0.0F)) { world.playSound(null, getPos().getX() + 0.5F, getPos().getY() + 0.5D, getPos().getZ() + 0.5F, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.5F, (world.rand.nextFloat() * 0.1F) + 0.9F); @@ -44,25 +42,19 @@ public class TileEntityPersonalChest extends TileEntityContainerBlock implements 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 (lidAngle > 1.0F) { lidAngle = 1.0F; } - float split = 0.5F; - if (lidAngle < split && angle >= split) { world.playSound(null, getPos().getX() + 0.5D, getPos().getY() + 0.5D, getPos().getZ() + 0.5D, - SoundEvents.BLOCK_CHEST_CLOSE, SoundCategory.BLOCKS, 0.5F, - (world.rand.nextFloat() * 0.1F) + 0.9F); + SoundEvents.BLOCK_CHEST_CLOSE, SoundCategory.BLOCKS, 0.5F, (world.rand.nextFloat() * 0.1F) + 0.9F); } - if (lidAngle < 0.0F) { lidAngle = 0.0F; } @@ -79,17 +71,13 @@ public class TileEntityPersonalChest extends TileEntityContainerBlock implements public int[] getSlotsForFace(@Nonnull EnumFacing side) { if (side == EnumFacing.DOWN || SecurityUtils.getSecurity(this, Side.SERVER) != SecurityMode.PUBLIC) { return InventoryUtils.EMPTY; - } else { - if (INV == null) { - INV = new int[54]; - - for (int i = 0; i < INV.length; i++) { - INV[i] = i; - } + } else if (INV == null) { + INV = new int[54]; + for (int i = 0; i < INV.length; i++) { + INV[i] = i; } - - return INV; } + return INV; } @Override @@ -119,4 +107,4 @@ public class TileEntityPersonalChest extends TileEntityContainerBlock implements public TileComponentSecurity getSecurity() { return securityComponent; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityPrecisionSawmill.java b/src/main/java/mekanism/common/tile/TileEntityPrecisionSawmill.java index dae746ed7..e0f1cb2e2 100644 --- a/src/main/java/mekanism/common/tile/TileEntityPrecisionSawmill.java +++ b/src/main/java/mekanism/common/tile/TileEntityPrecisionSawmill.java @@ -11,14 +11,12 @@ import mekanism.common.util.MekanismUtils.ResourceType; public class TileEntityPrecisionSawmill extends TileEntityChanceMachine { public TileEntityPrecisionSawmill() { - super("sawmill", "PrecisionSawmill", - MachineType.PRECISION_SAWMILL.getStorage(), - MachineType.PRECISION_SAWMILL.getUsage(), 200, - MekanismUtils.getResource(ResourceType.GUI, "GuiBasicMachine.png")); + super("sawmill", "PrecisionSawmill", MachineType.PRECISION_SAWMILL.getStorage(), MachineType.PRECISION_SAWMILL.getUsage(), 200, + MekanismUtils.getResource(ResourceType.GUI, "GuiBasicMachine.png")); } @Override public Map getRecipes() { return Recipe.PRECISION_SAWMILL.get(); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityPressureDisperser.java b/src/main/java/mekanism/common/tile/TileEntityPressureDisperser.java index 489df661f..3b80eba42 100644 --- a/src/main/java/mekanism/common/tile/TileEntityPressureDisperser.java +++ b/src/main/java/mekanism/common/tile/TileEntityPressureDisperser.java @@ -7,4 +7,4 @@ public class TileEntityPressureDisperser extends TileEntityBasicBlock { @Override public void onUpdate() { } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityPurificationChamber.java b/src/main/java/mekanism/common/tile/TileEntityPurificationChamber.java index 0a5fb77d8..6f98eb886 100644 --- a/src/main/java/mekanism/common/tile/TileEntityPurificationChamber.java +++ b/src/main/java/mekanism/common/tile/TileEntityPurificationChamber.java @@ -16,9 +16,8 @@ import net.minecraft.util.EnumFacing; public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMachine { public TileEntityPurificationChamber() { - super("purification", "PurificationChamber", - MachineType.PURIFICATION_CHAMBER.getStorage(), - MachineType.PURIFICATION_CHAMBER.getUsage(), BASE_TICKS_REQUIRED, BASE_GAS_PER_TICK); + super("purification", "PurificationChamber", MachineType.PURIFICATION_CHAMBER.getStorage(), MachineType.PURIFICATION_CHAMBER.getUsage(), + BASE_TICKS_REQUIRED, BASE_GAS_PER_TICK); } @Override @@ -50,7 +49,6 @@ public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMac return; } } - super.handleSecondaryFuel(); } @@ -68,4 +66,4 @@ public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMac public boolean useStatisticalMechanics() { return true; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityQuantumEntangloporter.java b/src/main/java/mekanism/common/tile/TileEntityQuantumEntangloporter.java index 4bf79d1b4..c5f4c7419 100644 --- a/src/main/java/mekanism/common/tile/TileEntityQuantumEntangloporter.java +++ b/src/main/java/mekanism/common/tile/TileEntityQuantumEntangloporter.java @@ -60,9 +60,8 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fml.common.FMLCommonHandler; -public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock implements ISideConfiguration, - ITankManager, IFluidHandlerWrapper, IFrequencyHandler, IGasHandler, IHeatTransfer, IComputerIntegration, - ISecurityTile, IChunkLoader, IUpgradeTile { +public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock implements ISideConfiguration, ITankManager, IFluidHandlerWrapper, IFrequencyHandler, + IGasHandler, IHeatTransfer, IComputerIntegration, ISecurityTile, IChunkLoader, IUpgradeTile { private static final int INV_SIZE = 1;//this.inventory size, used for upgrades. Manually handled private static final String[] methods = new String[]{"setFrequency"}; @@ -80,9 +79,7 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp public TileEntityQuantumEntangloporter() { super("QuantumEntangloporter", 0); - - configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.FLUID, - TransmissionType.GAS, TransmissionType.ENERGY, TransmissionType.HEAT); + configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.FLUID, TransmissionType.GAS, TransmissionType.ENERGY, TransmissionType.HEAT); for (TransmissionType type : TransmissionType.values()) { if (type != TransmissionType.HEAT) { @@ -100,8 +97,7 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp ejectorComponent = new TileComponentEjector(this); ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(2)); - ejectorComponent - .setOutputData(TransmissionType.FLUID, configComponent.getOutputs(TransmissionType.FLUID).get(2)); + ejectorComponent.setOutputData(TransmissionType.FLUID, configComponent.getOutputs(TransmissionType.FLUID).get(2)); ejectorComponent.setOutputData(TransmissionType.GAS, configComponent.getOutputs(TransmissionType.GAS).get(2)); securityComponent = new TileComponentSecurity(this); @@ -120,7 +116,6 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp if (configComponent.isEjecting(TransmissionType.ENERGY)) { CableUtils.emit(this); } - double[] loss = simulateHeat(); applyTemperatureChange(); @@ -132,21 +127,18 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp if (manager != null) { if (frequency != null && !frequency.valid) { - frequency = (InventoryFrequency) manager - .validateFrequency(getSecurity().getOwnerUUID(), Coord4D.get(this), frequency); + frequency = (InventoryFrequency) manager.validateFrequency(getSecurity().getOwnerUUID(), Coord4D.get(this), frequency); markDirty(); } if (frequency != null) { frequency = (InventoryFrequency) manager.update(Coord4D.get(this), frequency); - if (frequency == null) { markDirty(); } } } else { frequency = null; - if (lastFreq != null) { markDirty(); } @@ -161,11 +153,9 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp @Override public void invalidate() { super.invalidate(); - if (!world.isRemote) { if (frequency != null) { FrequencyManager manager = getManager(frequency); - if (manager != null) { manager.deactivate(Coord4D.get(this)); } @@ -178,7 +168,6 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp if (manager == Mekanism.securityFrequencies) { return getSecurity().getFrequency(); } - return frequency; } @@ -186,32 +175,24 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp if (getSecurity().getOwnerUUID() == null || freq == null) { return null; } - if (freq.isPublic()) { return Mekanism.publicEntangloporters; - } else { - if (!Mekanism.privateEntangloporters.containsKey(getSecurity().getOwnerUUID())) { - FrequencyManager manager = new FrequencyManager(InventoryFrequency.class, - InventoryFrequency.ENTANGLOPORTER, getSecurity().getOwnerUUID()); - Mekanism.privateEntangloporters.put(getSecurity().getOwnerUUID(), manager); - manager.createOrLoad(world); - } - - return Mekanism.privateEntangloporters.get(getSecurity().getOwnerUUID()); + } else if (!Mekanism.privateEntangloporters.containsKey(getSecurity().getOwnerUUID())) { + FrequencyManager manager = new FrequencyManager(InventoryFrequency.class, InventoryFrequency.ENTANGLOPORTER, getSecurity().getOwnerUUID()); + Mekanism.privateEntangloporters.put(getSecurity().getOwnerUUID(), manager); + manager.createOrLoad(world); } + return Mekanism.privateEntangloporters.get(getSecurity().getOwnerUUID()); } public void setFrequency(String name, boolean publicFreq) { FrequencyManager manager = getManager(new InventoryFrequency(name, null).setPublic(publicFreq)); manager.deactivate(Coord4D.get(this)); - for (Frequency freq : manager.getFrequencies()) { if (freq.name.equals(name)) { frequency = (InventoryFrequency) freq; frequency.activeCoords.add(Coord4D.get(this)); - markDirty(); - return; } } @@ -220,7 +201,6 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp freq.activeCoords.add(Coord4D.get(this)); manager.addFrequency(freq); frequency = (InventoryFrequency) freq; - MekanismUtils.saveChunk(this); markDirty(); } @@ -228,7 +208,6 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - if (nbtTags.hasKey("frequency")) { frequency = new InventoryFrequency(nbtTags.getCompoundTag("frequency")); frequency.valid = false; @@ -236,11 +215,9 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp NBTTagList tagList = nbtTags.getTagList("upgradesInv", Constants.NBT.TAG_COMPOUND); inventory = NonNullList.withSize(INV_SIZE, ItemStack.EMPTY); - for (int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(tagCount); byte slotID = tagCompound.getByte("Slot"); - if (slotID >= 0 && slotID < inventory.size()) { inventory.set(slotID, new ItemStack(tagCompound)); } @@ -252,7 +229,6 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - if (frequency != null) { NBTTagCompound frequencyTag = new NBTTagCompound(); frequency.write(frequencyTag); @@ -271,7 +247,6 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp } } nbtTags.setTag("upgradesInv", tagList); - return nbtTags; } @@ -279,23 +254,18 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp public void handlePacketData(ByteBuf dataStream) { if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { int type = dataStream.readInt(); - if (type == 0) { String name = PacketHandler.readString(dataStream); boolean isPublic = dataStream.readBoolean(); - setFrequency(name, isPublic); } else if (type == 1) { String freq = PacketHandler.readString(dataStream); boolean isPublic = dataStream.readBoolean(); - FrequencyManager manager = getManager(new InventoryFrequency(freq, null).setPublic(isPublic)); - if (manager != null) { manager.remove(freq, getSecurity().getOwnerUUID()); } } - return; } @@ -304,7 +274,6 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { lastTransferLoss = dataStream.readDouble(); lastEnvironmentLoss = dataStream.readDouble(); - if (dataStream.readBoolean()) { frequency = new InventoryFrequency(dataStream); } else { @@ -315,13 +284,10 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp privateCache.clear(); int amount = dataStream.readInt(); - for (int i = 0; i < amount; i++) { publicCache.add(new InventoryFrequency(dataStream)); } - amount = dataStream.readInt(); - for (int i = 0; i < amount; i++) { privateCache.add(new InventoryFrequency(dataStream)); } @@ -331,7 +297,6 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(lastTransferLoss); data.add(lastEnvironmentLoss); @@ -343,23 +308,19 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp } data.add(Mekanism.publicEntangloporters.getFrequencies().size()); - for (Frequency freq : Mekanism.publicEntangloporters.getFrequencies()) { freq.write(data); } FrequencyManager manager = getManager(new InventoryFrequency(null, null).setPublic(false)); - if (manager != null) { data.add(manager.getFrequencies().size()); - for (Frequency freq : manager.getFrequencies()) { freq.write(data); } } else { data.add(0); } - return data; } @@ -368,7 +329,6 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp if (!hasFrequency()) { return false; } - return configComponent.hasSideForData(TransmissionType.ENERGY, facing, 2, side); } @@ -377,7 +337,6 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp if (!hasFrequency()) { return false; } - return configComponent.hasSideForData(TransmissionType.ENERGY, facing, 1, side); } @@ -394,8 +353,7 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp @Override public void setEnergy(double energy) { if (hasFrequency()) { - frequency.storedEnergy = Math - .min(MekanismConfig.current().general.quantumEntangloporterEnergyTransfer.val(), energy); + frequency.storedEnergy = Math.min(MekanismConfig.current().general.quantumEntangloporterEnergyTransfer.val(), energy); } } @@ -414,7 +372,6 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp if (hasFrequency() && resource != null && resource.isFluidEqual(frequency.storedFluid.getFluid())) { return frequency.storedFluid.drain(resource.amount, doDrain); } - return null; } @@ -423,27 +380,22 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp if (hasFrequency()) { return frequency.storedFluid.drain(maxDrain, doDrain); } - return null; } @Override public boolean canFill(EnumFacing from, @Nullable FluidStack fluid) { - if (hasFrequency() - && configComponent.getOutput(TransmissionType.FLUID, from, facing).ioState == IOState.INPUT) { + if (hasFrequency() && configComponent.getOutput(TransmissionType.FLUID, from, facing).ioState == IOState.INPUT) { return frequency.storedFluid.getFluid() == null || frequency.storedFluid.getFluid().isFluidEqual(fluid); } - return false; } @Override public boolean canDrain(EnumFacing from, @Nullable FluidStack fluid) { - if (hasFrequency() - && configComponent.getOutput(TransmissionType.FLUID, from, facing).ioState == IOState.OUTPUT) { + if (hasFrequency() && configComponent.getOutput(TransmissionType.FLUID, from, facing).ioState == IOState.OUTPUT) { return frequency.storedFluid.getFluid() == null || frequency.storedFluid.getFluid().isFluidEqual(fluid); } - return false; } @@ -454,7 +406,6 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp return new FluidTankInfo[]{frequency.storedFluid.getInfo()}; } } - return PipeUtils.EMPTY; } @@ -478,7 +429,6 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp if (hasFrequency() && configComponent.getOutput(TransmissionType.GAS, side, facing).ioState == IOState.INPUT) { return frequency.storedGas.getGasType() == null || type == frequency.storedGas.getGasType(); } - return false; } @@ -487,7 +437,6 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp if (hasFrequency() && configComponent.getOutput(TransmissionType.GAS, side, facing).ioState == IOState.OUTPUT) { return frequency.storedGas.getGasType() == null || type == frequency.storedGas.getGasType(); } - return false; } @@ -537,9 +486,7 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp if (hasFrequency()) { frequency.temperature += heatToAbsorb; } - heatToAbsorb = 0; - return hasFrequency() ? frequency.temperature : 0; } @@ -551,20 +498,17 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp @Override public IHeatTransfer getAdjacent(EnumFacing side) { TileEntity adj = Coord4D.get(this).offset(side).getTileEntity(world); - if (hasFrequency() && configComponent.getOutput(TransmissionType.HEAT, side, facing).ioState == IOState.INPUT) { if (CapabilityUtils.hasCapability(adj, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite())) { return CapabilityUtils.getCapability(adj, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite()); } } - return null; } @Override public boolean canInsertItem(int slotID, @Nonnull ItemStack itemstack, @Nonnull EnumFacing side) { - return hasFrequency() - && configComponent.getOutput(TransmissionType.ITEM, side, facing).ioState == IOState.INPUT; + return hasFrequency() && configComponent.getOutput(TransmissionType.ITEM, side, facing).ioState == IOState.INPUT; } @Nonnull @@ -573,14 +517,12 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp if (hasFrequency() && configComponent.getOutput(TransmissionType.ITEM, side, facing).ioState != IOState.OFF) { return new int[]{0}; } - return InventoryUtils.EMPTY; } @Override public boolean canExtractItem(int slotID, @Nonnull ItemStack itemstack, @Nonnull EnumFacing side) { - return hasFrequency() - && configComponent.getOutput(TransmissionType.ITEM, side, facing).ioState == IOState.OUTPUT; + return hasFrequency() && configComponent.getOutput(TransmissionType.ITEM, side, facing).ioState == IOState.OUTPUT; } @Override @@ -588,7 +530,6 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp if (!hasFrequency()) { return null; } - return new Object[]{frequency.storedFluid, frequency.storedGas}; } @@ -617,10 +558,8 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp if (isCapabilityDisabled(capability, side)) { return false; } - return capability == Capabilities.GAS_HANDLER_CAPABILITY - || capability == Capabilities.HEAT_TRANSFER_CAPABILITY - || capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY - || super.hasCapability(capability, side); + return capability == Capabilities.GAS_HANDLER_CAPABILITY || capability == Capabilities.HEAT_TRANSFER_CAPABILITY + || capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, side); } @Override @@ -631,11 +570,9 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp if (capability == Capabilities.GAS_HANDLER_CAPABILITY || capability == Capabilities.HEAT_TRANSFER_CAPABILITY) { return (T) this; } - if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(new FluidHandlerWrapper(this, side)); } - return super.getCapability(capability, side); } @@ -645,8 +582,7 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp return true; } else if (capability == Capabilities.GAS_HANDLER_CAPABILITY) { //TODO: Figure out if checking ioState even needed - return side != null && (!hasFrequency() - || configComponent.getOutput(TransmissionType.GAS, side, facing).ioState == IOState.OFF); + return side != null && (!hasFrequency() || configComponent.getOutput(TransmissionType.GAS, side, facing).ioState == IOState.OFF); } return super.isCapabilityDisabled(capability, side); } @@ -662,12 +598,9 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp if (!(arguments[0] instanceof String) || !(arguments[1] instanceof Boolean)) { return new Object[]{"Invalid parameters."}; } - String freq = ((String) arguments[0]).trim(); boolean isPublic = (Boolean) arguments[1]; - setFrequency(freq, isPublic); - return new Object[]{"Frequency set."}; } throw new NoSuchMethodException(); @@ -681,9 +614,7 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp @Override public Set getChunkSet() { Set ret = new HashSet<>(); - ret.add(new Chunk3D(Coord4D.get(this)).getPos()); - return ret; } @@ -691,4 +622,4 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp public TileComponentUpgrade getComponent() { return this.upgradeComponent; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityResistiveHeater.java b/src/main/java/mekanism/common/tile/TileEntityResistiveHeater.java index 70ede9aa8..034032b39 100644 --- a/src/main/java/mekanism/common/tile/TileEntityResistiveHeater.java +++ b/src/main/java/mekanism/common/tile/TileEntityResistiveHeater.java @@ -28,13 +28,11 @@ import net.minecraft.util.NonNullList; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.FMLCommonHandler; -public class TileEntityResistiveHeater extends TileEntityEffectsBlock implements IHeatTransfer, IComputerIntegration, - IRedstoneControl, ISecurityTile { +public class TileEntityResistiveHeater extends TileEntityEffectsBlock implements IHeatTransfer, IComputerIntegration, IRedstoneControl, ISecurityTile { private static final int[] SLOTS = {0}; - private static final String[] methods = new String[]{"getEnergy", "getMaxEnergy", "getTemperature", - "setEnergyUsage"}; + private static final String[] methods = new String[]{"getEnergy", "getMaxEnergy", "getTemperature", "setEnergyUsage"}; public double energyUsage = 100; public double temperature; public double heatToAbsorb = 0; @@ -63,10 +61,8 @@ public class TileEntityResistiveHeater extends TileEntityEffectsBlock implements @Override public void onUpdate() { super.onUpdate(); - if (world.isRemote && updateDelay > 0) { updateDelay--; - if (updateDelay == 0 && clientActive != isActive) { isActive = clientActive; MekanismUtils.updateBlock(world, getPos()); @@ -75,19 +71,15 @@ public class TileEntityResistiveHeater extends TileEntityEffectsBlock implements if (!world.isRemote) { boolean packet = false; - if (updateDelay > 0) { updateDelay--; - if (updateDelay == 0 && clientActive != isActive) { packet = true; } } ChargeUtils.discharge(0, this); - double toUse = 0; - if (MekanismUtils.canFunction(this)) { toUse = Math.min(getEnergy(), energyUsage); heatToAbsorb += toUse / MekanismConfig.current().general.energyPerHeat.val(); @@ -95,24 +87,17 @@ public class TileEntityResistiveHeater extends TileEntityEffectsBlock implements } setActive(toUse > 0); - double[] loss = simulateHeat(); applyTemperatureChange(); - lastEnvironmentLoss = loss[1]; - - float newSoundScale = (float) Math.max(0, (toUse / 1E5)); - + float newSoundScale = (float) Math.max(0, toUse / 1E5); if (Math.abs(newSoundScale - soundScale) > 0.01) { packet = true; } soundScale = newSoundScale; - if (packet) { - Mekanism.packetHandler.sendToReceivers( - new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); } } } @@ -130,12 +115,10 @@ public class TileEntityResistiveHeater extends TileEntityEffectsBlock implements @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - energyUsage = nbtTags.getDouble("energyUsage"); temperature = nbtTags.getDouble("temperature"); clientActive = isActive = nbtTags.getBoolean("isActive"); controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - maxEnergy = energyUsage * 400; } @@ -143,12 +126,10 @@ public class TileEntityResistiveHeater extends TileEntityEffectsBlock implements @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setDouble("energyUsage", energyUsage); nbtTags.setDouble("temperature", temperature); nbtTags.setBoolean("isActive", isActive); nbtTags.setInteger("controlType", controlType.ordinal()); - return nbtTags; } @@ -157,12 +138,10 @@ public class TileEntityResistiveHeater extends TileEntityEffectsBlock implements if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { energyUsage = MekanismUtils.convertToJoules(dataStream.readInt()); maxEnergy = energyUsage * 400; - return; } super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { energyUsage = dataStream.readDouble(); temperature = dataStream.readDouble(); @@ -170,9 +149,7 @@ public class TileEntityResistiveHeater extends TileEntityEffectsBlock implements maxEnergy = dataStream.readDouble(); soundScale = dataStream.readFloat(); controlType = RedstoneControl.values()[dataStream.readInt()]; - lastEnvironmentLoss = dataStream.readDouble(); - if (updateDelay == 0 && clientActive != isActive) { updateDelay = MekanismConfig.current().general.UPDATE_DELAY.val(); isActive = clientActive; @@ -193,7 +170,6 @@ public class TileEntityResistiveHeater extends TileEntityEffectsBlock implements data.add(controlType.ordinal()); data.add(lastEnvironmentLoss); - return data; } @@ -226,7 +202,6 @@ public class TileEntityResistiveHeater extends TileEntityEffectsBlock implements public double applyTemperatureChange() { temperature += heatToAbsorb; heatToAbsorb = 0; - return temperature; } @@ -238,11 +213,9 @@ public class TileEntityResistiveHeater extends TileEntityEffectsBlock implements @Override public IHeatTransfer getAdjacent(EnumFacing side) { TileEntity adj = Coord4D.get(this).offset(side).getTileEntity(world); - if (CapabilityUtils.hasCapability(adj, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite())) { return CapabilityUtils.getCapability(adj, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite()); } - return null; } @@ -256,7 +229,6 @@ public class TileEntityResistiveHeater extends TileEntityEffectsBlock implements if (capability == Capabilities.HEAT_TRANSFER_CAPABILITY) { return Capabilities.HEAT_TRANSFER_CAPABILITY.cast(this); } - return super.getCapability(capability, side); } @@ -268,12 +240,8 @@ public class TileEntityResistiveHeater extends TileEntityEffectsBlock implements @Override public void setActive(boolean active) { isActive = active; - if (clientActive != active && updateDelay == 0) { - Mekanism.packetHandler - .sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); - + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); updateDelay = 10; clientActive = active; } @@ -310,7 +278,6 @@ public class TileEntityResistiveHeater extends TileEntityEffectsBlock implements return new Object[]{"Set energy usage."}; } } - return new Object[]{"Invalid parameters."}; default: throw new NoSuchMethodException(); @@ -347,4 +314,4 @@ public class TileEntityResistiveHeater extends TileEntityEffectsBlock implements public boolean isItemValidForSlot(int slot, @Nonnull ItemStack stack) { return ChargeUtils.canBeDischarged(stack); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java b/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java index f22cc4017..fd7f5d202 100644 --- a/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java +++ b/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java @@ -43,8 +43,7 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fml.common.FMLCommonHandler; -public class TileEntityRotaryCondensentrator extends TileEntityMachine implements ISustainedData, IFluidHandlerWrapper, - IGasHandler, IUpgradeInfoHandler, ITankManager { +public class TileEntityRotaryCondensentrator extends TileEntityMachine implements ISustainedData, IFluidHandlerWrapper, IGasHandler, IUpgradeInfoHandler, ITankManager { private static final int[] GAS_SLOTS = {0, 1}; private static final int[] LIQUID_SLOTS = {2, 3}; @@ -63,8 +62,7 @@ public class TileEntityRotaryCondensentrator extends TileEntityMachine implement public double clientEnergyUsed; public TileEntityRotaryCondensentrator() { - super("machine.rotarycondensentrator", "RotaryCondensentrator", - MachineType.ROTARY_CONDENSENTRATOR.getStorage(), + super("machine.rotarycondensentrator", "RotaryCondensentrator", MachineType.ROTARY_CONDENSENTRATOR.getStorage(), MachineType.ROTARY_CONDENSENTRATOR.getUsage(), 5); inventory = NonNullList.withSize(6, ItemStack.EMPTY); } @@ -78,14 +76,12 @@ public class TileEntityRotaryCondensentrator extends TileEntityMachine implement if (mode == 0) { TileUtils.receiveGas(inventory.get(1), gasTank); - if (FluidContainerUtils.isFluidContainer(inventory.get(2))) { FluidContainerUtils.handleContainerItemFill(this, fluidTank, 2, 3); } - if (getEnergy() >= energyPerTick && MekanismUtils.canFunction(this) && isValidGas(gasTank.getGas()) && ( - fluidTank.getFluid() == null || (fluidTank.getFluid().amount < MAX_FLUID && gasEquals( - gasTank.getGas(), fluidTank.getFluid())))) { + if (getEnergy() >= energyPerTick && MekanismUtils.canFunction(this) && isValidGas(gasTank.getGas()) && + (fluidTank.getFluid() == null || (fluidTank.getFluid().amount < MAX_FLUID && gasEquals(gasTank.getGas(), fluidTank.getFluid())))) { int operations = getUpgradedUsage(); double prev = getEnergy(); @@ -94,10 +90,8 @@ public class TileEntityRotaryCondensentrator extends TileEntityMachine implement gasTank.draw(operations, true); setEnergy(getEnergy() - energyPerTick * operations); clientEnergyUsed = prev - getEnergy(); - } else { - if (prevEnergy >= getEnergy()) { - setActive(false); - } + } else if (prevEnergy >= getEnergy()) { + setActive(false); } } else if (mode == 1) { TileUtils.drawGas(inventory.get(0), gasTank); @@ -107,43 +101,32 @@ public class TileEntityRotaryCondensentrator extends TileEntityMachine implement FluidContainerUtils.handleContainerItemEmpty(this, fluidTank, 2, 3); } - if (getEnergy() >= energyPerTick && MekanismUtils.canFunction(this) && isValidFluid( - fluidTank.getFluid()) && (gasTank.getGas() == null || (gasTank.getStored() < MAX_FLUID - && gasEquals(gasTank.getGas(), fluidTank.getFluid())))) { + if (getEnergy() >= energyPerTick && MekanismUtils.canFunction(this) && isValidFluid(fluidTank.getFluid()) && + (gasTank.getGas() == null || (gasTank.getStored() < MAX_FLUID && gasEquals(gasTank.getGas(), fluidTank.getFluid())))) { int operations = getUpgradedUsage(); double prev = getEnergy(); setActive(true); - gasTank - .receive(new GasStack(GasRegistry.getGas(fluidTank.getFluid().getFluid()), operations), true); + gasTank.receive(new GasStack(GasRegistry.getGas(fluidTank.getFluid().getFluid()), operations), true); fluidTank.drain(operations, true); setEnergy(getEnergy() - energyPerTick * operations); clientEnergyUsed = prev - getEnergy(); - } else { - if (prevEnergy >= getEnergy()) { - setActive(false); - } + } else if (prevEnergy >= getEnergy()) { + setActive(false); } } - prevEnergy = getEnergy(); } } public int getUpgradedUsage() { int possibleProcess = (int) Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)); - - if (mode == 0) //Gas to fluid - { - possibleProcess = Math - .min(Math.min(gasTank.getStored(), fluidTank.getCapacity() - fluidTank.getFluidAmount()), - possibleProcess); + if (mode == 0) { //Gas to fluid + possibleProcess = Math.min(Math.min(gasTank.getStored(), fluidTank.getCapacity() - fluidTank.getFluidAmount()), possibleProcess); } else { //Fluid to gas possibleProcess = Math.min(Math.min(fluidTank.getFluidAmount(), gasTank.getNeeded()), possibleProcess); } - possibleProcess = Math.min((int) (getEnergy() / energyPerTick), possibleProcess); - return possibleProcess; } @@ -166,22 +149,17 @@ public class TileEntityRotaryCondensentrator extends TileEntityMachine implement public void handlePacketData(ByteBuf dataStream) { if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { int type = dataStream.readInt(); - if (type == 0) { mode = mode == 0 ? 1 : 0; } - for (EntityPlayer player : playersUsing) { - Mekanism.packetHandler - .sendTo(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - (EntityPlayerMP) player); + Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), (EntityPlayerMP) player); } return; } super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { mode = dataStream.readInt(); clientEnergyUsed = dataStream.readDouble(); @@ -193,7 +171,6 @@ public class TileEntityRotaryCondensentrator extends TileEntityMachine implement @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(mode); data.add(clientEnergyUsed); TileUtils.addTankData(data, fluidTank); @@ -204,10 +181,8 @@ public class TileEntityRotaryCondensentrator extends TileEntityMachine implement @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - mode = nbtTags.getInteger("mode"); gasTank.read(nbtTags.getCompoundTag("gasTank")); - if (nbtTags.hasKey("fluidTank")) { fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank")); } @@ -217,14 +192,11 @@ public class TileEntityRotaryCondensentrator extends TileEntityMachine implement @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setInteger("mode", mode); nbtTags.setTag("gasTank", gasTank.write(new NBTTagCompound())); - if (fluidTank.getFluid() != null) { nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound())); } - return nbtTags; } @@ -240,12 +212,12 @@ public class TileEntityRotaryCondensentrator extends TileEntityMachine implement @Override public boolean canDrawGas(EnumFacing side, Gas type) { - return (mode == 1 && side == MekanismUtils.getLeft(facing)) && gasTank.canDraw(type); + return mode == 1 && side == MekanismUtils.getLeft(facing) && gasTank.canDraw(type); } @Override public boolean canReceiveGas(EnumFacing side, Gas type) { - return (mode == 0 && side == MekanismUtils.getLeft(facing)) && gasTank.canReceive(type); + return mode == 0 && side == MekanismUtils.getLeft(facing) && gasTank.canReceive(type); } @Nonnull @@ -259,8 +231,7 @@ public class TileEntityRotaryCondensentrator extends TileEntityMachine implement if (isCapabilityDisabled(capability, side)) { return false; } - return capability == Capabilities.GAS_HANDLER_CAPABILITY - || capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, side); + return capability == Capabilities.GAS_HANDLER_CAPABILITY || capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, side); } @Override @@ -272,7 +243,6 @@ public class TileEntityRotaryCondensentrator extends TileEntityMachine implement } else if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(new FluidHandlerWrapper(this, side)); } - return super.getCapability(capability, side); } @@ -289,7 +259,6 @@ public class TileEntityRotaryCondensentrator extends TileEntityMachine implement if (fluidTank.getFluid() != null) { ItemDataUtils.setCompound(itemStack, "fluidTank", fluidTank.getFluid().writeToNBT(new NBTTagCompound())); } - if (gasTank.getGas() != null) { ItemDataUtils.setCompound(itemStack, "gasTank", gasTank.getGas().write(new NBTTagCompound())); } @@ -306,24 +275,21 @@ public class TileEntityRotaryCondensentrator extends TileEntityMachine implement if (canFill(from, resource)) { return fluidTank.fill(resource, doFill); } - return 0; } @Override public FluidStack drain(EnumFacing from, @Nullable FluidStack resource, boolean doDrain) { - if (resource != null && fluidTank.getFluid() != null && fluidTank.getFluid().getFluid() == resource - .getFluid()) { + if (resource != null && fluidTank.getFluid() != null && fluidTank.getFluid().getFluid() == resource.getFluid()) { return drain(from, resource.amount, doDrain); } - return null; } @Override public boolean canFill(EnumFacing from, @Nullable FluidStack fluid) { - return fluid != null && mode == 1 && from == MekanismUtils.getRight(facing) && (fluidTank.getFluid() == null - ? isValidFluid(new FluidStack(fluid, 1)) : fluidTank.getFluid().isFluidEqual(fluid)); + return fluid != null && mode == 1 && from == MekanismUtils.getRight(facing) && + (fluidTank.getFluid() == null ? isValidFluid(new FluidStack(fluid, 1)) : fluidTank.getFluid().isFluidEqual(fluid)); } @Override @@ -336,7 +302,6 @@ public class TileEntityRotaryCondensentrator extends TileEntityMachine implement if (from == MekanismUtils.getRight(facing)) { return new FluidTankInfo[]{fluidTank.getInfo()}; } - return PipeUtils.EMPTY; } @@ -350,7 +315,6 @@ public class TileEntityRotaryCondensentrator extends TileEntityMachine implement if (canDrain(from, null)) { return fluidTank.drain(maxDrain, doDrain); } - return null; } @@ -390,4 +354,4 @@ public class TileEntityRotaryCondensentrator extends TileEntityMachine implement } return false; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntitySecurityDesk.java b/src/main/java/mekanism/common/tile/TileEntitySecurityDesk.java index 545036c6c..4cb292e34 100644 --- a/src/main/java/mekanism/common/tile/TileEntitySecurityDesk.java +++ b/src/main/java/mekanism/common/tile/TileEntitySecurityDesk.java @@ -33,7 +33,7 @@ import net.minecraftforge.items.CapabilityItemHandler; public class TileEntitySecurityDesk extends TileEntityContainerBlock implements IBoundingBlock { - private static final int[] SLOTS = {0,1}; + private static final int[] SLOTS = {0, 1}; public UUID ownerUUID; public String clientOwner; @@ -42,7 +42,6 @@ public class TileEntitySecurityDesk extends TileEntityContainerBlock implements public TileEntitySecurityDesk() { super("SecurityDesk"); - inventory = NonNullList.withSize(SLOTS.length, ItemStack.EMPTY); } @@ -52,11 +51,9 @@ public class TileEntitySecurityDesk extends TileEntityContainerBlock implements if (ownerUUID != null && frequency != null) { if (!inventory.get(0).isEmpty() && inventory.get(0).getItem() instanceof IOwnerItem) { IOwnerItem item = (IOwnerItem) inventory.get(0).getItem(); - if (item.hasOwner(inventory.get(0)) && item.getOwnerUUID(inventory.get(0)) != null) { if (item.getOwnerUUID(inventory.get(0)).equals(ownerUUID)) { item.setOwnerUUID(inventory.get(0), null); - if (item instanceof ISecurityItem && ((ISecurityItem) item).hasSecurity(inventory.get(0))) { ((ISecurityItem) item).setSecurity(inventory.get(0), SecurityMode.PUBLIC); } @@ -66,12 +63,10 @@ public class TileEntitySecurityDesk extends TileEntityContainerBlock implements if (!inventory.get(1).isEmpty() && inventory.get(1).getItem() instanceof IOwnerItem) { IOwnerItem item = (IOwnerItem) inventory.get(1).getItem(); - if (item.hasOwner(inventory.get(1))) { if (item.getOwnerUUID(inventory.get(1)) == null) { item.setOwnerUUID(inventory.get(1), ownerUUID); } - if (item.getOwnerUUID(inventory.get(1)).equals(ownerUUID)) { if (item instanceof ISecurityItem && ((ISecurityItem) item).hasSecurity(inventory.get(1))) { ((ISecurityItem) item).setSecurity(inventory.get(1), frequency.securityMode); @@ -86,12 +81,10 @@ public class TileEntitySecurityDesk extends TileEntityContainerBlock implements } FrequencyManager manager = getManager(frequency); - if (manager != null) { if (frequency != null && !frequency.valid) { frequency = (SecurityFrequency) manager.validateFrequency(ownerUUID, Coord4D.get(this), frequency); } - if (frequency != null) { frequency = (SecurityFrequency) manager.update(Coord4D.get(this), frequency); } @@ -105,19 +98,16 @@ public class TileEntitySecurityDesk extends TileEntityContainerBlock implements if (ownerUUID == null || freq == null) { return null; } - return Mekanism.securityFrequencies; } public void setFrequency(UUID owner) { FrequencyManager manager = Mekanism.securityFrequencies; manager.deactivate(Coord4D.get(this)); - for (Frequency freq : manager.getFrequencies()) { if (freq.ownerUUID.equals(owner)) { frequency = (SecurityFrequency) freq; frequency.activeCoords.add(Coord4D.get(this)); - return; } } @@ -126,7 +116,6 @@ public class TileEntitySecurityDesk extends TileEntityContainerBlock implements freq.activeCoords.add(Coord4D.get(this)); manager.addFrequency(freq); frequency = (SecurityFrequency) freq; - MekanismUtils.saveChunk(this); markDirty(); } @@ -135,7 +124,6 @@ public class TileEntitySecurityDesk extends TileEntityContainerBlock implements public void handlePacketData(ByteBuf dataStream) { if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { int type = dataStream.readInt(); - if (type == 0) { if (frequency != null) { frequency.trusted.add(PacketHandler.readString(dataStream)); @@ -147,21 +135,15 @@ public class TileEntitySecurityDesk extends TileEntityContainerBlock implements } else if (type == 2) { if (frequency != null) { frequency.override = !frequency.override; - - Mekanism.packetHandler.sendToAll( - new SecurityUpdateMessage(SecurityPacket.UPDATE, ownerUUID, new SecurityData(frequency))); + Mekanism.packetHandler.sendToAll(new SecurityUpdateMessage(SecurityPacket.UPDATE, ownerUUID, new SecurityData(frequency))); } } else if (type == 3) { if (frequency != null) { frequency.securityMode = SecurityMode.values()[dataStream.readInt()]; - - Mekanism.packetHandler.sendToAll( - new SecurityUpdateMessage(SecurityPacket.UPDATE, ownerUUID, new SecurityData(frequency))); + Mekanism.packetHandler.sendToAll(new SecurityUpdateMessage(SecurityPacket.UPDATE, ownerUUID, new SecurityData(frequency))); } } - MekanismUtils.saveChunk(this); - return; } @@ -173,7 +155,6 @@ public class TileEntitySecurityDesk extends TileEntityContainerBlock implements } else { clientOwner = null; } - if (dataStream.readBoolean()) { frequency = new SecurityFrequency(dataStream); } else { @@ -185,11 +166,9 @@ public class TileEntitySecurityDesk extends TileEntityContainerBlock implements @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - if (nbtTags.hasKey("ownerUUID")) { ownerUUID = UUID.fromString(nbtTags.getString("ownerUUID")); } - if (nbtTags.hasKey("frequency")) { frequency = new SecurityFrequency(nbtTags.getCompoundTag("frequency")); frequency.valid = false; @@ -200,49 +179,41 @@ public class TileEntitySecurityDesk extends TileEntityContainerBlock implements @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - if (ownerUUID != null) { nbtTags.setString("ownerUUID", ownerUUID.toString()); } - if (frequency != null) { NBTTagCompound frequencyTag = new NBTTagCompound(); frequency.write(frequencyTag); nbtTags.setTag("frequency", frequencyTag); } - return nbtTags; } @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - if (ownerUUID != null) { data.add(true); data.add(MekanismUtils.getLastKnownUsername(ownerUUID)); } else { data.add(false); } - if (frequency != null) { data.add(true); frequency.write(data); } else { data.add(false); } - return data; } @Override public void invalidate() { super.invalidate(); - if (!world.isRemote) { if (frequency != null) { FrequencyManager manager = getManager(frequency); - if (manager != null) { manager.deactivate(Coord4D.get(this)); } @@ -266,7 +237,6 @@ public class TileEntitySecurityDesk extends TileEntityContainerBlock implements if (manager == Mekanism.securityFrequencies) { return frequency; } - return null; } @@ -294,4 +264,4 @@ public class TileEntitySecurityDesk extends TileEntityContainerBlock implements } return super.isCapabilityDisabled(capability, side); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntitySeismicVibrator.java b/src/main/java/mekanism/common/tile/TileEntitySeismicVibrator.java index a082351be..c9cb30958 100644 --- a/src/main/java/mekanism/common/tile/TileEntitySeismicVibrator.java +++ b/src/main/java/mekanism/common/tile/TileEntitySeismicVibrator.java @@ -26,8 +26,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class TileEntitySeismicVibrator extends TileEntityElectricBlock implements IActiveState, IRedstoneControl, - ISecurityTile, IBoundingBlock { +public class TileEntitySeismicVibrator extends TileEntityElectricBlock implements IActiveState, IRedstoneControl, ISecurityTile, IBoundingBlock { private static final int[] SLOTS = {0}; @@ -47,22 +46,18 @@ public class TileEntitySeismicVibrator extends TileEntityElectricBlock implement public TileEntitySeismicVibrator() { super("SeismicVibrator", MachineType.SEISMIC_VIBRATOR.getStorage()); - - inventory = NonNullList.withSize(SLOTS .length, ItemStack.EMPTY); + inventory = NonNullList.withSize(SLOTS.length, ItemStack.EMPTY); } @Override public void onUpdate() { super.onUpdate(); - if (world.isRemote) { if (isActive) { clientPiston++; } - if (updateDelay > 0) { updateDelay--; - if (updateDelay == 0 && clientActive != isActive) { isActive = clientActive; MekanismUtils.updateBlock(world, getPos()); @@ -71,16 +66,12 @@ public class TileEntitySeismicVibrator extends TileEntityElectricBlock implement } else { if (updateDelay > 0) { updateDelay--; - if (updateDelay == 0 && clientActive != isActive) { - Mekanism.packetHandler.sendToReceivers( - new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); } } ChargeUtils.discharge(0, this); - if (MekanismUtils.canFunction(this) && getEnergy() >= BASE_ENERGY_PER_TICK) { setActive(true); setEnergy(getEnergy() - BASE_ENERGY_PER_TICK); @@ -88,7 +79,6 @@ public class TileEntitySeismicVibrator extends TileEntityElectricBlock implement setActive(false); } } - if (getActive()) { Mekanism.activeVibrators.add(Coord4D.get(this)); } else { @@ -99,7 +89,6 @@ public class TileEntitySeismicVibrator extends TileEntityElectricBlock implement @Override public void invalidate() { super.invalidate(); - Mekanism.activeVibrators.remove(Coord4D.get(this)); } @@ -107,17 +96,14 @@ public class TileEntitySeismicVibrator extends TileEntityElectricBlock implement @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setBoolean("isActive", isActive); nbtTags.setInteger("controlType", controlType.ordinal()); - return nbtTags; } @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - clientActive = isActive = nbtTags.getBoolean("isActive"); controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; } @@ -125,11 +111,9 @@ public class TileEntitySeismicVibrator extends TileEntityElectricBlock implement @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { clientActive = dataStream.readBoolean(); controlType = RedstoneControl.values()[dataStream.readInt()]; - if (updateDelay == 0 && clientActive != isActive) { updateDelay = MekanismConfig.current().general.UPDATE_DELAY.val(); isActive = clientActive; @@ -141,10 +125,8 @@ public class TileEntitySeismicVibrator extends TileEntityElectricBlock implement @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(isActive); data.add(controlType.ordinal()); - return data; } @@ -156,12 +138,8 @@ public class TileEntitySeismicVibrator extends TileEntityElectricBlock implement @Override public void setActive(boolean active) { isActive = active; - if (clientActive != active && updateDelay == 0) { - Mekanism.packetHandler - .sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); - + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); updateDelay = 10; clientActive = active; } @@ -236,4 +214,4 @@ public class TileEntitySeismicVibrator extends TileEntityElectricBlock implement public boolean isItemValidForSlot(int slot, @Nonnull ItemStack stack) { return ChargeUtils.canBeDischarged(stack); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntitySolarNeutronActivator.java b/src/main/java/mekanism/common/tile/TileEntitySolarNeutronActivator.java index 586db6b2e..a6a3b4c0c 100644 --- a/src/main/java/mekanism/common/tile/TileEntitySolarNeutronActivator.java +++ b/src/main/java/mekanism/common/tile/TileEntitySolarNeutronActivator.java @@ -43,9 +43,8 @@ import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock implements IRedstoneControl, - IBoundingBlock, IGasHandler, IActiveState, ISustainedData, ITankManager, ISecurityTile, IUpgradeTile, - IUpgradeInfoHandler { +public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock implements IRedstoneControl, IBoundingBlock, IGasHandler, IActiveState, ISustainedData, + ITankManager, ISecurityTile, IUpgradeTile, IUpgradeInfoHandler { public static final int MAX_GAS = 10000; private static final int[] INPUT_SLOT = {0}; @@ -75,7 +74,6 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im @Override public void validate() { super.validate(); - // Cache the flag to know if rain matters where this block is placed needsRainCheck = world.provider.getBiomeForCoords(getPos()).canRain(); } @@ -85,7 +83,6 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im if (!world.isRemote) { TileUtils.receiveGas(inventory.get(0), inputTank); TileUtils.drawGas(inventory.get(1), outputTank); - SolarNeutronRecipe recipe = getRecipe(); // TODO: Ideally the neutron activator should use the sky brightness to determine throughput; but @@ -105,14 +102,10 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im } TileUtils.emitGas(this, outputTank, gasOutput, facing); - // Every 20 ticks (once a second), send update to client. Note that this is a 50% reduction in network // traffic from previous implementation that send the update every 10 ticks. if (world.getTotalWorldTime() % 20 == 0) { - Mekanism.packetHandler - .sendToReceivers( - new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); } } } @@ -120,17 +113,14 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im public int getUpgradedUsage() { int possibleProcess = (int) Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)); possibleProcess = Math.min(Math.min(inputTank.getStored(), outputTank.getNeeded()), possibleProcess); - return possibleProcess; } public SolarNeutronRecipe getRecipe() { GasInput input = getInput(); - if (cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) { cachedRecipe = RecipeHandler.getSolarNeutronRecipe(getInput()); } - return cachedRecipe; } @@ -149,7 +139,6 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { isActive = dataStream.readBoolean(); controlType = RedstoneControl.values()[dataStream.readInt()]; @@ -161,7 +150,6 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(isActive); data.add(controlType.ordinal()); TileUtils.addTankData(data, inputTank); @@ -172,10 +160,8 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - isActive = nbtTags.getBoolean("isActive"); controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - inputTank.read(nbtTags.getCompoundTag("inputTank")); outputTank.read(nbtTags.getCompoundTag("outputTank")); } @@ -184,13 +170,10 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setBoolean("isActive", isActive); nbtTags.setInteger("controlType", controlType.ordinal()); - nbtTags.setTag("inputTank", inputTank.write(new NBTTagCompound())); nbtTags.setTag("outputTank", outputTank.write(new NBTTagCompound())); - return nbtTags; } @@ -215,7 +198,6 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im if (canReceiveGas(side, stack != null ? stack.getGas() : null)) { return inputTank.receive(stack, doTransfer); } - return 0; } @@ -224,7 +206,6 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im if (canDrawGas(side, null)) { return outputTank.draw(amount, doTransfer); } - return null; } @@ -259,7 +240,6 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im } else if (capability == Capabilities.GAS_HANDLER_CAPABILITY) { return Capabilities.GAS_HANDLER_CAPABILITY.cast(this); } - return super.getCapability(capability, side); } @@ -276,7 +256,6 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im if (inputTank.getGas() != null) { ItemDataUtils.setCompound(itemStack, "inputTank", inputTank.getGas().write(new NBTTagCompound())); } - if (outputTank.getGas() != null) { ItemDataUtils.setCompound(itemStack, "outputTank", outputTank.getGas().write(new NBTTagCompound())); } @@ -311,13 +290,10 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im @Override public void setActive(boolean active) { - boolean stateChange = (isActive != active); - + boolean stateChange = isActive != active; if (stateChange) { isActive = active; - Mekanism.packetHandler - .sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); } } @@ -375,4 +351,4 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im public boolean isItemValidForSlot(int slot, @Nonnull ItemStack stack) { return stack.getItem() instanceof IGasItem; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityStructuralGlass.java b/src/main/java/mekanism/common/tile/TileEntityStructuralGlass.java index 133cfa715..ef2f2cae8 100644 --- a/src/main/java/mekanism/common/tile/TileEntityStructuralGlass.java +++ b/src/main/java/mekanism/common/tile/TileEntityStructuralGlass.java @@ -19,14 +19,11 @@ public class TileEntityStructuralGlass extends TileEntity implements IStructural public boolean onActivate(EntityPlayer player, EnumHand hand, ItemStack stack) { if (master != null) { TileEntity masterTile = master.getTileEntity(world); - if (masterTile instanceof IMultiblock) { return ((IMultiblock) masterTile).onActivate(player, hand, stack); - } else { - master = null; } + master = null; } - return false; } @@ -34,7 +31,6 @@ public class TileEntityStructuralGlass extends TileEntity implements IStructural public void doUpdate() { if (master != null) { TileEntity masterTile = master.getTileEntity(world); - if (masterTile instanceof IMultiblock) { ((IMultiblock) masterTile).doUpdate(); } else { @@ -42,7 +38,6 @@ public class TileEntityStructuralGlass extends TileEntity implements IStructural } } else { IMultiblock multiblock = new ControllerFinder().find(); - if (multiblock != null) { multiblock.doUpdate(); } @@ -69,13 +64,10 @@ public class TileEntityStructuralGlass extends TileEntity implements IStructural if (iterated.size() > 2048 || found != null) { return; } - iterated.add(pos); - for (EnumFacing side : EnumFacing.VALUES) { Coord4D coord = pos.offset(side); TileEntity tile = coord.getTileEntity(world); - if (!iterated.contains(coord)) { if (tile instanceof IMultiblock) { found = (IMultiblock) tile; @@ -89,8 +81,7 @@ public class TileEntityStructuralGlass extends TileEntity implements IStructural public IMultiblock find() { loop(Coord4D.get(TileEntityStructuralGlass.this)); - return found; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntitySuperheatingElement.java b/src/main/java/mekanism/common/tile/TileEntitySuperheatingElement.java index fb041c25d..826c17b6d 100644 --- a/src/main/java/mekanism/common/tile/TileEntitySuperheatingElement.java +++ b/src/main/java/mekanism/common/tile/TileEntitySuperheatingElement.java @@ -2,8 +2,8 @@ package mekanism.common.tile; import mekanism.api.Coord4D; import mekanism.api.Range4D; -import mekanism.common.Mekanism; import mekanism.api.TileNetworkList; +import mekanism.common.Mekanism; import mekanism.common.content.boiler.SynchronizedBoilerData; import mekanism.common.multiblock.TileEntityInternalMultiblock; import mekanism.common.network.PacketTileEntity.TileEntityMessage; @@ -22,7 +22,6 @@ public class TileEntitySuperheatingElement extends TileEntityInternalMultiblock @Override public void setMultiblock(String id) { boolean packet = false; - if (id == null && multiblockUUID != null) { SynchronizedBoilerData.clientHotMap.remove(multiblockUUID); packet = true; @@ -33,9 +32,7 @@ public class TileEntitySuperheatingElement extends TileEntityInternalMultiblock super.setMultiblock(id); if (packet && !world.isRemote) { - Mekanism.packetHandler - .sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); } } @@ -43,16 +40,13 @@ public class TileEntitySuperheatingElement extends TileEntityInternalMultiblock public void onUpdate() { if (world.isRemote) { boolean newHot = false; - if (multiblockUUID != null && SynchronizedBoilerData.clientHotMap.get(multiblockUUID) != null) { newHot = SynchronizedBoilerData.clientHotMap.get(multiblockUUID); } - if (prevHot != newHot) { MekanismUtils.updateBlock(world, getPos()); - prevHot = newHot; } } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityTeleporter.java b/src/main/java/mekanism/common/tile/TileEntityTeleporter.java index 3710c189b..71023199f 100644 --- a/src/main/java/mekanism/common/tile/TileEntityTeleporter.java +++ b/src/main/java/mekanism/common/tile/TileEntityTeleporter.java @@ -50,11 +50,10 @@ import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class TileEntityTeleporter extends TileEntityElectricBlock implements IComputerIntegration, IChunkLoader, - IFrequencyHandler, IRedstoneControl, ISecurityTile, IUpgradeTile { +public class TileEntityTeleporter extends TileEntityElectricBlock implements IComputerIntegration, IChunkLoader, IFrequencyHandler, IRedstoneControl, ISecurityTile, + IUpgradeTile { - private static final String[] methods = new String[]{"getEnergy", "canTeleport", "getMaxEnergy", "teleport", - "setFrequency"}; + private static final String[] methods = new String[]{"getEnergy", "canTeleport", "getMaxEnergy", "teleport", "setFrequency"}; public AxisAlignedBB teleportBounds = null; public Set didTeleport = new HashSet<>(); @@ -94,8 +93,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo public static void teleportPlayerTo(EntityPlayerMP player, Coord4D coord, TileEntityTeleporter teleporter) { if (player.dimension != coord.dimensionId) { - player.changeDimension(coord.dimensionId, - (world, entity, yaw) -> entity.setPositionAndUpdate(coord.x + 0.5, coord.y + 1, coord.z + 0.5)); + player.changeDimension(coord.dimensionId, (world, entity, yaw) -> entity.setPositionAndUpdate(coord.x + 0.5, coord.y + 1, coord.z + 0.5)); } else { player.setPositionAndUpdate(coord.x + 0.5, coord.y + 1, coord.z + 0.5); } @@ -106,7 +104,6 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo Coord4D upperCoord = coord.offset(EnumFacing.UP); EnumFacing side = null; float yaw = player.rotationYaw; - for (EnumFacing iterSide : MekanismUtils.SIDE_DIRS) { if (upperCoord.offset(iterSide).isAirBlock(player.world)) { side = iterSide; @@ -132,26 +129,22 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo break; } } - player.connection.setPlayerLocation(player.posX, player.posY, player.posZ, yaw, player.rotationPitch); } @Override public void onUpdate() { super.onUpdate(); - if (teleportBounds == null) { resetBounds(); } if (!world.isRemote) { FrequencyManager manager = getManager(frequency); - if (manager != null) { if (frequency != null && !frequency.valid) { frequency = manager.validateFrequency(getSecurity().getOwnerUUID(), Coord4D.get(this), frequency); } - if (frequency != null) { frequency = manager.update(Coord4D.get(this), frequency); } @@ -160,28 +153,21 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo } status = canTeleport(); - if (MekanismUtils.canFunction(this) && status == 1 && teleDelay == 0) { teleport(); } - if (teleDelay == 0 && didTeleport.size() > 0) { cleanTeleportCache(); } shouldRender = status == 1 || status > 4; - if (shouldRender != prevShouldRender) { - Mekanism.packetHandler.sendToAllAround( - new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), + Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), Coord4D.get(this).getTargetPoint(40D)); } - prevShouldRender = shouldRender; - teleDelay = Math.max(0, teleDelay - 1); } - ChargeUtils.discharge(0, this); } @@ -190,7 +176,6 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo if (manager == Mekanism.securityFrequencies) { return getSecurity().getFrequency(); } - return frequency; } @@ -198,28 +183,23 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo if (frequency != null) { return frequency.getClosestCoords(Coord4D.get(this)); } - return null; } public void setFrequency(String name, boolean publicFreq) { FrequencyManager manager = getManager(new Frequency(name, null).setPublic(publicFreq)); manager.deactivate(Coord4D.get(this)); - for (Frequency freq : manager.getFrequencies()) { if (freq.name.equals(name)) { frequency = freq; frequency.activeCoords.add(Coord4D.get(this)); - return; } } - Frequency freq = new Frequency(name, getSecurity().getOwnerUUID()).setPublic(publicFreq); freq.activeCoords.add(Coord4D.get(this)); manager.addFrequency(freq); frequency = freq; - MekanismUtils.saveChunk(this); } @@ -227,28 +207,22 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo if (getSecurity().getOwnerUUID() == null || freq == null) { return null; } - if (freq.isPublic()) { return Mekanism.publicTeleporters; - } else { - if (!Mekanism.privateTeleporters.containsKey(getSecurity().getOwnerUUID())) { - FrequencyManager manager = new FrequencyManager(Frequency.class, Frequency.TELEPORTER, - getSecurity().getOwnerUUID()); - Mekanism.privateTeleporters.put(getSecurity().getOwnerUUID(), manager); - manager.createOrLoad(world); - } - - return Mekanism.privateTeleporters.get(getSecurity().getOwnerUUID()); + } else if (!Mekanism.privateTeleporters.containsKey(getSecurity().getOwnerUUID())) { + FrequencyManager manager = new FrequencyManager(Frequency.class, Frequency.TELEPORTER, getSecurity().getOwnerUUID()); + Mekanism.privateTeleporters.put(getSecurity().getOwnerUUID(), manager); + manager.createOrLoad(world); } + + return Mekanism.privateTeleporters.get(getSecurity().getOwnerUUID()); } @Override public void onChunkUnload() { super.onChunkUnload(); - if (!world.isRemote && frequency != null) { FrequencyManager manager = getManager(frequency); - if (manager != null) { manager.deactivate(Coord4D.get(this)); } @@ -258,11 +232,9 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo @Override public void invalidate() { super.invalidate(); - if (!world.isRemote) { if (frequency != null) { FrequencyManager manager = getManager(frequency); - if (manager != null) { manager.deactivate(Coord4D.get(this)); } @@ -272,13 +244,10 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo public void cleanTeleportCache() { List list = new ArrayList<>(); - for (Entity e : world.getEntitiesWithinAABB(Entity.class, teleportBounds)) { list.add(e.getPersistentID()); } - Set teleportCopy = new HashSet<>(didTeleport); - for (UUID id : teleportCopy) { if (!list.contains(id)) { didTeleport.remove(id); @@ -297,7 +266,6 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo if (slotID == 0) { return ChargeUtils.canBeDischarged(itemstack); } - return true; } @@ -312,24 +280,18 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo if (!hasFrame()) { return 2; } - if (getClosest() == null) { return 3; } - List entitiesInPortal = getToTeleport(); Coord4D closestCoords = getClosest(); - int electricityNeeded = 0; - for (Entity entity : entitiesInPortal) { electricityNeeded += calculateEnergyCost(entity, closestCoords); } - if (getEnergy() < electricityNeeded) { return 4; } - return 1; } @@ -337,47 +299,36 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo if (world.isRemote) { return; } - List entitiesInPortal = getToTeleport(); - Coord4D closestCoords = getClosest(); - if (closestCoords == null) { return; } - for (Entity entity : entitiesInPortal) { - World teleWorld = FMLCommonHandler.instance().getMinecraftServerInstance() - .getWorld(closestCoords.dimensionId); + World teleWorld = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(closestCoords.dimensionId); TileEntityTeleporter teleporter = (TileEntityTeleporter) closestCoords.getTileEntity(teleWorld); if (teleporter != null) { teleporter.didTeleport.add(entity.getPersistentID()); teleporter.teleDelay = 5; - if (entity instanceof EntityPlayerMP) { teleportPlayerTo((EntityPlayerMP) entity, closestCoords, teleporter); alignPlayer((EntityPlayerMP) entity, closestCoords); } else { teleportEntityTo(entity, closestCoords, teleporter); } - for (Coord4D coords : frequency.activeCoords) { Mekanism.packetHandler.sendToAllAround(new PortalFXMessage(coords), coords.getTargetPoint(40D)); } - setEnergy(getEnergy() - calculateEnergyCost(entity, closestCoords)); - - world.playSound(entity.posX, entity.posY, entity.posZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, - entity.getSoundCategory(), 1.0F, 1.0F, false); + world.playSound(entity.posX, entity.posY, entity.posZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, entity.getSoundCategory(), 1.0F, 1.0F, false); } } } public void teleportEntityTo(Entity entity, Coord4D coord, TileEntityTeleporter teleporter) { if (entity.world.provider.getDimension() != coord.dimensionId) { - entity.changeDimension(coord.dimensionId, - (world, entity2, yaw) -> entity2.setPositionAndUpdate(coord.x + 0.5, coord.y + 1, coord.z + 0.5)); + entity.changeDimension(coord.dimensionId, (world, entity2, yaw) -> entity2.setPositionAndUpdate(coord.x + 0.5, coord.y + 1, coord.z + 0.5)); } else { entity.setPositionAndUpdate(coord.x + 0.5, coord.y + 1, coord.z + 0.5); Mekanism.packetHandler.sendToReceivers(new EntityMoveMessage(entity), new Range4D(new Coord4D(entity))); @@ -387,51 +338,38 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo public List getToTeleport() { List entities = world.getEntitiesWithinAABB(Entity.class, teleportBounds); List ret = new ArrayList<>(); - for (Entity entity : entities) { if (!didTeleport.contains(entity.getPersistentID())) { ret.add(entity); } } - return ret; } public int calculateEnergyCost(Entity entity, Coord4D coords) { int energyCost = MekanismConfig.current().usage.teleporterBase.val(); - if (entity.world.provider.getDimension() != coords.dimensionId) { energyCost += MekanismConfig.current().usage.teleporterDimensionPenalty.val(); } else { int distance = (int) entity.getDistance(coords.x, coords.y, coords.z); - energyCost += (distance * MekanismConfig.current().usage.teleporterDistance.val()); + energyCost += distance * MekanismConfig.current().usage.teleporterDistance.val(); } - return energyCost; } public boolean hasFrame() { - if (isFrame(getPos().getX() - 1, getPos().getY(), getPos().getZ()) && isFrame(getPos().getX() + 1, - getPos().getY(), getPos().getZ()) - && isFrame(getPos().getX() - 1, getPos().getY() + 1, getPos().getZ()) && isFrame(getPos().getX() + 1, - getPos().getY() + 1, getPos().getZ()) - && isFrame(getPos().getX() - 1, getPos().getY() + 2, getPos().getZ()) && isFrame(getPos().getX() + 1, - getPos().getY() + 2, getPos().getZ()) - && isFrame(getPos().getX() - 1, getPos().getY() + 3, getPos().getZ()) && isFrame(getPos().getX() + 1, - getPos().getY() + 3, getPos().getZ()) - && isFrame(getPos().getX(), getPos().getY() + 3, getPos().getZ())) { + if (isFrame(getPos().getX() - 1, getPos().getY(), getPos().getZ()) && isFrame(getPos().getX() + 1, getPos().getY(), getPos().getZ()) + && isFrame(getPos().getX() - 1, getPos().getY() + 1, getPos().getZ()) && isFrame(getPos().getX() + 1, getPos().getY() + 1, getPos().getZ()) + && isFrame(getPos().getX() - 1, getPos().getY() + 2, getPos().getZ()) && isFrame(getPos().getX() + 1, getPos().getY() + 2, getPos().getZ()) + && isFrame(getPos().getX() - 1, getPos().getY() + 3, getPos().getZ()) && isFrame(getPos().getX() + 1, getPos().getY() + 3, getPos().getZ()) + && isFrame(getPos().getX(), getPos().getY() + 3, getPos().getZ())) { return true; } - return isFrame(getPos().getX(), getPos().getY(), getPos().getZ() - 1) && isFrame(getPos().getX(), - getPos().getY(), - getPos().getZ() + 1) - && isFrame(getPos().getX(), getPos().getY() + 1, getPos().getZ() - 1) && isFrame(getPos().getX(), - getPos().getY() + 1, getPos().getZ() + 1) - && isFrame(getPos().getX(), getPos().getY() + 2, getPos().getZ() - 1) && isFrame(getPos().getX(), - getPos().getY() + 2, getPos().getZ() + 1) - && isFrame(getPos().getX(), getPos().getY() + 3, getPos().getZ() - 1) && isFrame(getPos().getX(), - getPos().getY() + 3, getPos().getZ() + 1) - && isFrame(getPos().getX(), getPos().getY() + 3, getPos().getZ()); + return isFrame(getPos().getX(), getPos().getY(), getPos().getZ() - 1) && isFrame(getPos().getX(), getPos().getY(), getPos().getZ() + 1) + && isFrame(getPos().getX(), getPos().getY() + 1, getPos().getZ() - 1) && isFrame(getPos().getX(), getPos().getY() + 1, getPos().getZ() + 1) + && isFrame(getPos().getX(), getPos().getY() + 2, getPos().getZ() - 1) && isFrame(getPos().getX(), getPos().getY() + 2, getPos().getZ() + 1) + && isFrame(getPos().getX(), getPos().getY() + 3, getPos().getZ() - 1) && isFrame(getPos().getX(), getPos().getY() + 3, getPos().getZ() + 1) + && isFrame(getPos().getX(), getPos().getY() + 3, getPos().getZ()); } public boolean isFrame(int x, int y, int z) { @@ -442,9 +380,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - if (nbtTags.hasKey("frequency")) { frequency = new Frequency(nbtTags.getCompoundTag("frequency")); frequency.valid = false; @@ -455,15 +391,12 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setInteger("controlType", controlType.ordinal()); - if (frequency != null) { NBTTagCompound frequencyTag = new NBTTagCompound(); frequency.write(frequencyTag); nbtTags.setTag("frequency", frequencyTag); } - return nbtTags; } @@ -471,23 +404,18 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo public void handlePacketData(ByteBuf dataStream) { if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { int type = dataStream.readInt(); - if (type == 0) { String name = PacketHandler.readString(dataStream); boolean isPublic = dataStream.readBoolean(); - setFrequency(name, isPublic); } else if (type == 1) { String freq = PacketHandler.readString(dataStream); boolean isPublic = dataStream.readBoolean(); - FrequencyManager manager = getManager(new Frequency(freq, null).setPublic(isPublic)); - if (manager != null) { manager.remove(freq, getSecurity().getOwnerUUID()); } } - return; } @@ -508,13 +436,10 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo privateCache.clear(); int amount = dataStream.readInt(); - for (int i = 0; i < amount; i++) { publicCache.add(new Frequency(dataStream)); } - amount = dataStream.readInt(); - for (int i = 0; i < amount; i++) { privateCache.add(new Frequency(dataStream)); } @@ -535,25 +460,20 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo data.add(status); data.add(shouldRender); data.add(controlType.ordinal()); - data.add(Mekanism.publicTeleporters.getFrequencies().size()); - for (Frequency freq : Mekanism.publicTeleporters.getFrequencies()) { freq.write(data); } FrequencyManager manager = getManager(new Frequency(null, null).setPublic(false)); - if (manager != null) { data.add(manager.getFrequencies().size()); - for (Frequency freq : manager.getFrequencies()) { freq.write(data); } } else { data.add(0); } - return data; } @@ -583,12 +503,9 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo if (!(arguments[0] instanceof String) || !(arguments[1] instanceof Boolean)) { return new Object[]{"Invalid parameters."}; } - String freq = ((String) arguments[0]).trim(); boolean isPublic = (Boolean) arguments[1]; - setFrequency(freq, isPublic); - return new Object[]{"Frequency set."}; default: throw new NoSuchMethodException(); @@ -630,9 +547,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo @Override public Set getChunkSet() { Set ret = new HashSet<>(); - ret.add(new Chunk3D(Coord4D.get(this)).getPos()); - return ret; } @@ -640,4 +555,4 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo public TileComponentUpgrade getComponent() { return upgradeComponent; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationBlock.java b/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationBlock.java index 381f72ba7..0ab7ce544 100644 --- a/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationBlock.java @@ -14,26 +14,23 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.NonNullList; +import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.items.CapabilityItemHandler; -import net.minecraft.util.math.BlockPos; public class TileEntityThermalEvaporationBlock extends TileEntityContainerBlock implements IComputerIntegration { - private static final String[] methods = new String[]{"getTemperature", "getHeight", "isFormed", "getInput", - "getOutput"}; + private static final String[] methods = new String[]{"getTemperature", "getHeight", "isFormed", "getInput", "getOutput"}; public Coord4D master; public boolean attempted; public TileEntityThermalEvaporationBlock() { super("ThermalEvaporationBlock"); - inventory = NonNullList.withSize(0, ItemStack.EMPTY); } public TileEntityThermalEvaporationBlock(String fullName) { super(fullName); - inventory = NonNullList.withSize(0, ItemStack.EMPTY); } @@ -42,7 +39,6 @@ public class TileEntityThermalEvaporationBlock extends TileEntityContainerBlock if (!world.isRemote && ticker == 5 && !attempted && master == null) { updateController(); } - attempted = false; } @@ -57,10 +53,8 @@ public class TileEntityThermalEvaporationBlock extends TileEntityContainerBlock @Override public void onChunkUnload() { super.onChunkUnload(); - if (master != null) { TileEntityThermalEvaporationController tile = getController(); - if (tile != null) { tile.refresh(); } @@ -70,10 +64,8 @@ public class TileEntityThermalEvaporationBlock extends TileEntityContainerBlock @Override public void onNeighborChange(Block block) { super.onNeighborChange(block); - if (!world.isRemote) { TileEntityThermalEvaporationController tile = getController(); - if (tile != null) { tile.refresh(); } else { @@ -84,18 +76,17 @@ public class TileEntityThermalEvaporationBlock extends TileEntityContainerBlock public void updateController() { if (!(this instanceof TileEntityThermalEvaporationController)) { - for (EnumFacing side : EnumFacing.values()){ + for (EnumFacing side : EnumFacing.values()) { BlockPos checkPos = pos.offset(side); TileEntity check; if (world.isBlockLoaded(checkPos) && (check = world.getTileEntity(checkPos)) instanceof TileEntityThermalEvaporationBlock) { - if (check instanceof TileEntityThermalEvaporationController){ + if (check instanceof TileEntityThermalEvaporationController) { ((TileEntityThermalEvaporationController) check).refresh(); return; } } } TileEntityThermalEvaporationController found = new ControllerFinder().find(); - if (found != null) { found.refresh(); } @@ -105,12 +96,10 @@ public class TileEntityThermalEvaporationBlock extends TileEntityContainerBlock public TileEntityThermalEvaporationController getController() { if (master != null) { TileEntity tile = master.getTileEntity(world); - if (tile instanceof TileEntityThermalEvaporationController) { return (TileEntityThermalEvaporationController) tile; } } - return null; } @@ -122,11 +111,9 @@ public class TileEntityThermalEvaporationBlock extends TileEntityContainerBlock @Override public Object[] invoke(int method, Object[] args) throws Exception { TileEntityThermalEvaporationController controller = getController(); - if (controller == null) { return new Object[]{"Unformed."}; } - switch (method) { case 0: return new Object[]{controller.temperature}; @@ -195,8 +182,7 @@ public class TileEntityThermalEvaporationBlock extends TileEntityContainerBlock public TileEntityThermalEvaporationController find() { loop(TileEntityThermalEvaporationBlock.this.pos); - return found; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationController.java b/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationController.java index 603470412..e9e94d1eb 100644 --- a/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationController.java +++ b/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationController.java @@ -43,13 +43,12 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.items.CapabilityItemHandler; -public class TileEntityThermalEvaporationController extends TileEntityThermalEvaporationBlock implements IActiveState, - ITankManager { +public class TileEntityThermalEvaporationController extends TileEntityThermalEvaporationBlock implements IActiveState, ITankManager { public static final int MAX_OUTPUT = 10000; public static final int MAX_SOLARS = 4; public static final int MAX_HEIGHT = 18; - private static final int[] SLOTS = {0,1,2,3}; + private static final int[] SLOTS = {0, 1, 2, 3}; public FluidTank inputTank = new FluidTank(0); public FluidTank outputTank = new FluidTank(MAX_OUTPUT); @@ -88,21 +87,17 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva public TileEntityThermalEvaporationController() { super("ThermalEvaporationController"); - inventory = NonNullList.withSize(SLOTS.length, ItemStack.EMPTY); } @Override public void onUpdate() { super.onUpdate(); - if (!world.isRemote) { updatedThisTick = false; - if (ticker == 5) { refresh(); } - if (structured) { updateTemperature(); } @@ -110,17 +105,12 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva manageBuckets(); ThermalEvaporationRecipe recipe = getRecipe(); - if (canOperate(recipe)) { int outputNeeded = outputTank.getCapacity() - outputTank.getFluidAmount(); int inputStored = inputTank.getFluidAmount(); - double outputRatio = - (double) recipe.recipeOutput.output.amount / (double) recipe.recipeInput.ingredient.amount; - - double tempMult = - Math.max(0, getTemperature()) * MekanismConfig.current().general.evaporationTempMultiplier.val(); - double inputToUse = - (tempMult * recipe.recipeInput.ingredient.amount) * ((float) height / (float) MAX_HEIGHT); + double outputRatio = (double) recipe.recipeOutput.output.amount / (double) recipe.recipeInput.ingredient.amount; + double tempMult = Math.max(0, getTemperature()) * MekanismConfig.current().general.evaporationTempMultiplier.val(); + double inputToUse = tempMult * recipe.recipeInput.ingredient.amount * ((float) height / (float) MAX_HEIGHT); inputToUse = Math.min(inputTank.getFluidAmount(), inputToUse); inputToUse = Math.min(inputToUse, outputNeeded / outputRatio); @@ -131,7 +121,7 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva int inputInt = (int) Math.floor(partialInput); inputTank.drain(inputInt, true); partialInput %= 1; - partialOutput += ((double) inputInt) / recipe.recipeInput.ingredient.amount; + partialOutput += (double) inputInt / recipe.recipeInput.ingredient.amount; } if (partialOutput >= 1) { @@ -142,12 +132,9 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva } else { lastGain = 0; } - if (structured) { if (Math.abs((float) inputTank.getFluidAmount() / inputTank.getCapacity() - prevScale) > 0.01) { - Mekanism.packetHandler.sendToReceivers( - new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); prevScale = (float) inputTank.getFluidAmount() / inputTank.getCapacity(); } } @@ -161,14 +148,12 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva @Override public void onChunkUnload() { super.onChunkUnload(); - refresh(); } @Override public void onNeighborChange(Block block) { super.onNeighborChange(block); - refresh(); } @@ -176,7 +161,6 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva if (fluid == null) { return false; } - return Recipe.THERMAL_EVAPORATION_PLANT.containsRecipe(fluid); } @@ -185,11 +169,8 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva if (!updatedThisTick) { clearStructure(); structured = buildStructure(); - if (structured != clientStructured) { - Mekanism.packetHandler.sendToReceivers( - new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); clientStructured = structured; } @@ -210,7 +191,6 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva if (!structured || height < 3 || height > MAX_HEIGHT || inputTank.getFluid() == null) { return false; } - return recipe != null && recipe.canOperate(inputTank, outputTank); } @@ -239,7 +219,6 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva biomeTemp = world.getBiomeForCoordsBody(getPos()).getTemperature(getPos()); temperatureSet = true; } - heatToAbsorb += getActiveSolars() * MekanismConfig.current().general.evaporationSolarMultiplier.val(); temperature += heatToAbsorb / (float) height; @@ -249,26 +228,21 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva if (Math.abs(temperature - base) < 0.001) { temperature = base; } - - float incr = (float) Math.sqrt(Math.abs(temperature - base)) * (float) MekanismConfig - .current().general.evaporationHeatDissipation.val(); + float incr = (float) Math.sqrt(Math.abs(temperature - base)) * (float) MekanismConfig.current().general.evaporationHeatDissipation.val(); if (temperature > base) { incr = -incr; } float prev = temperature; - temperature = (float) Math - .min(MekanismConfig.current().general.evaporationMaxTemp.val(), temperature + incr / (float) height); + temperature = (float) Math.min(MekanismConfig.current().general.evaporationMaxTemp.val(), temperature + incr / (float) height); if (incr < 0) { totalLoss = prev - temperature; } else { totalLoss = 0; } - heatToAbsorb = 0; - MekanismUtils.saveChunk(this); } @@ -280,37 +254,30 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva if (world.isRemote) { return clientSolarAmount; } - int ret = 0; - for (IEvaporationSolar solar : solars) { if (solar != null && solar.canSeeSun()) { ret++; } } - return ret; } public boolean buildStructure() { EnumFacing right = MekanismUtils.getRight(facing); EnumFacing left = MekanismUtils.getLeft(facing); - height = 0; controllerConflict = false; updatedThisTick = true; Coord4D startPoint = Coord4D.get(this); - while (startPoint.offset(EnumFacing.UP).getTileEntity(world) instanceof TileEntityThermalEvaporationBlock) { startPoint = startPoint.offset(EnumFacing.UP); } Coord4D test = startPoint.offset(EnumFacing.DOWN).offset(right, 2); isLeftOnFace = test.getTileEntity(world) instanceof TileEntityThermalEvaporationBlock; - startPoint = startPoint.offset(left, isLeftOnFace ? 1 : 2); - if (!scanTopLayer(startPoint)) { return false; } @@ -318,60 +285,42 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva height = 1; Coord4D middlePointer = startPoint.offset(EnumFacing.DOWN); - while (scanLowerLayer(middlePointer)) { middlePointer = middlePointer.offset(EnumFacing.DOWN); } - renderY = middlePointer.y + 1; - if (height < 3 || height > MAX_HEIGHT) { height = 0; return false; } - structured = true; - markDirty(); - return true; } public boolean scanTopLayer(Coord4D current) { EnumFacing right = MekanismUtils.getRight(facing); EnumFacing back = MekanismUtils.getBack(facing); - for (int x = 0; x < 4; x++) { for (int z = 0; z < 4; z++) { Coord4D pointer = current.offset(right, x).offset(back, z); TileEntity pointerTile = pointer.getTileEntity(world); - int corner = getCorner(x, z); - if (corner != -1) { - if (addSolarPanel(pointer.getTileEntity(world), corner)) { - continue; - } else if (pointer.offset(EnumFacing.UP) - .getTileEntity(world) instanceof TileEntityThermalEvaporationBlock || !addTankPart( - pointerTile)) { + if (!addSolarPanel(pointer.getTileEntity(world), corner)) { + if (pointer.offset(EnumFacing.UP).getTileEntity(world) instanceof TileEntityThermalEvaporationBlock || !addTankPart(pointerTile)) { + return false; + } + } + } else if ((x == 1 || x == 2) && (z == 1 || z == 2)) { + if (!pointer.isAirBlock(world)) { return false; } - } else { - if ((x == 1 || x == 2) && (z == 1 || z == 2)) { - if (!pointer.isAirBlock(world)) { - return false; - } - } else { - if (pointer.offset(EnumFacing.UP) - .getTileEntity(world) instanceof TileEntityThermalEvaporationBlock || !addTankPart( - pointerTile)) { - return false; - } - } + } else if (pointer.offset(EnumFacing.UP).getTileEntity(world) instanceof TileEntityThermalEvaporationBlock || !addTankPart(pointerTile)) { + return false; } } } - return true; } @@ -389,21 +338,17 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva } else if (x == 3 && z == 3) { return 3; } - return -1; } public boolean scanLowerLayer(Coord4D current) { EnumFacing right = MekanismUtils.getRight(facing); EnumFacing back = MekanismUtils.getBack(facing); - boolean foundCenter = false; - for (int x = 0; x < 4; x++) { for (int z = 0; z < 4; z++) { Coord4D pointer = current.offset(right, x).offset(back, z); TileEntity pointerTile = pointer.getTileEntity(world); - if ((x == 1 || x == 2) && (z == 1 || z == 2)) { if (pointerTile instanceof TileEntityThermalEvaporationBlock) { if (!foundCenter) { @@ -414,17 +359,13 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva return false; } } - } else { - if (foundCenter || !pointer.isAirBlock(world)) { - height = -1; - return false; - } - } - } else { - if (!addTankPart(pointerTile)) { + } else if (foundCenter || !pointer.isAirBlock(world)) { height = -1; return false; } + } else if (!addTankPart(pointerTile)) { + height = -1; + return false; } } } @@ -435,31 +376,24 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva } public boolean addTankPart(TileEntity tile) { - if (tile instanceof TileEntityThermalEvaporationBlock && (tile == this - || !(tile instanceof TileEntityThermalEvaporationController))) { + if (tile instanceof TileEntityThermalEvaporationBlock && (tile == this || !(tile instanceof TileEntityThermalEvaporationController))) { if (tile != this) { ((TileEntityThermalEvaporationBlock) tile).addToStructure(Coord4D.get(this)); tankParts.add(Coord4D.get(tile)); } - return true; - } else { - if (tile != this && tile instanceof TileEntityThermalEvaporationController) { - controllerConflict = true; - } - - return false; + } else if (tile != this && tile instanceof TileEntityThermalEvaporationController) { + controllerConflict = true; } + return false; } public boolean addSolarPanel(TileEntity tile, int i) { - if (tile != null && !tile.isInvalid() && CapabilityUtils - .hasCapability(tile, Capabilities.EVAPORATION_SOLAR_CAPABILITY, EnumFacing.DOWN)) { + if (tile != null && !tile.isInvalid() && CapabilityUtils.hasCapability(tile, Capabilities.EVAPORATION_SOLAR_CAPABILITY, EnumFacing.DOWN)) { solars[i] = CapabilityUtils.getCapability(tile, Capabilities.EVAPORATION_SOLAR_CAPABILITY, EnumFacing.DOWN); return true; - } else { - return false; } + return false; } public int getScaledTempLevel(int i) { @@ -470,21 +404,17 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva if (!structured) { return null; } - EnumFacing right = MekanismUtils.getRight(facing); Coord4D startPoint = Coord4D.get(this).offset(right); startPoint = isLeftOnFace ? startPoint.offset(right) : startPoint; - startPoint = startPoint.offset(right.getOpposite()).offset(MekanismUtils.getBack(facing)); startPoint.y = renderY; - return startPoint; } @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { TileUtils.readTankData(dataStream, inputTank); TileUtils.readTankData(dataStream, outputTank); @@ -503,17 +433,14 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva if (structured != clientStructured) { inputTank.setCapacity(getMaxFluid()); MekanismUtils.updateBlock(world, getPos()); - if (structured) { // Calculate the two corners of the evap tower using the render location as basis (which is the // lowest rightmost corner inside the tower, relative to the controller). BlockPos corner1 = getRenderLocation().getPos().offset(facing).offset(facing.rotateYCCW()).down(); - BlockPos corner2 = corner1.offset(facing.getOpposite(), 3).offset(facing.rotateYCCW().getOpposite(), 3).up(height-1); + BlockPos corner2 = corner1.offset(facing.getOpposite(), 3).offset(facing.rotateYCCW().getOpposite(), 3).up(height - 1); // Use the corners to spin up the sparkle - Mekanism.proxy.doMultiblockSparkle(this, corner1, corner2, - tile -> tile instanceof TileEntityThermalEvaporationBlock); + Mekanism.proxy.doMultiblockSparkle(this, corner1, corner2, tile -> tile instanceof TileEntityThermalEvaporationBlock); } - clientStructured = structured; } } @@ -534,14 +461,12 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva data.add(lastGain); data.add(totalLoss); data.add(renderY); - return data; } @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - inputTank.readFromNBT(nbtTags.getCompoundTag("waterTank")); outputTank.readFromNBT(nbtTags.getCompoundTag("brineTank")); @@ -555,7 +480,6 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setTag("waterTank", inputTank.writeToNBT(new NBTTagCompound())); nbtTags.setTag("brineTank", outputTank.writeToNBT(new NBTTagCompound())); @@ -563,7 +487,6 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva nbtTags.setDouble("partialWater", partialInput); nbtTags.setDouble("partialBrine", partialOutput); - return nbtTags; } @@ -580,12 +503,10 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva public void clearStructure() { for (Coord4D tankPart : tankParts) { TileEntity tile = tankPart.getTileEntity(world); - if (tile instanceof TileEntityThermalEvaporationBlock) { ((TileEntityThermalEvaporationBlock) tile).controllerGone(); } } - tankParts.clear(); solars = new IEvaporationSolar[]{null, null, null, null}; } @@ -647,4 +568,4 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva } return super.isCapabilityDisabled(capability, side); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationValve.java b/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationValve.java index 8914f6593..32d630d7d 100644 --- a/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationValve.java +++ b/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationValve.java @@ -15,28 +15,23 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; -public class TileEntityThermalEvaporationValve extends TileEntityThermalEvaporationBlock implements - IFluidHandlerWrapper, IHeatTransfer { +public class TileEntityThermalEvaporationValve extends TileEntityThermalEvaporationBlock implements IFluidHandlerWrapper, IHeatTransfer { public boolean prevMaster = false; @Override public void onUpdate() { super.onUpdate(); - if (!world.isRemote) { if ((master == null) == prevMaster) { for (EnumFacing side : EnumFacing.VALUES) { Coord4D obj = Coord4D.get(this).offset(side); - - if (obj.exists(world) && !obj.isAirBlock(world) && !(obj - .getTileEntity(world) instanceof TileEntityThermalEvaporationBlock)) { + if (obj.exists(world) && !obj.isAirBlock(world) && !(obj.getTileEntity(world) instanceof TileEntityThermalEvaporationBlock)) { MekanismUtils.notifyNeighborofChange(world, obj, this.pos); } } } - - prevMaster = (master != null); + prevMaster = master != null; } } @@ -49,22 +44,18 @@ public class TileEntityThermalEvaporationValve extends TileEntityThermalEvaporat @Override public FluidStack drain(EnumFacing from, @Nullable FluidStack resource, boolean doDrain) { TileEntityThermalEvaporationController controller = getController(); - if (controller != null && resource != null && resource.isFluidEqual(controller.outputTank.getFluid())) { return controller.outputTank.drain(resource.amount, doDrain); } - return null; } @Override public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) { TileEntityThermalEvaporationController controller = getController(); - if (controller != null) { return controller.outputTank.drain(maxDrain, doDrain); } - return null; } @@ -83,11 +74,9 @@ public class TileEntityThermalEvaporationValve extends TileEntityThermalEvaporat @Override public FluidTankInfo[] getTankInfo(EnumFacing from) { TileEntityThermalEvaporationController controller = getController(); - if (controller == null) { return PipeUtils.EMPTY; } - return new FluidTankInfo[]{new FluidTankInfo(controller.inputTank), new FluidTankInfo(controller.outputTank)}; } @@ -114,7 +103,6 @@ public class TileEntityThermalEvaporationValve extends TileEntityThermalEvaporat @Override public void transferHeatTo(double heat) { TileEntityThermalEvaporationController controller = getController(); - if (controller != null) { controller.heatToAbsorb += heat; } @@ -142,9 +130,8 @@ public class TileEntityThermalEvaporationValve extends TileEntityThermalEvaporat @Override public boolean hasCapability(@Nonnull Capability capability, EnumFacing side) { - return capability == Capabilities.HEAT_TRANSFER_CAPABILITY || - (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && getController() != null) || - super.hasCapability(capability, side); + return capability == Capabilities.HEAT_TRANSFER_CAPABILITY || (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && getController() != null) || + super.hasCapability(capability, side); } @Override @@ -152,11 +139,9 @@ public class TileEntityThermalEvaporationValve extends TileEntityThermalEvaporat if (capability == Capabilities.HEAT_TRANSFER_CAPABILITY) { return Capabilities.HEAT_TRANSFER_CAPABILITY.cast(this); } - if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && getController() != null) { return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(new FluidHandlerWrapper(this, side)); } - return super.getCapability(capability, side); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/component/SideConfig.java b/src/main/java/mekanism/common/tile/component/SideConfig.java index 9d53be469..11eaf8ed4 100644 --- a/src/main/java/mekanism/common/tile/component/SideConfig.java +++ b/src/main/java/mekanism/common/tile/component/SideConfig.java @@ -52,4 +52,4 @@ public class SideConfig { public void deleteObserver(Observer o) { observable.deleteObserver(o); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/component/TileComponentChunkLoader.java b/src/main/java/mekanism/common/tile/component/TileComponentChunkLoader.java index b9536e45c..25e609756 100644 --- a/src/main/java/mekanism/common/tile/component/TileComponentChunkLoader.java +++ b/src/main/java/mekanism/common/tile/component/TileComponentChunkLoader.java @@ -37,7 +37,6 @@ public class TileComponentChunkLoader implements ITileComponent { public TileComponentChunkLoader(TileEntityContainerBlock tile) { tileEntity = tile; - tile.components.add(this); } @@ -48,10 +47,8 @@ public class TileComponentChunkLoader implements ITileComponent { ForgeChunkManager.unforceChunk(chunkTicket, chunk); } } - ForgeChunkManager.releaseTicket(chunkTicket); } - chunkTicket = t; } @@ -68,7 +65,6 @@ public class TileComponentChunkLoader implements ITileComponent { } } } - for (ChunkPos chunk : chunkSet) { if (!chunkTicket.getChunkList().contains(chunk)) { ForgeChunkManager.forceChunk(chunkTicket, chunk); @@ -79,7 +75,6 @@ public class TileComponentChunkLoader implements ITileComponent { public void refreshChunkSet() { IChunkLoader loader = (IChunkLoader) tileEntity; - if (!chunkSet.equals(loader.getChunkSet())) { chunkSet = loader.getChunkSet(); sortChunks(); @@ -88,15 +83,13 @@ public class TileComponentChunkLoader implements ITileComponent { public void forceChunks(Ticket ticket) { setTicket(ticket); - for (ChunkPos chunk : chunkSet) { ForgeChunkManager.forceChunk(chunkTicket, chunk); } } public boolean canOperate() { - return MekanismConfig.current().general.allowChunkloading.val() && ((IUpgradeTile) tileEntity).getComponent() - .getInstalledTypes().contains(Upgrade.ANCHOR); + return MekanismConfig.current().general.allowChunkloading.val() && ((IUpgradeTile) tileEntity).getComponent().getInstalledTypes().contains(Upgrade.ANCHOR); } @Override @@ -117,8 +110,7 @@ public class TileComponentChunkLoader implements ITileComponent { Ticket ticket; if (tileEntity instanceof ISecurityTile) { ticket = ForgeChunkManager.requestPlayerTicket(Mekanism.instance, - MekanismUtils.getLastKnownUsername(((ISecurityTile) tileEntity).getSecurity().getOwnerUUID()), - tileEntity.getWorld(), Type.NORMAL); + MekanismUtils.getLastKnownUsername(((ISecurityTile) tileEntity).getSecurity().getOwnerUUID()), tileEntity.getWorld(), Type.NORMAL); } else { ticket = ForgeChunkManager.requestTicket(Mekanism.instance, tileEntity.getWorld(), Type.NORMAL); } @@ -127,7 +119,6 @@ public class TileComponentChunkLoader implements ITileComponent { ticket.getModData().setInteger("x", tileEntity.getPos().getX()); ticket.getModData().setInteger("y", tileEntity.getPos().getY()); ticket.getModData().setInteger("z", tileEntity.getPos().getZ()); - forceChunks(ticket); } } @@ -137,10 +128,8 @@ public class TileComponentChunkLoader implements ITileComponent { @Override public void read(NBTTagCompound nbtTags) { prevCoord = Coord4D.read(nbtTags.getCompoundTag("prevCoord")); - chunkSet.clear(); NBTTagList list = nbtTags.getTagList("chunkSet", NBT.TAG_COMPOUND); - for (int i = 0; i < list.tagCount(); i++) { NBTTagCompound compound = list.getCompoundTagAt(i); chunkSet.add(new ChunkPos(compound.getInteger("chunkX"), compound.getInteger("chunkZ"))); @@ -158,14 +147,12 @@ public class TileComponentChunkLoader implements ITileComponent { } NBTTagList list = new NBTTagList(); - for (ChunkPos pos : chunkSet) { NBTTagCompound compound = new NBTTagCompound(); compound.setInteger("chunkX", pos.x); compound.setInteger("chunkZ", pos.z); list.appendTag(compound); } - nbtTags.setTag("chunkSet", list); } @@ -179,4 +166,4 @@ public class TileComponentChunkLoader implements ITileComponent { release(); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/component/TileComponentConfig.java b/src/main/java/mekanism/common/tile/component/TileComponentConfig.java index e6ad0fa40..e9f14cc08 100644 --- a/src/main/java/mekanism/common/tile/component/TileComponentConfig.java +++ b/src/main/java/mekanism/common/tile/component/TileComponentConfig.java @@ -37,11 +37,9 @@ public class TileComponentConfig implements ITileComponent { public TileComponentConfig(TileEntityContainerBlock tile, TransmissionType... types) { tileEntity = tile; - for (TransmissionType type : types) { addSupported(type); } - tile.components.add(this); } @@ -56,7 +54,6 @@ public class TileComponentConfig implements ITileComponent { if (!transmissions.contains(type)) { transmissions.add(type); } - sideOutputs.put(type, new ArrayList<>()); ejecting.put(type, false); canEject.put(type, true); @@ -72,7 +69,6 @@ public class TileComponentConfig implements ITileComponent { ret.add(sideToCheck); } } - return ret; } @@ -112,7 +108,6 @@ public class TileComponentConfig implements ITileComponent { public void fillConfig(TransmissionType type, int data) { byte sideData = (byte) data; - setConfig(type, sideData, sideData, sideData, sideData, sideData, sideData); } @@ -120,14 +115,12 @@ public class TileComponentConfig implements ITileComponent { addOutput(type, new SideData("None", EnumColor.GREY, IOState.OFF)); addOutput(type, new SideData("Input", EnumColor.DARK_GREEN, IOState.INPUT)); addOutput(type, new SideData("Output", EnumColor.DARK_RED, IOState.OUTPUT)); - setConfig(type, new byte[]{1, 1, 2, 1, 1, 1}); } public void setInputConfig(TransmissionType type) { addOutput(type, new SideData("None", EnumColor.GREY, IOState.OFF)); addOutput(type, new SideData("Input", EnumColor.DARK_GREEN, IOState.INPUT)); - fillConfig(type, 1); setCanEject(type, false); } @@ -157,7 +150,6 @@ public class TileComponentConfig implements ITileComponent { if (side == null) { return EMPTY; } - return getOutput(type, MekanismUtils.getBaseOrientation(side, facing)); } @@ -175,7 +167,6 @@ public class TileComponentConfig implements ITileComponent { sideConfig.set(side, (byte) 0); index = 0; } - return getOutputs(type).get(index); } @@ -212,7 +203,6 @@ public class TileComponentConfig implements ITileComponent { for (TransmissionType type : transmissions) { byte[] array = new byte[6]; dataStream.readBytes(array); - sideConfigs.put(type, new SideConfig(array)); ejecting.put(type, dataStream.readBoolean()); } @@ -224,7 +214,6 @@ public class TileComponentConfig implements ITileComponent { nbtTags.setByteArray("config" + type.ordinal(), sideConfigs.get(type).asByteArray()); nbtTags.setBoolean("ejecting" + type.ordinal(), ejecting.get(type)); } - nbtTags.setBoolean("sideDataStored", true); } @@ -235,7 +224,6 @@ public class TileComponentConfig implements ITileComponent { for (TransmissionType type : transmissions) { data.add(type.ordinal()); } - for (TransmissionType type : transmissions) { data.add(sideConfigs.get(type).asByteArray()); data.add(ejecting.get(type)); @@ -254,4 +242,4 @@ public class TileComponentConfig implements ITileComponent { ejecting.put(type, eject); MekanismUtils.saveChunk(tileEntity); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/component/TileComponentEjector.java b/src/main/java/mekanism/common/tile/component/TileComponentEjector.java index 75917738c..19d914fc1 100644 --- a/src/main/java/mekanism/common/tile/component/TileComponentEjector.java +++ b/src/main/java/mekanism/common/tile/component/TileComponentEjector.java @@ -48,14 +48,12 @@ public class TileComponentEjector implements ITileComponent { public TileComponentEjector(TileEntityContainerBlock tile) { tileEntity = tile; - tile.components.add(this); } public TileComponentEjector setOutputData(TransmissionType type, SideData data) { sideData.put(type, data); trackers.put(type, new int[data.availableSlots.length]); - return this; } @@ -69,7 +67,6 @@ public class TileComponentEjector implements ITileComponent { private List getTrackedOutputs(TransmissionType type, int index, Set dirs) { List sides = new ArrayList<>(); - for (int i = trackers.get(type)[index] + 1; i <= trackers.get(type)[index] + 6; i++) { for (EnumFacing side : dirs) { if (EnumFacing.byIndex(i % 6) == side) { @@ -77,7 +74,6 @@ public class TileComponentEjector implements ITileComponent { } } } - return sides; } @@ -90,15 +86,12 @@ public class TileComponentEjector implements ITileComponent { } else { tickDelay--; } - if (!tileEntity.getWorld().isRemote) { if (sideData.get(TransmissionType.GAS) != null && getEjecting(TransmissionType.GAS)) { SideData data = sideData.get(TransmissionType.GAS); Set outputSides = getOutputSides(TransmissionType.GAS, data); - if (((ITankManager) tileEntity).getTanks() != null) { GasTank tank = (GasTank) ((ITankManager) tileEntity).getTanks()[data.availableSlots[0]]; - if (tank.getStored() > 0) { GasStack toEmit = tank.getGas().copy().withAmount(Math.min(GAS_OUTPUT, tank.getStored())); int emit = GasUtils.emit(toEmit, tileEntity, outputSides); @@ -110,13 +103,10 @@ public class TileComponentEjector implements ITileComponent { if (sideData.get(TransmissionType.FLUID) != null && getEjecting(TransmissionType.FLUID)) { SideData data = sideData.get(TransmissionType.FLUID); Set outputSides = getOutputSides(TransmissionType.FLUID, data); - if (((ITankManager) tileEntity).getTanks() != null) { FluidTank tank = (FluidTank) ((ITankManager) tileEntity).getTanks()[data.availableSlots[0]]; - if (tank.getFluidAmount() > 0) { - FluidStack toEmit = PipeUtils - .copy(tank.getFluid(), Math.min(FLUID_OUTPUT, tank.getFluidAmount())); + FluidStack toEmit = PipeUtils.copy(tank.getFluid(), Math.min(FLUID_OUTPUT, tank.getFluidAmount())); int emit = PipeUtils.emit(outputSides, toEmit, tileEntity); tank.drain(emit, true); } @@ -131,14 +121,12 @@ public class TileComponentEjector implements ITileComponent { SideConfig sideConfig = config.getConfig(type); ArrayList outputs = config.getOutputs(type); EnumFacing[] facings = MekanismUtils.getBaseOrientations(tileEntity.facing); - for (int i = 0; i < EnumFacing.VALUES.length; i++) { EnumFacing side = facings[i]; if (sideConfig.get(side) == outputs.indexOf(data)) { outputSides.add(EnumFacing.VALUES[i]); } } - return outputSides; } @@ -149,34 +137,26 @@ public class TileComponentEjector implements ITileComponent { SideData data = sideData.get(TransmissionType.ITEM); Set outputSides = getOutputSides(TransmissionType.ITEM, data); - for (int index = 0; index < sideData.get(TransmissionType.ITEM).availableSlots.length; index++) { int slotID = sideData.get(TransmissionType.ITEM).availableSlots[index]; - if (tileEntity.getStackInSlot(slotID).isEmpty()) { continue; } ItemStack stack = tileEntity.getStackInSlot(slotID); List outputs = getTrackedOutputs(TransmissionType.ITEM, index, outputSides); - for (EnumFacing side : outputs) { TileEntity tile = Coord4D.get(tileEntity).offset(side).getTileEntity(tileEntity.getWorld()); ItemStack prev = stack.copy(); - if (CapabilityUtils - .hasCapability(tile, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, side.getOpposite())) { - TransitResponse response = TransporterUtils.insert(tileEntity, CapabilityUtils - .getCapability(tile, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, side.getOpposite()), + if (CapabilityUtils.hasCapability(tile, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, side.getOpposite())) { + TransitResponse response = TransporterUtils.insert(tileEntity, CapabilityUtils.getCapability(tile, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, side.getOpposite()), TransitRequest.getFromStack(stack.copy()), outputColor, true, 0); - if (!response.isEmpty()) { stack.shrink(response.getStack().getCount()); } } else { - TransitResponse response = InventoryUtils - .putStackInInventory(tile, TransitRequest.getFromStack(stack.copy()), side, false); - + TransitResponse response = InventoryUtils.putStackInInventory(tile, TransitRequest.getFromStack(stack.copy()), side, false); if (!response.isEmpty()) { stack.shrink(response.getStack().getCount()); } @@ -185,7 +165,6 @@ public class TileComponentEjector implements ITileComponent { if (stack.isEmpty() || prev.getCount() != stack.getCount()) { trackers.get(TransmissionType.ITEM)[index] = side.ordinal(); } - if (stack.isEmpty()) { break; } @@ -194,7 +173,6 @@ public class TileComponentEjector implements ITileComponent { tileEntity.setInventorySlotContents(slotID, stack); tileEntity.markDirty(); } - tickDelay = 20; } @@ -242,7 +220,6 @@ public class TileComponentEjector implements ITileComponent { 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); } else { @@ -278,17 +255,14 @@ public class TileComponentEjector implements ITileComponent { @Override public void write(NBTTagCompound nbtTags) { nbtTags.setBoolean("strictInput", strictInput); - if (outputColor != null) { nbtTags.setInteger("ejectColor", TransporterUtils.colors.indexOf(outputColor)); } - for (TransmissionType type : sideData.keySet()) { for (int i = 0; i < sideData.get(type).availableSlots.length; i++) { nbtTags.setInteger("tracker" + type.getTransmission() + i, trackers.get(type)[i]); } } - for (int i = 0; i < 6; i++) { if (inputColors[i] == null) { nbtTags.setInteger("inputColors" + i, -1); @@ -324,4 +298,4 @@ public class TileComponentEjector implements ITileComponent { private boolean getEjecting(TransmissionType type) { return ((ISideConfiguration) tileEntity).getConfig().isEjecting(type); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/component/TileComponentSecurity.java b/src/main/java/mekanism/common/tile/component/TileComponentSecurity.java index bf97f7c22..a6953142d 100644 --- a/src/main/java/mekanism/common/tile/component/TileComponentSecurity.java +++ b/src/main/java/mekanism/common/tile/component/TileComponentSecurity.java @@ -32,7 +32,6 @@ public class TileComponentSecurity implements ITileComponent { public TileComponentSecurity(TileEntityContainerBlock tile) { tileEntity = tile; - tile.components.add(this); } @@ -53,7 +52,6 @@ public class TileComponentSecurity implements ITileComponent { if (freq.ownerUUID.equals(owner)) { frequency = (SecurityFrequency) freq; frequency.activeCoords.add(Coord4D.get(tileEntity)); - return; } } @@ -83,9 +81,8 @@ public class TileComponentSecurity implements ITileComponent { public SecurityMode getMode() { if (MekanismConfig.current().general.allowProtection.val()) { return securityMode; - } else { - return SecurityMode.PUBLIC; } + return SecurityMode.PUBLIC; } public void setMode(SecurityMode mode) { @@ -96,7 +93,6 @@ public class TileComponentSecurity implements ITileComponent { if (ownerUUID == null || freq == null) { return null; } - return Mekanism.securityFrequencies; } @@ -106,15 +102,12 @@ public class TileComponentSecurity implements ITileComponent { if (frequency == null && ownerUUID != null) { setFrequency(ownerUUID); } - FrequencyManager manager = getManager(frequency); if (manager != null) { if (frequency != null && !frequency.valid) { - frequency = (SecurityFrequency) manager - .validateFrequency(ownerUUID, Coord4D.get(tileEntity), frequency); + frequency = (SecurityFrequency) manager.validateFrequency(ownerUUID, Coord4D.get(tileEntity), frequency); } - if (frequency != null) { frequency = (SecurityFrequency) manager.update(Coord4D.get(tileEntity), frequency); } @@ -127,11 +120,9 @@ public class TileComponentSecurity implements ITileComponent { @Override public void read(NBTTagCompound nbtTags) { securityMode = SecurityMode.values()[nbtTags.getInteger("securityMode")]; - if (nbtTags.hasKey("ownerUUID")) { ownerUUID = UUID.fromString(nbtTags.getString("ownerUUID")); } - if (nbtTags.hasKey("securityFreq")) { frequency = new SecurityFrequency(nbtTags.getCompoundTag("securityFreq")); frequency.valid = false; @@ -160,11 +151,9 @@ public class TileComponentSecurity implements ITileComponent { @Override public void write(NBTTagCompound nbtTags) { nbtTags.setInteger("securityMode", securityMode.ordinal()); - if (ownerUUID != null) { nbtTags.setString("ownerUUID", ownerUUID.toString()); } - if (frequency != null) { NBTTagCompound frequencyTag = new NBTTagCompound(); frequency.write(frequencyTag); @@ -197,11 +186,10 @@ public class TileComponentSecurity implements ITileComponent { if (!tileEntity.getWorld().isRemote) { if (frequency != null) { FrequencyManager manager = getManager(frequency); - if (manager != null) { manager.deactivate(Coord4D.get(tileEntity)); } } } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/component/TileComponentUpgrade.java b/src/main/java/mekanism/common/tile/component/TileComponentUpgrade.java index 673beaa0a..c55fe1a5f 100644 --- a/src/main/java/mekanism/common/tile/component/TileComponentUpgrade.java +++ b/src/main/java/mekanism/common/tile/component/TileComponentUpgrade.java @@ -7,11 +7,11 @@ import java.util.Map; import java.util.Set; import mekanism.api.Coord4D; import mekanism.api.Range4D; +import mekanism.api.TileNetworkList; import mekanism.common.Mekanism; import mekanism.common.Upgrade; import mekanism.common.base.ITileComponent; import mekanism.common.base.IUpgradeItem; -import mekanism.api.TileNetworkList; import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.tile.prefab.TileEntityContainerBlock; import net.minecraft.nbt.NBTTagCompound; @@ -40,10 +40,8 @@ public class TileComponentUpgrade implements ITileComponent { public TileComponentUpgrade(TileEntityContainerBlock tile, int slot) { tileEntity = tile; upgradeSlot = slot; - setSupported(Upgrade.SPEED); setSupported(Upgrade.ENERGY); - tile.components.add(this); } @@ -58,10 +56,8 @@ public class TileComponentUpgrade implements ITileComponent { @Override public void tick() { if (!tileEntity.getWorld().isRemote) { - if (!tileEntity.inventory.get(upgradeSlot).isEmpty() && tileEntity.inventory.get(upgradeSlot) - .getItem() instanceof IUpgradeItem) { - Upgrade type = ((IUpgradeItem) tileEntity.inventory.get(upgradeSlot).getItem()) - .getUpgradeType(tileEntity.inventory.get(upgradeSlot)); + if (!tileEntity.inventory.get(upgradeSlot).isEmpty() && tileEntity.inventory.get(upgradeSlot).getItem() instanceof IUpgradeItem) { + Upgrade type = ((IUpgradeItem) tileEntity.inventory.get(upgradeSlot).getItem()).getUpgradeType(tileEntity.inventory.get(upgradeSlot)); if (supports(type) && getUpgrades(type) < type.getMax()) { if (upgradeTicks < UPGRADE_TICKS_REQUIRED) { @@ -69,11 +65,8 @@ public class TileComponentUpgrade implements ITileComponent { } else if (upgradeTicks == UPGRADE_TICKS_REQUIRED) { upgradeTicks = 0; addUpgrade(type); - tileEntity.inventory.get(upgradeSlot).shrink(1); - - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), - tileEntity.getNetworkedData(new TileNetworkList())), + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(tileEntity))); tileEntity.markDirty(); } @@ -102,23 +95,19 @@ public class TileComponentUpgrade implements ITileComponent { if (upgrades.get(upgrade) == null) { return 0; } - return upgrades.get(upgrade); } public void addUpgrade(Upgrade upgrade) { upgrades.put(upgrade, Math.min(upgrade.getMax(), getUpgrades(upgrade) + 1)); - tileEntity.recalculateUpgradables(upgrade); } public void removeUpgrade(Upgrade upgrade) { upgrades.put(upgrade, Math.max(0, getUpgrades(upgrade) - 1)); - if (upgrades.get(upgrade) == 0) { upgrades.remove(upgrade); } - tileEntity.recalculateUpgradables(upgrade); } @@ -153,15 +142,12 @@ public class TileComponentUpgrade implements ITileComponent { @Override public void read(ByteBuf dataStream) { upgrades.clear(); - int amount = dataStream.readInt(); for (int i = 0; i < amount; i++) { upgrades.put(Upgrade.values()[dataStream.readInt()], dataStream.readInt()); } - upgradeTicks = dataStream.readInt(); - for (Upgrade upgrade : getSupportedTypes()) { tileEntity.recalculateUpgradables(upgrade); } @@ -170,19 +156,16 @@ public class TileComponentUpgrade implements ITileComponent { @Override public void write(TileNetworkList data) { data.add(upgrades.size()); - for (Map.Entry entry : upgrades.entrySet()) { data.add(entry.getKey().ordinal()); data.add(entry.getValue()); } - data.add(upgradeTicks); } @Override public void read(NBTTagCompound nbtTags) { upgrades = Upgrade.buildMap(nbtTags); - for (Upgrade upgrade : getSupportedTypes()) { tileEntity.recalculateUpgradables(upgrade); } @@ -196,4 +179,4 @@ public class TileComponentUpgrade implements ITileComponent { @Override public void invalidate() { } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/prefab/TileEntityAdvancedElectricMachine.java b/src/main/java/mekanism/common/tile/prefab/TileEntityAdvancedElectricMachine.java index 2a1752722..2c736af82 100644 --- a/src/main/java/mekanism/common/tile/prefab/TileEntityAdvancedElectricMachine.java +++ b/src/main/java/mekanism/common/tile/prefab/TileEntityAdvancedElectricMachine.java @@ -37,11 +37,10 @@ import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.FMLCommonHandler; public abstract class TileEntityAdvancedElectricMachine> extends - TileEntityUpgradeableMachine implements IGasHandler, - ISustainedData { + TileEntityUpgradeableMachine implements IGasHandler, ISustainedData { - private static final String[] methods = new String[]{"getEnergy", "getSecondaryStored", "getProgress", "isActive", - "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"}; + private static final String[] methods = new String[]{"getEnergy", "getSecondaryStored", "getProgress", "isActive", "facing", "canOperate", "getMaxEnergy", + "getEnergyNeeded"}; public static final int BASE_TICKS_REQUIRED = 200; public static final int BASE_GAS_PER_TICK = 1; public static int MAX_GAS = 210; @@ -58,22 +57,18 @@ public abstract class TileEntityAdvancedElectricMachine= energyPerTick - && gasTank.getStored() >= secondaryEnergyThisTick) { + if (canOperate(recipe) && MekanismUtils.canFunction(this) && getEnergy() >= energyPerTick && gasTank.getStored() >= secondaryEnergyThisTick) { setActive(true); - operatingTicks++; - if (operatingTicks >= ticksRequired) { operate(recipe); - operatingTicks = 0; } - gasTank.draw(secondaryEnergyThisTick, true); electricityStored -= energyPerTick; } else { @@ -169,9 +154,7 @@ public abstract class TileEntityAdvancedElectricMachine 0) { GasStack stack = getItemGas(inventory.get(1)); int gasNeeded = gasTank.getNeeded(); - if (stack != null && gasTank.canReceive(stack.getGas()) && gasNeeded >= stack.amount) { gasTank.receive(stack, true); - inventory.get(1).shrink(1); } } @@ -204,8 +185,7 @@ public abstract class TileEntityAdvancedElectricMachine 0) { for (EntityPlayer player : playersUsing) { - Mekanism.packetHandler - .sendTo(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - (EntityPlayerMP) player); + Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), (EntityPlayerMP) player); } } } - ticker++; redstoneLastTick = redstone; } @@ -105,7 +98,6 @@ public abstract class TileEntityBasicBlock extends TileEntity implements ITileNe @Override public void updateContainingBlockInfo() { super.updateContainingBlockInfo(); - onAdded(); } @@ -122,13 +114,11 @@ public abstract class TileEntityBasicBlock extends TileEntity implements ITileNe if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { facing = EnumFacing.byIndex(dataStream.readInt()); redstone = dataStream.readBoolean(); - if (clientFacing != facing) { MekanismUtils.updateBlock(world, getPos()); world.notifyNeighborsOfStateChange(getPos(), world.getBlockState(getPos()).getBlock(), true); clientFacing = facing; } - for (ITileComponent component : components) { component.read(dataStream); } @@ -139,18 +129,15 @@ public abstract class TileEntityBasicBlock extends TileEntity implements ITileNe public TileNetworkList getNetworkedData(TileNetworkList data) { data.add(facing == null ? -1 : facing.ordinal()); data.add(redstone); - for (ITileComponent component : components) { component.write(data); } - return data; } @Override public void invalidate() { super.invalidate(); - for (ITileComponent component : components) { component.invalidate(); } @@ -159,7 +146,6 @@ public abstract class TileEntityBasicBlock extends TileEntity implements ITileNe @Override public void validate() { super.validate(); - if (world.isRemote) { Mekanism.packetHandler.sendToServer(new DataRequestMessage(Coord4D.get(this))); } @@ -173,13 +159,10 @@ public abstract class TileEntityBasicBlock extends TileEntity implements ITileNe @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - if (nbtTags.hasKey("facing")) { facing = EnumFacing.byIndex(nbtTags.getInteger("facing")); } - redstone = nbtTags.getBoolean("redstone"); - for (ITileComponent component : components) { component.read(nbtTags); } @@ -189,17 +172,13 @@ public abstract class TileEntityBasicBlock extends TileEntity implements ITileNe @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - if (facing != null) { nbtTags.setInteger("facing", facing.ordinal()); } - nbtTags.setBoolean("redstone", redstone); - for (ITileComponent component : components) { component.write(nbtTags); } - return nbtTags; } @@ -220,11 +199,8 @@ public abstract class TileEntityBasicBlock extends TileEntity implements ITileNe if (canSetFacing(direction)) { facing = EnumFacing.byIndex(direction); } - if (!(facing == clientFacing || world.isRemote)) { - Mekanism.packetHandler - .sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); markDirty(); clientFacing = facing; } @@ -234,6 +210,7 @@ public abstract class TileEntityBasicBlock extends TileEntity implements ITileNe * Whether or not this block's orientation can be changed to a specific direction. True by default. * * @param facing - facing to check + * * @return if the block's orientation can be changed */ public boolean canSetFacing(int facing) { @@ -259,13 +236,9 @@ public abstract class TileEntityBasicBlock extends TileEntity implements ITileNe private void updatePower() { boolean power = world.getRedstonePowerFromNeighbors(getPos()) > 0; - if (redstone != power) { redstone = power; - Mekanism.packetHandler - .sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); - + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); onPowerChange(); } } @@ -282,7 +255,6 @@ public abstract class TileEntityBasicBlock extends TileEntity implements ITileNe if (manager == Mekanism.securityFrequencies && this instanceof ISecurityTile) { return ((ISecurityTile) this).getSecurity().getFrequency(); } - return null; } @@ -302,4 +274,4 @@ public abstract class TileEntityBasicBlock extends TileEntity implements ITileNe // a full NBT object, don't pass it to our custom read methods. super.readFromNBT(tag); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/prefab/TileEntityBasicMachine.java b/src/main/java/mekanism/common/tile/prefab/TileEntityBasicMachine.java index 888ab4051..ea78072f1 100644 --- a/src/main/java/mekanism/common/tile/prefab/TileEntityBasicMachine.java +++ b/src/main/java/mekanism/common/tile/prefab/TileEntityBasicMachine.java @@ -17,8 +17,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.capabilities.Capability; public abstract class TileEntityBasicMachine, OUTPUT extends MachineOutput, RECIPE extends MachineRecipe> extends - TileEntityOperationalMachine implements IElectricMachine, IComputerIntegration, - ISideConfiguration, IConfigCardAccess { + TileEntityOperationalMachine implements IElectricMachine, IComputerIntegration, ISideConfiguration, IConfigCardAccess { public ResourceLocation guiLocation; @@ -28,18 +27,15 @@ public abstract class TileEntityBasicMachine, public TileComponentConfig configComponent; /** - * The foundation of all machines - a simple tile entity with a facing, active state, initialized state, sound - * effect, and animated texture. + * 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 - * @param name - full name of this machine - * @param baseMaxEnergy - how much energy this machine can store + * @param soundPath - location of the sound effect + * @param name - full name of this machine + * @param baseMaxEnergy - how much energy this machine can store * @param baseTicksRequired - how many ticks it takes to run a cycle */ - public TileEntityBasicMachine(String soundPath, String name, double baseMaxEnergy, double baseEnergyUsage, - int upgradeSlot, int baseTicksRequired, ResourceLocation location) { + public TileEntityBasicMachine(String soundPath, String name, double baseMaxEnergy, double baseEnergyUsage, int upgradeSlot, int baseTicksRequired, ResourceLocation location) { super("machine." + soundPath, name, baseMaxEnergy, baseEnergyUsage, upgradeSlot, baseTicksRequired); - guiLocation = location; } @@ -85,13 +81,11 @@ public abstract class TileEntityBasicMachine, if (capability == Capabilities.CONFIG_CARD_CAPABILITY) { return Capabilities.CONFIG_CARD_CAPABILITY.cast(this); } - return super.getCapability(capability, side); } @Override public boolean isCapabilityDisabled(@Nonnull Capability capability, EnumFacing side) { - return configComponent.isCapabilityDisabled(capability, side, facing) || super - .isCapabilityDisabled(capability, side); + return configComponent.isCapabilityDisabled(capability, side, facing) || super.isCapabilityDisabled(capability, side); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/prefab/TileEntityContainerBlock.java b/src/main/java/mekanism/common/tile/prefab/TileEntityContainerBlock.java index d1ecda6a1..6f64fb2c8 100644 --- a/src/main/java/mekanism/common/tile/prefab/TileEntityContainerBlock.java +++ b/src/main/java/mekanism/common/tile/prefab/TileEntityContainerBlock.java @@ -24,8 +24,7 @@ import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.wrapper.InvWrapper; -public abstract class TileEntityContainerBlock extends TileEntityBasicBlock implements ISidedInventory, - ISustainedInventory, ITickable, IToggleableCapability { +public abstract class TileEntityContainerBlock extends TileEntityBasicBlock implements ISidedInventory, ISustainedInventory, ITickable, IToggleableCapability { /** * The inventory slot itemstacks used by this block. @@ -36,8 +35,7 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl * The full name of this machine. */ public String fullName; - private CapabilityWrapperManager itemManager = new CapabilityWrapperManager<>( - ISidedInventory.class, ItemHandlerWrapper.class); + private CapabilityWrapperManager itemManager = new CapabilityWrapperManager<>(ISidedInventory.class, ItemHandlerWrapper.class); /** * Read only itemhandler for the null facing. */ @@ -76,22 +74,18 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl return false; } } - return true; } @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - if (handleInventory()) { NBTTagList tagList = nbtTags.getTagList("Items", NBT.TAG_COMPOUND); inventory = NonNullList.withSize(getSizeInventory(), ItemStack.EMPTY); - for (int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(tagCount); byte slotID = tagCompound.getByte("Slot"); - if (slotID >= 0 && slotID < getSizeInventory()) { setInventorySlotContents(slotID, new ItemStack(tagCompound)); } @@ -106,7 +100,6 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl if (handleInventory()) { NBTTagList tagList = new NBTTagList(); - for (int slotCount = 0; slotCount < getSizeInventory(); slotCount++) { ItemStack stackInSlot = getStackInSlot(slotCount); if (!stackInSlot.isEmpty()) { @@ -116,10 +109,8 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl tagList.appendTag(tagCompound); } } - nbtTags.setTag("Items", tagList); } - return nbtTags; } @@ -144,7 +135,6 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl if (getInventory() == null) { return ItemStack.EMPTY; } - return ItemStackHelper.getAndSplit(getInventory(), slotID, amount); } @@ -154,25 +144,21 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl if (getInventory() == null) { return ItemStack.EMPTY; } - return ItemStackHelper.getAndRemove(getInventory(), slotID); } @Override public void setInventorySlotContents(int slotID, @Nonnull ItemStack itemstack) { getInventory().set(slotID, itemstack); - if (!itemstack.isEmpty() && itemstack.getCount() > getInventoryStackLimit()) { itemstack.setCount(getInventoryStackLimit()); } - markDirty(); } @Override public boolean isUsableByPlayer(@Nonnull EntityPlayer entityplayer) { - return !isInvalid() && this.world - .isBlockLoaded(this.pos);//prevent Containers from remaining valid after the chunk has unloaded; + return !isInvalid() && this.world.isBlockLoaded(this.pos);//prevent Containers from remaining valid after the chunk has unloaded; } @Nonnull @@ -223,13 +209,10 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl if (nbtTags == null || nbtTags.tagCount() == 0 || !handleInventory()) { return; } - inventory = NonNullList.withSize(getSizeInventory(), ItemStack.EMPTY); - for (int slots = 0; slots < nbtTags.tagCount(); slots++) { NBTTagCompound tagCompound = nbtTags.getCompoundTagAt(slots); byte slotID = tagCompound.getByte("Slot"); - if (slotID >= 0 && slotID < inventory.size()) { inventory.set(slotID, new ItemStack(tagCompound)); } @@ -239,7 +222,6 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl @Override public NBTTagList getInventory(Object... data) { NBTTagList tagList = new NBTTagList(); - if (handleInventory()) { for (int slots = 0; slots < inventory.size(); slots++) { if (!inventory.get(slots).isEmpty()) { @@ -250,7 +232,6 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl } } } - return tagList; } @@ -300,11 +281,10 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl } else if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(getItemHandler(side)); } - return super.getCapability(capability, facing); } protected IItemHandler getItemHandler(EnumFacing side) { return side == null ? nullHandler : itemManager.getWrapper(this, side); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/prefab/TileEntityDoubleElectricMachine.java b/src/main/java/mekanism/common/tile/prefab/TileEntityDoubleElectricMachine.java index c38046e8b..01e284272 100644 --- a/src/main/java/mekanism/common/tile/prefab/TileEntityDoubleElectricMachine.java +++ b/src/main/java/mekanism/common/tile/prefab/TileEntityDoubleElectricMachine.java @@ -20,28 +20,22 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.NonNullList; -public abstract class TileEntityDoubleElectricMachine> extends - TileEntityUpgradeableMachine { +public abstract class TileEntityDoubleElectricMachine> extends TileEntityUpgradeableMachine { - private static final String[] methods = new String[]{"getEnergy", "getProgress", "isActive", "facing", "canOperate", - "getMaxEnergy", "getEnergyNeeded"}; + private static final String[] methods = new String[]{"getEnergy", "getProgress", "isActive", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"}; /** - * Double Electric Machine -- a machine like this has a total of 4 slots. Input slot (0), secondary 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. + * Double Electric Machine -- a machine like this has a total of 4 slots. Input slot (0), secondary 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. * - * @param soundPath - location of the sound effect - * @param name - full name of this machine - * @param baseMaxEnergy - maximum amount of energy this machine can hold. + * @param soundPath - location of the sound effect + * @param name - full name of this machine + * @param baseMaxEnergy - maximum amount of energy this machine can hold. * @param baseEnergyUsage - how much energy this machine uses per tick. - * @param ticksRequired - how many ticks it takes to smelt an item. + * @param ticksRequired - how many ticks it takes to smelt an item. */ - public TileEntityDoubleElectricMachine(String soundPath, String name, double baseMaxEnergy, double baseEnergyUsage, - int ticksRequired) { - super(soundPath, name, baseMaxEnergy, baseEnergyUsage, 4, ticksRequired, - MekanismUtils.getResource(ResourceType.GUI, "guibasicmachine.png")); - + public TileEntityDoubleElectricMachine(String soundPath, String name, double baseMaxEnergy, double baseEnergyUsage, int ticksRequired) { + super(soundPath, name, baseMaxEnergy, baseEnergyUsage, 4, ticksRequired, MekanismUtils.getResource(ResourceType.GUI, "guibasicmachine.png")); configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY); configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); @@ -72,34 +66,25 @@ public abstract class TileEntityDoubleElectricMachine= energyPerTick) { setActive(true); - operatingTicks++; - if (operatingTicks >= ticksRequired) { operate(recipe); - operatingTicks = 0; } - electricityStored -= energyPerTick; } else { inactive = true; setActive(false); } - if (inactive && getRecipe() == null) { operatingTicks = 0; } - prevEnergy = getEnergy(); } } @@ -109,8 +94,7 @@ public abstract class TileEntityDoubleElectricMachine 0) { long updateDiff = world.getTotalWorldTime() - lastActive; if (updateDiff > RECENT_THRESHOLD) { @@ -148,13 +142,10 @@ public abstract class TileEntityEffectsBlock extends TileEntityElectricBlock imp @Override public void setActive(boolean active) { - boolean stateChange = (isActive != active); - + boolean stateChange = isActive != active; if (stateChange) { isActive = active; - Mekanism.packetHandler - .sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); } } @@ -167,11 +158,9 @@ public abstract class TileEntityEffectsBlock extends TileEntityElectricBlock imp @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { boolean newActive = dataStream.readBoolean(); - - boolean stateChange = (newActive != isActive); + boolean stateChange = newActive != isActive; isActive = newActive; if (stateChange && !isActive) { @@ -191,7 +180,6 @@ public abstract class TileEntityEffectsBlock extends TileEntityElectricBlock imp @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(isActive); return data; } @@ -206,9 +194,7 @@ public abstract class TileEntityEffectsBlock extends TileEntityElectricBlock imp @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setBoolean("isActive", isActive); - return nbtTags; } @@ -216,12 +202,10 @@ public abstract class TileEntityEffectsBlock extends TileEntityElectricBlock imp if (!(this instanceof IUpgradeTile)) { return false; } - IUpgradeTile tile = (IUpgradeTile) this; if (tile.getComponent().supports(Upgrade.MUFFLING)) { return tile.getComponent().getUpgrades(Upgrade.MUFFLING) == Upgrade.MUFFLING.getMax(); } - return false; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/prefab/TileEntityElectricBlock.java b/src/main/java/mekanism/common/tile/prefab/TileEntityElectricBlock.java index 20b6b7401..f267ee7b3 100644 --- a/src/main/java/mekanism/common/tile/prefab/TileEntityElectricBlock.java +++ b/src/main/java/mekanism/common/tile/prefab/TileEntityElectricBlock.java @@ -44,16 +44,13 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i public double maxEnergy; private boolean ic2Registered = false; - private CapabilityWrapperManager teslaManager = new CapabilityWrapperManager<>( - IEnergyWrapper.class, TeslaIntegration.class); - private CapabilityWrapperManager forgeEnergyManager = new CapabilityWrapperManager<>( - IEnergyWrapper.class, ForgeEnergyIntegration.class); + private CapabilityWrapperManager teslaManager = new CapabilityWrapperManager<>(IEnergyWrapper.class, TeslaIntegration.class); + private CapabilityWrapperManager forgeEnergyManager = new CapabilityWrapperManager<>(IEnergyWrapper.class, ForgeEnergyIntegration.class); /** - * The base of all blocks that deal with electricity. It has a facing state, initialized state, and a current amount - * of stored energy. + * The base of all blocks that deal with electricity. It has a facing state, initialized state, and a current amount of stored energy. * - * @param name - full name of this block + * @param name - full name of this block * @param baseMaxEnergy - how much energy this block can store */ public TileEntityElectricBlock(String name, double baseMaxEnergy) { @@ -88,8 +85,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Override public void onUpdate() { - /*if(MekanismUtils.useIC2()) - { + /*if(MekanismUtils.useIC2()) { register(); }*/ } @@ -128,7 +124,6 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { setEnergy(dataStream.readDouble()); } @@ -137,9 +132,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(getEnergy()); - return data; } @@ -148,14 +141,12 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i if (MekanismUtils.useIC2()) { deregister(); } - super.onChunkUnload(); } @Override public void invalidate() { super.invalidate(); - if (MekanismUtils.useIC2()) { deregister(); } @@ -173,7 +164,6 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - electricityStored = nbtTags.getDouble("electricityStored"); } @@ -181,9 +171,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setDouble("electricityStored", getEnergy()); - return nbtTags; } @@ -191,6 +179,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i * Gets the scaled energy level for the GUI. * * @param i - multiplier + * * @return scaled energy */ public int getScaledEnergyLevel(int i) { @@ -200,17 +189,15 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Override @Method(modid = MekanismHooks.REDSTONEFLUX_MOD_ID) public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate) { - return MekanismUtils.clampToInt( - acceptEnergy(from, maxReceive * MekanismConfig.current().general.FROM_RF.val(), simulate) - * MekanismConfig.current().general.TO_RF.val()); + return MekanismUtils.clampToInt(acceptEnergy(from, maxReceive * MekanismConfig.current().general.FROM_RF.val(), simulate) + * MekanismConfig.current().general.TO_RF.val()); } @Override @Method(modid = MekanismHooks.REDSTONEFLUX_MOD_ID) public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate) { - return MekanismUtils.clampToInt( - pullEnergy(from, maxExtract * MekanismConfig.current().general.FROM_RF.val(), simulate) - * MekanismConfig.current().general.TO_RF.val()); + return MekanismUtils.clampToInt(pullEnergy(from, maxExtract * MekanismConfig.current().general.FROM_RF.val(), simulate) + * MekanismConfig.current().general.TO_RF.val()); } @Override @@ -273,8 +260,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Override @Method(modid = MekanismHooks.IC2_MOD_ID) public boolean emitsEnergyTo(IEnergyAcceptor receiver, EnumFacing direction) { - return !MekanismConfig.current().general.blacklistIC2.val() && sideIsOutput(direction) - && receiver instanceof IEnergyConductor; + return !MekanismConfig.current().general.blacklistIC2.val() && sideIsOutput(direction) && receiver instanceof IEnergyConductor; } @Override @@ -306,15 +292,13 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Override @Method(modid = MekanismHooks.IC2_MOD_ID) public double getDemandedEnergy() { - return !MekanismConfig.current().general.blacklistIC2.val() ? (getMaxEnergy() - getEnergy()) * MekanismConfig - .current().general.TO_IC2.val() : 0; + return !MekanismConfig.current().general.blacklistIC2.val() ? (getMaxEnergy() - getEnergy()) * MekanismConfig.current().general.TO_IC2.val() : 0; } @Override @Method(modid = MekanismHooks.IC2_MOD_ID) public double getOfferedEnergy() { - return !MekanismConfig.current().general.blacklistIC2.val() ? Math.min(getEnergy(), getMaxOutput()) - * MekanismConfig.current().general.TO_IC2.val() : 0; + return !MekanismConfig.current().general.blacklistIC2.val() ? Math.min(getEnergy(), getMaxOutput()) * MekanismConfig.current().general.TO_IC2.val() : 0; } @Override @@ -325,24 +309,19 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Override @Method(modid = MekanismHooks.IC2_MOD_ID) public double getOutputEnergyUnitsPerTick() { - return !MekanismConfig.current().general.blacklistIC2.val() ? getMaxOutput() * MekanismConfig - .current().general.TO_IC2.val() : 0; + return !MekanismConfig.current().general.blacklistIC2.val() ? getMaxOutput() * MekanismConfig.current().general.TO_IC2.val() : 0; } @Override @Method(modid = MekanismHooks.IC2_MOD_ID) - public double injectEnergy(EnumFacing pushDirection, double amount, - double voltage) {// nb: the facing param contains the side relative to the pushing block + public double injectEnergy(EnumFacing pushDirection, double amount, double voltage) { + // nb: the facing param contains the side relative to the pushing block TileEntity tile = getWorld().getTileEntity(getPos().offset(pushDirection.getOpposite())); - - if (MekanismConfig.current().general.blacklistIC2.val() || (CapabilityUtils - .hasCapability(tile, Capabilities.GRID_TRANSMITTER_CAPABILITY, pushDirection))) { + if (MekanismConfig.current().general.blacklistIC2.val() || CapabilityUtils.hasCapability(tile, Capabilities.GRID_TRANSMITTER_CAPABILITY, pushDirection)) { return amount; } - - return amount - - acceptEnergy(pushDirection.getOpposite(), amount * MekanismConfig.current().general.FROM_IC2.val(), false) - * MekanismConfig.current().general.TO_IC2.val(); + return amount - acceptEnergy(pushDirection.getOpposite(), amount * MekanismConfig.current().general.FROM_IC2.val(), false) + * MekanismConfig.current().general.TO_IC2.val(); } @Override @@ -354,30 +333,24 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Override public double acceptEnergy(EnumFacing side, double amount, boolean simulate) { double toUse = Math.min(getMaxEnergy() - getEnergy(), amount); - if (toUse < 0.0001 || (side != null && !sideIsConsumer(side))) { return 0; } - if (!simulate) { setEnergy(getEnergy() + toUse); } - return toUse; } @Override public double pullEnergy(EnumFacing side, double amount, boolean simulate) { double toGive = Math.min(getEnergy(), amount); - if (toGive < 0.0001 || (side != null && !sideIsOutput(side))) { return 0; } - if (!simulate) { setEnergy(getEnergy() - toGive); } - return toGive; } @@ -386,8 +359,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i if (isCapabilityDisabled(capability, side)) { return false; } - return isStrictEnergy(capability) || capability == CapabilityEnergy.ENERGY || isTesla(capability, side) || super - .hasCapability(capability, side); + return isStrictEnergy(capability) || capability == CapabilityEnergy.ENERGY || isTesla(capability, side) || super.hasCapability(capability, side); } @Override @@ -405,15 +377,12 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i } protected boolean isStrictEnergy(@Nonnull Capability capability) { - return capability == Capabilities.ENERGY_STORAGE_CAPABILITY - || capability == Capabilities.ENERGY_ACCEPTOR_CAPABILITY || - capability == Capabilities.ENERGY_OUTPUTTER_CAPABILITY; + return capability == Capabilities.ENERGY_STORAGE_CAPABILITY || capability == Capabilities.ENERGY_ACCEPTOR_CAPABILITY || capability == Capabilities.ENERGY_OUTPUTTER_CAPABILITY; } protected boolean isTesla(@Nonnull Capability capability, EnumFacing side) { - return capability == Capabilities.TESLA_HOLDER_CAPABILITY - || (capability == Capabilities.TESLA_CONSUMER_CAPABILITY && sideIsConsumer(side)) - || (capability == Capabilities.TESLA_PRODUCER_CAPABILITY && sideIsOutput(side)); + return capability == Capabilities.TESLA_HOLDER_CAPABILITY || (capability == Capabilities.TESLA_CONSUMER_CAPABILITY && sideIsConsumer(side)) + || (capability == Capabilities.TESLA_PRODUCER_CAPABILITY && sideIsOutput(side)); } protected ForgeEnergyIntegration getForgeEnergyWrapper(EnumFacing side) { @@ -431,4 +400,4 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i } return super.isCapabilityDisabled(capability, side); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/prefab/TileEntityElectricMachine.java b/src/main/java/mekanism/common/tile/prefab/TileEntityElectricMachine.java index 1144cef46..cd422f2f6 100644 --- a/src/main/java/mekanism/common/tile/prefab/TileEntityElectricMachine.java +++ b/src/main/java/mekanism/common/tile/prefab/TileEntityElectricMachine.java @@ -20,27 +20,22 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.NonNullList; -public abstract class TileEntityElectricMachine> extends - TileEntityUpgradeableMachine { +public abstract class TileEntityElectricMachine> extends TileEntityUpgradeableMachine { - private static final String[] methods = new String[]{"getEnergy", "getProgress", "isActive", "facing", "canOperate", - "getMaxEnergy", "getEnergyNeeded"}; + private static final String[] methods = new String[]{"getEnergy", "getProgress", "isActive", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"}; /** - * 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. + * 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 perTick - energy used per tick. + * @param soundPath - location of the sound effect + * @param name - full name of this machine + * @param perTick - energy used per tick. * @param ticksRequired - ticks required to operate -- or smelt an item. - * @param maxEnergy - maximum energy this machine can hold. + * @param maxEnergy - maximum energy this machine can hold. */ - public TileEntityElectricMachine(String soundPath, String name, double maxEnergy, double perTick, - int ticksRequired) { - super(soundPath, name, maxEnergy, perTick, 3, ticksRequired, - MekanismUtils.getResource(ResourceType.GUI, "GuiBasicMachine.png")); - + public TileEntityElectricMachine(String soundPath, String name, double maxEnergy, double perTick, int ticksRequired) { + super(soundPath, name, maxEnergy, perTick, 3, ticksRequired, MekanismUtils.getResource(ResourceType.GUI, "GuiBasicMachine.png")); configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY); configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); @@ -68,33 +63,24 @@ public abstract class TileEntityElectricMachine= energyPerTick) { setActive(true); electricityStored -= energyPerTick; - if ((operatingTicks + 1) < ticksRequired) { operatingTicks++; } else if ((operatingTicks + 1) >= ticksRequired) { operate(recipe); - operatingTicks = 0; } - } else { - if (prevEnergy >= getEnergy()) { - setActive(false); - } + } else if (prevEnergy >= getEnergy()) { + setActive(false); } - if (!canOperate(recipe)) { operatingTicks = 0; } - prevEnergy = getEnergy(); } } @@ -104,14 +90,12 @@ public abstract class TileEntityElectricMachine implements ITierUpgradeable { /** - * The foundation of all machines - a simple tile entity with a facing, active state, initialized state, sound - * effect, and animated texture. + * 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 - * @param name - full name of this machine - * @param baseMaxEnergy - how much energy this machine can store + * @param soundPath - location of the sound effect + * @param name - full name of this machine + * @param baseMaxEnergy - how much energy this machine can store * @param baseTicksRequired - how many ticks it takes to run a cycle */ - public TileEntityUpgradeableMachine(String soundPath, String name, double baseMaxEnergy, double baseEnergyUsage, - int upgradeSlot, int baseTicksRequired, ResourceLocation location) { + public TileEntityUpgradeableMachine(String soundPath, String name, double baseMaxEnergy, double baseEnergyUsage, int upgradeSlot, int baseTicksRequired, ResourceLocation location) { super(soundPath, name, baseMaxEnergy, baseEnergyUsage, upgradeSlot, baseTicksRequired, location); } @@ -34,7 +32,6 @@ public abstract class TileEntityUpgradeableMachine updates, Set deletes) { TileNetworkList data = new TileNetworkList(); - if (Mekanism.hooks.MCMPLoaded) { MultipartTileNetworkJoiner.addMultipartHeader(this, data, null); } - data.add(BATCH_PACKET); - data.add(updates.size()); for (Entry entry : updates.entrySet()) { data.add(entry.getKey()); entry.getValue().write(getTransmitter(), data); } - data.add(deletes.size()); data.addAll(deletes); - return data; } @@ -274,11 +244,9 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter implements - IFluidHandlerWrapper { +public class TileEntityMechanicalPipe extends TileEntityTransmitter implements IFluidHandlerWrapper { public PipeTier tier = PipeTier.BASIC; @@ -36,8 +35,7 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter manager = new CapabilityWrapperManager<>( - IFluidHandlerWrapper.class, FluidHandlerWrapper.class); + public CapabilityWrapperManager manager = new CapabilityWrapperManager<>(IFluidHandlerWrapper.class, FluidHandlerWrapper.class); @Override public BaseTier getBaseTier() { @@ -54,16 +52,12 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter 0) { FluidStack last = getSaveShare(); - - if ((last != null && !(lastWrite != null && lastWrite.amount == last.amount && lastWrite.getFluid() == last - .getFluid())) || (last == null && lastWrite != null)) { + if ((last != null && !(lastWrite != null && lastWrite.amount == last.amount && lastWrite.getFluid() == last.getFluid())) || (last == null && lastWrite != null)) { lastWrite = last; markDirty(); } @@ -93,14 +84,11 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter 0) { nbtTags.setTag("cacheFluid", lastWrite.writeToNBT(new NBTTagCompound())); } else { nbtTags.removeTag("cacheFluid"); } - nbtTags.setInteger("tier", tier.ordinal()); - return nbtTags; } @@ -207,8 +188,7 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter implements - IGasHandler { +public class TileEntityPressurizedTube extends TileEntityTransmitter implements IGasHandler { public TubeTier tier = TubeTier.BASIC; @@ -78,33 +77,24 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter 0.01) { currentScale = (9 * currentScale + targetScale) / 10; } } - super.update(); } @@ -112,9 +102,7 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter 0) { GasStack last = getSaveShare(); - - if ((last != null && !(lastWrite != null && lastWrite.amount == last.amount && lastWrite.getGas() == last - .getGas())) || (last == null && lastWrite != null)) { + if ((last != null && !(lastWrite != null && lastWrite.amount == last.amount && lastWrite.getGas() == last.getGas())) || (last == null && lastWrite != null)) { lastWrite = last; markDirty(); } @@ -123,18 +111,13 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter 0) { nbtTags.setTag("cacheGas", lastWrite.write(new NBTTagCompound())); } else { nbtTags.removeTag("cacheGas"); } - nbtTags.setInteger("tier", tier.ordinal()); - return nbtTags; } @@ -245,8 +221,7 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter getCollisionBoxes(AxisAlignedBB entityBox) { List list = new ArrayList<>(); - for (EnumFacing side : EnumFacing.values()) { int ord = side.ordinal(); byte connections = getAllCurrentConnections(); - if (connectionMapContainsSide(connections, side)) { - AxisAlignedBB box = getTransmitterType().getSize() == Size.SMALL ? BlockTransmitter.smallSides[ord] - : BlockTransmitter.largeSides[ord]; + AxisAlignedBB box = getTransmitterType().getSize() == Size.SMALL ? BlockTransmitter.smallSides[ord] : BlockTransmitter.largeSides[ord]; if (box.intersects(entityBox)) { list.add(box); } } } - - AxisAlignedBB box = getTransmitterType().getSize() == Size.SMALL ? BlockTransmitter.smallSides[6] - : BlockTransmitter.largeSides[6]; + AxisAlignedBB box = getTransmitterType().getSize() == Size.SMALL ? BlockTransmitter.smallSides[6] : BlockTransmitter.largeSides[6]; if (box.intersects(entityBox)) { list.add(box); } @@ -295,20 +259,16 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet if (!canConnect(side)) { return false; } - TileEntity tile = getWorld().getTileEntity(getPos().offset(side)); - if (!CapabilityUtils.hasCapability(tile, Capabilities.BLOCKABLE_CONNECTION_CAPABILITY, side.getOpposite())) { return true; } - - return CapabilityUtils.getCapability(tile, Capabilities.BLOCKABLE_CONNECTION_CAPABILITY, side.getOpposite()) - .canConnect(side.getOpposite()); + return CapabilityUtils.getCapability(tile, Capabilities.BLOCKABLE_CONNECTION_CAPABILITY, side.getOpposite()).canConnect(side.getOpposite()); } @Override public boolean canConnect(EnumFacing side) { - if(connectionTypes[side.ordinal()] == ConnectionType.NONE) { + if (connectionTypes[side.ordinal()] == ConnectionType.NONE) { return false; } if (handlesRedstone()) { @@ -318,19 +278,15 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet } else { redstonePowered = false; } - redstoneSet = true; } - if (redstoneReactive && redstonePowered) { return false; } } - if (Mekanism.hooks.MCMPLoaded) { return MultipartMekanism.hasConnectionWith(this, side); } - return true; } @@ -339,11 +295,9 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { currentTransmitterConnections = dataStream.readByte(); currentAcceptorConnections = dataStream.readByte(); - for (int i = 0; i < 6; i++) { connectionTypes[i] = ConnectionType.values()[dataStream.readInt()]; } - markDirty(); MekanismUtils.updateBlock(world, pos); } @@ -354,23 +308,18 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet if (Mekanism.hooks.MCMPLoaded) { MultipartTileNetworkJoiner.addMultipartHeader(this, data, null); } - data.add(currentTransmitterConnections); data.add(currentAcceptorConnections); - for (int i = 0; i < 6; i++) { data.add(connectionTypes[i].ordinal()); } - return data; } @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - redstoneReactive = nbtTags.getBoolean("redstoneReactive"); - for (int i = 0; i < 6; i++) { connectionTypes[i] = ConnectionType.values()[nbtTags.getInteger("connection" + i)]; } @@ -380,13 +329,10 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setBoolean("redstoneReactive", redstoneReactive); - for (int i = 0; i < 6; i++) { nbtTags.setInteger("connection" + i, connectionTypes[i].ordinal()); } - return nbtTags; } @@ -416,7 +362,6 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet // it is no longer valid markDirtyTransmitters(); } - redstoneSet = true; } @@ -427,7 +372,6 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet if ((possibleTransmitters | possibleAcceptors) != getAllCurrentConnections()) { sendDesc = true; - if (possibleTransmitters != currentTransmitterConnections) { //If they don't match get the difference newlyEnabledTransmitters = (byte) (possibleTransmitters ^ currentTransmitterConnections); @@ -440,7 +384,6 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet currentTransmitterConnections = possibleTransmitters; currentAcceptorConnections = possibleAcceptors; - if (newlyEnabledTransmitters != 0) { //If any sides are now valid transmitters that were not before recheck the connection recheckConnections(newlyEnabledTransmitters); @@ -454,10 +397,8 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet boolean possibleAcceptor = getPossibleAcceptorConnection(side); boolean transmitterChanged = false; - if ((possibleTransmitter || possibleAcceptor) != connectionMapContainsSide(getAllCurrentConnections(), - side)) { + if ((possibleTransmitter || possibleAcceptor) != connectionMapContainsSide(getAllCurrentConnections(), side)) { sendDesc = true; - if (possibleTransmitter != connectionMapContainsSide(currentTransmitterConnections, side)) { //If it doesn't match check if it is now enabled, as we don't care about it changing to disabled transmitterChanged = possibleTransmitter; @@ -466,7 +407,6 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet currentTransmitterConnections = setConnectionBit(currentTransmitterConnections, possibleTransmitter, side); currentAcceptorConnections = setConnectionBit(currentAcceptorConnections, possibleAcceptor, side); - if (transmitterChanged) { //If this side is now a valid transmitter and it wasn't before recheck the connection recheckConnection(side); @@ -476,6 +416,7 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet /** * Only call this from server side + * * @param newlyEnabledTransmitters The transmitters that are now enabled and were not before. */ protected void recheckConnections(byte newlyEnabledTransmitters) { @@ -483,6 +424,7 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet /** * Only call this from server side + * * @param side The side that a transmitter is now enabled on after having been disabled. */ protected void recheckConnection(EnumFacing side) { @@ -551,7 +493,6 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet public void onPartChanged(IMultipart part) { byte transmittersBefore = currentTransmitterConnections; refreshConnections(); - if (transmittersBefore != currentTransmitterConnections) { markDirtyTransmitters(); } @@ -563,13 +504,11 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet public List getConnections(ConnectionType type) { List sides = new ArrayList<>(); - for (EnumFacing side : EnumFacing.values()) { if (getConnectionType(side) == type) { sides.add(side); } } - return sides; } @@ -577,13 +516,11 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet public EnumActionResult onSneakRightClick(EntityPlayer player, EnumFacing side) { if (!getWorld().isRemote) { RayTraceResult hit = reTrace(getWorld(), getPos(), player); - if (hit == null) { return EnumActionResult.PASS; } else { EnumFacing hitSide = sideHit(hit.subHit + 1); - - if(hitSide == null) { + if (hitSide == null) { if (connectionTypes[side.ordinal()] != ConnectionType.NONE && onConfigure(player, 6, side) == EnumActionResult.SUCCESS) { return EnumActionResult.SUCCESS; } @@ -593,49 +530,37 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet if (hitSide != null) { connectionTypes[hitSide.ordinal()] = connectionTypes[hitSide.ordinal()].next(); sendDesc = true; - onModeChange(EnumFacing.byIndex(hitSide.ordinal())); refreshConnections(); notifyTileChange(); - - player.sendMessage( - new TextComponentGroup().translation("tooltip.configurator.modeChange").string(" ") - .translation(connectionTypes[hitSide.ordinal()].translationKey())); - + player.sendMessage(new TextComponentGroup().translation("tooltip.configurator.modeChange").string(" ").translation(connectionTypes[hitSide.ordinal()].translationKey())); return EnumActionResult.SUCCESS; } else { return EnumActionResult.PASS; } } } - return EnumActionResult.SUCCESS; } private RayTraceResult reTrace(World world, BlockPos pos, EntityPlayer player) { Pair vecs = MultipartUtils.getRayTraceVectors(player); - AdvancedRayTraceResult result = MultipartUtils - .collisionRayTrace(getPos(), vecs.getLeft(), vecs.getRight(), getCollisionBoxes()); - + AdvancedRayTraceResult result = MultipartUtils.collisionRayTrace(getPos(), vecs.getLeft(), vecs.getRight(), getCollisionBoxes()); return result == null ? null : result.hit; } protected EnumFacing sideHit(int boxIndex) { List list = new ArrayList<>(); - for (EnumFacing side : EnumFacing.values()) { byte connections = getAllCurrentConnections(); - if (connectionMapContainsSide(connections, side)) { list.add(side); } } - if (boxIndex < list.size()) { return list.get(boxIndex); } - return null; } @@ -653,31 +578,23 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet redstoneReactive ^= true; refreshConnections(); notifyTileChange(); - - player.sendMessage(new TextComponentString( - EnumColor.DARK_BLUE + Mekanism.LOG_TAG + EnumColor.GREY + " Redstone sensitivity turned " - + EnumColor.INDIGO + (redstoneReactive ? "on." : "off."))); + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + Mekanism.LOG_TAG + EnumColor.GREY + " Redstone sensitivity turned " + EnumColor.INDIGO + + (redstoneReactive ? "on." : "off."))); } - return EnumActionResult.SUCCESS; } public List getVisibleGroups() { List visible = new ArrayList<>(); - for (EnumFacing side : EnumFacing.values()) { visible.add(side.getName() + getConnectionType(side).getName().toUpperCase()); } - return visible; } public IBlockState getExtendedState(IBlockState state) { - PropertyConnection connectionProp = new PropertyConnection(getAllCurrentConnections(), - currentTransmitterConnections, connectionTypes, renderCenter()); - - return ((IExtendedBlockState) state).withProperty(OBJProperty.INSTANCE, new OBJState(getVisibleGroups(), true)) - .withProperty(PropertyConnection.INSTANCE, connectionProp); + PropertyConnection connectionProp = new PropertyConnection(getAllCurrentConnections(), currentTransmitterConnections, connectionTypes, renderCenter()); + return ((IExtendedBlockState) state).withProperty(OBJProperty.INSTANCE, new OBJState(getVisibleGroups(), true)).withProperty(PropertyConnection.INSTANCE, connectionProp); } public void notifyTileChange() { @@ -692,16 +609,15 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet @Override public boolean hasCapability(@Nonnull Capability capability, EnumFacing facing) { return capability == Capabilities.CONFIGURABLE_CAPABILITY || capability == Capabilities.TILE_NETWORK_CAPABILITY - || capability == Capabilities.BLOCKABLE_CONNECTION_CAPABILITY || super.hasCapability(capability, facing); + || capability == Capabilities.BLOCKABLE_CONNECTION_CAPABILITY || super.hasCapability(capability, facing); } @Override public T getCapability(@Nonnull Capability capability, EnumFacing facing) { if (capability == Capabilities.CONFIGURABLE_CAPABILITY || capability == Capabilities.TILE_NETWORK_CAPABILITY - || capability == Capabilities.BLOCKABLE_CONNECTION_CAPABILITY) { + || capability == Capabilities.BLOCKABLE_CONNECTION_CAPABILITY) { return (T) this; } - return super.getCapability(capability, facing); } @@ -715,7 +631,6 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet if (ordinal() == values().length - 1) { return NORMAL; } - return values()[ordinal() + 1]; } @@ -728,4 +643,4 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet return "mekanism.pipe.connectiontype." + getName(); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/transmitter/TileEntityThermodynamicConductor.java b/src/main/java/mekanism/common/tile/transmitter/TileEntityThermodynamicConductor.java index 0376c3bf0..295f53ba1 100644 --- a/src/main/java/mekanism/common/tile/transmitter/TileEntityThermodynamicConductor.java +++ b/src/main/java/mekanism/common/tile/transmitter/TileEntityThermodynamicConductor.java @@ -10,11 +10,11 @@ import mekanism.api.TileNetworkList; import mekanism.api.transmitters.TransmissionType; import mekanism.common.ColourRGBA; import mekanism.common.Mekanism; -import mekanism.common.tier.BaseTier; -import mekanism.common.tier.ConductorTier; import mekanism.common.block.states.BlockStateTransmitter.TransmitterType; import mekanism.common.capabilities.Capabilities; import mekanism.common.network.PacketTileEntity.TileEntityMessage; +import mekanism.common.tier.BaseTier; +import mekanism.common.tier.ConductorTier; import mekanism.common.transmitters.grid.HeatNetwork; import mekanism.common.util.CapabilityUtils; import mekanism.common.util.HeatUtils; @@ -23,8 +23,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; -public class TileEntityThermodynamicConductor extends TileEntityTransmitter implements - IHeatTransfer { +public class TileEntityThermodynamicConductor extends TileEntityTransmitter implements IHeatTransfer { public ConductorTier tier = ConductorTier.BASIC; @@ -78,11 +77,9 @@ public class TileEntityThermodynamicConductor extends TileEntityTransmitter (temperature / 20)) { clientTemperature = temperature; sendTemp(); } - return temperature; } @@ -200,12 +184,10 @@ public class TileEntityThermodynamicConductor extends TileEntityTransmitter, BUFFER> extends - TileEntitySidedPipe implements IAlloyInteraction { +public abstract class TileEntityTransmitter, BUFFER> extends TileEntitySidedPipe implements IAlloyInteraction { public TransmitterImpl transmitterDelegate; @@ -51,14 +50,12 @@ public abstract class TileEntityTransmitter> list = new ArrayList<>(getTransmitter().getTransmitterNetwork().getTransmitters()); - list.sort((o1, o2) -> { if (o1 != null && o2 != null) { Coord4D thisCoord = new Coord4D(getPos(), getWorld()); @@ -240,25 +230,20 @@ public abstract class TileEntityTransmitter iter : list) { if (iter instanceof TransmitterImpl) { TileEntityTransmitter t = ((TransmitterImpl) iter).containingTile; - if (t.upgrade(tierOrdinal)) { upgraded++; - if (upgraded == 8) { break; } } } } - if (upgraded > 0) { if (!player.capabilities.isCreativeMode) { stack.shrink(1); - if (stack.getCount() == 0) { player.setHeldItem(hand, ItemStack.EMPTY); } @@ -292,9 +277,7 @@ public abstract class TileEntityTransmitter capability, EnumFacing side) { - return capability == Capabilities.GRID_TRANSMITTER_CAPABILITY - || capability == Capabilities.ALLOY_INTERACTION_CAPABILITY - || super.hasCapability(capability, side); + return capability == Capabilities.GRID_TRANSMITTER_CAPABILITY || capability == Capabilities.ALLOY_INTERACTION_CAPABILITY || super.hasCapability(capability, side); } @Override @@ -304,7 +287,6 @@ public abstract class TileEntityTransmitter implements - IStrictEnergyAcceptor, IStrictEnergyStorage, IEnergyReceiver { +public class TileEntityUniversalCable extends TileEntityTransmitter implements IStrictEnergyAcceptor, + IStrictEnergyStorage, IEnergyReceiver { public CableTier tier = CableTier.BASIC; @@ -50,10 +49,8 @@ public class TileEntityUniversalCable extends public double lastWrite = 0; public EnergyStack buffer = new EnergyStack(0); - private CapabilityWrapperManager teslaManager = new CapabilityWrapperManager<>(getClass(), - TeslaCableIntegration.class); - private CapabilityWrapperManager forgeEnergyManager = new CapabilityWrapperManager<>(getClass(), - ForgeEnergyCableIntegration.class); + private CapabilityWrapperManager teslaManager = new CapabilityWrapperManager<>(getClass(), TeslaCableIntegration.class); + private CapabilityWrapperManager forgeEnergyManager = new CapabilityWrapperManager<>(getClass(), ForgeEnergyCableIntegration.class); @Override public BaseTier getBaseTier() { @@ -68,106 +65,67 @@ public class TileEntityUniversalCable extends @Override public void update() { if (getWorld().isRemote) { - double targetPower = - getTransmitter().hasTransmitterNetwork() ? getTransmitter().getTransmitterNetwork().clientEnergyScale - : 0; - + double targetPower = getTransmitter().hasTransmitterNetwork() ? getTransmitter().getTransmitterNetwork().clientEnergyScale : 0; if (Math.abs(currentPower - targetPower) > 0.01) { currentPower = (9 * currentPower + targetPower) / 10; } } else { updateShare(); - List sides = getConnections(ConnectionType.PULL); - if (!sides.isEmpty()) { TileEntity[] connectedOutputters = CableUtils.getConnectedOutputters(getPos(), getWorld()); double canDraw = tier.getCableCapacity(); - for (EnumFacing side : sides) { if (connectedOutputters[side.ordinal()] != null) { TileEntity outputter = connectedOutputters[side.ordinal()]; - if (CapabilityUtils - .hasCapability(outputter, Capabilities.ENERGY_OUTPUTTER_CAPABILITY, side.getOpposite()) - && CapabilityUtils - .hasCapability(outputter, Capabilities.ENERGY_STORAGE_CAPABILITY, side.getOpposite())) { - IStrictEnergyStorage storage = CapabilityUtils - .getCapability(outputter, Capabilities.ENERGY_STORAGE_CAPABILITY, side.getOpposite()); + if (CapabilityUtils.hasCapability(outputter, Capabilities.ENERGY_OUTPUTTER_CAPABILITY, side.getOpposite()) + && CapabilityUtils.hasCapability(outputter, Capabilities.ENERGY_STORAGE_CAPABILITY, side.getOpposite())) { + IStrictEnergyStorage storage = CapabilityUtils.getCapability(outputter, Capabilities.ENERGY_STORAGE_CAPABILITY, side.getOpposite()); double received = Math.min(storage.getEnergy(), canDraw); double toDraw = received; - if (received > 0) { toDraw -= takeEnergy(received, true); } - storage.setEnergy(storage.getEnergy() - toDraw); - } else if (MekanismUtils.useTesla() && CapabilityUtils - .hasCapability(outputter, Capabilities.TESLA_PRODUCER_CAPABILITY, side.getOpposite())) { - ITeslaProducer producer = CapabilityUtils - .getCapability(outputter, Capabilities.TESLA_PRODUCER_CAPABILITY, side.getOpposite()); - double toDraw = producer - .takePower(MekanismUtils - .clampToInt(canDraw * MekanismConfig.current().general.TO_TESLA.val()), true) - * MekanismConfig.current().general.FROM_TESLA.val(); - + } else if (MekanismUtils.useTesla() && CapabilityUtils.hasCapability(outputter, Capabilities.TESLA_PRODUCER_CAPABILITY, side.getOpposite())) { + ITeslaProducer producer = CapabilityUtils.getCapability(outputter, Capabilities.TESLA_PRODUCER_CAPABILITY, side.getOpposite()); + double toDraw = producer.takePower(MekanismUtils.clampToInt(canDraw * MekanismConfig.current().general.TO_TESLA.val()), true) + * MekanismConfig.current().general.FROM_TESLA.val(); if (toDraw > 0) { toDraw -= takeEnergy(toDraw, true); } - - producer.takePower(Math.round(toDraw * MekanismConfig.current().general.TO_TESLA.val()), - false); - } else if (MekanismUtils.useForge() && CapabilityUtils - .hasCapability(outputter, CapabilityEnergy.ENERGY, side.getOpposite())) { - IEnergyStorage storage = CapabilityUtils - .getCapability(outputter, CapabilityEnergy.ENERGY, side.getOpposite()); - double toDraw = storage.extractEnergy( - MekanismUtils.clampToInt(canDraw * MekanismConfig.current().general.TO_FORGE.val()), - true) - * MekanismConfig.current().general.FROM_FORGE.val(); - + producer.takePower(Math.round(toDraw * MekanismConfig.current().general.TO_TESLA.val()), false); + } else if (MekanismUtils.useForge() && CapabilityUtils.hasCapability(outputter, CapabilityEnergy.ENERGY, side.getOpposite())) { + IEnergyStorage storage = CapabilityUtils.getCapability(outputter, CapabilityEnergy.ENERGY, side.getOpposite()); + double toDraw = storage.extractEnergy(MekanismUtils.clampToInt(canDraw * MekanismConfig.current().general.TO_FORGE.val()), true) + * MekanismConfig.current().general.FROM_FORGE.val(); if (toDraw > 0) { toDraw -= takeEnergy(toDraw, true); } - - storage.extractEnergy( - MekanismUtils.clampToInt(toDraw * MekanismConfig.current().general.TO_TESLA.val()), - false); + storage.extractEnergy(MekanismUtils.clampToInt(toDraw * MekanismConfig.current().general.TO_TESLA.val()), false); } else if (MekanismUtils.useRF() && outputter instanceof IEnergyProvider) { double toDraw = ((IEnergyProvider) outputter).extractEnergy(side.getOpposite(), - MekanismUtils.clampToInt(canDraw * MekanismConfig.current().general.TO_RF.val()), - true) - * MekanismConfig.current().general.FROM_RF.val(); - + MekanismUtils.clampToInt(canDraw * MekanismConfig.current().general.TO_RF.val()), true) * MekanismConfig.current().general.FROM_RF.val(); if (toDraw > 0) { toDraw -= takeEnergy(toDraw, true); } - - ((IEnergyProvider) outputter).extractEnergy(side.getOpposite(), - MekanismUtils.clampToInt(toDraw * MekanismConfig.current().general.TO_RF.val()), - false); + ((IEnergyProvider) outputter).extractEnergy(side.getOpposite(), MekanismUtils.clampToInt(toDraw * MekanismConfig.current().general.TO_RF.val()), false); } else if (MekanismUtils.useIC2()) { IEnergyTile tile = EnergyNet.instance.getSubTile(outputter.getWorld(), outputter.getPos()); - if (tile instanceof IEnergySource) { - double received = Math - .min(((IEnergySource) tile).getOfferedEnergy() * MekanismConfig - .current().general.FROM_IC2.val(), canDraw); + double received = Math.min(((IEnergySource) tile).getOfferedEnergy() * MekanismConfig.current().general.FROM_IC2.val(), canDraw); double toDraw = received; - if (received > 0) { toDraw -= takeEnergy(received, true); } - - ((IEnergySource) tile) - .drawEnergy(toDraw * MekanismConfig.current().general.TO_IC2.val()); + ((IEnergySource) tile).drawEnergy(toDraw * MekanismConfig.current().general.TO_IC2.val()); } } } } } } - super.update(); } @@ -175,7 +133,6 @@ public class TileEntityUniversalCable extends public void updateShare() { if (getTransmitter().hasTransmitterNetwork() && getTransmitter().getTransmitterNetworkSize() > 0) { double last = getSaveShare(); - if (last != lastWrite) { lastWrite = last; markDirty(); @@ -185,11 +142,9 @@ public class TileEntityUniversalCable extends private double getSaveShare() { if (getTransmitter().hasTransmitterNetwork()) { - return EnergyNetwork.round(getTransmitter().getTransmitterNetwork().buffer.amount * (1F / getTransmitter() - .getTransmitterNetwork().transmittersSize())); - } else { - return buffer.amount; + return EnergyNetwork.round(getTransmitter().getTransmitterNetwork().buffer.amount * (1F / getTransmitter().getTransmitterNetwork().transmittersSize())); } + return buffer.amount; } @Override @@ -200,12 +155,10 @@ public class TileEntityUniversalCable extends @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - buffer.amount = nbtTags.getDouble("cacheEnergy"); if (buffer.amount < 0) { buffer.amount = 0; } - if (nbtTags.hasKey("tier")) { tier = CableTier.values()[nbtTags.getInteger("tier")]; } @@ -215,10 +168,8 @@ public class TileEntityUniversalCable extends @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setDouble("cacheEnergy", lastWrite); nbtTags.setInteger("tier", tier.ordinal()); - return nbtTags; } @@ -258,9 +209,8 @@ public class TileEntityUniversalCable extends @Override @Optional.Method(modid = MekanismHooks.REDSTONEFLUX_MOD_ID) public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate) { - return maxReceive - MekanismUtils.clampToInt( - takeEnergy(maxReceive * MekanismConfig.current().general.FROM_RF.val(), !simulate) * MekanismConfig - .current().general.TO_RF.val()); + return maxReceive - MekanismUtils.clampToInt(takeEnergy(maxReceive * MekanismConfig.current().general.FROM_RF.val(), !simulate) * + MekanismConfig.current().general.TO_RF.val()); } @Override @@ -289,15 +239,12 @@ public class TileEntityUniversalCable extends @Override public double acceptEnergy(EnumFacing side, double amount, boolean simulate) { double toUse = Math.min(getMaxEnergy() - getEnergy(), amount); - if (toUse < 0.0001 || (side != null && !canReceiveEnergy(side))) { return 0; } - if (!simulate) { setEnergy(getEnergy() + toUse); } - return toUse; } @@ -306,7 +253,6 @@ public class TileEntityUniversalCable extends if (side == null) { return true; } - return getConnectionType(side) == ConnectionType.NORMAL; } @@ -314,18 +260,16 @@ public class TileEntityUniversalCable extends public double getMaxEnergy() { if (getTransmitter().hasTransmitterNetwork()) { return getTransmitter().getTransmitterNetwork().getCapacity(); - } else { - return getCapacity(); } + return getCapacity(); } @Override public double getEnergy() { if (getTransmitter().hasTransmitterNetwork()) { return getTransmitter().getTransmitterNetwork().buffer.amount; - } else { - return buffer.amount; } + return buffer.amount; } @Override @@ -340,15 +284,12 @@ public class TileEntityUniversalCable extends public double takeEnergy(double energy, boolean doEmit) { if (getTransmitter().hasTransmitterNetwork()) { return getTransmitter().getTransmitterNetwork().emit(energy, doEmit); - } else { - double used = Math.min(getCapacity() - buffer.amount, energy); - - if (doEmit) { - buffer.amount += used; - } - - return energy - used; } + double used = Math.min(getCapacity() - buffer.amount, energy); + if (doEmit) { + buffer.amount += used; + } + return energy - used; } @Override @@ -360,56 +301,43 @@ public class TileEntityUniversalCable extends public boolean upgrade(int tierOrdinal) { if (tier.ordinal() < BaseTier.ULTIMATE.ordinal() && tierOrdinal == tier.ordinal() + 1) { tier = CableTier.values()[tier.ordinal() + 1]; - markDirtyTransmitters(); sendDesc = true; - return true; } - return false; } @Override public void handlePacketData(ByteBuf dataStream) throws Exception { tier = CableTier.values()[dataStream.readInt()]; - super.handlePacketData(dataStream); } @Override public TileNetworkList getNetworkedData(TileNetworkList data) { data.add(tier.ordinal()); - super.getNetworkedData(data); - return data; } @Override public boolean hasCapability(@Nonnull Capability capability, EnumFacing facing) { - return capability == Capabilities.ENERGY_STORAGE_CAPABILITY - || capability == Capabilities.ENERGY_ACCEPTOR_CAPABILITY - || capability == Capabilities.TESLA_CONSUMER_CAPABILITY - || capability == CapabilityEnergy.ENERGY - || super.hasCapability(capability, facing); + return capability == Capabilities.ENERGY_STORAGE_CAPABILITY || capability == Capabilities.ENERGY_ACCEPTOR_CAPABILITY + || capability == Capabilities.TESLA_CONSUMER_CAPABILITY || capability == CapabilityEnergy.ENERGY || super.hasCapability(capability, facing); } @Override public T getCapability(@Nonnull Capability capability, EnumFacing facing) { - if (capability == Capabilities.ENERGY_STORAGE_CAPABILITY - || capability == Capabilities.ENERGY_ACCEPTOR_CAPABILITY) { + if (capability == Capabilities.ENERGY_STORAGE_CAPABILITY || capability == Capabilities.ENERGY_ACCEPTOR_CAPABILITY) { return (T) this; } - if (capability == Capabilities.TESLA_CONSUMER_CAPABILITY) { return (T) teslaManager.getWrapper(this, facing); } - if (capability == CapabilityEnergy.ENERGY) { return (T) forgeEnergyManager.getWrapper(this, facing); } - return super.getCapability(capability, facing); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/transmitters/Transmitter.java b/src/main/java/mekanism/common/transmitters/Transmitter.java index 496bc60aa..b07d32c73 100644 --- a/src/main/java/mekanism/common/transmitters/Transmitter.java +++ b/src/main/java/mekanism/common/transmitters/Transmitter.java @@ -19,18 +19,14 @@ public abstract class Transmitter) transmitter).getTransmitterNetwork(); } } - return null; } @@ -156,4 +140,4 @@ public class TransmitterImpl containingPart) { this.containingTile = containingPart; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/transmitters/TransporterImpl.java b/src/main/java/mekanism/common/transmitters/TransporterImpl.java index 44e6e4f57..f5ce54785 100644 --- a/src/main/java/mekanism/common/transmitters/TransporterImpl.java +++ b/src/main/java/mekanism/common/transmitters/TransporterImpl.java @@ -72,7 +72,6 @@ public class TransporterImpl extends TransmitterImpl deletes = new HashSet<>(); - getTileEntity().pullItems(); - for (Map.Entry entry : transit.entrySet()) { int stackId = entry.getKey(); TransporterStack stack = entry.getValue(); - if (!stack.initiatedPath) { if (stack.itemStack.isEmpty() || !recalculate(stackId, stack, null)) { deletes.add(stackId); @@ -122,42 +116,30 @@ public class TransporterImpl extends TransmitterImpl= 100) { Coord4D prevSet = null; - if (stack.hasPath()) { int currentIndex = stack.getPath().indexOf(coord()); - - if (currentIndex == 0) //Necessary for transition reasons, not sure why - { + if (currentIndex == 0) { //Necessary for transition reasons, not sure why deletes.add(stackId); continue; } Coord4D next = stack.getPath().get(currentIndex - 1); - if (!stack.isFinal(this)) { - if (next != null && stack.canInsertToTransporter(next.getTileEntity(world()), - stack.getSide(this))) { - ILogisticalTransporter nextTile = CapabilityUtils - .getCapability(next.getTileEntity(world()), - Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, null); + if (next != null && stack.canInsertToTransporter(next.getTileEntity(world()), stack.getSide(this))) { + ILogisticalTransporter nextTile = CapabilityUtils.getCapability(next.getTileEntity(world()), Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, null); nextTile.entityEntering(stack, stack.progress % 100); deletes.add(stackId); continue; - } else if (next != null) { prevSet = next; } } else if (stack.pathType != Path.NONE) { TileEntity tile = next.getTileEntity(world()); - if (tile != null) { - TransitResponse response = InventoryUtils - .putStackInInventory(tile, TransitRequest.getFromTransport(stack), - stack.getSide(this), stack.pathType == Path.HOME); - + TransitResponse response = InventoryUtils.putStackInInventory(tile, TransitRequest.getFromTransport(stack), + stack.getSide(this), stack.pathType == Path.HOME); // Nothing was rejected; remove the stack from the prediction tracker and // schedule this stack for deletion. Continue the loop thereafter if (response.getRejected(stack.itemStack).isEmpty()) { @@ -173,7 +155,6 @@ public class TransporterImpl extends TransmitterImpl 0 || needsSync.size() > 0) { - TileEntityMessage msg = new TileEntityMessage(coord(), - getTileEntity().makeBatchPacket(needsSync, deletes)); - + TileEntityMessage msg = new TileEntityMessage(coord(), getTileEntity().makeBatchPacket(needsSync, deletes)); // Now remove any entries from transit that have been deleted deletes.forEach(id -> transit.remove(id)); @@ -219,33 +196,27 @@ public class TransporterImpl extends TransmitterImpl getCapacity()) { buffer.amount = getCapacity(); } - if (buffer.amount < 0) { buffer.amount = 0; } @@ -85,11 +82,9 @@ public class EnergyNetwork extends DynamicNetwork cable : transmitters) { reciprocalSum += 1.0 / (double) cable.getCapacity(); } - meanCapacity = (double) numCables / reciprocalSum; } @@ -97,7 +92,6 @@ public class EnergyNetwork extends DynamicNetwork 0.01 || (currentPowerScale != lastPowerScale && ( - currentPowerScale == 0 || currentPowerScale == 1))) { + if (Math.abs(currentPowerScale - lastPowerScale) > 0.01 || (currentPowerScale != lastPowerScale && (currentPowerScale == 0 || currentPowerScale == 1))) { needsUpdate = true; } - if (needsUpdate) { MinecraftForge.EVENT_BUS.post(new EnergyTransferEvent(this, currentPowerScale)); lastPowerScale = currentPowerScale; needsUpdate = false; } - if (buffer.amount > 0) { joulesTransmitted = tickEmit(buffer.amount); buffer.amount -= joulesTransmitted; @@ -173,8 +159,7 @@ public class EnergyNetwork extends DynamicNetwork buffer.amount) { - buffer = net.buffer.copy(); - } - + } else if (buffer.getFluid() == net.buffer.getFluid()) { + buffer.amount += net.buffer.amount; + } else if (net.buffer.amount > buffer.amount) { + buffer = net.buffer.copy(); } - net.buffer = null; } super.adoptTransmittersAndAcceptorsFrom(net); @@ -82,11 +76,9 @@ public class FluidNetwork extends DynamicNetwork transmitter) { FluidStack fluid = transmitter.getBuffer(); - if (fluid == null || fluid.getFluid() == null || fluid.amount == 0) { return; } - if (buffer == null || buffer.getFluid() == null || buffer.amount == 0) { buffer = fluid.copy(); fluid.amount = 0; @@ -97,7 +89,6 @@ public class FluidNetwork extends DynamicNetwork pipe : transmitters) { sum += pipe.getCapacity(); } - meanCapacity = sum / (double) numCables; } @@ -136,13 +125,10 @@ public class FluidNetwork extends DynamicNetwork 0) { didTransfer = true; transferDelay = 2; } - if (buffer != null) { buffer.amount -= prevTransferAmount; - if (buffer.amount <= 0) { buffer = null; } @@ -226,14 +198,11 @@ public class FluidNetwork extends DynamicNetwork 0) { fluidScale = getScale(); - if (fluidScale == 0) { buffer = null; } @@ -241,7 +210,7 @@ public class FluidNetwork extends DynamicNetwork buffer.amount) { - buffer = net.buffer.copy(); - } - + } else if (buffer.isGasEqual(net.buffer)) { + buffer.amount += net.buffer.amount; + } else if (net.buffer.amount > buffer.amount) { + buffer = net.buffer.copy(); } net.buffer = null; } @@ -98,11 +92,9 @@ public class GasNetwork extends DynamicNetwork transmitter) { GasStack gas = transmitter.getBuffer(); - if (gas == null || gas.getGas() == null || gas.amount == 0) { return; } - if (buffer == null || buffer.getGas() == null || buffer.amount == 0) { buffer = gas.copy(); gas.amount = 0; @@ -113,7 +105,6 @@ public class GasNetwork extends DynamicNetwork 0) { @@ -216,7 +196,6 @@ public class GasNetwork extends DynamicNetwork 0) { gasScale = Math.max(getScale(), Math.max(0, gasScale - 0.02F)); - if (gasScale == 0) { buffer = null; } @@ -242,7 +218,7 @@ public class GasNetwork extends DynamicNetwork transmitter : transmitters) { - if (transmitter instanceof TransmitterImpl && ((TransmitterImpl) transmitter).getTileEntity() - .hasCapability(Capabilities.HEAT_TRANSFER_CAPABILITY, null)) { - IHeatTransfer heatTransmitter = (IHeatTransfer) ((TransmitterImpl) transmitter).getTileEntity() - .getCapability(Capabilities.HEAT_TRANSFER_CAPABILITY, null); + if (transmitter instanceof TransmitterImpl && ((TransmitterImpl) transmitter).getTileEntity().hasCapability(Capabilities.HEAT_TRANSFER_CAPABILITY, null)) { + IHeatTransfer heatTransmitter = (IHeatTransfer) ((TransmitterImpl) transmitter).getTileEntity().getCapability(Capabilities.HEAT_TRANSFER_CAPABILITY, null); double[] d = heatTransmitter.simulateHeat(); newHeatTransferred += d[0]; newHeatLost += d[1]; @@ -78,9 +74,8 @@ public class HeatNetwork extends DynamicNetwork calculateAcceptors(TransitRequest request, TransporterStack stack) { List toReturn = new ArrayList<>(); - for (Coord4D coord : possibleAcceptors) { if (coord == null || coord.equals(stack.homeLocation)) { continue; @@ -41,17 +39,13 @@ public class InventoryNetwork extends DynamicNetwork sides = acceptorDirections.get(coord); TileEntity acceptor = coord.getTileEntity(getWorld()); - if (acceptor == null || sides == null || sides.isEmpty()) { continue; } AcceptorData data = null; - for (EnumFacing side : sides) { - TransitResponse response = TransporterManager - .getPredictedInsert(acceptor, stack.color, request, side.getOpposite()); - + TransitResponse response = TransporterManager.getPredictedInsert(acceptor, stack.color, request, side.getOpposite()); if (!response.isEmpty()) { if (data == null) { data = new AcceptorData(coord, response, side.getOpposite()); @@ -60,19 +54,16 @@ public class InventoryNetwork extends DynamicNetwork 0) { Coord4D coord = Coord4D.get(tileEntity); //Fake that we have one target given we know that no sides will overlap @@ -149,8 +125,7 @@ public final class CableUtils { //Get the opposite side as the current side is relative to us EnumFacing opposite = side.getOpposite(); EnergyAcceptorWrapper acceptor = EnergyAcceptorWrapper.get(tile, opposite); - if (acceptor != null && acceptor.canReceiveEnergy(opposite) && acceptor - .needsEnergy(opposite)) { + if (acceptor != null && acceptor.canReceiveEnergy(opposite) && acceptor.needsEnergy(opposite)) { target.addHandler(opposite, acceptor); } } diff --git a/src/main/java/mekanism/common/util/CapabilityUtils.java b/src/main/java/mekanism/common/util/CapabilityUtils.java index bb913f538..2dc726e8b 100644 --- a/src/main/java/mekanism/common/util/CapabilityUtils.java +++ b/src/main/java/mekanism/common/util/CapabilityUtils.java @@ -10,7 +10,6 @@ public final class CapabilityUtils { if (provider == null || cap == null) { return false; } - return provider.hasCapability(cap, side); } @@ -18,7 +17,6 @@ public final class CapabilityUtils { if (provider == null || cap == null) { return null; } - return provider.getCapability(cap, side); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/util/ChargeUtils.java b/src/main/java/mekanism/common/util/ChargeUtils.java index cdfb03f61..89b66ea1b 100644 --- a/src/main/java/mekanism/common/util/ChargeUtils.java +++ b/src/main/java/mekanism/common/util/ChargeUtils.java @@ -36,42 +36,28 @@ public final class ChargeUtils { public static void discharge(int slotID, IStrictEnergyStorage storer) { IInventory inv = (TileEntityContainerBlock) storer; ItemStack stack = inv.getStackInSlot(slotID); - if (!stack.isEmpty() && storer.getEnergy() < storer.getMaxEnergy()) { if (stack.getItem() instanceof IEnergizedItem) { - storer.setEnergy(storer.getEnergy() + EnergizedItemManager - .discharge(stack, storer.getMaxEnergy() - storer.getEnergy())); + storer.setEnergy(storer.getEnergy() + EnergizedItemManager.discharge(stack, storer.getMaxEnergy() - storer.getEnergy())); } else if (MekanismUtils.useForge() && stack.hasCapability(CapabilityEnergy.ENERGY, null)) { IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null); if (storage.canExtract()) { - int needed = MekanismUtils.clampToInt((storer.getMaxEnergy() - storer.getEnergy()) * - MekanismConfig.current().general.TO_FORGE.val()); - storer.setEnergy(storer.getEnergy() + storage.extractEnergy(needed, false) * MekanismConfig - .current().general.FROM_FORGE.val()); + int needed = MekanismUtils.clampToInt((storer.getMaxEnergy() - storer.getEnergy()) * MekanismConfig.current().general.TO_FORGE.val()); + storer.setEnergy(storer.getEnergy() + storage.extractEnergy(needed, false) * MekanismConfig.current().general.FROM_FORGE.val()); } } else if (MekanismUtils.useRF() && stack.getItem() instanceof IEnergyContainerItem) { IEnergyContainerItem item = (IEnergyContainerItem) stack.getItem(); - int needed = MekanismUtils.clampToInt((storer.getMaxEnergy() - storer.getEnergy()) * - MekanismConfig.current().general.TO_RF.val()); - storer.setEnergy(storer.getEnergy() + (item.extractEnergy(stack, needed, false) * MekanismConfig - .current().general.FROM_RF.val())); + int needed = MekanismUtils.clampToInt((storer.getMaxEnergy() - storer.getEnergy()) * MekanismConfig.current().general.TO_RF.val()); + storer.setEnergy(storer.getEnergy() + (item.extractEnergy(stack, needed, false) * MekanismConfig.current().general.FROM_RF.val())); } else if (MekanismUtils.useTesla() && stack.hasCapability(Capabilities.TESLA_PRODUCER_CAPABILITY, null)) { ITeslaProducer producer = stack.getCapability(Capabilities.TESLA_PRODUCER_CAPABILITY, null); - - long needed = Math.round( - (storer.getMaxEnergy() - storer.getEnergy()) * MekanismConfig.current().general.TO_TESLA.val()); - storer.setEnergy(storer.getEnergy() + producer.takePower(needed, false) * MekanismConfig - .current().general.FROM_TESLA.val()); + long needed = Math.round((storer.getMaxEnergy() - storer.getEnergy()) * MekanismConfig.current().general.TO_TESLA.val()); + storer.setEnergy(storer.getEnergy() + producer.takePower(needed, false) * MekanismConfig.current().general.FROM_TESLA.val()); } else if (MekanismUtils.useIC2() && isIC2Dischargeable(stack)) { - double gain = ElectricItem.manager - .discharge(stack, - (storer.getMaxEnergy() - storer.getEnergy()) * MekanismConfig.current().general.TO_IC2 - .val(), 4, true, true, - false) * MekanismConfig.current().general.FROM_IC2.val(); + double gain = ElectricItem.manager.discharge(stack, (storer.getMaxEnergy() - storer.getEnergy()) * MekanismConfig.current().general.TO_IC2.val(), + 4, true, true, false) * MekanismConfig.current().general.FROM_IC2.val(); storer.setEnergy(storer.getEnergy() + gain); - } else if (stack.getItem() == Items.REDSTONE - && storer.getEnergy() + MekanismConfig.current().general.ENERGY_PER_REDSTONE.val() <= storer - .getMaxEnergy()) { + } else if (stack.getItem() == Items.REDSTONE && storer.getEnergy() + MekanismConfig.current().general.ENERGY_PER_REDSTONE.val() <= storer.getMaxEnergy()) { storer.setEnergy(storer.getEnergy() + MekanismConfig.current().general.ENERGY_PER_REDSTONE.val()); stack.shrink(1); } @@ -92,7 +78,7 @@ public final class ChargeUtils { /** * Universally charges an item, and updates the TileEntity's energy level. * - * @param stack - ItemStack to charge + * @param stack - ItemStack to charge * @param storer - TileEntity the item is being discharged in */ public static void charge(ItemStack stack, IStrictEnergyStorage storer) { @@ -102,36 +88,30 @@ public final class ChargeUtils { } else if (MekanismUtils.useForge() && stack.hasCapability(CapabilityEnergy.ENERGY, null)) { IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null); if (storage.canReceive()) { - int stored = MekanismUtils - .clampToInt(storer.getEnergy() * MekanismConfig.current().general.TO_FORGE.val()); - storer.setEnergy(storer.getEnergy() - storage.receiveEnergy(stored, false) * MekanismConfig - .current().general.FROM_FORGE.val()); + int stored = MekanismUtils.clampToInt(storer.getEnergy() * MekanismConfig.current().general.TO_FORGE.val()); + storer.setEnergy(storer.getEnergy() - storage.receiveEnergy(stored, false) * MekanismConfig.current().general.FROM_FORGE.val()); } } else if (MekanismUtils.useRF() && stack.getItem() instanceof IEnergyContainerItem) { IEnergyContainerItem item = (IEnergyContainerItem) stack.getItem(); - int toTransfer = MekanismUtils - .clampToInt(storer.getEnergy() * MekanismConfig.current().general.TO_RF.val()); - storer.setEnergy(storer.getEnergy() - (item.receiveEnergy(stack, toTransfer, false) * MekanismConfig - .current().general.FROM_RF.val())); + int toTransfer = MekanismUtils.clampToInt(storer.getEnergy() * MekanismConfig.current().general.TO_RF.val()); + storer.setEnergy(storer.getEnergy() - (item.receiveEnergy(stack, toTransfer, false) * MekanismConfig.current().general.FROM_RF.val())); } else if (MekanismUtils.useTesla() && stack.hasCapability(Capabilities.TESLA_CONSUMER_CAPABILITY, null)) { ITeslaConsumer consumer = stack.getCapability(Capabilities.TESLA_CONSUMER_CAPABILITY, null); long stored = Math.round(storer.getEnergy() * MekanismConfig.current().general.TO_TESLA.val()); - storer.setEnergy(storer.getEnergy() - consumer.givePower(stored, false) * MekanismConfig - .current().general.FROM_TESLA.val()); + storer.setEnergy(storer.getEnergy() - consumer.givePower(stored, false) * MekanismConfig.current().general.FROM_TESLA.val()); } else if (MekanismUtils.useIC2() && isIC2Chargeable(stack)) { - double sent = ElectricItem.manager - .charge(stack, storer.getEnergy() * MekanismConfig.current().general.TO_IC2.val(), 4, true, false) - * MekanismConfig.current().general.FROM_IC2.val(); + double sent = ElectricItem.manager.charge(stack, storer.getEnergy() * MekanismConfig.current().general.TO_IC2.val(), 4, true, false) + * MekanismConfig.current().general.FROM_IC2.val(); storer.setEnergy(storer.getEnergy() - sent); } } } /** - * Whether or not a defined ItemStack can be discharged for energy in some way. Note: The ItemStack must also have - * energy to discharge. + * Whether or not a defined ItemStack can be discharged for energy in some way. Note: The ItemStack must also have energy to discharge. * * @param itemstack - ItemStack to check + * * @return if the ItemStack can be discharged */ public static boolean canBeDischarged(ItemStack itemstack) { @@ -172,10 +152,10 @@ public final class ChargeUtils { } /** - * Whether or not a defined ItemStack can be charged with energy in some way. Note: The ItemStack must also have - * room for more energy. + * Whether or not a defined ItemStack can be charged with energy in some way. Note: The ItemStack must also have room for more energy. * * @param itemstack - ItemStack to check + * * @return if the ItemStack can be discharged */ public static boolean canBeCharged(ItemStack itemstack) { @@ -217,30 +197,27 @@ public final class ChargeUtils { } /** - * Whether or not a defined deemed-electrical ItemStack can be outputted out of a slot. This puts into account - * whether or not that slot is used for charging or discharging. + * Whether or not a defined deemed-electrical ItemStack can be outputted out of a slot. This puts into account whether or not that slot is used for charging or + * discharging. * - * @param itemstack - ItemStack to perform the check on + * @param itemstack - ItemStack to perform the check on * @param chargeSlot - whether or not the outputting slot is for charging or discharging + * * @return if the ItemStack can be outputted */ public static boolean canBeOutputted(ItemStack itemstack, boolean chargeSlot) { if (itemstack.getItem() instanceof IEnergizedItem) { IEnergizedItem energized = (IEnergizedItem) itemstack.getItem(); - if (chargeSlot) { return energized.getEnergy(itemstack) == energized.getMaxEnergy(itemstack); - } else { - return energized.getEnergy(itemstack) == 0; } + return energized.getEnergy(itemstack) == 0; } else if (MekanismUtils.useRF() && itemstack.getItem() instanceof IEnergyContainerItem) { IEnergyContainerItem energyContainer = (IEnergyContainerItem) itemstack.getItem(); - if (chargeSlot) { return energyContainer.receiveEnergy(itemstack, 1, true) == 0; - } else { - return energyContainer.extractEnergy(itemstack, 1, true) == 0; } + return energyContainer.extractEnergy(itemstack, 1, true) == 0; } else if (MekanismUtils.useTesla()) { if (chargeSlot && itemstack.hasCapability(Capabilities.TESLA_CONSUMER_CAPABILITY, null)) { ITeslaConsumer consumer = itemstack.getCapability(Capabilities.TESLA_CONSUMER_CAPABILITY, null); @@ -251,24 +228,19 @@ public final class ChargeUtils { } } else if (MekanismUtils.useForge() && itemstack.hasCapability(CapabilityEnergy.ENERGY, null)) { IEnergyStorage storage = itemstack.getCapability(CapabilityEnergy.ENERGY, null); - if (chargeSlot) { return !storage.canReceive() || storage.receiveEnergy(1, true) == 0; - } else { - return !storage.canExtract() || storage.extractEnergy(1, true) == 0; } + return !storage.canExtract() || storage.extractEnergy(1, true) == 0; } else if (MekanismUtils.useIC2() && (isIC2Chargeable(itemstack) || isIC2Dischargeable(itemstack))) { IElectricItemManager manager = ElectricItem.manager; - if (manager != null) { if (chargeSlot) { return manager.charge(itemstack, 1, 3, true, true) == 0; - } else { - return manager.discharge(itemstack, 1, 3, true, true, true) == 0; } + return manager.discharge(itemstack, 1, 3, true, true, true) == 0; } } - return true; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/util/EmitUtils.java b/src/main/java/mekanism/common/util/EmitUtils.java index a0d6e20c9..dcbe728a4 100644 --- a/src/main/java/mekanism/common/util/EmitUtils.java +++ b/src/main/java/mekanism/common/util/EmitUtils.java @@ -10,19 +10,19 @@ import mekanism.common.base.target.Target; public class EmitUtils { /** - * @param The handler of our target. - * @param The type of the number - * @param Any extra information we may need. - * @param The emitter target. + * @param The handler of our target. + * @param The type of the number + * @param Any extra information we may need. + * @param The emitter target. * @param availableTargets The targets to distribute toSend fairly among. - * @param totalTargets The total number of targets. Note: this number is bigger than availableTargets.size if any - * targets have more than one acceptor. - * @param splitInfo Information containing the split. - * @param toSend Any extra information such as gas stack or fluid stack. + * @param totalTargets The total number of targets. Note: this number is bigger than availableTargets.size if any targets have more than one acceptor. + * @param splitInfo Information containing the split. + * @param toSend Any extra information such as gas stack or fluid stack. + * * @return The amount that actually got sent. */ - private static , EXTRA, TARGET extends Target> - TYPE sendToAcceptors(Set availableTargets, int totalTargets, SplitInfo splitInfo, EXTRA toSend) { + private static , EXTRA, TARGET extends Target> TYPE sendToAcceptors( + Set availableTargets, int totalTargets, SplitInfo splitInfo, EXTRA toSend) { if (availableTargets.isEmpty() || totalTargets == 0) { return splitInfo.getTotalSent(); } @@ -46,32 +46,28 @@ public class EmitUtils { } /** - * @param The handler of our target. - * @param Any extra information we may need - * @param The emitter target + * @param The handler of our target. + * @param Any extra information we may need + * @param The emitter target * @param availableTargets The targets to distribute toSend fairly among. - * @param totalTargets The total number of targets. Note: this number is bigger than availableTargets.size if any - * targets have more than one acceptor. - * @param amountToSplit The amount to split between all the targets - * @param toSend Any extra information such as gas stack or fluid stack. + * @param totalTargets The total number of targets. Note: this number is bigger than availableTargets.size if any targets have more than one acceptor. + * @param amountToSplit The amount to split between all the targets + * @param toSend Any extra information such as gas stack or fluid stack. + * * @return The amount that actually got sent. */ - public static > int sendToAcceptors( - Set availableTargets, int totalTargets, int amountToSplit, EXTRA toSend) { - return sendToAcceptors(availableTargets, totalTargets, new IntegerSplitInfo(amountToSplit, totalTargets), - toSend); + public static > int sendToAcceptors(Set availableTargets, int totalTargets, int amountToSplit, EXTRA toSend) { + return sendToAcceptors(availableTargets, totalTargets, new IntegerSplitInfo(amountToSplit, totalTargets), toSend); } /** * @param availableTargets The EnergyAcceptorWrapper targets to send energy fairly to. - * @param totalTargets The total number of targets. Note: this number is bigger than availableTargets.size if any - * targets have more than one acceptor. - * @param amountToSplit The amount of energy to attempt to send + * @param totalTargets The total number of targets. Note: this number is bigger than availableTargets.size if any targets have more than one acceptor. + * @param amountToSplit The amount of energy to attempt to send + * * @return The amount that actually got sent */ - public static double sendToAcceptors(Set availableTargets, int totalTargets, - double amountToSplit) { - return sendToAcceptors(availableTargets, totalTargets, new DoubleSplitInfo(amountToSplit, totalTargets), - amountToSplit); + public static double sendToAcceptors(Set availableTargets, int totalTargets, double amountToSplit) { + return sendToAcceptors(availableTargets, totalTargets, new DoubleSplitInfo(amountToSplit, totalTargets), amountToSplit); } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/util/FieldsAreNonnullByDefault.java b/src/main/java/mekanism/common/util/FieldsAreNonnullByDefault.java index c5e72673a..ebe16052e 100644 --- a/src/main/java/mekanism/common/util/FieldsAreNonnullByDefault.java +++ b/src/main/java/mekanism/common/util/FieldsAreNonnullByDefault.java @@ -10,5 +10,4 @@ import javax.annotation.meta.TypeQualifierDefault; @TypeQualifierDefault(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) public @interface FieldsAreNonnullByDefault { - -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/util/FluidContainerUtils.java b/src/main/java/mekanism/common/util/FluidContainerUtils.java index e07315ec9..b59e04f51 100644 --- a/src/main/java/mekanism/common/util/FluidContainerUtils.java +++ b/src/main/java/mekanism/common/util/FluidContainerUtils.java @@ -23,8 +23,7 @@ public final class FluidContainerUtils { return extractFluid(tileTank, tile, slotID, FluidChecker.check(tileTank.getFluid())); } - public static FluidStack extractFluid(FluidTank tileTank, TileEntityContainerBlock tile, int slotID, - FluidChecker checker) { + public static FluidStack extractFluid(FluidTank tileTank, TileEntityContainerBlock tile, int slotID, FluidChecker checker) { IFluidHandlerItem handler = FluidUtil.getFluidHandler(tile.inventory.get(slotID)); FluidStack ret = null; if (handler != null) { @@ -38,17 +37,13 @@ public final class FluidContainerUtils { if (handler == null) { return null; } - FluidStack fluidStack = handler.drain(Integer.MAX_VALUE, false); - if (fluidStack == null) { return null; } - if (checker != null && !checker.isValid(fluidStack.getFluid())) { return null; } - return handler.drain(needed, true); } @@ -60,62 +55,48 @@ public final class FluidContainerUtils { if (fluid == null || handler == null) { return 0; } - return handler.fill(fluid, true); } - public static void handleContainerItemFill(TileEntityContainerBlock tileEntity, FluidTank tank, int inSlot, - int outSlot) { + public static void handleContainerItemFill(TileEntityContainerBlock tileEntity, FluidTank tank, int inSlot, int outSlot) { tank.setFluid(handleContainerItemFill(tileEntity, tileEntity.inventory, tank.getFluid(), inSlot, outSlot)); } - public static FluidStack handleContainerItemFill(TileEntity tileEntity, NonNullList inventory, - FluidStack stack, int inSlot, int outSlot) { + public static FluidStack handleContainerItemFill(TileEntity tileEntity, NonNullList inventory, FluidStack stack, int inSlot, int outSlot) { if (stack != null) { ItemStack inputCopy = StackUtils.size(inventory.get(inSlot).copy(), 1); - IFluidHandlerItem handler = FluidUtil.getFluidHandler(inputCopy); int drained = 0; if (handler != null) { drained = insertFluid(stack, handler); inputCopy = handler.getContainer(); } - - if (!inventory.get(outSlot).isEmpty() && ( - !ItemHandlerHelper.canItemStacksStack(inventory.get(outSlot), inputCopy) - || inventory.get(outSlot).getCount() == inventory.get(outSlot).getMaxStackSize())) { + if (!inventory.get(outSlot).isEmpty() && (!ItemHandlerHelper.canItemStacksStack(inventory.get(outSlot), inputCopy) || + inventory.get(outSlot).getCount() == inventory.get(outSlot).getMaxStackSize())) { return stack; } - stack.amount -= drained; - if (inventory.get(outSlot).isEmpty()) { inventory.set(outSlot, inputCopy); } else if (ItemHandlerHelper.canItemStacksStack(inventory.get(outSlot), inputCopy)) { inventory.get(outSlot).grow(1); } - inventory.get(inSlot).shrink(1); - tileEntity.markDirty(); } - return stack; } - public static void handleContainerItemEmpty(TileEntityContainerBlock tileEntity, FluidTank tank, int inSlot, - int outSlot) { + public static void handleContainerItemEmpty(TileEntityContainerBlock tileEntity, FluidTank tank, int inSlot, int outSlot) { handleContainerItemEmpty(tileEntity, tank, inSlot, outSlot, null); } - public static void handleContainerItemEmpty(TileEntityContainerBlock tileEntity, FluidTank tank, int inSlot, - int outSlot, FluidChecker checker) { - tank.setFluid(handleContainerItemEmpty(tileEntity, tileEntity.inventory, tank.getFluid(), - tank.getCapacity() - tank.getFluidAmount(), inSlot, outSlot, checker)); + public static void handleContainerItemEmpty(TileEntityContainerBlock tileEntity, FluidTank tank, int inSlot, int outSlot, FluidChecker checker) { + tank.setFluid(handleContainerItemEmpty(tileEntity, tileEntity.inventory, tank.getFluid(), tank.getCapacity() - tank.getFluidAmount(), inSlot, outSlot, checker)); } - public static FluidStack handleContainerItemEmpty(TileEntity tileEntity, NonNullList inventory, - FluidStack stored, int needed, int inSlot, int outSlot, final FluidChecker checker) { + public static FluidStack handleContainerItemEmpty(TileEntity tileEntity, NonNullList inventory, FluidStack stored, int needed, int inSlot, int outSlot, + final FluidChecker checker) { final Fluid storedFinal = stored != null ? stored.getFluid() : null; final ItemStack input = StackUtils.size(inventory.get(inSlot).copy(), 1); final IFluidHandlerItem handler = FluidUtil.getFluidHandler(input); @@ -123,7 +104,6 @@ public final class FluidContainerUtils { if (handler == null) { return stored; } - FluidStack ret = extractFluid(needed, handler, new FluidChecker() { @Override public boolean isValid(Fluid f) { @@ -132,11 +112,9 @@ public final class FluidContainerUtils { }); ItemStack inputCopy = handler.getContainer(); - if (FluidUtil.getFluidContained(inputCopy) == null && !inputCopy.isEmpty()) { - if (!inventory.get(outSlot).isEmpty() && ( - !ItemHandlerHelper.canItemStacksStack(inventory.get(outSlot), inputCopy) - || inventory.get(outSlot).getCount() == inventory.get(outSlot).getMaxStackSize())) { + if (!inventory.get(outSlot).isEmpty() && (!ItemHandlerHelper.canItemStacksStack(inventory.get(outSlot), inputCopy) || + inventory.get(outSlot).getCount() == inventory.get(outSlot).getMaxStackSize())) { return stored; } } @@ -147,9 +125,7 @@ public final class FluidContainerUtils { } else { stored.amount += ret.amount; } - needed -= ret.amount; - tileEntity.markDirty(); } @@ -161,39 +137,30 @@ public final class FluidContainerUtils { inventory.get(outSlot).grow(1); } } - inventory.get(inSlot).shrink(1); - tileEntity.markDirty(); } else { inventory.set(inSlot, inputCopy); } - return stored; } - public static void handleContainerItem(TileEntityContainerBlock tileEntity, ContainerEditMode editMode, - FluidTank tank, int inSlot, int outSlot) { + public static void handleContainerItem(TileEntityContainerBlock tileEntity, ContainerEditMode editMode, FluidTank tank, int inSlot, int outSlot) { handleContainerItem(tileEntity, editMode, tank, inSlot, outSlot, null); } - public static void handleContainerItem(TileEntityContainerBlock tileEntity, ContainerEditMode editMode, - FluidTank tank, int inSlot, int outSlot, FluidChecker checker) { - tank.setFluid(handleContainerItem(tileEntity, tileEntity.inventory, editMode, tank.getFluid(), - tank.getCapacity() - tank.getFluidAmount(), inSlot, outSlot, checker)); + public static void handleContainerItem(TileEntityContainerBlock tileEntity, ContainerEditMode editMode, FluidTank tank, int inSlot, int outSlot, FluidChecker checker) { + tank.setFluid(handleContainerItem(tileEntity, tileEntity.inventory, editMode, tank.getFluid(), tank.getCapacity() - tank.getFluidAmount(), inSlot, outSlot, checker)); } - public static FluidStack handleContainerItem(TileEntity tileEntity, NonNullList inventory, - ContainerEditMode editMode, FluidStack stack, int needed, int inSlot, int outSlot, - final FluidChecker checker) { + public static FluidStack handleContainerItem(TileEntity tileEntity, NonNullList inventory, ContainerEditMode editMode, FluidStack stack, int needed, + int inSlot, int outSlot, final FluidChecker checker) { FluidStack fluidStack = FluidUtil.getFluidContained(inventory.get(inSlot)); - if (editMode == ContainerEditMode.FILL || (editMode == ContainerEditMode.BOTH && fluidStack == null)) { return handleContainerItemFill(tileEntity, inventory, stack, inSlot, outSlot); } else if (editMode == ContainerEditMode.EMPTY || editMode == ContainerEditMode.BOTH) { return handleContainerItemEmpty(tileEntity, inventory, stack, needed, inSlot, outSlot, checker); } - return stack; } @@ -239,4 +206,4 @@ public final class FluidContainerUtils { return true; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/util/GasUtils.java b/src/main/java/mekanism/common/util/GasUtils.java index 683f5d43a..61a0c1fbd 100644 --- a/src/main/java/mekanism/common/util/GasUtils.java +++ b/src/main/java/mekanism/common/util/GasUtils.java @@ -35,17 +35,12 @@ public final class GasUtils { public static IGasHandler[] getConnectedAcceptors(BlockPos pos, World world, Set sides) { IGasHandler[] acceptors = new IGasHandler[]{null, null, null, null, null, null}; - for (EnumFacing orientation : sides) { TileEntity acceptor = world.getTileEntity(pos.offset(orientation)); - - if (CapabilityUtils - .hasCapability(acceptor, Capabilities.GAS_HANDLER_CAPABILITY, orientation.getOpposite())) { - acceptors[orientation.ordinal()] = CapabilityUtils - .getCapability(acceptor, Capabilities.GAS_HANDLER_CAPABILITY, orientation.getOpposite()); + if (CapabilityUtils.hasCapability(acceptor, Capabilities.GAS_HANDLER_CAPABILITY, orientation.getOpposite())) { + acceptors[orientation.ordinal()] = CapabilityUtils.getCapability(acceptor, Capabilities.GAS_HANDLER_CAPABILITY, orientation.getOpposite()); } } - return acceptors; } @@ -62,7 +57,6 @@ public final class GasUtils { if (CapabilityUtils.hasCapability(tile, Capabilities.GRID_TRANSMITTER_CAPABILITY, side.getOpposite())) { return false; } - return CapabilityUtils.hasCapability(tile, Capabilities.GAS_HANDLER_CAPABILITY, side.getOpposite()); } @@ -70,22 +64,19 @@ public final class GasUtils { * 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 + * @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.isEmpty() && 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)) { + 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; } @@ -93,15 +84,14 @@ public final class GasUtils { * Adds a specified amount of gas to an IGasItem. * * @param itemStack - ItemStack of the IGasItem - * @param stack - stack to add to the IGasItem + * @param stack - stack to add to the IGasItem + * * @return amount of gas accepted by the IGasItem */ public static int addGas(ItemStack itemStack, GasStack stack) { - if (!itemStack.isEmpty() && itemStack.getItem() instanceof IGasItem && ((IGasItem) itemStack.getItem()) - .canReceiveGas(itemStack, stack.getGas())) { + if (!itemStack.isEmpty() && itemStack.getItem() instanceof IGasItem && ((IGasItem) itemStack.getItem()).canReceiveGas(itemStack, stack.getGas())) { return ((IGasItem) itemStack.getItem()).addGas(itemStack, stack.copy()); } - return 0; } @@ -109,8 +99,9 @@ public final class GasUtils { * Emits gas from a central block by splitting the received stack among the sides given. * * @param stack - the stack to output - * @param from - the TileEntity to output from + * @param from - the TileEntity to output from * @param sides - the list of sides to output from + * * @return the amount of gas emitted */ public static int emit(GasStack stack, TileEntity from, Set sides) { @@ -128,8 +119,7 @@ public final class GasUtils { } EnumFacing opposite = orientation.getOpposite(); if (CapabilityUtils.hasCapability(acceptor, Capabilities.GAS_HANDLER_CAPABILITY, opposite)) { - IGasHandler handler = CapabilityUtils.getCapability(acceptor, Capabilities.GAS_HANDLER_CAPABILITY, - opposite); + IGasHandler handler = CapabilityUtils.getCapability(acceptor, Capabilities.GAS_HANDLER_CAPABILITY, opposite); if (handler != null && handler.canReceiveGas(opposite, stack.getGas())) { target.addHandler(opposite, handler); } @@ -162,6 +152,7 @@ public final class GasUtils { * Gets the amount of ticks the declared itemstack can fuel this machine. * * @param itemStack - itemstack to check with + * * @return fuel ticks */ public static GasStack getItemGas(ItemStack itemStack, BiFunction getIfValid) { @@ -210,7 +201,6 @@ public final class GasUtils { } } } - return gasStack; } @@ -236,4 +226,4 @@ public final class GasUtils { stacks.add(MekanismUtils.getFullGasTank(GasTankTier.BASIC, type)); return stacks; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/util/HeatUtils.java b/src/main/java/mekanism/common/util/HeatUtils.java index bafa1565b..88eb4d4b5 100644 --- a/src/main/java/mekanism/common/util/HeatUtils.java +++ b/src/main/java/mekanism/common/util/HeatUtils.java @@ -9,35 +9,25 @@ public class HeatUtils { public static double[] simulate(IHeatTransfer source) { double[] heatTransferred = new double[]{0, 0}; - for (EnumFacing side : EnumFacing.VALUES) { IHeatTransfer sink = source.getAdjacent(side); - if (sink != null) { - double invConduction = - sink.getInverseConductionCoefficient() + source.getInverseConductionCoefficient(); + double invConduction = sink.getInverseConductionCoefficient() + source.getInverseConductionCoefficient(); double heatToTransfer = source.getTemp() / invConduction; source.transferHeatTo(-heatToTransfer); sink.transferHeatTo(heatToTransfer); - - if (!(sink instanceof ICapabilityProvider && CapabilityUtils - .hasCapability((ICapabilityProvider) sink, Capabilities.GRID_TRANSMITTER_CAPABILITY, - side.getOpposite()))) { + if (!(sink instanceof ICapabilityProvider && CapabilityUtils.hasCapability((ICapabilityProvider) sink, Capabilities.GRID_TRANSMITTER_CAPABILITY, side.getOpposite()))) { heatTransferred[0] += heatToTransfer; } - continue; } //Transfer to air otherwise - double invConduction = - IHeatTransfer.AIR_INVERSE_COEFFICIENT + source.getInsulationCoefficient(side) + source - .getInverseConductionCoefficient(); + double invConduction = IHeatTransfer.AIR_INVERSE_COEFFICIENT + source.getInsulationCoefficient(side) + source.getInverseConductionCoefficient(); double heatToTransfer = source.getTemp() / invConduction; source.transferHeatTo(-heatToTransfer); heatTransferred[1] += heatToTransfer; } - return heatTransferred; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/util/InventoryUtils.java b/src/main/java/mekanism/common/util/InventoryUtils.java index 1e542f5a2..4bd6c0ac3 100644 --- a/src/main/java/mekanism/common/util/InventoryUtils.java +++ b/src/main/java/mekanism/common/util/InventoryUtils.java @@ -1,8 +1,6 @@ package mekanism.common.util; import java.util.Map; -import net.minecraftforge.items.ItemHandlerHelper; -import org.apache.commons.lang3.tuple.Pair; import mekanism.api.EnumColor; import mekanism.common.Mekanism; import mekanism.common.base.ISideConfiguration; @@ -17,38 +15,32 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.items.ItemHandlerHelper; +import org.apache.commons.lang3.tuple.Pair; public final class InventoryUtils { - public static final int[] EMPTY = new int[] {}; + public static final int[] EMPTY = new int[]{}; public static int[] getIntRange(int start, int end) { int[] ret = new int[1 + end - start]; - for (int i = start; i <= end; i++) { ret[i - start] = i; } - return ret; } - public static TransitResponse putStackInInventory(TileEntity tile, TransitRequest request, EnumFacing side, - boolean force) { + public static TransitResponse putStackInInventory(TileEntity tile, TransitRequest request, EnumFacing side, boolean force) { if (force && tile instanceof TileEntityLogisticalSorter) { return ((TileEntityLogisticalSorter) tile).sendHome(request.getSingleStack()); } - - for (Map.Entry>> requestEntry : request.getItemMap() - .entrySet()) { + for (Map.Entry>> requestEntry : request.getItemMap().entrySet()) { ItemStack origInsert = StackUtils.size(requestEntry.getKey().getStack(), requestEntry.getValue().getLeft()); ItemStack toInsert = origInsert.copy(); - if (!isItemHandler(tile, side.getOpposite())) { return TransitResponse.EMPTY; } - IItemHandler inventory = getItemHandler(tile, side.getOpposite()); - for (int i = 0; i < inventory.getSlots(); i++) { // Check validation if (inventory.isItemValid(i, toInsert)) { @@ -61,48 +53,39 @@ public final class InventoryUtils { } } } - if (TransporterManager.didEmit(origInsert, toInsert)) { - return new TransitResponse(TransporterManager.getToUse(origInsert, toInsert), - requestEntry.getValue().getRight()); + return new TransitResponse(TransporterManager.getToUse(origInsert, toInsert), requestEntry.getValue().getRight()); } } - return TransitResponse.EMPTY; } /** - * Like {@link ItemHandlerHelper#canItemStacksStack(ItemStack, ItemStack)} but empty stacks mean equal (either param). - * Thiakil: not sure why. + * Like {@link ItemHandlerHelper#canItemStacksStack(ItemStack, ItemStack)} but empty stacks mean equal (either param). Thiakil: not sure why. * * @param toInsert stack a - * @param inSlot stack b + * @param inSlot stack b + * * @return true if they are compatible */ public static boolean areItemsStackable(ItemStack toInsert, ItemStack inSlot) { if (toInsert.isEmpty() || inSlot.isEmpty()) { return true; } - return ItemHandlerHelper.canItemStacksStack(inSlot, toInsert); - //return inSlot.isItemEqual(toInsert) && ItemStack.areItemStackTagsEqual(inSlot, toInsert); } public static InvStack takeDefinedItem(TileEntity tile, EnumFacing side, ItemStack type, int min, int max) { InvStack ret = new InvStack(tile, side.getOpposite()); - if (!isItemHandler(tile, side.getOpposite())) { return null; } IItemHandler inventory = getItemHandler(tile, side.getOpposite()); - for (int i = inventory.getSlots() - 1; i >= 0; i--) { ItemStack stack = inventory.extractItem(i, max, true); - if (!stack.isEmpty() && StackUtils.equalsWildcardWithNBT(stack, type)) { int current = ret.getStack().getCount(); - if (current + stack.getCount() <= max) { ret.appendStack(i, stack.copy()); } else { @@ -110,72 +93,57 @@ public final class InventoryUtils { copy.setCount(max - current); ret.appendStack(i, copy); } - if (!ret.getStack().isEmpty() && ret.getStack().getCount() == max) { return ret; } } } - if (!ret.getStack().isEmpty() && ret.getStack().getCount() >= min) { return ret; } - return null; } - public static boolean canInsert(TileEntity tileEntity, EnumColor color, ItemStack itemStack, EnumFacing side, - boolean force) { + public static boolean canInsert(TileEntity tileEntity, EnumColor color, ItemStack itemStack, EnumFacing side, boolean force) { if (force && tileEntity instanceof TileEntityLogisticalSorter) { return ((TileEntityLogisticalSorter) tileEntity).canSendHome(itemStack); } - if (!force && tileEntity instanceof ISideConfiguration) { ISideConfiguration config = (ISideConfiguration) tileEntity; EnumFacing tileSide = config.getOrientation(); - EnumColor configColor = - config.getEjector().getInputColor(MekanismUtils.getBaseOrientation(side, tileSide).getOpposite()); - + EnumColor configColor = config.getEjector().getInputColor(MekanismUtils.getBaseOrientation(side, tileSide).getOpposite()); if (config.getEjector().hasStrictInput() && configColor != null && configColor != color) { return false; } } - if (!isItemHandler(tileEntity, side.getOpposite())) { return false; } IItemHandler inventory = getItemHandler(tileEntity, side.getOpposite()); - for (int i = 0; i < inventory.getSlots(); i++) { // Check validation if (inventory.isItemValid(i, itemStack)) { // Simulate insert ItemStack rejects = inventory.insertItem(i, itemStack, true); - if (TransporterManager.didEmit(itemStack, rejects)) { return true; } } } - return false; } public static boolean assertItemHandler(String desc, TileEntity tileEntity, EnumFacing side) { if (!isItemHandler(tileEntity, side)) { - Mekanism.logger - .warn("'" + desc + "' was wrapped around a non-IItemHandler inventory. This should not happen!"); - + Mekanism.logger.warn("'" + desc + "' was wrapped around a non-IItemHandler inventory. This should not happen!"); if (tileEntity == null) { Mekanism.logger.warn(" - null tile"); } else { Mekanism.logger.warn(" - details: " + tileEntity + " " + tileEntity.getPos()); } - return false; } - return true; } @@ -189,9 +157,8 @@ public final class InventoryUtils { /* TODO From CCLib -- go back to that version when we're using dependencies again */ public static boolean canStack(ItemStack stack1, ItemStack stack2) { - return stack1.isEmpty() || stack2.isEmpty() - || (stack1.getItem() == stack2.getItem() - && (!stack2.getHasSubtypes() || stack2.getItemDamage() == stack1.getItemDamage()) - && ItemStack.areItemStackTagsEqual(stack2, stack1)) && stack1.isStackable(); + return stack1.isEmpty() || stack2.isEmpty() || + stack1.getItem() == stack2.getItem() && (!stack2.getHasSubtypes() || stack2.getItemDamage() == stack1.getItemDamage()) + && ItemStack.areItemStackTagsEqual(stack2, stack1) && stack1.isStackable(); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/util/ItemDataUtils.java b/src/main/java/mekanism/common/util/ItemDataUtils.java index 34cc7b961..88c2c64b6 100644 --- a/src/main/java/mekanism/common/util/ItemDataUtils.java +++ b/src/main/java/mekanism/common/util/ItemDataUtils.java @@ -14,7 +14,6 @@ public final class ItemDataUtils { @Nonnull public static NBTTagCompound getDataMap(ItemStack stack) { initStack(stack); - return stack.getTagCompound().getCompoundTag(DATA_ID); } @@ -32,7 +31,6 @@ public final class ItemDataUtils { if (!hasDataTag(stack)) { return false; } - return getDataMap(stack).hasKey(key); } @@ -40,7 +38,6 @@ public final class ItemDataUtils { if (!hasDataTag(stack)) { return; } - getDataMap(stack).removeTag(key); } @@ -48,7 +45,6 @@ public final class ItemDataUtils { if (!hasDataTag(stack)) { return 0; } - return getDataMap(stack).getInteger(key); } @@ -56,7 +52,6 @@ public final class ItemDataUtils { if (!hasDataTag(stack)) { return false; } - return getDataMap(stack).getBoolean(key); } @@ -64,7 +59,6 @@ public final class ItemDataUtils { if (!hasDataTag(stack)) { return 0; } - return getDataMap(stack).getDouble(key); } @@ -72,7 +66,6 @@ public final class ItemDataUtils { if (!hasDataTag(stack)) { return ""; } - return getDataMap(stack).getString(key); } @@ -80,7 +73,6 @@ public final class ItemDataUtils { if (!hasDataTag(stack)) { return new NBTTagCompound(); } - return getDataMap(stack).getCompoundTag(key); } @@ -88,43 +80,36 @@ public final class ItemDataUtils { if (!hasDataTag(stack)) { return new NBTTagList(); } - return getDataMap(stack).getTagList(key, NBT.TAG_COMPOUND); } public static void setInt(ItemStack stack, String key, int i) { initStack(stack); - getDataMap(stack).setInteger(key, i); } public static void setBoolean(ItemStack stack, String key, boolean b) { initStack(stack); - getDataMap(stack).setBoolean(key, b); } public static void setDouble(ItemStack stack, String key, double d) { initStack(stack); - getDataMap(stack).setDouble(key, d); } public static void setString(ItemStack stack, String key, String s) { initStack(stack); - getDataMap(stack).setString(key, s); } public static void setCompound(ItemStack stack, String key, NBTTagCompound tag) { initStack(stack); - getDataMap(stack).setTag(key, tag); } public static void setList(ItemStack stack, String key, NBTTagList tag) { initStack(stack); - getDataMap(stack).setTag(key, tag); } @@ -136,9 +121,8 @@ public final class ItemDataUtils { if (stack.getTagCompound() == null) { stack.setTagCompound(new NBTTagCompound()); } - if (!stack.getTagCompound().hasKey(DATA_ID)) { stack.getTagCompound().setTag(DATA_ID, new NBTTagCompound()); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/util/ItemRegistryUtils.java b/src/main/java/mekanism/common/util/ItemRegistryUtils.java index 89bdbd875..a2967c2d2 100644 --- a/src/main/java/mekanism/common/util/ItemRegistryUtils.java +++ b/src/main/java/mekanism/common/util/ItemRegistryUtils.java @@ -39,7 +39,6 @@ public final class ItemRegistryUtils { String modId = itemResourceLocation.getNamespace(); String lowercaseModId = modId.toLowerCase(Locale.ENGLISH); String modName = modIDMap.computeIfAbsent(lowercaseModId, k -> WordUtils.capitalize(modId)); - return modName; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/util/LangUtils.java b/src/main/java/mekanism/common/util/LangUtils.java index 5f7700ff2..7d9f7d82f 100644 --- a/src/main/java/mekanism/common/util/LangUtils.java +++ b/src/main/java/mekanism/common/util/LangUtils.java @@ -26,14 +26,14 @@ public final class LangUtils { } public static String localizeFluidStack(FluidStack fluidStack) { - return (fluidStack == null || fluidStack.getFluid() == null) ? null - : fluidStack.getFluid().getLocalizedName(fluidStack); + return (fluidStack == null || fluidStack.getFluid() == null) ? null : fluidStack.getFluid().getLocalizedName(fluidStack); } /** * Localizes the defined string. * * @param s - string to localized + * * @return localized string */ public static String localize(String s) { @@ -42,7 +42,6 @@ public final class LangUtils { public static String localizeWithFormat(String key, Object... format) { String s = localize(key); - try { return String.format(s, format); } catch (IllegalFormatException e) { @@ -66,4 +65,4 @@ public final class LangUtils { translation.getStyle().setColor(isOn ? TextFormatting.DARK_GREEN : TextFormatting.DARK_RED); return translation; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/util/MekanismUtils.java b/src/main/java/mekanism/common/util/MekanismUtils.java index b444ca603..e1530b1ef 100644 --- a/src/main/java/mekanism/common/util/MekanismUtils.java +++ b/src/main/java/mekanism/common/util/MekanismUtils.java @@ -87,8 +87,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; */ public final class MekanismUtils { - public static final EnumFacing[] SIDE_DIRS = new EnumFacing[]{EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.WEST, - EnumFacing.EAST}; + public static final EnumFacing[] SIDE_DIRS = new EnumFacing[]{EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.WEST, EnumFacing.EAST}; public static final Map> classesFound = new HashMap<>(); @@ -101,8 +100,7 @@ public final class MekanismUtils { static { for (int blockFacing = 0; blockFacing < EnumFacing.VALUES.length; blockFacing++) { for (int side = 0; side < EnumFacing.VALUES.length; side++) { - baseOrientations[blockFacing][side] = getBaseOrientation(EnumFacing.VALUES[side], - EnumFacing.VALUES[blockFacing]); + baseOrientations[blockFacing][side] = getBaseOrientation(EnumFacing.VALUES[side], EnumFacing.VALUES[blockFacing]); } } } @@ -120,7 +118,6 @@ public final class MekanismUtils { ItemStack stack = new ItemStack(MekanismBlocks.Transmitter, amount, type.ordinal()); ItemBlockTransmitter itemTransmitter = (ItemBlockTransmitter) stack.getItem(); itemTransmitter.setBaseTier(stack, tier); - return stack; } @@ -129,11 +126,11 @@ public final class MekanismUtils { * * @param tier - tier to add to the Factory * @param type - recipe type to add to the Factory + * * @return factory with defined tier and recipe type */ public static ItemStack getFactory(FactoryTier tier, RecipeType type) { - ItemStack itemstack = new ItemStack(MekanismBlocks.MachineBlock, 1, - MachineType.BASIC_FACTORY.ordinal() + tier.ordinal()); + ItemStack itemstack = new ItemStack(MekanismBlocks.MachineBlock, 1, MachineType.BASIC_FACTORY.ordinal() + tier.ordinal()); ((IFactory) itemstack.getItem()).setRecipeType(type.ordinal(), itemstack); return itemstack; } @@ -142,18 +139,17 @@ public final class MekanismUtils { * Checks if a machine is in it's active state. * * @param world World of the machine to check - * @param pos The position of the machine + * @param pos The position of the machine + * * @return if machine is active */ public static boolean isActive(IBlockAccess world, BlockPos pos) { TileEntity tileEntity = world.getTileEntity(pos); - if (tileEntity != null) { if (tileEntity instanceof IActiveState) { return ((IActiveState) tileEntity).getActive(); } } - return false; } @@ -161,6 +157,7 @@ public final class MekanismUtils { * Gets the left side of a certain orientation. * * @param orientation Current orientation of the machine + * * @return left side */ public static EnumFacing getLeft(EnumFacing orientation) { @@ -171,6 +168,7 @@ public final class MekanismUtils { * Gets the right side of a certain orientation. * * @param orientation Current orientation of the machine + * * @return right side */ public static EnumFacing getRight(EnumFacing orientation) { @@ -181,6 +179,7 @@ public final class MekanismUtils { * Gets the opposite side of a certain orientation. * * @param orientation Current orientation of the machine + * * @return opposite side */ public static EnumFacing getBack(EnumFacing orientation) { @@ -191,6 +190,7 @@ public final class MekanismUtils { * Returns the sides in the modified order relative to the machine-based orientation. * * @param blockFacing - what orientation the block is facing + * * @return EnumFacing.VALUES, translated to machine orientation */ public static EnumFacing[] getBaseOrientations(EnumFacing blockFacing) { @@ -200,8 +200,9 @@ public final class MekanismUtils { /** * Returns an integer facing that converts a world-based orientation to a machine-based orientation. * - * @param side - world based + * @param side - world based * @param blockFacing - what orientation the block is facing + * * @return machine orientation */ public static EnumFacing getBaseOrientation(EnumFacing side, EnumFacing blockFacing) { @@ -235,36 +236,31 @@ public final class MekanismUtils { if (side.getAxis() == Axis.Z) { return side.getOpposite(); } - return side; } else if (blockFacing == EnumFacing.NORTH) { if (side.getAxis() == Axis.Z) { return side; } - return side.getOpposite(); } else if (blockFacing == EnumFacing.WEST) { if (side.getAxis() == Axis.Z) { return getRight(side); } - return getLeft(side); } else if (blockFacing == EnumFacing.EAST) { if (side.getAxis() == Axis.Z) { return getLeft(side); } - return getRight(side); } - return side; } /** * Increments the output type of a machine's side. * - * @param config - configurable machine - * @param type - the TransmissionType to modify + * @param config - configurable machine + * @param type - the TransmissionType to modify * @param direction - side to increment output of */ public static void incrementOutput(ISideConfiguration config, TransmissionType type, EnumFacing direction) { @@ -272,13 +268,11 @@ public final class MekanismUtils { SideConfig sideConfig = config.getConfig().getConfig(type); int max = outputs.size() - 1; int current = outputs.indexOf(outputs.get(sideConfig.get(direction))); - if (current < max) { sideConfig.set(direction, (byte) (current + 1)); } else if (current == max) { sideConfig.set(direction, (byte) 0); } - assert config instanceof TileEntity; TileEntity tile = (TileEntity) config; tile.markDirty(); @@ -287,8 +281,8 @@ public final class MekanismUtils { /** * Decrements the output type of a machine's side. * - * @param config - configurable machine - * @param type - the TransmissionType to modify + * @param config - configurable machine + * @param type - the TransmissionType to modify * @param direction - side to increment output of */ public static void decrementOutput(ISideConfiguration config, TransmissionType type, EnumFacing direction) { @@ -296,13 +290,11 @@ public final class MekanismUtils { SideConfig sideConfig = config.getConfig().getConfig(type); int max = outputs.size() - 1; int current = outputs.indexOf(outputs.get(sideConfig.get(direction))); - if (current > 0) { sideConfig.set(direction, (byte) (current - 1)); } else if (current == 0) { sideConfig.set(direction, (byte) max); } - assert config instanceof TileEntity; TileEntity tile = (TileEntity) config; tile.markDirty(); @@ -316,79 +308,77 @@ public final class MekanismUtils { * Gets the operating ticks required for a machine via it's upgrades. * * @param mgmt - tile containing upgrades - * @param def - the original, default ticks required + * @param def - the original, default ticks required + * * @return required operating ticks */ public static int getTicks(IUpgradeTile mgmt, int def) { - return (int) (def * Math.pow( - MekanismConfig.current().general.maxUpgradeMultiplier.val(), -fractionUpgrades(mgmt, Upgrade.SPEED))); + return (int) (def * Math.pow(MekanismConfig.current().general.maxUpgradeMultiplier.val(), -fractionUpgrades(mgmt, Upgrade.SPEED))); } /** * Gets the energy required per tick for a machine via it's upgrades. * * @param mgmt - tile containing upgrades - * @param def - the original, default energy required + * @param def - the original, default energy required + * * @return required energy per tick */ public static double getEnergyPerTick(IUpgradeTile mgmt, double def) { - return def * Math.pow(MekanismConfig.current().general.maxUpgradeMultiplier.val(), - 2 * fractionUpgrades(mgmt, Upgrade.SPEED) - fractionUpgrades(mgmt, Upgrade.ENERGY)); + return def * Math.pow(MekanismConfig.current().general.maxUpgradeMultiplier.val(), 2 * fractionUpgrades(mgmt, Upgrade.SPEED) - fractionUpgrades(mgmt, Upgrade.ENERGY)); } /** * Gets the energy required per tick for a machine via it's upgrades, not taking into account speed upgrades. * * @param mgmt - tile containing upgrades - * @param def - the original, default energy required + * @param def - the original, default energy required + * * @return required energy per tick */ public static double getBaseEnergyPerTick(IUpgradeTile mgmt, double def) { - return def * Math.pow(MekanismConfig.current().general.maxUpgradeMultiplier.val(), - -fractionUpgrades(mgmt, Upgrade.ENERGY)); + return def * Math.pow(MekanismConfig.current().general.maxUpgradeMultiplier.val(), -fractionUpgrades(mgmt, Upgrade.ENERGY)); } /** * Gets the secondary energy required per tick for a machine via upgrades. * * @param mgmt - tile containing upgrades - * @param def - the original, default secondary energy required + * @param def - the original, default secondary energy required + * * @return max secondary energy per tick */ public static double getSecondaryEnergyPerTickMean(IUpgradeTile mgmt, int def) { if (mgmt.getComponent().supports(Upgrade.GAS)) { - return def * Math.pow(MekanismConfig.current().general.maxUpgradeMultiplier.val(), - 2 * fractionUpgrades(mgmt, Upgrade.SPEED) - fractionUpgrades(mgmt, Upgrade.GAS)); + return def * Math.pow(MekanismConfig.current().general.maxUpgradeMultiplier.val(), 2 * fractionUpgrades(mgmt, Upgrade.SPEED) - fractionUpgrades(mgmt, Upgrade.GAS)); } - - return def * Math - .pow(MekanismConfig.current().general.maxUpgradeMultiplier.val(), fractionUpgrades(mgmt, Upgrade.SPEED)); + return def * Math.pow(MekanismConfig.current().general.maxUpgradeMultiplier.val(), fractionUpgrades(mgmt, Upgrade.SPEED)); } /** * Gets the maximum energy for a machine via it's upgrades. * * @param mgmt - tile containing upgrades - best known for "Kids", 2008 - * @param def - original, default max energy + * @param def - original, default max energy + * * @return max energy */ public static double getMaxEnergy(IUpgradeTile mgmt, double def) { - return def * Math - .pow(MekanismConfig.current().general.maxUpgradeMultiplier.val(), fractionUpgrades(mgmt, Upgrade.ENERGY)); + return def * Math.pow(MekanismConfig.current().general.maxUpgradeMultiplier.val(), fractionUpgrades(mgmt, Upgrade.ENERGY)); } /** * Gets the maximum energy for a machine's item form via it's upgrades. * * @param itemStack - stack holding energy upgrades - * @param def - original, default max energy + * @param def - original, default max energy + * * @return max energy */ public static double getMaxEnergy(ItemStack itemStack, double def) { Map upgrades = Upgrade.buildMap(ItemDataUtils.getDataMap(itemStack)); float numUpgrades = upgrades.get(Upgrade.ENERGY) == null ? 0 : (float) upgrades.get(Upgrade.ENERGY); - return def * Math.pow(MekanismConfig.current().general.maxUpgradeMultiplier.val(), - numUpgrades / (float) Upgrade.ENERGY.getMax()); + return def * Math.pow(MekanismConfig.current().general.maxUpgradeMultiplier.val(), numUpgrades / (float) Upgrade.ENERGY.getMax()); } /** @@ -396,16 +386,15 @@ public final class MekanismUtils { * * @param world - the world to perform the check in * @param coord - the coordinate of the block performing the check + * * @return if the block is indirectly getting powered by LOADED chunks */ public static boolean isGettingPowered(World world, Coord4D coord) { for (EnumFacing side : EnumFacing.VALUES) { Coord4D sideCoord = coord.offset(side); - if (sideCoord.exists(world) && sideCoord.offset(side).exists(world)) { IBlockState blockState = sideCoord.getBlockState(world); boolean weakPower = blockState.getBlock().shouldCheckWeakPower(blockState, world, coord.getPos(), side); - if (weakPower && isDirectlyGettingPowered(world, sideCoord)) { return true; } else if (!weakPower && blockState.getWeakPower(world, sideCoord.getPos(), side) > 0) { @@ -413,7 +402,6 @@ public final class MekanismUtils { } } } - return false; } @@ -422,19 +410,18 @@ public final class MekanismUtils { * * @param world - the world to perform the check in * @param coord - the Coord4D of the block to check + * * @return if the block is directly getting powered */ public static boolean isDirectlyGettingPowered(World world, Coord4D coord) { for (EnumFacing side : EnumFacing.VALUES) { Coord4D sideCoord = coord.offset(side); - if (sideCoord.exists(world)) { if (world.getRedstonePower(coord.getPos(), side) > 0) { return true; } } } - return false; } @@ -447,16 +434,12 @@ public final class MekanismUtils { public static void notifyLoadedNeighborsOfTileChange(World world, Coord4D coord) { for (EnumFacing dir : EnumFacing.VALUES) { Coord4D offset = coord.offset(dir); - if (offset.exists(world)) { notifyNeighborofChange(world, offset, coord.getPos()); - if (offset.getBlockState(world).isNormalCube()) { offset = offset.offset(dir); - if (offset.exists(world)) { Block block1 = offset.getBlock(world); - if (block1.getWeakChanges(world, offset.getPos())) { block1.onNeighborChange(world, offset.getPos(), coord.getPos()); } @@ -469,8 +452,8 @@ public final class MekanismUtils { /** * Calls BOTH neighbour changed functions because nobody can decide on which one to implement. * - * @param world world the change exists in - * @param coord neighbor to notify + * @param world world the change exists in + * @param coord neighbor to notify * @param fromPos pos of our block that updated */ public static void notifyNeighborofChange(World world, Coord4D coord, BlockPos fromPos) { @@ -482,9 +465,9 @@ public final class MekanismUtils { /** * Calls BOTH neighbour changed functions because nobody can decide on which one to implement. * - * @param world world the change exists in + * @param world world the change exists in * @param neighborSide The side the neighbor to notify is on - * @param fromPos pos of our block that updated + * @param fromPos pos of our block that updated */ public static void notifyNeighborOfChange(World world, EnumFacing neighborSide, BlockPos fromPos) { BlockPos neighbor = fromPos.offset(neighborSide); @@ -496,13 +479,12 @@ public final class MekanismUtils { /** * Places a fake bounding block at the defined location. * - * @param world - world to place block in + * @param world - world to place block in * @param boundingLocation - coordinates of bounding block - * @param orig - original block + * @param orig - original block */ public static void makeBoundingBlock(World world, BlockPos boundingLocation, Coord4D orig) { world.setBlockState(boundingLocation, MekanismBlocks.BoundingBlock.getStateFromMeta(0)); - if (!world.isRemote) { ((TileEntityBoundingBlock) world.getTileEntity(boundingLocation)).setMainLocation(orig.getPos()); } @@ -511,13 +493,12 @@ public final class MekanismUtils { /** * Places a fake advanced bounding block at the defined location. * - * @param world - world to place block in + * @param world - world to place block in * @param boundingLocation - coordinates of bounding block - * @param orig - original block + * @param orig - original block */ public static void makeAdvancedBoundingBlock(World world, BlockPos boundingLocation, Coord4D orig) { world.setBlockState(boundingLocation, MekanismBlocks.BoundingBlock.getStateFromMeta(1)); - if (!world.isRemote) { ((TileEntityAdvancedBoundingBlock) world.getTileEntity(boundingLocation)).setMainLocation(orig.getPos()); } @@ -527,7 +508,7 @@ public final class MekanismUtils { * Updates a block's light value and marks it for a render update. * * @param world - world the block is in - * @param pos Position of the block + * @param pos Position of the block */ public static void updateBlock(World world, BlockPos pos) { //Schedule a render update regardless of it is an IActiveState with IActiveState#renderUpdate() as true @@ -535,10 +516,8 @@ public final class MekanismUtils { // anyways here in case IActiveState#renderUpdate() is false and we just had the block rotate. // For example the laser, or charge pad. world.markBlockRangeForRenderUpdate(pos, pos); - TileEntity tileEntity = world.getTileEntity(pos); - if (!(tileEntity instanceof IActiveState) || ((IActiveState) tileEntity).lightUpdate() && MekanismConfig - .current().client.machineEffects.val()) { + if (!(tileEntity instanceof IActiveState) || ((IActiveState) tileEntity).lightUpdate() && MekanismConfig.current().client.machineEffects.val()) { updateAllLightTypes(world, pos); } } @@ -547,7 +526,7 @@ public final class MekanismUtils { * Updates all light types at the given coordinates. * * @param world - the world to perform the lighting update in - * @param pos - coordinates of the block to update + * @param pos - coordinates of the block to update */ public static void updateAllLightTypes(World world, BlockPos pos) { world.checkLightFor(EnumSkyBlock.BLOCK, pos); @@ -558,7 +537,8 @@ public final class MekanismUtils { * Whether or not a certain block is considered a fluid. * * @param world - world the block is in - * @param pos - coordinates + * @param pos - coordinates + * * @return if the block is a fluid */ public static boolean isFluid(World world, Coord4D pos) { @@ -569,29 +549,26 @@ public final class MekanismUtils { * Gets a fluid from a certain location. * * @param world - world the block is in - * @param pos - location of the block + * @param pos - location of the block + * * @return the fluid at the certain location, null if it doesn't exist */ public static FluidStack getFluid(World world, Coord4D pos, boolean filter) { IBlockState state = pos.getBlockState(world); Block block = state.getBlock(); - if ((block == Blocks.WATER || block == Blocks.FLOWING_WATER) && state.getValue(BlockLiquid.LEVEL) == 0) { if (!filter) { return new FluidStack(FluidRegistry.WATER, Fluid.BUCKET_VOLUME); - } else { - return new FluidStack(MekanismFluids.HeavyWater, 10); } + return new FluidStack(MekanismFluids.HeavyWater, 10); } else if ((block == Blocks.LAVA || block == Blocks.FLOWING_LAVA) && state.getValue(BlockLiquid.LEVEL) == 0) { return new FluidStack(FluidRegistry.LAVA, Fluid.BUCKET_VOLUME); } else if (block instanceof IFluidBlock) { IFluidBlock fluid = (IFluidBlock) block; - if (state.getProperties().containsKey(BlockFluidBase.LEVEL) && state.getValue(BlockFluidBase.LEVEL) == 0) { return fluid.drain(world, pos.getPos(), false); } } - return null; } @@ -599,17 +576,16 @@ public final class MekanismUtils { * Whether or not a block is a dead fluid. * * @param world - world the block is in - * @param pos - coordinates + * @param pos - coordinates + * * @return if the block is a dead fluid */ public static boolean isDeadFluid(World world, Coord4D pos) { IBlockState state = pos.getBlockState(world); Block block = state.getBlock(); - if (block.getMetaFromState(state) == 0) { return false; } - return block instanceof BlockLiquid || block instanceof IFluidBlock; } @@ -618,6 +594,7 @@ public final class MekanismUtils { * Gets the flowing block type from a Forge-based fluid. Incorporates the MC system of fliuds as well. * * @param fluid - the fluid type + * * @return the block corresponding to the given fluid */ public static Block getFlowingBlock(Fluid fluid) { @@ -627,36 +604,28 @@ public final class MekanismUtils { return Blocks.FLOWING_WATER; } else if (fluid == FluidRegistry.LAVA) { return Blocks.FLOWING_LAVA; - } else { - return fluid.getBlock(); } + return fluid.getBlock(); } /** - * 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! + * 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 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 + * @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 openPersonalChestGui(EntityPlayerMP player, TileEntityPersonalChest tileEntity, - InventoryPersonalChest inventory, boolean isBlock) { + public static void openPersonalChestGui(EntityPlayerMP player, TileEntityPersonalChest tileEntity, InventoryPersonalChest inventory, boolean isBlock) { player.getNextWindowId(); player.closeContainer(); int id = player.currentWindowId; if (isBlock) { - Mekanism.packetHandler.sendTo( - new PersonalChestMessage(PersonalChestPacketType.CLIENT_OPEN, true, 0, id, Coord4D.get(tileEntity), - null), player); + Mekanism.packetHandler.sendTo(new PersonalChestMessage(PersonalChestPacketType.CLIENT_OPEN, true, 0, id, Coord4D.get(tileEntity), null), player); } else { - Mekanism.packetHandler.sendTo( - new PersonalChestMessage(PersonalChestPacketType.CLIENT_OPEN, false, 0, id, null, - inventory.currentHand), player); + Mekanism.packetHandler.sendTo(new PersonalChestMessage(PersonalChestPacketType.CLIENT_OPEN, false, 0, id, null, inventory.currentHand), player); } - player.openContainer = new ContainerPersonalChest(player.inventory, tileEntity, inventory, isBlock); player.openContainer.windowId = id; player.openContainer.addListener(player); @@ -667,6 +636,7 @@ public final class MekanismUtils { * * @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) { @@ -674,8 +644,7 @@ public final class MekanismUtils { } /** - * Marks the chunk this TileEntity is in as modified. Call this method to be sure NBT is written by the defined tile - * entity. + * 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 */ @@ -683,24 +652,21 @@ public final class MekanismUtils { if (tileEntity == null || tileEntity.isInvalid() || tileEntity.getWorld() == null) { return; } - tileEntity.getWorld().markChunkDirty(tileEntity.getPos(), tileEntity); } /** - * Whether or not a certain TileEntity can function with redstone logic. Illogical to use unless the defined - * TileEntity implements IRedstoneControl. + * 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; } - IRedstoneControl control = (IRedstoneControl) tileEntity; - switch (control.getControlType()) { case DISABLED: return true; @@ -711,24 +677,22 @@ public final class MekanismUtils { case PULSE: return control.isPowered() && !control.wasPowered(); } - return false; } /** * Ray-traces what block a player is looking at. * - * @param world - world the player is in + * @param world - world the player is in * @param player - player to raytrace + * * @return raytraced value */ public static RayTraceResult rayTrace(World world, EntityPlayer player) { double reach = Mekanism.proxy.getReach(player); - Vec3d headVec = getHeadVec(player); Vec3d lookVec = player.getLook(1); Vec3d endVec = headVec.add(lookVec.x * reach, lookVec.y * reach, lookVec.z * reach); - return world.rayTraceBlocks(headVec, endVec, true); } @@ -736,21 +700,19 @@ public final class MekanismUtils { * Gets the head vector of a player for a ray trace. * * @param player - player to check + * * @return head location */ private static Vec3d getHeadVec(EntityPlayer player) { double posX = player.posX; double posY = player.posY; double posZ = player.posZ; - if (!player.world.isRemote) { posY += player.getEyeHeight(); - if (player instanceof EntityPlayerMP && player.isSneaking()) { posY -= 0.08; } } - return new Vec3d(posX, posY, posZ); } @@ -758,27 +720,23 @@ public final class MekanismUtils { * 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) { if (energy == Double.MAX_VALUE) { return LangUtils.localize("gui.infinite"); } - switch (MekanismConfig.current().general.energyUnit.val()) { case J: return UnitDisplayUtils.getDisplayShort(energy, ElectricUnit.JOULES); case RF: - return UnitDisplayUtils.getDisplayShort(energy * MekanismConfig.current().general.TO_RF.val(), - ElectricUnit.REDSTONE_FLUX); + return UnitDisplayUtils.getDisplayShort(energy * MekanismConfig.current().general.TO_RF.val(), ElectricUnit.REDSTONE_FLUX); case EU: - return UnitDisplayUtils.getDisplayShort(energy * MekanismConfig.current().general.TO_IC2.val(), - ElectricUnit.ELECTRICAL_UNITS); + return UnitDisplayUtils.getDisplayShort(energy * MekanismConfig.current().general.TO_IC2.val(), ElectricUnit.ELECTRICAL_UNITS); case T: - return UnitDisplayUtils - .getDisplayShort(energy * MekanismConfig.current().general.TO_TESLA.val(), ElectricUnit.TESLA); + return UnitDisplayUtils.getDisplayShort(energy * MekanismConfig.current().general.TO_TESLA.val(), ElectricUnit.TESLA); } - return "error"; } @@ -786,10 +744,8 @@ public final class MekanismUtils { if (energy == Double.MAX_VALUE) { return LangUtils.localize("gui.infinite"); } - String energyString = getEnergyDisplay(energy); String maxString = getEnergyDisplay(max); - return energyString + "/" + maxString; } @@ -797,6 +753,7 @@ public final class MekanismUtils { * Convert from the unit defined in the configuration to joules. * * @param energy - energy to convert + * * @return energy converted to joules */ public static double convertToJoules(double energy) { @@ -816,6 +773,7 @@ public final class MekanismUtils { * Convert from joules to the unit defined in the configuration. * * @param energy - energy to convert + * * @return energy converted to configured unit */ public static double convertToDisplay(double energy) { @@ -835,11 +793,11 @@ public final class MekanismUtils { * Gets a rounded energy display of a defined amount of energy. * * @param T - temperature to display + * * @return rounded energy display */ public static String getTemperatureDisplay(double T, TemperatureUnit unit) { double TK = unit.convertToK(T, true); - switch (MekanismConfig.current().general.tempUnit.val()) { case K: return UnitDisplayUtils.getDisplayShort(TK, TemperatureUnit.KELVIN); @@ -852,19 +810,16 @@ public final class MekanismUtils { case STP: return UnitDisplayUtils.getDisplayShort(TK, TemperatureUnit.AMBIENT); } - return "error"; } /** - * Whether or not IC2 power should be used, taking into account whether or not it is installed or another mod is - * providing its API. + * Whether or not IC2 power should be used, taking into account whether or not it is installed or another mod is providing its API. * * @return if IC2 power should be used */ public static boolean useIC2() { - return Mekanism.hooks.IC2Loaded && EnergyNet.instance != null && !MekanismConfig.current().general.blacklistIC2 - .val(); + return Mekanism.hooks.IC2Loaded && EnergyNet.instance != null && !MekanismConfig.current().general.blacklistIC2.val(); } /** @@ -898,6 +853,7 @@ public final class MekanismUtils { * 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) { @@ -907,30 +863,27 @@ public final class MekanismUtils { @SideOnly(Side.CLIENT) public static List splitTooltip(String s, ItemStack stack) { s = s.trim(); - FontRenderer renderer = (FontRenderer) Mekanism.proxy.getFontRenderer(); if (!stack.isEmpty() && stack.getItem().getFontRenderer(stack) != null) { renderer = stack.getItem().getFontRenderer(stack); } - if (renderer != null) { return renderer.listFormattedStringToWidth(s, 200); - } else { - return Collections.emptyList(); } + return Collections.emptyList(); } /** * 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(GasTankTier tier, Gas gas) { ItemStack tank = getEmptyGasTank(tier); ItemBlockGasTank item = (ItemBlockGasTank) tank.getItem(); item.setGas(tank, new GasStack(gas, item.MAX_GAS)); - return tank; } @@ -941,20 +894,19 @@ public final class MekanismUtils { return false; } }; - return new InventoryCrafting(tempContainer, 3, 3); } /** * Finds the output of a defined InventoryCrafting grid. * - * @param inv - InventoryCrafting to check + * @param inv - InventoryCrafting to check * @param world - world reference + * * @return output ItemStack */ public static ItemStack findMatchingRecipe(InventoryCrafting inv, World world) { NonNullList dmgItems = NonNullList.withSize(2, ItemStack.EMPTY); - for (int i = 0; i < inv.getSizeInventory(); i++) { if (!inv.getStackInSlot(i).isEmpty()) { if (dmgItems.get(0).isEmpty()) { @@ -970,18 +922,15 @@ public final class MekanismUtils { return ItemStack.EMPTY; } - if ((!dmgItems.get(1).isEmpty()) && (dmgItems.get(0).getItem() == dmgItems.get(1).getItem()) && ( - dmgItems.get(0).getCount() == 1) && (dmgItems.get(1).getCount() == 1) && dmgItems.get(0).getItem() - .isRepairable()) { + if (!dmgItems.get(1).isEmpty() && (dmgItems.get(0).getItem() == dmgItems.get(1).getItem()) && + (dmgItems.get(0).getCount() == 1) && (dmgItems.get(1).getCount() == 1) && dmgItems.get(0).getItem().isRepairable()) { Item theItem = dmgItems.get(0).getItem(); int dmgDiff0 = theItem.getMaxDamage() - dmgItems.get(0).getItemDamage(); int dmgDiff1 = theItem.getMaxDamage() - dmgItems.get(1).getItemDamage(); int value = dmgDiff0 + dmgDiff1 + theItem.getMaxDamage() * 5 / 100; int solve = Math.max(0, theItem.getMaxDamage() - value); - return new ItemStack(dmgItems.get(0).getItem(), 1, solve); } - IRecipe potentialResult = CraftingManager.findMatchingRecipe(inv, world); return potentialResult != null ? potentialResult.getRecipeOutput() : ItemStack.EMPTY; } @@ -990,6 +939,7 @@ public final class MekanismUtils { * Whether or not the provided chunk is being vibrated by a Seismic Vibrator. * * @param chunk - chunk to check + * * @return if the chunk is being vibrated */ public static boolean isChunkVibrated(Chunk3D chunk) { @@ -998,7 +948,6 @@ public final class MekanismUtils { return true; } } - return false; } @@ -1006,30 +955,28 @@ public final class MekanismUtils { * Whether or not a given EntityPlayer is considered an Op. * * @param p - player to check + * * @return if the player has operator privileges */ public static boolean isOp(EntityPlayer p) { if (!(p instanceof EntityPlayerMP)) { return false; } - EntityPlayerMP player = (EntityPlayerMP) p; - - return MekanismConfig.current().general.opsBypassRestrictions.val() && player.server.getPlayerList() - .canSendCommands(player.getGameProfile()); + return MekanismConfig.current().general.opsBypassRestrictions.val() && player.server.getPlayerList().canSendCommands(player.getGameProfile()); } /** * Gets the item ID from a given ItemStack * * @param itemStack - ItemStack to check + * * @return item ID of the ItemStack */ public static int getID(ItemStack itemStack) { if (itemStack.isEmpty()) { return -1; } - return Item.getIdFromItem(itemStack.getItem()); } @@ -1037,23 +984,18 @@ public final class MekanismUtils { if (classesFound.containsKey(className)) { return classesFound.get(className) != null; } - Class found; - try { found = Class.forName(className); } catch (ClassNotFoundException e) { found = null; } - classesFound.put(className, found); - return found != null; } public static boolean existsAndInstance(Object obj, String className) { Class theClass; - if (classesFound.containsKey(className)) { theClass = classesFound.get(className); } else { @@ -1065,7 +1007,6 @@ public final class MekanismUtils { return false; } } - return theClass != null && theClass.isInstance(obj); } @@ -1081,65 +1022,51 @@ public final class MekanismUtils { * Whether or not the player has a usable wrench for a block at the coordinates given. * * @param player - the player using the wrench - * @param pos - the coordinate of the block being wrenched + * @param pos - the coordinate of the block being wrenched + * * @return if the player can use the wrench + * * @deprecated use {@link mekanism.common.integration.wrenches.Wrenches#getHandler(ItemStack)} */ @Deprecated public static boolean hasUsableWrench(EntityPlayer player, BlockPos pos) { ItemStack tool = player.inventory.getCurrentItem(); - if (tool.isEmpty()) { return false; } - if (tool.getItem() instanceof IMekWrench && ((IMekWrench) tool.getItem()).canUseWrench(tool, player, pos)) { return true; } - try { - if (isBCWrench(tool.getItem())) //TODO too much hassle to check BC wrench-ability - { + if (isBCWrench(tool.getItem())) { //TODO too much hassle to check BC wrench-ability return true; } - - if (isCoFHHammer( - tool.getItem())) // TODO Implement CoFH Hammer && ((IToolHammer)tool.getItem()).isUsable(tool, player, pos)) - { + if (isCoFHHammer(tool.getItem())) { // TODO Implement CoFH Hammer && ((IToolHammer)tool.getItem()).isUsable(tool, player, pos)) return true; } } catch (Throwable ignored) { } - return false; } @Nonnull public static String getLastKnownUsername(UUID uuid) { String ret = UsernameCache.getLastKnownUsername(uuid); - - if (ret == null && !warnedFails.contains(uuid) && FMLCommonHandler.instance().getEffectiveSide() - == Side.SERVER) { // see if MC/Yggdrasil knows about it?! - GameProfile gp = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerProfileCache() - .getProfileByUUID(uuid); - + if (ret == null && !warnedFails.contains(uuid) && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { // see if MC/Yggdrasil knows about it?! + GameProfile gp = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerProfileCache().getProfileByUUID(uuid); if (gp != null) { ret = gp.getName(); } } - if (ret == null && !warnedFails.contains(uuid)) { - Mekanism.logger - .warn("Failed to retrieve username for UUID {}, you might want to add it to the JSON cache", uuid); + Mekanism.logger.warn("Failed to retrieve username for UUID {}, you might want to add it to the JSON cache", uuid); warnedFails.add(uuid); } - return ret != null ? ret : ""; } public static TileEntity getTileEntitySafe(IBlockAccess worldIn, BlockPos pos) { - return worldIn instanceof ChunkCache ? ((ChunkCache) worldIn) - .getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos); + return worldIn instanceof ChunkCache ? ((ChunkCache) worldIn).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos); } /** @@ -1151,26 +1078,25 @@ public final class MekanismUtils { } /** - * Clamp a double to int without using Math.min due to double representation issues. Primary use: power systems that - * use int, where Mek uses doubles internally + * Clamp a double to int without using Math.min due to double representation issues. Primary use: power systems that use int, where Mek uses doubles internally * * - * double d = 1e300; // way bigger than longs, so the long should always be what's returned by Math.min - * System.out.println((long)Math.min(123456781234567812L, d)); // result is 123456781234567808 - 4 less than what - * you'd expect System.out.println((long)Math.min(123456789012345678L, d)); // result is 123456789012345680 - 2 more + * double d = 1e300; // way bigger than longs, so the long should always be what's returned by Math.min System.out.println((long)Math.min(123456781234567812L, d)); // + * result is 123456781234567808 - 4 less than what you'd expect System.out.println((long)Math.min(123456789012345678L, d)); // result is 123456789012345680 - 2 more * than what you'd expect * * * @param d double to clamp + * * @return an int clamped to Integer.MAX_VALUE + * * @see Original PR */ public static int clampToInt(double d) { if (d < Integer.MAX_VALUE) { return (int) d; - } else { - return Integer.MAX_VALUE; } + return Integer.MAX_VALUE; } public enum ResourceType { @@ -1193,4 +1119,4 @@ public final class MekanismUtils { return prefix + "/"; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/util/MinerUtils.java b/src/main/java/mekanism/common/util/MinerUtils.java index ff77ccdeb..675d1f44e 100644 --- a/src/main/java/mekanism/common/util/MinerUtils.java +++ b/src/main/java/mekanism/common/util/MinerUtils.java @@ -34,8 +34,7 @@ public final class MinerUtils { static { try { - getSilkTouchDrop = ReflectionHelper - .findMethod(Block.class, "getSilkTouchDrop", "func_180643_i", IBlockState.class); + getSilkTouchDrop = ReflectionHelper.findMethod(Block.class, "getSilkTouchDrop", "func_180643_i", IBlockState.class); } catch (UnableToFindMethodException e) { Mekanism.logger.error("Unable to find method Block.getSilkTouchDrop"); } @@ -45,31 +44,25 @@ public final class MinerUtils { IBlockState state = coord.getBlockState(world); Block block = state.getBlock(); EntityPlayer fakePlayer = Mekanism.proxy.getDummyPlayer((WorldServer) world, minerPosition).get(); - if (block.isAir(state, world, coord.getPos())) { return Collections.emptyList(); } - if (block instanceof BlockShulkerBox){ + if (block instanceof BlockShulkerBox) { //special case Shulker Boxes because bad Mojang code / no forge patch ItemStack shulkerBoxItem = new ItemStack(Item.getItemFromBlock(block)); - TileEntity tileentity = world.getTileEntity(coord.getPos()); //copied from BlockShulkerBox.breakBlock - if (tileentity instanceof TileEntityShulkerBox) - { - TileEntityShulkerBox tileentityshulkerbox = (TileEntityShulkerBox)tileentity; + if (tileentity instanceof TileEntityShulkerBox) { + TileEntityShulkerBox tileentityshulkerbox = (TileEntityShulkerBox) tileentity; - if (!tileentityshulkerbox.isCleared() && tileentityshulkerbox.shouldDrop()) - { + if (!tileentityshulkerbox.isCleared() && tileentityshulkerbox.shouldDrop()) { NBTTagCompound itemTag = new NBTTagCompound(); NBTTagCompound nbtBlockEntity = new NBTTagCompound(); - itemTag.setTag("BlockEntityTag", ((TileEntityShulkerBox)tileentity).saveToNbt(nbtBlockEntity)); + itemTag.setTag("BlockEntityTag", ((TileEntityShulkerBox) tileentity).saveToNbt(nbtBlockEntity)); shulkerBoxItem.setTagCompound(itemTag); - - if (tileentityshulkerbox.hasCustomName()) - { + if (tileentityshulkerbox.hasCustomName()) { shulkerBoxItem.setStackDisplayName(tileentityshulkerbox.getName()); } } @@ -101,7 +94,7 @@ public final class MinerUtils { } } else { @SuppressWarnings("deprecation")//needed for backwards compatibility - List blockDrops = block.getDrops(world, coord.getPos(), state, 0); + List blockDrops = block.getDrops(world, coord.getPos(), state, 0); if (blockDrops.size() > 0) { ForgeEventFactory.fireBlockHarvesting(blockDrops, world, coord.getPos(), state, 0, 1.0F, false, fakePlayer); } else if (block == Blocks.CHORUS_FLOWER) { diff --git a/src/main/java/mekanism/common/util/MultipartUtils.java b/src/main/java/mekanism/common/util/MultipartUtils.java index de2b52bb6..2958bb9a8 100644 --- a/src/main/java/mekanism/common/util/MultipartUtils.java +++ b/src/main/java/mekanism/common/util/MultipartUtils.java @@ -16,7 +16,6 @@ public final class MultipartUtils { public static AxisAlignedBB rotate(AxisAlignedBB aabb, EnumFacing side) { Vec3d v1 = rotate(new Vec3d(aabb.minX, aabb.minY, aabb.minZ), side); Vec3d v2 = rotate(new Vec3d(aabb.maxX, aabb.maxY, aabb.maxZ), side); - return new AxisAlignedBB(v1.x, v1.y, v1.z, v2.x, v2.y, v2.z); } @@ -35,7 +34,6 @@ public final class MultipartUtils { case EAST: return new Vec3d(-vec.y, vec.x, vec.z); } - return null; } @@ -51,51 +49,40 @@ public final class MultipartUtils { float f5 = f2 * f3; float f6 = f1 * f3; double d3 = 5.0D; - if (player instanceof EntityPlayerMP) { d3 = player.getEntityAttribute(EntityPlayer.REACH_DISTANCE).getAttributeValue(); } - Vec3d end = start.add(f5 * d3, f4 * d3, f6 * d3); return Pair.of(start, end); } - public static AdvancedRayTraceResult collisionRayTrace(BlockPos pos, Vec3d start, Vec3d end, - Collection boxes) { + public static AdvancedRayTraceResult collisionRayTrace(BlockPos pos, Vec3d start, Vec3d end, Collection boxes) { double minDistance = Double.POSITIVE_INFINITY; AdvancedRayTraceResult hit = null; int i = -1; for (AxisAlignedBB aabb : boxes) { AdvancedRayTraceResult result = aabb == null ? null : collisionRayTrace(pos, start, end, aabb, i, null); - if (result != null) { double d = result.squareDistanceTo(start); - if (d < minDistance) { minDistance = d; hit = result; } } - i++; } - return hit; } - public static AdvancedRayTraceResult collisionRayTrace(BlockPos pos, Vec3d start, Vec3d end, AxisAlignedBB bounds, - int subHit, Object hitInfo) { + public static AdvancedRayTraceResult collisionRayTrace(BlockPos pos, Vec3d start, Vec3d end, AxisAlignedBB bounds, int subHit, Object hitInfo) { RayTraceResult result = bounds.offset(pos).calculateIntercept(start, end); - if (result == null) { return null; } - result = new RayTraceResult(RayTraceResult.Type.BLOCK, result.hitVec, result.sideHit, pos); result.subHit = subHit; result.hitInfo = hitInfo; - return new AdvancedRayTraceResult(result, bounds); } @@ -124,4 +111,4 @@ public final class MultipartUtils { super(mop, bounds); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/util/PipeUtils.java b/src/main/java/mekanism/common/util/PipeUtils.java index 1edbdb60f..b81af5dcc 100644 --- a/src/main/java/mekanism/common/util/PipeUtils.java +++ b/src/main/java/mekanism/common/util/PipeUtils.java @@ -19,22 +19,17 @@ public final class PipeUtils { public static final FluidTankInfo[] EMPTY = new FluidTankInfo[]{}; public static boolean isValidAcceptorOnSide(TileEntity tile, EnumFacing side) { - if (tile == null || CapabilityUtils - .hasCapability(tile, Capabilities.GRID_TRANSMITTER_CAPABILITY, side.getOpposite()) || - !CapabilityUtils - .hasCapability(tile, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite())) { + if (tile == null || CapabilityUtils.hasCapability(tile, Capabilities.GRID_TRANSMITTER_CAPABILITY, side.getOpposite()) || + !CapabilityUtils.hasCapability(tile, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite())) { return false; } - IFluidHandler container = CapabilityUtils - .getCapability(tile, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite()); - + IFluidHandler container = CapabilityUtils.getCapability(tile, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite()); if (container == null) { return false; } IFluidTankProperties[] infoArray = container.getTankProperties(); - if (infoArray != null && infoArray.length > 0) { for (IFluidTankProperties info : infoArray) { if (info != null) { @@ -42,7 +37,6 @@ public final class PipeUtils { } } } - return false; } @@ -56,16 +50,11 @@ public final class PipeUtils { for (EnumFacing orientation : EnumFacing.VALUES) { TileEntity acceptor = world.getTileEntity(pos.offset(orientation)); - - if (CapabilityUtils.hasCapability(acceptor, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, - orientation.getOpposite())) { - IFluidHandler handler = CapabilityUtils - .getCapability(acceptor, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, - orientation.getOpposite()); + if (CapabilityUtils.hasCapability(acceptor, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, orientation.getOpposite())) { + IFluidHandler handler = CapabilityUtils.getCapability(acceptor, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, orientation.getOpposite()); acceptors[orientation.ordinal()] = handler; } } - return acceptors; } @@ -74,7 +63,8 @@ public final class PipeUtils { * * @param sides - the list of sides to output from * @param stack - the stack to output - * @param from - the TileEntity to output from + * @param from - the TileEntity to output from + * * @return the amount of gas emitted */ public static int emit(Set sides, FluidStack stack, TileEntity from) { @@ -91,8 +81,7 @@ public final class PipeUtils { } EnumFacing opposite = orientation.getOpposite(); if (CapabilityUtils.hasCapability(acceptor, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opposite)) { - IFluidHandler handler = CapabilityUtils.getCapability(acceptor, - CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opposite); + IFluidHandler handler = CapabilityUtils.getCapability(acceptor, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opposite); if (handler != null && canFill(handler, stack)) { target.addHandler(opposite, handler); } @@ -110,7 +99,6 @@ public final class PipeUtils { public static FluidStack copy(FluidStack fluid, int amount) { FluidStack ret = fluid.copy(); ret.amount = amount; - return ret; } @@ -120,7 +108,6 @@ public final class PipeUtils { return true; } } - return false; } @@ -130,7 +117,6 @@ public final class PipeUtils { return true; } } - return false; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/util/RecipeUtils.java b/src/main/java/mekanism/common/util/RecipeUtils.java index db5df4230..11882cab2 100644 --- a/src/main/java/mekanism/common/util/RecipeUtils.java +++ b/src/main/java/mekanism/common/util/RecipeUtils.java @@ -30,18 +30,14 @@ public class RecipeUtils { } else if (target.isEmpty()) { return true; } - if (target.getItem() != input.getItem()) { return false; } - if (target.getItemDamage() != input.getItemDamage() && target.getItemDamage() != OreDictionary.WILDCARD_VALUE) { return false; } - if (target.getItem() instanceof ITierItem && input.getItem() instanceof ITierItem) { - if (((ITierItem) target.getItem()).getBaseTier(target) != ((ITierItem) input.getItem()) - .getBaseTier(input)) { + if (((ITierItem) target.getItem()).getBaseTier(target) != ((ITierItem) input.getItem()).getBaseTier(input)) { return false; } } @@ -50,34 +46,26 @@ public class RecipeUtils { if (isFactory(target) && isFactory(input)) { RecipeType recipeTypeInput = ((IFactory) input.getItem()).getRecipeTypeOrNull(input); //If either factory has invalid NBT don't crash it - return recipeTypeInput != null - && ((IFactory) target.getItem()).getRecipeTypeOrNull(target) == recipeTypeInput; + return recipeTypeInput != null && ((IFactory) target.getItem()).getRecipeTypeOrNull(target) == recipeTypeInput; } } - 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; + return MachineType.get(stack) == MachineType.BASIC_FACTORY || MachineType.get(stack) == MachineType.ADVANCED_FACTORY || MachineType.get(stack) == MachineType.ELITE_FACTORY; } public static ItemStack getCraftingResult(InventoryCrafting inv, ItemStack toReturn) { int invLength = inv.getSizeInventory(); - if (toReturn.getItem() instanceof IEnergizedItem) { double energyFound = 0; - for (int i = 0; i < invLength; i++) { ItemStack itemstack = inv.getStackInSlot(i); - if (!itemstack.isEmpty() && itemstack.getItem() instanceof IEnergizedItem) { energyFound += ((IEnergizedItem) itemstack.getItem()).getEnergy(itemstack); } } - double energyToSet = Math.min(((IEnergizedItem) toReturn.getItem()).getMaxEnergy(toReturn), energyFound); if (energyToSet > 0) { ((IEnergizedItem) toReturn.getItem()).setEnergy(toReturn, energyToSet); @@ -86,25 +74,20 @@ public class RecipeUtils { if (toReturn.getItem() instanceof IGasItem) { GasStack gasFound = null; - for (int i = 0; i < invLength; i++) { ItemStack itemstack = inv.getStackInSlot(i); - if (!itemstack.isEmpty() && itemstack.getItem() instanceof IGasItem) { GasStack stored = ((IGasItem) itemstack.getItem()).getGas(itemstack); - if (stored != null) { if (!((IGasItem) toReturn.getItem()).canReceiveGas(toReturn, stored.getGas())) { return ItemStack.EMPTY; } - if (gasFound == null) { gasFound = stored; } else { if (gasFound.getGas() != stored.getGas()) { return ItemStack.EMPTY; } - gasFound.amount += stored.amount; } } @@ -120,13 +103,9 @@ public class RecipeUtils { if (toReturn.getItem() instanceof ISecurityItem) { for (int i = 0; i < invLength; i++) { ItemStack itemstack = inv.getStackInSlot(i); - if (!itemstack.isEmpty() && itemstack.getItem() instanceof ISecurityItem) { - ((ISecurityItem) toReturn.getItem()) - .setOwnerUUID(toReturn, ((ISecurityItem) itemstack.getItem()).getOwnerUUID(itemstack)); - ((ISecurityItem) toReturn.getItem()) - .setSecurity(toReturn, ((ISecurityItem) itemstack.getItem()).getSecurity(itemstack)); - + ((ISecurityItem) toReturn.getItem()).setOwnerUUID(toReturn, ((ISecurityItem) itemstack.getItem()).getOwnerUUID(itemstack)); + ((ISecurityItem) toReturn.getItem()).setSecurity(toReturn, ((ISecurityItem) itemstack.getItem()).getSecurity(itemstack)); break; } } @@ -134,25 +113,20 @@ public class RecipeUtils { if (FluidContainerUtils.isFluidContainer(toReturn)) { FluidStack fluidFound = null; - for (int i = 0; i < invLength; i++) { ItemStack itemstack = inv.getStackInSlot(i); - if (FluidContainerUtils.isFluidContainer(itemstack)) { FluidStack stored = FluidUtil.getFluidContained(itemstack); - if (stored != null) { if (FluidUtil.getFluidHandler(itemstack).fill(stored, false) == 0) { return ItemStack.EMPTY; } - if (fluidFound == null) { fluidFound = stored; } else { if (fluidFound.getFluid() != stored.getFluid()) { return ItemStack.EMPTY; } - fluidFound.amount += stored.amount; } } @@ -167,13 +141,10 @@ public class RecipeUtils { if (BasicBlockType.get(toReturn) == BasicBlockType.BIN) { int foundCount = 0; ItemStack foundType = ItemStack.EMPTY; - for (int i = 0; i < invLength; i++) { ItemStack itemstack = inv.getStackInSlot(i); - if (!itemstack.isEmpty() && BasicBlockType.get(itemstack) == BasicBlockType.BIN) { InventoryBin binInv = new InventoryBin(itemstack); - foundCount = binInv.getItemCount(); foundType = binInv.getItemType(); } @@ -188,32 +159,24 @@ public class RecipeUtils { if (MachineType.get(toReturn) != null && MachineType.get(toReturn).supportsUpgrades) { Map upgrades = new HashMap<>(); - for (int i = 0; i < invLength; i++) { ItemStack itemstack = inv.getStackInSlot(i); - - if (!itemstack.isEmpty() && MachineType.get(itemstack) != null && MachineType - .get(itemstack).supportsUpgrades) { + if (!itemstack.isEmpty() && MachineType.get(itemstack) != null && MachineType.get(itemstack).supportsUpgrades) { Map stackMap = Upgrade.buildMap(ItemDataUtils.getDataMapIfPresent(itemstack)); - for (Map.Entry entry : stackMap.entrySet()) { if (entry != null && entry.getKey() != null && entry.getValue() != null) { Integer val = upgrades.get(entry.getKey()); - - upgrades.put(entry.getKey(), - Math.min(entry.getKey().getMax(), (val != null ? val : 0) + entry.getValue())); + upgrades.put(entry.getKey(), Math.min(entry.getKey().getMax(), (val != null ? val : 0) + entry.getValue())); } } } } - Upgrade.saveMap(upgrades, ItemDataUtils.getDataMap(toReturn)); } - return toReturn; } public static IRecipe getRecipeFromGrid(InventoryCrafting inv, World world) { return CraftingManager.findMatchingRecipe(inv, world); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/util/SecurityUtils.java b/src/main/java/mekanism/common/util/SecurityUtils.java index 07563e0bc..7132e8440 100644 --- a/src/main/java/mekanism/common/util/SecurityUtils.java +++ b/src/main/java/mekanism/common/util/SecurityUtils.java @@ -25,23 +25,17 @@ public final class SecurityUtils { if (!MekanismConfig.current().general.allowProtection.val()) { return true; } - if (!(stack.getItem() instanceof ISecurityItem) && stack.getItem() instanceof IOwnerItem) { UUID owner = ((IOwnerItem) stack.getItem()).getOwnerUUID(stack); - return owner == null || owner.equals(player.getUniqueID()); } - if (stack.isEmpty() || !(stack.getItem() instanceof ISecurityItem)) { return true; } - ISecurityItem security = (ISecurityItem) stack.getItem(); - if (MekanismUtils.isOp(player)) { return true; } - return canAccess(security.getSecurity(stack), player, security.getOwnerUUID(stack)); } @@ -49,13 +43,10 @@ public final class SecurityUtils { if (!(tile instanceof ISecurityTile)) { return true; } - ISecurityTile security = (ISecurityTile) tile; - if (MekanismUtils.isOp(player)) { return true; } - return canAccess(security.getSecurity().getMode(), player, security.getSecurity().getOwnerUUID()); } @@ -64,27 +55,21 @@ public final class SecurityUtils { if (!MekanismConfig.current().general.allowProtection.val()) { return true; } - if (owner == null || player.getUniqueID().equals(owner)) { return true; } - SecurityFrequency freq = getFrequency(owner); - if (freq == null) { return true; } - if (freq.override) { mode = freq.securityMode; } - if (mode == SecurityMode.PUBLIC) { return true; } else if (mode == SecurityMode.TRUSTED) { return freq.trusted.contains(player.getName()); } - return false; } @@ -96,7 +81,6 @@ public final class SecurityUtils { } } } - return null; } @@ -104,113 +88,90 @@ public final class SecurityUtils { if (ownerName == null) { return EnumColor.RED + LangUtils.localize("gui.noOwner"); } - return EnumColor.GREY + LangUtils.localize("gui.owner") + ": " + (player.getName().equals(ownerName) - ? EnumColor.BRIGHT_GREEN : EnumColor.RED) + ownerName; + ? EnumColor.BRIGHT_GREEN : EnumColor.RED) + ownerName; } public static void displayNoAccess(EntityPlayer player) { - player.sendMessage(new TextComponentString( - EnumColor.DARK_BLUE + Mekanism.LOG_TAG + " " + EnumColor.RED + LangUtils.localize("gui.noAccessDesc"))); + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + Mekanism.LOG_TAG + " " + EnumColor.RED + LangUtils.localize("gui.noAccessDesc"))); } public static SecurityMode getSecurity(ISecurityTile security, Side side) { if (side == Side.SERVER) { SecurityFrequency freq = security.getSecurity().getFrequency(); - if (freq != null && freq.override) { return freq.securityMode; } } else if (side == Side.CLIENT) { SecurityData data = MekanismClient.clientSecurityMap.get(security.getSecurity().getOwnerUUID()); - if (data != null && data.override) { return data.mode; } } - return security.getSecurity().getMode(); } public static String getSecurityDisplay(ItemStack stack, Side side) { ISecurityItem security = (ISecurityItem) stack.getItem(); SecurityMode mode = security.getSecurity(stack); - if (security.getOwnerUUID(stack) != null) { if (side == Side.SERVER) { SecurityFrequency freq = getFrequency(security.getOwnerUUID(stack)); - if (freq != null && freq.override) { mode = freq.securityMode; } } else if (side == Side.CLIENT) { SecurityData data = MekanismClient.clientSecurityMap.get(security.getOwnerUUID(stack)); - if (data != null && data.override) { mode = data.mode; } } } - return mode.getDisplay(); } public static String getSecurityDisplay(TileEntity tile, Side side) { ISecurityTile security = (ISecurityTile) tile; SecurityMode mode = security.getSecurity().getMode(); - if (security.getSecurity().getOwnerUUID() != null) { if (side == Side.SERVER) { SecurityFrequency freq = getFrequency(security.getSecurity().getOwnerUUID()); - if (freq != null && freq.override) { mode = freq.securityMode; } } else if (side == Side.CLIENT) { SecurityData data = MekanismClient.clientSecurityMap.get(security.getSecurity().getOwnerUUID()); - if (data != null && data.override) { mode = data.mode; } } } - return mode.getDisplay(); } public static boolean isOverridden(ItemStack stack, Side side) { ISecurityItem security = (ISecurityItem) stack.getItem(); - if (security.getOwnerUUID(stack) == null) { return false; } - if (side == Side.SERVER) { SecurityFrequency freq = getFrequency(security.getOwnerUUID(stack)); - return freq != null && freq.override; - } else { - SecurityData data = MekanismClient.clientSecurityMap.get(security.getOwnerUUID(stack)); - - return data != null && data.override; } + SecurityData data = MekanismClient.clientSecurityMap.get(security.getOwnerUUID(stack)); + return data != null && data.override; } public static boolean isOverridden(TileEntity tile, Side side) { ISecurityTile security = (ISecurityTile) tile; - if (security.getSecurity().getOwnerUUID() == null) { return false; } - if (side == Side.SERVER) { SecurityFrequency freq = getFrequency(security.getSecurity().getOwnerUUID()); - return freq != null && freq.override; - } else { - SecurityData data = MekanismClient.clientSecurityMap.get(security.getSecurity().getOwnerUUID()); - - return data != null && data.override; } + SecurityData data = MekanismClient.clientSecurityMap.get(security.getSecurity().getOwnerUUID()); + return data != null && data.override; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/util/StackUtils.java b/src/main/java/mekanism/common/util/StackUtils.java index 91891ffae..5e34e0f6a 100644 --- a/src/main/java/mekanism/common/util/StackUtils.java +++ b/src/main/java/mekanism/common/util/StackUtils.java @@ -22,23 +22,18 @@ public final class StackUtils { if (wild.isEmpty() && check.isEmpty()) { return true; } - - return wild.getItem() == check.getItem() && (wild.getItemDamage() == OreDictionary.WILDCARD_VALUE - || check.getItemDamage() == OreDictionary.WILDCARD_VALUE || wild.getItemDamage() == check - .getItemDamage()); + return wild.getItem() == check.getItem() && (wild.getItemDamage() == OreDictionary.WILDCARD_VALUE || check.getItemDamage() == OreDictionary.WILDCARD_VALUE || + wild.getItemDamage() == check.getItemDamage()); } //ignores count public static boolean equalsWildcardWithNBT(ItemStack wild, ItemStack check) { boolean wildcard = equalsWildcard(wild, check); - if (wild.isEmpty() || check.isEmpty()) { return wildcard; } - - return wildcard && (!wild.hasTagCompound() ? !check.hasTagCompound() - : (wild.getTagCompound() == check.getTagCompound() || wild.getTagCompound() - .equals(check.getTagCompound()))); + return wildcard && (!wild.hasTagCompound() ? !check.hasTagCompound() : (wild.getTagCompound() == check.getTagCompound() || + wild.getTagCompound().equals(check.getTagCompound()))); } //assumes stacks same @@ -48,7 +43,6 @@ public final class StackUtils { } else if (stack2.isEmpty()) { return stack1; } - return size(stack1, stack1.getCount() - stack2.getCount()); } @@ -56,26 +50,21 @@ public final class StackUtils { if (size <= 0 || stack.isEmpty()) { return ItemStack.EMPTY; } - ItemStack ret = stack.copy(); ret.setCount(size); - return ret; } public static List getMergeRejects(NonNullList orig, NonNullList toAdd) { List ret = new ArrayList<>(); - for (int i = 0; i < toAdd.size(); i++) { if (!toAdd.get(i).isEmpty()) { ItemStack reject = getMergeReject(orig.get(i), toAdd.get(i)); - if (!reject.isEmpty()) { ret.add(reject); } } } - return ret; } @@ -91,15 +80,12 @@ public final class StackUtils { if (orig.isEmpty()) { return toAdd; } - if (toAdd.isEmpty()) { return orig; } - if (!orig.isItemEqual(toAdd) || !ItemStack.areItemStackTagsEqual(orig, toAdd)) { return orig; } - return size(orig, Math.min(orig.getMaxStackSize(), orig.getCount() + toAdd.getCount())); } @@ -107,29 +93,23 @@ public final class StackUtils { if (orig.isEmpty()) { return ItemStack.EMPTY; } - if (toAdd.isEmpty()) { return orig; } - if (!orig.isItemEqual(toAdd) || !ItemStack.areItemStackTagsEqual(orig, toAdd)) { return orig; } - int newSize = orig.getCount() + toAdd.getCount(); - if (newSize > orig.getMaxStackSize()) { return size(orig, newSize - orig.getMaxStackSize()); - } else { - return size(orig, newSize); } + return size(orig, newSize); } public static int hashItemStack(ItemStack stack) { if (stack.isEmpty()) { return -1; } - ResourceLocation registryName = stack.getItem().getRegistryName(); int nameHash = registryName == null ? 0 : registryName.hashCode(); return nameHash << 8 | stack.getMetadata(); @@ -138,15 +118,17 @@ public final class StackUtils { /** * Get state for placement for a generic item, with our fake player * - * @param stack the item to place - * @param world which universe - * @param pos where + * @param stack the item to place + * @param world which universe + * @param pos where * @param player our fake player, usually - * @return the result of {@link Block#getStateForPlacement(net.minecraft.world.World, net.minecraft.util.math.BlockPos, net.minecraft.util.EnumFacing, float, float, float, int, net.minecraft.entity.EntityLivingBase, net.minecraft.util.EnumHand)} + * + * @return the result of {@link Block#getStateForPlacement(net.minecraft.world.World, net.minecraft.util.math.BlockPos, net.minecraft.util.EnumFacing, float, float, + * float, int, net.minecraft.entity.EntityLivingBase, net.minecraft.util.EnumHand)} */ @Nonnull public static IBlockState getStateForPlacement(ItemStack stack, World world, BlockPos pos, EntityPlayer player) { Block blockFromItem = Block.getBlockFromItem(stack.getItem()); - return blockFromItem.getStateForPlacement(world, pos, EnumFacing.UP, 0,0,0, stack.getMetadata(), player, EnumHand.MAIN_HAND); + return blockFromItem.getStateForPlacement(world, pos, EnumFacing.UP, 0, 0, 0, stack.getMetadata(), player, EnumHand.MAIN_HAND); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/util/StatUtils.java b/src/main/java/mekanism/common/util/StatUtils.java index c2966174b..517331611 100644 --- a/src/main/java/mekanism/common/util/StatUtils.java +++ b/src/main/java/mekanism/common/util/StatUtils.java @@ -19,12 +19,10 @@ public class StatUtils { double p = 1; double stirlingValue = mean * E; double stirlingCoeff = 1 / sqrt(2 * PI); - while ((p < r) && (m < 3 * ceil(mean))) { m++; - p += stirlingCoeff / sqrt(m) * pow((stirlingValue / m), m); + p += stirlingCoeff / sqrt(m) * pow(stirlingValue / m, m); } - return m; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/util/TextComponentGroup.java b/src/main/java/mekanism/common/util/TextComponentGroup.java index 539b40736..c39419c66 100644 --- a/src/main/java/mekanism/common/util/TextComponentGroup.java +++ b/src/main/java/mekanism/common/util/TextComponentGroup.java @@ -31,11 +31,9 @@ public class TextComponentGroup extends TextComponentString { public TextComponentGroup createCopy() { TextComponentGroup textcomponentstring = new TextComponentGroup(); textcomponentstring.setStyle(this.getStyle().createShallowCopy()); - for (ITextComponent itextcomponent : this.getSiblings()) { textcomponentstring.appendSibling(itextcomponent.createCopy()); } - return textcomponentstring; } @@ -85,4 +83,4 @@ public class TextComponentGroup extends TextComponentString { this.appendSibling(component); return this; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/util/TileUtils.java b/src/main/java/mekanism/common/util/TileUtils.java index c86fa031d..f8b384c02 100644 --- a/src/main/java/mekanism/common/util/TileUtils.java +++ b/src/main/java/mekanism/common/util/TileUtils.java @@ -83,4 +83,4 @@ public class TileUtils { tank.draw(GasUtils.emit(toSend, tile, EnumSet.of(facing)), true); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/util/TransporterUtils.java b/src/main/java/mekanism/common/util/TransporterUtils.java index fcb30ad87..ad82c324b 100644 --- a/src/main/java/mekanism/common/util/TransporterUtils.java +++ b/src/main/java/mekanism/common/util/TransporterUtils.java @@ -18,10 +18,8 @@ import net.minecraft.util.math.BlockPos; public final class TransporterUtils { - public static List colors = Arrays - .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); + public static List colors = Arrays.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); public static boolean isValidAcceptorOnSide(TileEntity tile, EnumFacing side) { if (CapabilityUtils.hasCapability(tile, Capabilities.GRID_TRANSMITTER_CAPABILITY, side.getOpposite())) { @@ -30,13 +28,11 @@ public final class TransporterUtils { return InventoryUtils.isItemHandler(tile, side.getOpposite()); } - public static TransitResponse insert(TileEntity outputter, ILogisticalTransporter transporter, - TransitRequest request, EnumColor color, boolean doEmit, int min) { + public static TransitResponse insert(TileEntity outputter, ILogisticalTransporter transporter, TransitRequest request, EnumColor color, boolean doEmit, int min) { return transporter.insert(Coord4D.get(outputter), request, color, doEmit, min); } - public static TransitResponse insertRR(TileEntityLogisticalSorter outputter, ILogisticalTransporter transporter, - TransitRequest request, EnumColor color, boolean doEmit, int min) { + public static TransitResponse insertRR(TileEntityLogisticalSorter outputter, ILogisticalTransporter transporter, TransitRequest request, EnumColor color, boolean doEmit, int min) { return transporter.insertRR(outputter, request, color, doEmit, min); } @@ -46,7 +42,6 @@ public final class TransporterUtils { } else if (colors.indexOf(color) == colors.size() - 1) { return null; } - return colors.get(colors.indexOf(color) + 1); } @@ -56,30 +51,24 @@ public final class TransporterUtils { } 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; - if (stack.hasPath()) { pos = TransporterUtils.getStackPosition(tileEntity, stack, 0); } else { pos = new float[]{0, 0, 0}; } - TransporterManager.remove(stack); - BlockPos blockPos = new BlockPos(tileEntity.coord().x + pos[0], tileEntity.coord().y + pos[1], - tileEntity.coord().z + pos[2]); + BlockPos blockPos = new BlockPos(tileEntity.coord().x + pos[0], tileEntity.coord().y + pos[1], tileEntity.coord().z + pos[2]); Block.spawnAsEntity(tileEntity.world(), blockPos, stack.itemStack); } public static float[] getStackPosition(ILogisticalTransporter tileEntity, TransporterStack stack, float partial) { - Coord4D offset = new Coord4D(0, 0, 0, tileEntity.world().provider.getDimension()) - .offset(stack.getSide(tileEntity)); + Coord4D offset = new Coord4D(0, 0, 0, tileEntity.world().provider.getDimension()).offset(stack.getSide(tileEntity)); float progress = (((float) stack.progress + partial) / 100F) - 0.5F; - return new float[]{0.5F + offset.x * progress, 0.25F + offset.y * progress, 0.5F + offset.z * progress}; } @@ -91,8 +80,7 @@ public final class TransporterUtils { 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/src/main/java/mekanism/common/util/UnitDisplayUtils.java b/src/main/java/mekanism/common/util/UnitDisplayUtils.java index c583ccbfe..a9b8df96b 100644 --- a/src/main/java/mekanism/common/util/UnitDisplayUtils.java +++ b/src/main/java/mekanism/common/util/UnitDisplayUtils.java @@ -6,49 +6,37 @@ package mekanism.common.util; public class UnitDisplayUtils { /** - * Displays the unit as text. Does handle negative numbers, and will place a negative sign in front of the output - * string showing this. Use string.replace to remove the negative sign if unwanted + * Displays the unit as text. Does handle negative numbers, and will place a negative sign in front of the output string showing this. Use string.replace to remove + * the negative sign if unwanted */ public static String getDisplay(double value, ElectricUnit unit, int decimalPlaces, boolean isShort) { String unitName = unit.name; String prefix = ""; - if (value < 0) { value = Math.abs(value); prefix = "-"; } - if (isShort) { unitName = unit.symbol; } else if (value > 1) { unitName = unit.getPlural(); } - if (value == 0) { return value + " " + unitName; - } else { - 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; - } + } + 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; } } - return prefix + roundDecimals(value, decimalPlaces) + " " + unitName; } @@ -65,57 +53,43 @@ public class UnitDisplayUtils { if (decimalPlaces < 1) { return (int) value + " " + unit.getPlural(); } - return roundDecimals(value, decimalPlaces) + " " + unit.getPlural(); } - if (decimalPlaces < 1) { return (int) value + " " + unit.name; } - return roundDecimals(value, decimalPlaces) + " " + unit.name; } public static String getDisplay(double T, TemperatureUnit unit, int decimalPlaces, boolean shift, boolean isShort) { String unitName = unit.name; String prefix = ""; - double value = unit.convertFromK(T, shift); - if (value < 0) { value = Math.abs(value); prefix = "-"; } - if (isShort) { unitName = unit.symbol; } - if (value == 0) { return value + (isShort ? "" : " ") + unitName; - } else { - for (int i = 0; i < MeasurementUnit.values().length; i++) { - MeasurementUnit lowerMeasure = MeasurementUnit.values()[i]; + } + 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) + (isShort ? "" : " ") + lowerMeasure.getName(isShort) + unitName; + } - if (lowerMeasure.below(value) && lowerMeasure.ordinal() == 0) { - return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces) + (isShort ? "" : " ") - + lowerMeasure.getName(isShort) + unitName; - } + if (lowerMeasure.ordinal() + 1 >= MeasurementUnit.values().length) { + return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces) + (isShort ? "" : " ") + lowerMeasure.getName(isShort) + unitName; + } - if (lowerMeasure.ordinal() + 1 >= MeasurementUnit.values().length) { - return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces) + (isShort ? "" : " ") - + 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) + (isShort ? "" : " ") - + 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) + (isShort ? "" : " ") + lowerMeasure.getName(isShort) + unitName; } } - return prefix + roundDecimals(value, decimalPlaces) + (isShort ? "" : " ") + unitName; } @@ -262,4 +236,4 @@ public class UnitDisplayUtils { F, STP } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/voice/VoiceConnection.java b/src/main/java/mekanism/common/voice/VoiceConnection.java index 704717695..b2c5c7a81 100644 --- a/src/main/java/mekanism/common/voice/VoiceConnection.java +++ b/src/main/java/mekanism/common/voice/VoiceConnection.java @@ -34,20 +34,15 @@ public class VoiceConnection extends Thread { try { input = new DataInputStream(new BufferedInputStream(socket.getInputStream())); output = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream())); - synchronized (Mekanism.voiceManager) { int retryCount = 0; - while (uuid == null && retryCount <= 100) { try { - List l = Collections - .synchronizedList(new ArrayList<>(server.getPlayerList().getPlayers())); + List l = Collections.synchronizedList(new ArrayList<>(server.getPlayerList().getPlayers())); for (EntityPlayerMP playerMP : l) { String playerIP = playerMP.getPlayerIP(); - - if (!server.isDedicatedServer() && playerIP.equals("local") && !Mekanism.voiceManager - .isFoundLocal()) { + if (!server.isDedicatedServer() && playerIP.equals("local") && !Mekanism.voiceManager.isFoundLocal()) { Mekanism.voiceManager.setFoundLocal(true); uuid = playerMP.getUniqueID(); break; @@ -56,7 +51,6 @@ public class VoiceConnection extends Thread { break; } } - retryCount++; Thread.sleep(50); } catch (Exception ignored) { @@ -83,7 +77,6 @@ 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); } @@ -91,7 +84,6 @@ public class VoiceConnection extends Thread { open = false; } } - if (!open) { kill(); } @@ -119,11 +111,9 @@ public class VoiceConnection extends Thread { if (!open) { kill(); } - try { output.writeShort(byteCount); output.write(audioData); - output.flush(); } catch (Exception e) { Mekanism.logger.error("VoiceServer: Error while sending data to player.", e); @@ -132,7 +122,7 @@ public class VoiceConnection extends Thread { public boolean canListen(int channel) { return getPlayer().inventory.mainInventory.stream().anyMatch(itemStack -> canListen(channel, itemStack)) - || getPlayer().inventory.offHandInventory.stream().anyMatch(itemStack -> canListen(channel, itemStack)); + || getPlayer().inventory.offHandInventory.stream().anyMatch(itemStack -> canListen(channel, itemStack)); } private boolean canListen(int channel, ItemStack itemStack) { @@ -140,20 +130,17 @@ public class VoiceConnection extends Thread { ItemWalkieTalkie walkieTalkie = (ItemWalkieTalkie) itemStack.getItem(); return walkieTalkie.getOn(itemStack) && walkieTalkie.getChannel(itemStack) == channel; } - return false; } public int getCurrentChannel() { ItemStack itemStack = getPlayer().inventory.getCurrentItem(); - if (!itemStack.isEmpty() && itemStack.getItem() instanceof ItemWalkieTalkie) { ItemWalkieTalkie walkieTalkie = (ItemWalkieTalkie) itemStack.getItem(); if (walkieTalkie.getOn(itemStack)) { return walkieTalkie.getChannel(itemStack); } } - return 0; } diff --git a/src/main/java/mekanism/common/voice/VoiceServerManager.java b/src/main/java/mekanism/common/voice/VoiceServerManager.java index 82f73e907..b03207c9b 100644 --- a/src/main/java/mekanism/common/voice/VoiceServerManager.java +++ b/src/main/java/mekanism/common/voice/VoiceServerManager.java @@ -18,7 +18,6 @@ public class VoiceServerManager { public void start() { Mekanism.logger.info("VoiceServer: Starting up server..."); - try { running = true; serverSocket = new ServerSocket(MekanismConfig.current().general.VOICE_PORT.val()); @@ -30,14 +29,11 @@ public class VoiceServerManager { public void stop() { try { Mekanism.logger.info("VoiceServer: Shutting down server..."); - try { listenThread.interrupt(); } catch (Exception ignored) { } - foundLocal = false; - try { serverSocket.close(); serverSocket = null; @@ -46,7 +42,6 @@ public class VoiceServerManager { } catch (Exception e) { Mekanism.logger.error("VoiceServer: Error while shutting down server.", e); } - running = false; } @@ -66,13 +61,10 @@ public class VoiceServerManager { 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)) { iterConn.sendToPlayer(byteCount, audioData, connection); @@ -95,7 +87,6 @@ public class VoiceServerManager { VoiceConnection connection = new VoiceConnection(s); connection.start(); connections.add(connection); - Mekanism.logger.info("VoiceServer: Accepted new connection."); } catch (SocketException | NullPointerException ignored) { } catch (Exception e) { diff --git a/src/main/java/mekanism/common/world/GenHandler.java b/src/main/java/mekanism/common/world/GenHandler.java index fbaedaf1f..5c32d1d20 100644 --- a/src/main/java/mekanism/common/world/GenHandler.java +++ b/src/main/java/mekanism/common/world/GenHandler.java @@ -17,31 +17,24 @@ import net.minecraftforge.fml.common.IWorldGenerator; public class GenHandler implements IWorldGenerator { @Override - public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, - IChunkProvider chunkProvider) { + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { if (!(chunkGenerator instanceof ChunkGeneratorHell) && !(chunkGenerator instanceof ChunkGeneratorEnd)) { for (int i = 0; i < MekanismConfig.current().general.osmiumPerChunk.val(); i++) { - BlockPos pos = new BlockPos(chunkX * 16 + random.nextInt(16), random.nextInt(60), - (chunkZ * 16) + random.nextInt(16)); - new WorldGenMinable(MekanismBlocks.OreBlock.getStateFromMeta(0), - MekanismConfig.current().general.osmiumMaxVeinSize.val(), BlockMatcher.forBlock(Blocks.STONE)) - .generate(world, random, pos); + BlockPos pos = new BlockPos(chunkX * 16 + random.nextInt(16), random.nextInt(60), (chunkZ * 16) + random.nextInt(16)); + new WorldGenMinable(MekanismBlocks.OreBlock.getStateFromMeta(0), MekanismConfig.current().general.osmiumMaxVeinSize.val(), + BlockMatcher.forBlock(Blocks.STONE)).generate(world, random, pos); } for (int i = 0; i < MekanismConfig.current().general.copperPerChunk.val(); i++) { - BlockPos pos = new BlockPos(chunkX * 16 + random.nextInt(16), random.nextInt(60), - (chunkZ * 16) + random.nextInt(16)); - new WorldGenMinable(MekanismBlocks.OreBlock.getStateFromMeta(1), - MekanismConfig.current().general.copperMaxVeinSize.val(), BlockMatcher.forBlock(Blocks.STONE)) - .generate(world, random, pos); + BlockPos pos = new BlockPos(chunkX * 16 + random.nextInt(16), random.nextInt(60), (chunkZ * 16) + random.nextInt(16)); + new WorldGenMinable(MekanismBlocks.OreBlock.getStateFromMeta(1), MekanismConfig.current().general.copperMaxVeinSize.val(), + BlockMatcher.forBlock(Blocks.STONE)).generate(world, random, pos); } for (int i = 0; i < MekanismConfig.current().general.tinPerChunk.val(); i++) { - BlockPos pos = new BlockPos(chunkX * 16 + random.nextInt(16), random.nextInt(60), - (chunkZ * 16) + random.nextInt(16)); - new WorldGenMinable(MekanismBlocks.OreBlock.getStateFromMeta(2), - MekanismConfig.current().general.tinMaxVeinSize.val(), BlockMatcher.forBlock(Blocks.STONE)) - .generate(world, random, pos); + BlockPos pos = new BlockPos(chunkX * 16 + random.nextInt(16), random.nextInt(60), (chunkZ * 16) + random.nextInt(16)); + new WorldGenMinable(MekanismBlocks.OreBlock.getStateFromMeta(2), MekanismConfig.current().general.tinMaxVeinSize.val(), + BlockMatcher.forBlock(Blocks.STONE)).generate(world, random, pos); } for (int i = 0; i < MekanismConfig.current().general.saltPerChunk.val(); i++) { @@ -52,4 +45,4 @@ public class GenHandler implements IWorldGenerator { } } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/world/WorldGenSalt.java b/src/main/java/mekanism/common/world/WorldGenSalt.java index 95f758099..b895284f6 100644 --- a/src/main/java/mekanism/common/world/WorldGenSalt.java +++ b/src/main/java/mekanism/common/world/WorldGenSalt.java @@ -25,29 +25,24 @@ public class WorldGenSalt extends WorldGenerator { public boolean generate(@Nonnull World world, @Nonnull Random random, @Nonnull BlockPos pos) { if (world.getBlockState(pos).getMaterial() != Material.WATER) { return false; - } else { - int toGenerate = random.nextInt(numberOfBlocks - 2) + 2; - byte yOffset = 1; - - for (int xPos = pos.getX() - toGenerate; xPos <= pos.getX() + toGenerate; xPos++) { - for (int zPos = pos.getZ() - toGenerate; zPos <= pos.getZ() + toGenerate; zPos++) { - int xOffset = xPos - pos.getX(); - int zOffset = zPos - pos.getZ(); - - if ((xOffset * xOffset) + (zOffset * zOffset) <= toGenerate * toGenerate) { - for (int yPos = pos.getY() - yOffset; yPos <= pos.getY() + yOffset; yPos++) { - BlockPos newPos = new BlockPos(xPos, yPos, zPos); - Block block = world.getBlockState(newPos).getBlock(); - - if (block == Blocks.DIRT || block == Blocks.CLAY || block == MekanismBlocks.SaltBlock) { - world.setBlockState(newPos, blockGen.getDefaultState(), 2); - } + } + int toGenerate = random.nextInt(numberOfBlocks - 2) + 2; + byte yOffset = 1; + for (int xPos = pos.getX() - toGenerate; xPos <= pos.getX() + toGenerate; xPos++) { + for (int zPos = pos.getZ() - toGenerate; zPos <= pos.getZ() + toGenerate; zPos++) { + int xOffset = xPos - pos.getX(); + int zOffset = zPos - pos.getZ(); + if ((xOffset * xOffset) + (zOffset * zOffset) <= toGenerate * toGenerate) { + for (int yPos = pos.getY() - yOffset; yPos <= pos.getY() + yOffset; yPos++) { + BlockPos newPos = new BlockPos(xPos, yPos, zPos); + Block block = world.getBlockState(newPos).getBlock(); + if (block == Blocks.DIRT || block == Blocks.CLAY || block == MekanismBlocks.SaltBlock) { + world.setBlockState(newPos, blockGen.getDefaultState(), 2); } } } } - - return true; } + return true; } } \ No newline at end of file diff --git a/src/main/java/mekanism/coremod/KeybindingMigrationHelper.java b/src/main/java/mekanism/coremod/KeybindingMigrationHelper.java index 35969e0b5..b6636e1a1 100644 --- a/src/main/java/mekanism/coremod/KeybindingMigrationHelper.java +++ b/src/main/java/mekanism/coremod/KeybindingMigrationHelper.java @@ -14,14 +14,14 @@ import org.objectweb.asm.commons.GeneratorAdapter; import org.objectweb.asm.commons.Method; /** - * Allows us to run a mini datafixer on the GameSettings to migrate the old keybind options - * (before we correctly used the translation key). + * Allows us to run a mini datafixer on the GameSettings to migrate the old keybind options (before we correctly used the translation key). * - * Hooks into {@link net.minecraft.client.settings.GameSettings#dataFix(net.minecraft.nbt.NBTTagCompound)} and always - * calls our static method datafixer {@link mekanism.common.fixers.KeybindingFixer#runFix(net.minecraft.nbt.NBTTagCompound)} + * Hooks into {@link net.minecraft.client.settings.GameSettings#dataFix(net.minecraft.nbt.NBTTagCompound)} and always calls our static method datafixer {@link + * mekanism.common.fixers.KeybindingFixer#runFix(net.minecraft.nbt.NBTTagCompound)} */ @SuppressWarnings("unused")//coremod land public class KeybindingMigrationHelper implements IClassTransformer { + private static final Logger LOGGER = LogManager.getLogger("Mekanism KeybindingMigrationHelper"); @Override @@ -35,20 +35,21 @@ public class KeybindingMigrationHelper implements IClassTransformer { } private static class Visitor extends ClassVisitor { + private static final String DATAFIX_SIG = "(Lnet/minecraft/nbt/NBTTagCompound;)Lnet/minecraft/nbt/NBTTagCompound;"; //net.minecraft.client.settings.GameSettings func_189988_a(Lnet/minecraft/nbt/NBTTagCompound;)Lnet/minecraft/nbt/NBTTagCompound; #dataFix private String datafixMethodName = FMLDeobfuscatingRemapper.INSTANCE.mapMethodName("net/minecraft/client/settings/GameSettings", "func_189988_a", DATAFIX_SIG); - Visitor(ClassVisitor parent){ + Visitor(ClassVisitor parent) { super(Opcodes.ASM5, parent); - LOGGER.debug("Looking for "+datafixMethodName+DATAFIX_SIG); + LOGGER.debug("Looking for " + datafixMethodName + DATAFIX_SIG); } @Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { MethodVisitor visitor = super.visitMethod(access, name, desc, signature, exceptions); - if (name.equals(datafixMethodName) && desc.equals(DATAFIX_SIG)){ + if (name.equals(datafixMethodName) && desc.equals(DATAFIX_SIG)) { LOGGER.info("Patching GameSettings.datafix"); return new GeneratorAdapter(Opcodes.ASM5, visitor, access, name, desc) { @Override @@ -62,4 +63,4 @@ public class KeybindingMigrationHelper implements IClassTransformer { return visitor; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/coremod/MekanismCoremod.java b/src/main/java/mekanism/coremod/MekanismCoremod.java index 98f69656c..b44048406 100644 --- a/src/main/java/mekanism/coremod/MekanismCoremod.java +++ b/src/main/java/mekanism/coremod/MekanismCoremod.java @@ -30,11 +30,10 @@ public class MekanismCoremod implements IFMLLoadingPlugin { @Override public void injectData(Map data) { - } @Override public String getAccessTransformerClass() { return null; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/client/GeneratorsClientProxy.java b/src/main/java/mekanism/generators/client/GeneratorsClientProxy.java index f3bdd4877..cf7c5b962 100644 --- a/src/main/java/mekanism/generators/client/GeneratorsClientProxy.java +++ b/src/main/java/mekanism/generators/client/GeneratorsClientProxy.java @@ -70,8 +70,7 @@ public class GeneratorsClientProxy extends GeneratorsCommonProxy { @Override public void registerTESRs() { - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityAdvancedSolarGenerator.class, - new RenderAdvancedSolarGenerator()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityAdvancedSolarGenerator.class, new RenderAdvancedSolarGenerator()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBioGenerator.class, new RenderBioGenerator()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityGasGenerator.class, new RenderGasGenerator()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityHeatGenerator.class, new RenderHeatGenerator()); @@ -100,13 +99,11 @@ public class GeneratorsClientProxy extends GeneratorsCommonProxy { ModelLoader.setCustomStateMapper(GeneratorsBlocks.ReactorGlass, reactorMapper); for (GeneratorType type : GeneratorType.values()) { - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(type.blockType.getBlock()), type.meta, - new ModelResourceLocation("mekanismgenerators:" + type.getName(), "inventory")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(type.blockType.getBlock()), type.meta, new ModelResourceLocation("mekanismgenerators:" + type.getName(), "inventory")); } for (ReactorBlockType type : ReactorBlockType.values()) { - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(type.blockType.getBlock()), type.meta, - new ModelResourceLocation("mekanismgenerators:" + type.getName(), "inventory")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(type.blockType.getBlock()), type.meta, new ModelResourceLocation("mekanismgenerators:" + type.getName(), "inventory")); } } @@ -174,4 +171,4 @@ public class GeneratorsClientProxy extends GeneratorsCommonProxy { @SubscribeEvent public void onStitch(TextureStitchEvent.Pre event) { } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/client/gui/GeneratorsGuiFactory.java b/src/main/java/mekanism/generators/client/gui/GeneratorsGuiFactory.java index 5b502303a..a7de280d9 100644 --- a/src/main/java/mekanism/generators/client/gui/GeneratorsGuiFactory.java +++ b/src/main/java/mekanism/generators/client/gui/GeneratorsGuiFactory.java @@ -12,7 +12,6 @@ public class GeneratorsGuiFactory implements IModGuiFactory { @Override public void initialize(Minecraft minecraftInstance) { - } @Override @@ -29,4 +28,4 @@ public class GeneratorsGuiFactory implements IModGuiFactory { public GuiScreen createConfigGui(GuiScreen parentScreen) { return new GuiGeneratorsConfig(parentScreen); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/client/gui/GuiBioGenerator.java b/src/main/java/mekanism/generators/client/gui/GuiBioGenerator.java index e7e9f2296..3c6e3886e 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiBioGenerator.java +++ b/src/main/java/mekanism/generators/client/gui/GuiBioGenerator.java @@ -30,11 +30,8 @@ public class GuiBioGenerator extends GuiMekanismTile { addGuiElement(new GuiRedstoneControl(this, tileEntity, resource)); addGuiElement(new GuiSecurityTab(this, tileEntity, resource)); addGuiElement(new GuiEnergyInfo(() -> Arrays.asList( - LangUtils.localize("gui.producing") + ": " + MekanismUtils - .getEnergyDisplay( - tileEntity.getActive() ? MekanismConfig.current().generators.bioGeneration.val() : 0) + "/t", - LangUtils.localize("gui.maxOutput") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) - + "/t"), this, resource)); + LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getActive() ? MekanismConfig.current().generators.bioGeneration.val() : 0) + "/t", + LangUtils.localize("gui.maxOutput") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t"), this, resource)); addGuiElement(new GuiPowerBar(this, tileEntity, resource, 164, 15)); addGuiElement(new GuiSlot(SlotType.NORMAL, this, resource, 16, 34)); addGuiElement(new GuiSlot(SlotType.NORMAL, this, resource, 142, 34).with(SlotOverlay.POWER)); @@ -45,12 +42,8 @@ public class GuiBioGenerator extends GuiMekanismTile { fontRenderer.drawString(tileEntity.getName(), 45, 6, 0x404040); fontRenderer.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00); - fontRenderer - .drawString(LangUtils.localize("gui.bioGenerator.bioFuel") + ": " + tileEntity.bioFuelSlot.fluidStored, - 51, 35, 0x00CD00); - fontRenderer.drawString( - LangUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", - 51, 44, 0x00CD00); + fontRenderer.drawString(LangUtils.localize("gui.bioGenerator.bioFuel") + ": " + tileEntity.bioFuelSlot.fluidStored, 51, 35, 0x00CD00); + fontRenderer.drawString(LangUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", 51, 44, 0x00CD00); super.drawGuiContainerForegroundLayer(mouseX, mouseY); } diff --git a/src/main/java/mekanism/generators/client/gui/GuiGasGenerator.java b/src/main/java/mekanism/generators/client/gui/GuiGasGenerator.java index c1986e9d6..dea30ea46 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiGasGenerator.java +++ b/src/main/java/mekanism/generators/client/gui/GuiGasGenerator.java @@ -31,10 +31,8 @@ public class GuiGasGenerator extends GuiMekanismTile { addGuiElement(new GuiRedstoneControl(this, tileEntity, resource)); addGuiElement(new GuiSecurityTab(this, tileEntity, resource)); addGuiElement(new GuiEnergyInfo(() -> Arrays.asList( - LangUtils.localize("gui.producing") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.generationRate * tileEntity.clientUsed) + "/t", - LangUtils.localize("gui.maxOutput") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) - + "/t"), this, resource)); + LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.generationRate * tileEntity.clientUsed) + "/t", + LangUtils.localize("gui.maxOutput") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t"), this, resource)); addGuiElement(new GuiGasGauge(() -> tileEntity.fuelTank, Type.WIDE, this, resource, 55, 18)); addGuiElement(new GuiPowerBar(this, tileEntity, resource, 164, 15)); addGuiElement(new GuiSlot(SlotType.NORMAL, this, resource, 16, 34).with(SlotOverlay.MINUS)); @@ -43,9 +41,7 @@ public class GuiGasGenerator extends GuiMekanismTile { @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - fontRenderer - .drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), - 6, 0x404040); + fontRenderer.drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), 6, 0x404040); fontRenderer.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); String s = LangUtils.localize("gui.burnRate") + ": " + tileEntity.clientUsed; fontRenderer.drawString(s, xSize - 8 - fontRenderer.getStringWidth(s), (ySize - 96) + 2, 0x404040); diff --git a/src/main/java/mekanism/generators/client/gui/GuiGeneratorsConfig.java b/src/main/java/mekanism/generators/client/gui/GuiGeneratorsConfig.java index eafb100bb..03f8eb873 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiGeneratorsConfig.java +++ b/src/main/java/mekanism/generators/client/gui/GuiGeneratorsConfig.java @@ -27,12 +27,9 @@ public class GuiGeneratorsConfig extends GuiConfig { private static List getConfigElements() { List list = new ArrayList<>(); - list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.generators.general"), - "mekanism.configgui.ctgy.generators.general", GeneralEntry.class)); - list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.generators.generators"), - "mekanism.configgui.ctgy.generators.generators", GeneratorsEntry.class)); - list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.generators.generation"), - "mekanism.configgui.ctgy.generators.generation", GenerationEntry.class)); + list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.generators.general"), "mekanism.configgui.ctgy.generators.general", GeneralEntry.class)); + list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.generators.generators"), "mekanism.configgui.ctgy.generators.generators", GeneratorsEntry.class)); + list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.generators.generation"), "mekanism.configgui.ctgy.generators.generation", GenerationEntry.class)); return list; } @@ -44,11 +41,8 @@ public class GuiGeneratorsConfig extends GuiConfig { @Override protected GuiScreen buildChildScreen() { - return new GuiConfig(owningScreen, - new ConfigElement(Mekanism.configuration.getCategory(Configuration.CATEGORY_GENERAL)) - .getChildElements(), - owningScreen.modID, Configuration.CATEGORY_GENERAL, false, false, - GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); + return new GuiConfig(owningScreen, new ConfigElement(Mekanism.configuration.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), owningScreen.modID, + Configuration.CATEGORY_GENERAL, false, false, GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); } } @@ -60,10 +54,8 @@ public class GuiGeneratorsConfig extends GuiConfig { @Override protected GuiScreen buildChildScreen() { - return new GuiConfig(owningScreen, - new ConfigElement(Mekanism.configuration.getCategory("generators")).getChildElements(), - owningScreen.modID, Configuration.CATEGORY_GENERAL, false, false, - GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); + return new GuiConfig(owningScreen, new ConfigElement(Mekanism.configuration.getCategory("generators")).getChildElements(), owningScreen.modID, + Configuration.CATEGORY_GENERAL, false, false, GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); } } @@ -75,10 +67,8 @@ public class GuiGeneratorsConfig extends GuiConfig { @Override protected GuiScreen buildChildScreen() { - return new GuiConfig(owningScreen, - new ConfigElement(Mekanism.configuration.getCategory("generation")).getChildElements(), - owningScreen.modID, Configuration.CATEGORY_GENERAL, false, false, - GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); + return new GuiConfig(owningScreen, new ConfigElement(Mekanism.configuration.getCategory("generation")).getChildElements(), owningScreen.modID, + Configuration.CATEGORY_GENERAL, false, false, GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/client/gui/GuiHeatGenerator.java b/src/main/java/mekanism/generators/client/gui/GuiHeatGenerator.java index 841cf5af9..b7e66e786 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiHeatGenerator.java +++ b/src/main/java/mekanism/generators/client/gui/GuiHeatGenerator.java @@ -35,10 +35,8 @@ public class GuiHeatGenerator extends GuiMekanismTile { addGuiElement(new GuiRedstoneControl(this, tileEntity, resource)); addGuiElement(new GuiSecurityTab(this, tileEntity, resource)); addGuiElement(new GuiEnergyInfo(() -> Arrays.asList( - LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.producingEnergy) - + "/t", - LangUtils.localize("gui.maxOutput") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) - + "/t"), this, resource)); + LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.producingEnergy) + "/t", + LangUtils.localize("gui.maxOutput") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t"), this, resource)); addGuiElement(new GuiFluidGauge(() -> tileEntity.lavaTank, Type.WIDE, this, resource, 55, 18)); addGuiElement(new GuiPowerBar(this, tileEntity, resource, 164, 15)); addGuiElement(new GuiSlot(SlotType.NORMAL, this, resource, 16, 34)); @@ -47,8 +45,7 @@ public class GuiHeatGenerator extends GuiMekanismTile { TemperatureUnit unit = TemperatureUnit.values()[MekanismConfig.current().general.tempUnit.val().ordinal()]; String transfer = UnitDisplayUtils.getDisplayShort(tileEntity.lastTransferLoss, false, unit); String environment = UnitDisplayUtils.getDisplayShort(tileEntity.lastEnvironmentLoss, false, unit); - return Arrays.asList(LangUtils.localize("gui.transferred") + ": " + transfer + "/t", - LangUtils.localize("gui.dissipated") + ": " + environment + "/t"); + return Arrays.asList(LangUtils.localize("gui.transferred") + ": " + transfer + "/t", LangUtils.localize("gui.dissipated") + ": " + environment + "/t"); }, this, resource)); } diff --git a/src/main/java/mekanism/generators/client/gui/GuiIndustrialTurbine.java b/src/main/java/mekanism/generators/client/gui/GuiIndustrialTurbine.java index 0089e86a9..bf4a6ac25 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiIndustrialTurbine.java +++ b/src/main/java/mekanism/generators/client/gui/GuiIndustrialTurbine.java @@ -45,64 +45,44 @@ public class GuiIndustrialTurbine extends GuiEmbeddedGaugeTile { - double energyMultiplier = - (MekanismConfig.current().general.maxEnergyPerSteam.val() / TurbineUpdateProtocol.MAX_BLADES) * Math - .min(tileEntity.structure.blades, - tileEntity.structure.coils * MekanismConfig.current().generators.turbineBladesPerCoil - .val()); + double energyMultiplier = (MekanismConfig.current().general.maxEnergyPerSteam.val() / TurbineUpdateProtocol.MAX_BLADES) * + Math.min(tileEntity.structure.blades, tileEntity.structure.coils * MekanismConfig.current().generators.turbineBladesPerCoil.val()); return Arrays.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), - LangUtils.localize("gui.producing") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.structure.clientFlow * energyMultiplier) + "/t"); + LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), + LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.clientFlow * energyMultiplier) + "/t"); }, this, resource)); } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { fontRenderer.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 4, 0x404040); - fontRenderer - .drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), - 5, 0x404040); - double energyMultiplier = - (MekanismConfig.current().general.maxEnergyPerSteam.val() / TurbineUpdateProtocol.MAX_BLADES) * Math - .min(tileEntity.structure.blades, - tileEntity.structure.coils * MekanismConfig.current().generators.turbineBladesPerCoil.val()); - double rate = tileEntity.structure.lowerVolume * (tileEntity.structure.clientDispersers - * MekanismConfig.current().generators.turbineDisperserGasFlow.val()); - rate = Math - .min(rate, tileEntity.structure.vents * MekanismConfig.current().generators.turbineVentGasFlow.val()); - renderScaledText(LangUtils.localize("gui.production") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.structure.clientFlow * energyMultiplier), 53, 26, 0x00CD00, 106); - renderScaledText(LangUtils.localize("gui.flowRate") + ": " + tileEntity.structure.clientFlow + " mB/t", 53, 35, - 0x00CD00, 106); - renderScaledText(LangUtils.localize("gui.capacity") + ": " + tileEntity.structure.getFluidCapacity() + " mB", - 53, 44, 0x00CD00, 106); + fontRenderer.drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), 5, 0x404040); + double energyMultiplier = (MekanismConfig.current().general.maxEnergyPerSteam.val() / TurbineUpdateProtocol.MAX_BLADES) * + Math.min(tileEntity.structure.blades, tileEntity.structure.coils * MekanismConfig.current().generators.turbineBladesPerCoil.val()); + double rate = tileEntity.structure.lowerVolume * (tileEntity.structure.clientDispersers * MekanismConfig.current().generators.turbineDisperserGasFlow.val()); + rate = Math.min(rate, tileEntity.structure.vents * MekanismConfig.current().generators.turbineVentGasFlow.val()); + renderScaledText(LangUtils.localize("gui.production") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.structure.clientFlow * energyMultiplier), 53, 26, 0x00CD00, 106); + renderScaledText(LangUtils.localize("gui.flowRate") + ": " + tileEntity.structure.clientFlow + " mB/t", 53, 35, 0x00CD00, 106); + renderScaledText(LangUtils.localize("gui.capacity") + ": " + tileEntity.structure.getFluidCapacity() + " mB", 53, 44, 0x00CD00, 106); renderScaledText(LangUtils.localize("gui.maxFlow") + ": " + rate + " mB/t", 53, 53, 0x00CD00, 106); - String name = chooseByMode(tileEntity.structure.dumpMode, LangUtils.localize("gui.idle"), - LangUtils.localize("gui.dumping"), LangUtils.localize("gui.dumping_excess")); - renderScaledText(name, 156 - (int) (fontRenderer.getStringWidth(name) * getNeededScale(name, 66)), 73, 0x404040, - 66); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + String name = chooseByMode(tileEntity.structure.dumpMode, LangUtils.localize("gui.idle"), LangUtils.localize("gui.dumping"), LangUtils.localize("gui.dumping_excess")); + renderScaledText(name, 156 - (int) (fontRenderer.getStringWidth(name) * getNeededScale(name, 66)), 73, 0x404040, 66); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; if (xAxis >= 7 && xAxis <= 39 && yAxis >= 14 && yAxis <= 72) { - drawHoveringText(tileEntity.structure.fluidStored != null ? - LangUtils.localizeFluidStack(tileEntity.structure.fluidStored) + ": " - + tileEntity.structure.fluidStored.amount + "mB" : LangUtils.localize("gui.empty"), xAxis, - yAxis); + drawHoveringText(tileEntity.structure.fluidStored != null + ? LangUtils.localizeFluidStack(tileEntity.structure.fluidStored) + ": " + tileEntity.structure.fluidStored.amount + "mB" + : LangUtils.localize("gui.empty"), xAxis, yAxis); } super.drawGuiContainerForegroundLayer(mouseX, mouseY); } @@ -132,8 +112,8 @@ public class GuiIndustrialTurbine extends GuiEmbeddedGaugeTile 160 && xAxis < 169 && yAxis > 73 && yAxis < 82) { TileNetworkList data = TileNetworkList.withContents((byte) 0); Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); diff --git a/src/main/java/mekanism/generators/client/gui/GuiReactorController.java b/src/main/java/mekanism/generators/client/gui/GuiReactorController.java index 970bc1afa..be2358b5b 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiReactorController.java +++ b/src/main/java/mekanism/generators/client/gui/GuiReactorController.java @@ -28,12 +28,10 @@ public class GuiReactorController extends GuiMekanismTile tileEntity.isFormed() ? Arrays.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), - LangUtils.localize("gui.producing") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getReactor().getPassiveGeneration(false, true)) + "/t") - : new ArrayList<>(), this, resource)); - addGuiElement(new GuiSlot(SlotType.NORMAL, this, resource, 79, 38)); + LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), + LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getReactor().getPassiveGeneration(false, true)) + "/t") + : new ArrayList<>(), this, resource)); + addGuiElement(new GuiSlot(SlotType.NORMAL, this, resource, 79, 38)); addGuiElement(new GuiHeatTab(this, tileEntity, resource)); addGuiElement(new GuiFuelTab(this, tileEntity, resource)); addGuiElement(new GuiStatTab(this, tileEntity, resource)); diff --git a/src/main/java/mekanism/generators/client/gui/GuiReactorFuel.java b/src/main/java/mekanism/generators/client/gui/GuiReactorFuel.java index 48d102f31..df495abae 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiReactorFuel.java +++ b/src/main/java/mekanism/generators/client/gui/GuiReactorFuel.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import mekanism.api.Coord4D; +import mekanism.api.TileNetworkList; import mekanism.client.gui.GuiMekanismTile; import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiGasGauge; @@ -13,7 +14,6 @@ import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler; import mekanism.client.gui.element.GuiProgress.ProgressBar; import mekanism.client.sound.SoundHandler; import mekanism.common.Mekanism; -import mekanism.api.TileNetworkList; import mekanism.common.inventory.container.ContainerNull; import mekanism.common.network.PacketSimpleGui.SimpleGuiMessage; import mekanism.common.network.PacketTileEntity.TileEntityMessage; @@ -41,11 +41,9 @@ public class GuiReactorFuel extends GuiMekanismTile super(tile, new ContainerNull(inventory.player, tile)); ResourceLocation resource = getGuiLocation(); addGuiElement(new GuiEnergyInfo(() -> tileEntity.isFormed() ? Arrays.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), - LangUtils.localize("gui.producing") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getReactor().getPassiveGeneration(false, true)) + "/t") - : new ArrayList<>(), this, resource)); + LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), + LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getReactor().getPassiveGeneration(false, true)) + "/t") + : new ArrayList<>(), this, resource)); addGuiElement(new GuiGasGauge(() -> tileEntity.deuteriumTank, Type.SMALL, this, resource, 25, 64)); addGuiElement(new GuiGasGauge(() -> tileEntity.fuelTank, Type.STANDARD, this, resource, 79, 50)); addGuiElement(new GuiGasGauge(() -> tileEntity.tritiumTank, Type.SMALL, this, resource, 133, 64)); @@ -69,8 +67,7 @@ public class GuiReactorFuel extends GuiMekanismTile protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { super.drawGuiContainerForegroundLayer(mouseX, mouseY); fontRenderer.drawString(tileEntity.getName(), 46, 6, 0x404040); - String str = LangUtils.localize("gui.reactor.injectionRate") + ": " + (tileEntity.getReactor() == null ? "None" - : tileEntity.getReactor().getInjectionRate()); + String str = LangUtils.localize("gui.reactor.injectionRate") + ": " + (tileEntity.getReactor() == null ? "None" : tileEntity.getReactor().getInjectionRate()); fontRenderer.drawString(str, (xSize / 2) - (fontRenderer.getStringWidth(str) / 2), 35, 0x404040); fontRenderer.drawString("Edit Rate" + ":", 50, 117, 0x404040); } @@ -82,15 +79,14 @@ public class GuiReactorFuel extends GuiMekanismTile 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); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; if (xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, 0, 14, 14); } else { drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, 14, 14, 14); } super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - injectionRateField.drawTextBox(); } @@ -104,8 +100,8 @@ public class GuiReactorFuel extends GuiMekanismTile public void mouseClicked(int mouseX, int mouseY, int button) throws IOException { super.mouseClicked(mouseX, mouseY, button); injectionRateField.mouseClicked(mouseX, mouseY, button); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; if (button == 0) { if (xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); diff --git a/src/main/java/mekanism/generators/client/gui/GuiReactorHeat.java b/src/main/java/mekanism/generators/client/gui/GuiReactorHeat.java index 4d6f14c16..6443c6e69 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiReactorHeat.java +++ b/src/main/java/mekanism/generators/client/gui/GuiReactorHeat.java @@ -43,11 +43,9 @@ public class GuiReactorHeat extends GuiMekanismTile super(tile, new ContainerNull(inventory.player, tile)); ResourceLocation resource = getGuiLocation(); addGuiElement(new GuiEnergyInfo(() -> tileEntity.isFormed() ? Arrays.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), - LangUtils.localize("gui.producing") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getReactor().getPassiveGeneration(false, true)) + "/t") - : new ArrayList<>(), this, resource)); + LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), + LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getReactor().getPassiveGeneration(false, true)) + "/t") + : new ArrayList<>(), this, resource)); addGuiElement(new GuiNumberGauge(new INumberInfoHandler() { @Override public TextureAtlasSprite getIcon() { @@ -105,8 +103,7 @@ public class GuiReactorHeat extends GuiMekanismTile addGuiElement(new GuiProgress(new IProgressInfoHandler() { @Override public double getProgress() { - return (tileEntity.getCaseTemp() > 0 && tileEntity.waterTank.getFluidAmount() > 0 - && tileEntity.steamTank.getFluidAmount() < tileEntity.steamTank.getCapacity()) ? 1 : 0; + return (tileEntity.getCaseTemp() > 0 && tileEntity.waterTank.getFluidAmount() > 0 && tileEntity.steamTank.getFluidAmount() < tileEntity.steamTank.getCapacity()) ? 1 : 0; } }, ProgressBar.SMALL_RIGHT, this, resource, 81, 90)); addGuiElement(new GuiFluidGauge(() -> tileEntity.waterTank, Type.SMALL, this, resource, 115, 84)); @@ -129,8 +126,8 @@ public class GuiReactorHeat extends GuiMekanismTile 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); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; if (xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, 0, 14, 14); } else { @@ -142,8 +139,8 @@ public class GuiReactorHeat extends GuiMekanismTile @Override public void mouseClicked(int mouseX, int mouseY, int button) throws IOException { super.mouseClicked(mouseX, mouseY, button); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = mouseX - (width - xSize) / 2; + int yAxis = mouseY - (height - ySize) / 2; if (button == 0) { if (xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); diff --git a/src/main/java/mekanism/generators/client/gui/GuiReactorLogicAdapter.java b/src/main/java/mekanism/generators/client/gui/GuiReactorLogicAdapter.java index ad9243891..aca6fe34d 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiReactorLogicAdapter.java +++ b/src/main/java/mekanism/generators/client/gui/GuiReactorLogicAdapter.java @@ -3,11 +3,11 @@ package mekanism.generators.client.gui; import java.io.IOException; import mekanism.api.Coord4D; import mekanism.api.EnumColor; +import mekanism.api.TileNetworkList; import mekanism.client.gui.GuiMekanismTile; import mekanism.client.render.MekanismRenderer; import mekanism.client.sound.SoundHandler; import mekanism.common.Mekanism; -import mekanism.api.TileNetworkList; import mekanism.common.inventory.container.ContainerNull; import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.util.LangUtils; @@ -34,15 +34,10 @@ public class GuiReactorLogicAdapter extends GuiMekanismTile= 24 && xAxis <= 152 && yAxis >= 32 + (22 * type.ordinal()) && yAxis <= 32 + 22 + (22 * type - .ordinal())) { + if (xAxis >= 24 && xAxis <= 152 && yAxis >= 32 + (22 * type.ordinal()) && yAxis <= 32 + 22 + (22 * type.ordinal())) { displayTooltips(MekanismUtils.splitTooltip(type.getDescription(), ItemStack.EMPTY), xAxis, yAxis); } } @@ -74,12 +67,11 @@ public class GuiReactorLogicAdapter extends GuiMekanismTile= 23 && xAxis <= 34 && yAxis >= 19 && yAxis <= 30) { @@ -94,8 +86,8 @@ public class GuiReactorLogicAdapter extends GuiMekanismTile= 23 && xAxis <= 34 && yAxis >= 19 && yAxis <= 30) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); TileNetworkList data = TileNetworkList.withContents(0); @@ -103,8 +95,7 @@ public class GuiReactorLogicAdapter extends GuiMekanismTile= 24 && xAxis <= 152 && yAxis >= 32 + (22 * type.ordinal()) && yAxis <= 32 + 22 + (22 * type - .ordinal())) { + if (xAxis >= 24 && xAxis <= 152 && yAxis >= 32 + (22 * type.ordinal()) && yAxis <= 32 + 22 + (22 * type.ordinal())) { if (type != tileEntity.logicType) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); TileNetworkList data = TileNetworkList.withContents(1, type.ordinal()); diff --git a/src/main/java/mekanism/generators/client/gui/GuiReactorStats.java b/src/main/java/mekanism/generators/client/gui/GuiReactorStats.java index da91c0ea5..a5a20d069 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiReactorStats.java +++ b/src/main/java/mekanism/generators/client/gui/GuiReactorStats.java @@ -35,11 +35,9 @@ public class GuiReactorStats extends GuiMekanismTile tileEntity.isFormed() ? Arrays.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), - LangUtils.localize("gui.producing") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getReactor().getPassiveGeneration(false, true)) + "/t") - : new ArrayList<>(), this, resource)); + LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), + LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getReactor().getPassiveGeneration(false, true)) + "/t") + : new ArrayList<>(), this, resource)); addGuiElement(new GuiHeatTab(this, tileEntity, resource)); addGuiElement(new GuiFuelTab(this, tileEntity, resource)); } @@ -49,39 +47,26 @@ public class GuiReactorStats extends GuiMekanismTile= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, 0, 14, 14); } else { @@ -106,8 +91,8 @@ public class GuiReactorStats extends GuiMekanismTile= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); diff --git a/src/main/java/mekanism/generators/client/gui/GuiSolarGenerator.java b/src/main/java/mekanism/generators/client/gui/GuiSolarGenerator.java index 865b90045..1dab9b5bf 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiSolarGenerator.java +++ b/src/main/java/mekanism/generators/client/gui/GuiSolarGenerator.java @@ -35,12 +35,8 @@ public class GuiSolarGenerator extends GuiMekanismTile protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { fontRenderer.drawString(tileEntity.getName(), !tileEntity.fullName.contains("Advanced") ? 45 : 30, 6, 0x404040); fontRenderer.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - - renderCenteredText(48, 80, 28, 0x00CD00, - LangUtils.localize("gui.producing")); - renderCenteredText(48, 80, 42, 0x00CD00, - MekanismUtils.getEnergyDisplay(tileEntity.getProduction()) + "/t"); - + renderCenteredText(48, 80, 28, 0x00CD00, LangUtils.localize("gui.producing")); + renderCenteredText(48, 80, 42, 0x00CD00, MekanismUtils.getEnergyDisplay(tileEntity.getProduction()) + "/t"); super.drawGuiContainerForegroundLayer(mouseX, mouseY); } @@ -51,7 +47,7 @@ public class GuiSolarGenerator extends GuiMekanismTile int guiWidth = (width - xSize) / 2; int guiHeight = (height - ySize) / 2; drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - drawTexturedModalRect(guiWidth + 20, guiHeight + 37, 176, (tileEntity.canSeeSun() ? 52 : 64), 12, 12); + drawTexturedModalRect(guiWidth + 20, guiHeight + 37, 176, tileEntity.canSeeSun() ? 52 : 64, 12, 12); super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); } diff --git a/src/main/java/mekanism/generators/client/gui/GuiTurbineStats.java b/src/main/java/mekanism/generators/client/gui/GuiTurbineStats.java index 3a1937642..aa5fc2eb2 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiTurbineStats.java +++ b/src/main/java/mekanism/generators/client/gui/GuiTurbineStats.java @@ -27,16 +27,11 @@ public class GuiTurbineStats extends GuiMekanismTile { ResourceLocation resource = getGuiLocation(); addGuiElement(new GuiTurbineTab(this, tileEntity, TurbineTab.MAIN, 6, resource)); addGuiElement(new GuiEnergyInfo(() -> { - double energyMultiplier = - (MekanismConfig.current().general.maxEnergyPerSteam.val() / TurbineUpdateProtocol.MAX_BLADES) * Math - .min(tileEntity.structure.blades, - tileEntity.structure.coils * MekanismConfig.current().generators.turbineBladesPerCoil - .val()); + double energyMultiplier = (MekanismConfig.current().general.maxEnergyPerSteam.val() / TurbineUpdateProtocol.MAX_BLADES) * + Math.min(tileEntity.structure.blades, tileEntity.structure.coils * MekanismConfig.current().generators.turbineBladesPerCoil.val()); return Arrays.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), - LangUtils.localize("gui.producing") + ": " + MekanismUtils - .getEnergyDisplay(tileEntity.structure.clientFlow * energyMultiplier) + "/t"); + LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), + LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.clientFlow * energyMultiplier) + "/t"); }, this, resource)); } @@ -45,44 +40,27 @@ public class GuiTurbineStats extends GuiMekanismTile { String stats = LangUtils.localize("gui.turbineStats"); String limiting = EnumColor.DARK_RED + " (" + LangUtils.localize("gui.limiting") + ")"; fontRenderer.drawString(stats, (xSize / 2) - (fontRenderer.getStringWidth(stats) / 2), 6, 0x404040); - fontRenderer.drawString(LangUtils.localize("gui.tankVolume") + ": " + tileEntity.structure.lowerVolume, 8, 26, - 0x404040); - boolean dispersersLimiting = tileEntity.structure.lowerVolume * tileEntity.structure.clientDispersers - * MekanismConfig.current().generators.turbineDisperserGasFlow.val() < - tileEntity.structure.vents * MekanismConfig.current().generators.turbineVentGasFlow.val(); - boolean ventsLimiting = tileEntity.structure.lowerVolume * tileEntity.structure.clientDispersers - * MekanismConfig.current().generators.turbineDisperserGasFlow.val() > - tileEntity.structure.vents * MekanismConfig.current().generators.turbineVentGasFlow.val(); + fontRenderer.drawString(LangUtils.localize("gui.tankVolume") + ": " + tileEntity.structure.lowerVolume, 8, 26, 0x404040); + boolean dispersersLimiting = tileEntity.structure.lowerVolume * tileEntity.structure.clientDispersers * MekanismConfig.current().generators.turbineDisperserGasFlow.val() + < tileEntity.structure.vents * MekanismConfig.current().generators.turbineVentGasFlow.val(); + boolean ventsLimiting = tileEntity.structure.lowerVolume * tileEntity.structure.clientDispersers * MekanismConfig.current().generators.turbineDisperserGasFlow.val() + > tileEntity.structure.vents * MekanismConfig.current().generators.turbineVentGasFlow.val(); fontRenderer.drawString(LangUtils.localize("gui.steamFlow"), 8, 40, 0x797979); - fontRenderer.drawString( - LangUtils.localize("gui.dispersers") + ": " + tileEntity.structure.clientDispersers + (dispersersLimiting - ? limiting : ""), 14, 49, 0x404040); - fontRenderer.drawString( - LangUtils.localize("gui.vents") + ": " + tileEntity.structure.vents + (ventsLimiting ? limiting : ""), 14, - 58, 0x404040); + fontRenderer.drawString(LangUtils.localize("gui.dispersers") + ": " + tileEntity.structure.clientDispersers + (dispersersLimiting ? limiting : ""), 14, 49, 0x404040); + fontRenderer.drawString(LangUtils.localize("gui.vents") + ": " + tileEntity.structure.vents + (ventsLimiting ? limiting : ""), 14, 58, 0x404040); boolean bladesLimiting = tileEntity.structure.coils * 4 > tileEntity.structure.blades; boolean coilsLimiting = tileEntity.structure.coils * 4 < tileEntity.structure.blades; fontRenderer.drawString(LangUtils.localize("gui.production"), 8, 72, 0x797979); - fontRenderer.drawString( - LangUtils.localize("gui.blades") + ": " + tileEntity.structure.blades + (bladesLimiting ? limiting : ""), - 14, 81, 0x404040); - fontRenderer.drawString( - LangUtils.localize("gui.coils") + ": " + tileEntity.structure.coils + (coilsLimiting ? limiting : ""), 14, - 90, 0x404040); - double energyMultiplier = - (MekanismConfig.current().general.maxEnergyPerSteam.val() / TurbineUpdateProtocol.MAX_BLADES) * Math - .min(tileEntity.structure.blades, - tileEntity.structure.coils * MekanismConfig.current().generators.turbineBladesPerCoil.val()); + fontRenderer.drawString(LangUtils.localize("gui.blades") + ": " + tileEntity.structure.blades + (bladesLimiting ? limiting : ""), 14, 81, 0x404040); + fontRenderer.drawString(LangUtils.localize("gui.coils") + ": " + tileEntity.structure.coils + (coilsLimiting ? limiting : ""), 14, 90, 0x404040); + double energyMultiplier = (MekanismConfig.current().general.maxEnergyPerSteam.val() / TurbineUpdateProtocol.MAX_BLADES) * + Math.min(tileEntity.structure.blades, tileEntity.structure.coils * MekanismConfig.current().generators.turbineBladesPerCoil.val()); double rate = tileEntity.structure.lowerVolume * (tileEntity.structure.clientDispersers - * MekanismConfig.current().generators.turbineDisperserGasFlow.val()); - rate = Math - .min(rate, tileEntity.structure.vents * MekanismConfig.current().generators.turbineVentGasFlow.val()); - fontRenderer.drawString( - LangUtils.localize("gui.maxProduction") + ": " + MekanismUtils.getEnergyDisplay(rate * energyMultiplier), - 8, 104, 0x404040); - fontRenderer.drawString(LangUtils.localize("gui.maxWaterOutput") + ": " - + tileEntity.structure.condensers * MekanismConfig.current().generators.condenserRate.val() + " mB/t", 8, - 113, 0x404040); + * MekanismConfig.current().generators.turbineDisperserGasFlow.val()); + rate = Math.min(rate, tileEntity.structure.vents * MekanismConfig.current().generators.turbineVentGasFlow.val()); + fontRenderer.drawString(LangUtils.localize("gui.maxProduction") + ": " + MekanismUtils.getEnergyDisplay(rate * energyMultiplier), 8, 104, 0x404040); + fontRenderer.drawString(LangUtils.localize("gui.maxWaterOutput") + ": " + + tileEntity.structure.condensers * MekanismConfig.current().generators.condenserRate.val() + " mB/t", 8, 113, 0x404040); super.drawGuiContainerForegroundLayer(mouseX, mouseY); } diff --git a/src/main/java/mekanism/generators/client/gui/GuiWindGenerator.java b/src/main/java/mekanism/generators/client/gui/GuiWindGenerator.java index 5e34aa633..be2ec2b4a 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiWindGenerator.java +++ b/src/main/java/mekanism/generators/client/gui/GuiWindGenerator.java @@ -34,11 +34,9 @@ public class GuiWindGenerator extends GuiMekanismTile { addGuiElement(new GuiRedstoneControl(this, tileEntity, resource)); addGuiElement(new GuiSecurityTab(this, tileEntity, resource)); addGuiElement(new GuiEnergyInfo(() -> Arrays.asList( - LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay( - tileEntity.getActive() ? MekanismConfig.current().generators.windGenerationMin.val() * tileEntity - .getCurrentMultiplier() : 0) + "/t", - LangUtils.localize("gui.maxOutput") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) - + "/t"), this, resource)); + LangUtils.localize("gui.producing") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.getActive() ? MekanismConfig.current().generators.windGenerationMin.val() * tileEntity.getCurrentMultiplier() : 0) + "/t", + LangUtils.localize("gui.maxOutput") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t"), this, resource)); addGuiElement(new GuiPowerBar(this, tileEntity, resource, 164, 15)); addGuiElement(new GuiSlot(SlotType.NORMAL, this, resource, 142, 34).with(SlotOverlay.POWER)); } @@ -47,16 +45,10 @@ public class GuiWindGenerator extends GuiMekanismTile { protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { fontRenderer.drawString(tileEntity.getName(), 45, 6, 0x404040); fontRenderer.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - fontRenderer - .drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), 51, 26, - 0x00CD00); - fontRenderer.drawString(LangUtils.localize("gui.power") + ": " + powerFormat - .format(MekanismUtils.convertToDisplay( - MekanismConfig.current().generators.windGenerationMin.val() * tileEntity.getCurrentMultiplier())), - 51, 35, 0x00CD00); - fontRenderer.drawString( - LangUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", - 51, 44, 0x00CD00); + fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), 51, 26, 0x00CD00); + fontRenderer.drawString(LangUtils.localize("gui.power") + ": " + powerFormat.format(MekanismUtils.convertToDisplay( + MekanismConfig.current().generators.windGenerationMin.val() * tileEntity.getCurrentMultiplier())), 51, 35, 0x00CD00); + fontRenderer.drawString(LangUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", 51, 44, 0x00CD00); int size = 44; if (!tileEntity.getActive()) { size += 9; @@ -76,7 +68,7 @@ public class GuiWindGenerator extends GuiMekanismTile { int guiWidth = (width - xSize) / 2; int guiHeight = (height - ySize) / 2; drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - drawTexturedModalRect(guiWidth + 20, guiHeight + 37, 176, (tileEntity.getActive() ? 52 : 64), 12, 12); + drawTexturedModalRect(guiWidth + 20, guiHeight + 37, 176, tileEntity.getActive() ? 52 : 64, 12, 12); super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); } diff --git a/src/main/java/mekanism/generators/client/jei/GeneratorsJEI.java b/src/main/java/mekanism/generators/client/jei/GeneratorsJEI.java index 335b7f252..3358f3914 100644 --- a/src/main/java/mekanism/generators/client/jei/GeneratorsJEI.java +++ b/src/main/java/mekanism/generators/client/jei/GeneratorsJEI.java @@ -12,7 +12,6 @@ public class GeneratorsJEI implements IModPlugin { @Override public void registerItemSubtypes(ISubtypeRegistry registry) { - registry.registerSubtypeInterpreter(Item.getItemFromBlock(GeneratorsBlocks.Generator), - MekanismJEI.NBT_INTERPRETER); + registry.registerSubtypeInterpreter(Item.getItemFromBlock(GeneratorsBlocks.Generator), MekanismJEI.NBT_INTERPRETER); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/client/model/ModelAdvancedSolarGenerator.java b/src/main/java/mekanism/generators/client/model/ModelAdvancedSolarGenerator.java index e6c56261d..4d99c13fe 100644 --- a/src/main/java/mekanism/generators/client/model/ModelAdvancedSolarGenerator.java +++ b/src/main/java/mekanism/generators/client/model/ModelAdvancedSolarGenerator.java @@ -151,4 +151,4 @@ public class ModelAdvancedSolarGenerator extends ModelBase { model.rotateAngleY = y; model.rotateAngleZ = z; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/client/model/ModelBioGenerator.java b/src/main/java/mekanism/generators/client/model/ModelBioGenerator.java index 1a90258c2..e82dfbd2a 100644 --- a/src/main/java/mekanism/generators/client/model/ModelBioGenerator.java +++ b/src/main/java/mekanism/generators/client/model/ModelBioGenerator.java @@ -72,4 +72,4 @@ public class ModelBioGenerator extends ModelBase { model.rotateAngleY = y; model.rotateAngleZ = z; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/client/model/ModelGasGenerator.java b/src/main/java/mekanism/generators/client/model/ModelGasGenerator.java index 222d8bbb5..02a3f2269 100644 --- a/src/main/java/mekanism/generators/client/model/ModelGasGenerator.java +++ b/src/main/java/mekanism/generators/client/model/ModelGasGenerator.java @@ -175,4 +175,4 @@ public class ModelGasGenerator extends ModelBase { model.rotateAngleY = y; model.rotateAngleZ = z; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/client/model/ModelHeatGenerator.java b/src/main/java/mekanism/generators/client/model/ModelHeatGenerator.java index 96222d306..fddbc0117 100644 --- a/src/main/java/mekanism/generators/client/model/ModelHeatGenerator.java +++ b/src/main/java/mekanism/generators/client/model/ModelHeatGenerator.java @@ -14,10 +14,8 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ModelHeatGenerator extends ModelBase { - public static ResourceLocation OVERLAY_ON = MekanismUtils - .getResource(ResourceType.RENDER, "HeatGenerator_OverlayOn.png"); - public static ResourceLocation OVERLAY_OFF = MekanismUtils - .getResource(ResourceType.RENDER, "HeatGenerator_OverlayOff.png"); + public static ResourceLocation OVERLAY_ON = MekanismUtils.getResource(ResourceType.RENDER, "HeatGenerator_OverlayOn.png"); + public static ResourceLocation OVERLAY_OFF = MekanismUtils.getResource(ResourceType.RENDER, "HeatGenerator_OverlayOff.png"); ModelRenderer drum; ModelRenderer ring1; diff --git a/src/main/java/mekanism/generators/client/model/ModelSolarGenerator.java b/src/main/java/mekanism/generators/client/model/ModelSolarGenerator.java index da23440c4..500e68dc8 100644 --- a/src/main/java/mekanism/generators/client/model/ModelSolarGenerator.java +++ b/src/main/java/mekanism/generators/client/model/ModelSolarGenerator.java @@ -84,4 +84,4 @@ public class ModelSolarGenerator extends ModelBase { model.rotateAngleY = y; model.rotateAngleZ = z; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/client/model/ModelTurbine.java b/src/main/java/mekanism/generators/client/model/ModelTurbine.java index 38d3f3dc3..46b7f16c2 100644 --- a/src/main/java/mekanism/generators/client/model/ModelTurbine.java +++ b/src/main/java/mekanism/generators/client/model/ModelTurbine.java @@ -107,4 +107,4 @@ public class ModelTurbine extends ModelBase { modelRenderer.rotateAngleY = y; modelRenderer.rotateAngleZ = z; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/client/model/ModelWindGenerator.java b/src/main/java/mekanism/generators/client/model/ModelWindGenerator.java index 5418d7e70..177fae327 100644 --- a/src/main/java/mekanism/generators/client/model/ModelWindGenerator.java +++ b/src/main/java/mekanism/generators/client/model/ModelWindGenerator.java @@ -210,4 +210,4 @@ public class ModelWindGenerator extends ModelBase { model.rotateAngleY = y; model.rotateAngleZ = z; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/client/render/RenderAdvancedSolarGenerator.java b/src/main/java/mekanism/generators/client/render/RenderAdvancedSolarGenerator.java index 8251b7310..ed1e97a77 100644 --- a/src/main/java/mekanism/generators/client/render/RenderAdvancedSolarGenerator.java +++ b/src/main/java/mekanism/generators/client/render/RenderAdvancedSolarGenerator.java @@ -15,8 +15,7 @@ public class RenderAdvancedSolarGenerator extends TileEntitySpecialRenderer energyDisplays = new HashMap<>(); @Override - public void render(TileEntityBioGenerator tileEntity, double x, double y, double z, float partialTick, - int destroyStage, float alpha) { + public void render(TileEntityBioGenerator tileEntity, double x, double y, double z, float partialTick, int destroyStage, float alpha) { if (tileEntity.bioFuelSlot.fluidStored > 0) { push(); @@ -138,4 +137,4 @@ public class RenderBioGenerator extends TileEntitySpecialRenderer 0) { + if (tileEntity.structure.fluidStored != null && tileEntity.structure.fluidStored.amount != 0 && tileEntity.structure.volLength > 0) { RenderData data = new RenderData(); data.location = tileEntity.structure.renderLocation; - data.height = tileEntity.structure.lowerVolume / (tileEntity.structure.volLength - * tileEntity.structure.volWidth); + data.height = tileEntity.structure.lowerVolume / (tileEntity.structure.volLength * tileEntity.structure.volWidth); data.length = tileEntity.structure.volLength; data.width = tileEntity.structure.volWidth; data.fluidType = STEAM; @@ -69,9 +63,8 @@ public class RenderIndustrialTurbine extends TileEntitySpecialRenderer 0) { @@ -67,4 +63,4 @@ public class RenderTurbineRotor extends TileEntitySpecialRenderer { @Override protected void renderBlockSpecific(@Nonnull ItemStack stack, TransformType transformType) { GeneratorType generatorType = GeneratorType.get(stack); - if (generatorType != null) { if (generatorType == GeneratorType.BIO_GENERATOR) { RenderBioGeneratorItem.renderStack(stack, transformType); diff --git a/src/main/java/mekanism/generators/client/render/item/RenderHeatGeneratorItem.java b/src/main/java/mekanism/generators/client/render/item/RenderHeatGeneratorItem.java index 8a7fe38a6..5fdd19407 100644 --- a/src/main/java/mekanism/generators/client/render/item/RenderHeatGeneratorItem.java +++ b/src/main/java/mekanism/generators/client/render/item/RenderHeatGeneratorItem.java @@ -23,7 +23,6 @@ public class RenderHeatGeneratorItem { GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F); GL11.glTranslated(0.0F, -1.0F, 0.0F); MekanismRenderer.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "HeatGenerator.png")); - heatGenerator.render(0.0625F, ItemDataUtils.getDouble(stack, "energyStored") > 0, - Minecraft.getMinecraft().renderEngine); + heatGenerator.render(0.0625F, ItemDataUtils.getDouble(stack, "energyStored") > 0, Minecraft.getMinecraft().renderEngine); } } \ No newline at end of file diff --git a/src/main/java/mekanism/generators/client/render/item/RenderWindGeneratorItem.java b/src/main/java/mekanism/generators/client/render/item/RenderWindGeneratorItem.java index 0e4a73aaf..e5856624a 100644 --- a/src/main/java/mekanism/generators/client/render/item/RenderWindGeneratorItem.java +++ b/src/main/java/mekanism/generators/client/render/item/RenderWindGeneratorItem.java @@ -20,8 +20,7 @@ public class RenderWindGeneratorItem { public static void renderStack(@Nonnull ItemStack stack, TransformType transformType) { GlStateManager.pushMatrix(); GlStateManager.rotate(180, 0.0F, 0.0F, 1.0F); - if (transformType == TransformType.THIRD_PERSON_RIGHT_HAND - || transformType == TransformType.THIRD_PERSON_LEFT_HAND) { + if (transformType == TransformType.THIRD_PERSON_RIGHT_HAND || transformType == TransformType.THIRD_PERSON_LEFT_HAND) { GlStateManager.rotate(180F, 0.0F, 1.0F, 0.0F); GlStateManager.translate(0.0F, 0.4F, 0.0F); if (transformType == TransformType.THIRD_PERSON_LEFT_HAND) { diff --git a/src/main/java/mekanism/generators/common/FusionReactor.java b/src/main/java/mekanism/generators/common/FusionReactor.java index 27846d15a..d572e1099 100644 --- a/src/main/java/mekanism/generators/common/FusionReactor.java +++ b/src/main/java/mekanism/generators/common/FusionReactor.java @@ -1,8 +1,5 @@ package mekanism.generators.common; -import static java.lang.Math.max; -import static java.lang.Math.min; - import java.util.HashSet; import java.util.List; import java.util.Set; @@ -78,14 +75,11 @@ public class FusionReactor { public boolean hasHohlraum() { if (controller != null) { ItemStack hohlraum = controller.inventory.get(0); - if (!hohlraum.isEmpty() && hohlraum.getItem() instanceof ItemHohlraum) { GasStack gasStack = ((ItemHohlraum) hohlraum.getItem()).getGas(hohlraum); - return gasStack != null && gasStack.getGas() == MekanismFluids.FusionFuel - && gasStack.amount == ItemHohlraum.MAX_GAS; + return gasStack != null && gasStack.getGas() == MekanismFluids.FusionFuel && gasStack.amount == ItemHohlraum.MAX_GAS; } } - return false; } @@ -93,7 +87,6 @@ public class FusionReactor { if (controller.getWorld().isRemote) { lastPlasmaTemperature = plasmaTemperature; lastCaseTemperature = caseTemperature; - return; } @@ -110,7 +103,6 @@ public class FusionReactor { if (burning) { injectFuel(); int fuelBurned = burnFuel(); - if (fuelBurned == 0) { burning = false; } @@ -125,7 +117,6 @@ public class FusionReactor { if (burning) { kill(); } - updateTemperatures(); } @@ -135,36 +126,26 @@ public class FusionReactor { } public void vaporiseHohlraum() { - getFuelTank() - .receive(((ItemHohlraum) controller.inventory.get(0).getItem()).getGas(controller.inventory.get(0)), - true); + getFuelTank().receive(((ItemHohlraum) controller.inventory.get(0).getItem()).getGas(controller.inventory.get(0)), true); lastPlasmaTemperature = plasmaTemperature; - controller.inventory.set(0, ItemStack.EMPTY); - burning = true; } public void injectFuel() { int amountNeeded = getFuelTank().getNeeded(); - int amountAvailable = 2 * min(getDeuteriumTank().getStored(), getTritiumTank().getStored()); - int amountToInject = min(amountNeeded, min(amountAvailable, injectionRate)); - + int amountAvailable = 2 * Math.min(getDeuteriumTank().getStored(), getTritiumTank().getStored()); + int amountToInject = Math.min(amountNeeded, Math.min(amountAvailable, injectionRate)); amountToInject -= amountToInject % 2; - getDeuteriumTank().draw(amountToInject / 2, true); getTritiumTank().draw(amountToInject / 2, true); getFuelTank().receive(new GasStack(MekanismFluids.FusionFuel, amountToInject), true); } public int burnFuel() { - int fuelBurned = (int) min(getFuelTank().getStored(), - max(0, lastPlasmaTemperature - burnTemperature) * burnRatio); - + int fuelBurned = (int) Math.min(getFuelTank().getStored(), Math.max(0, lastPlasmaTemperature - burnTemperature) * burnRatio); getFuelTank().draw(fuelBurned, true); - plasmaTemperature += - MekanismConfig.current().generators.energyPerFusionFuel.val() * fuelBurned / plasmaHeatCapacity; - + plasmaTemperature += MekanismConfig.current().generators.energyPerFusionFuel.val() * fuelBurned / plasmaHeatCapacity; return fuelBurned; } @@ -178,9 +159,7 @@ public class FusionReactor { if (activelyCooled) { double caseWaterHeat = caseWaterConductivity * lastCaseTemperature; int waterToVaporize = (int) (steamTransferEfficiency * caseWaterHeat / enthalpyOfVaporization); - waterToVaporize = min(waterToVaporize, - min(getWaterTank().getFluidAmount(), getSteamTank().getCapacity() - getSteamTank().getFluidAmount())); - + waterToVaporize = Math.min(waterToVaporize, Math.min(getWaterTank().getFluidAmount(), getSteamTank().getCapacity() - getSteamTank().getFluidAmount())); if (waterToVaporize > 0) { getWaterTank().drain(waterToVaporize, true); getSteamTank().fill(new FluidStack(FluidRegistry.getFluid("steam"), waterToVaporize), true); @@ -188,17 +167,14 @@ public class FusionReactor { caseWaterHeat = waterToVaporize * enthalpyOfVaporization / steamTransferEfficiency; caseTemperature -= caseWaterHeat / caseHeatCapacity; - for (IHeatTransfer source : heatTransfers) { source.simulateHeat(); } - applyTemperatureChange(); } //Transfer from casing to environment double caseAirHeat = caseAirConductivity * lastCaseTemperature; - caseTemperature -= caseAirHeat / caseHeatCapacity; setBufferedEnergy(getBufferedEnergy() + caseAirHeat * thermocoupleEfficiency); } @@ -253,8 +229,7 @@ public class FusionReactor { public void kill() { AxisAlignedBB death_zone = new AxisAlignedBB(controller.getPos().getX() - 1, controller.getPos().getY() - 3, - controller.getPos().getZ() - 1, controller.getPos().getX() + 2, controller.getPos().getY(), - controller.getPos().getZ() + 2); + controller.getPos().getZ() - 1, controller.getPos().getX() + 2, controller.getPos().getY(), controller.getPos().getZ() + 2); List entitiesToDie = controller.getWorld().getEntitiesWithinAABB(Entity.class, death_zone); for (Entity entity : entitiesToDie) { @@ -274,33 +249,19 @@ public class FusionReactor { burning = burning && keepBurning; if (!controller.getWorld().isRemote) { - Mekanism.packetHandler.sendToDimension( - new TileEntityMessage(Coord4D.get(controller), controller.getNetworkedData(new TileNetworkList())), + Mekanism.packetHandler.sendToDimension(new TileEntityMessage(Coord4D.get(controller), controller.getNetworkedData(new TileNetworkList())), controller.getWorld().provider.getDimension()); } } public void formMultiblock(boolean keepBurning) { updatedThisTick = true; - Coord4D controllerPosition = Coord4D.get(controller); Coord4D centreOfReactor = controllerPosition.offset(EnumFacing.DOWN, 2); - unformMultiblock(true); - reactorBlocks.add(controller); - if (!createFrame(centreOfReactor)) { - unformMultiblock(keepBurning); - return; - } - - if (!addSides(centreOfReactor)) { - unformMultiblock(keepBurning); - return; - } - - if (!centreIsClear(centreOfReactor)) { + if (!createFrame(centreOfReactor) || !addSides(centreOfReactor) || !centreIsClear(centreOfReactor)) { unformMultiblock(keepBurning); return; } @@ -308,28 +269,20 @@ public class FusionReactor { formed = true; if (!controller.getWorld().isRemote) { - Mekanism.packetHandler.sendToDimension( - new TileEntityMessage(Coord4D.get(controller), controller.getNetworkedData(new TileNetworkList())), + Mekanism.packetHandler.sendToDimension(new TileEntityMessage(Coord4D.get(controller), controller.getNetworkedData(new TileNetworkList())), controller.getWorld().provider.getDimension()); } } public boolean createFrame(Coord4D centre) { int[][] positions = new int[][]{ - {+2, +2, +0}, {+2, +1, +1}, {+2, +0, +2}, {+2, -1, +1}, {+2, -2, +0}, {+2, -1, -1}, {+2, +0, -2}, - {+2, +1, -1}, - {+1, +2, +1}, {+1, +1, +2}, {+1, -1, +2}, {+1, -2, +1}, {+1, -2, -1}, {+1, -1, -2}, {+1, +1, -2}, - {+1, +2, -1}, - {+0, +2, +2}, {+0, -2, +2}, {+0, -2, -2}, {+0, +2, -2}, - {-1, +2, +1}, {-1, +1, +2}, {-1, -1, +2}, {-1, -2, +1}, {-1, -2, -1}, {-1, -1, -2}, {-1, +1, -2}, - {-1, +2, -1}, - {-2, +2, +0}, {-2, +1, +1}, {-2, +0, +2}, {-2, -1, +1}, {-2, -2, +0}, {-2, -1, -1}, {-2, +0, -2}, - {-2, +1, -1}, - }; + {+2, +2, +0}, {+2, +1, +1}, {+2, +0, +2}, {+2, -1, +1}, {+2, -2, +0}, {+2, -1, -1}, {+2, +0, -2}, {+2, +1, -1}, {+1, +2, +1}, {+1, +1, +2}, {+1, -1, +2}, + {+1, -2, +1}, {+1, -2, -1}, {+1, -1, -2}, {+1, +1, -2}, {+1, +2, -1}, {+0, +2, +2}, {+0, -2, +2}, {+0, -2, -2}, {+0, +2, -2}, {-1, +2, +1}, {-1, +1, +2}, + {-1, -1, +2}, {-1, -2, +1}, {-1, -2, -1}, {-1, -1, -2}, {-1, +1, -2}, {-1, +2, -1}, {-2, +2, +0}, {-2, +1, +1}, {-2, +0, +2}, {-2, -1, +1}, {-2, -2, +0}, + {-2, -1, -1}, {-2, +0, -2}, {-2, +1, -1},}; for (int[] coords : positions) { - TileEntity tile = centre.clone().translate(coords[0], coords[1], coords[2]) - .getTileEntity(controller.getWorld()); + TileEntity tile = centre.clone().translate(coords[0], coords[1], coords[2]).getTileEntity(controller.getWorld()); if (tile instanceof TileEntityReactorBlock && ((TileEntityReactorBlock) tile).isFrame()) { reactorBlocks.add((TileEntityReactorBlock) tile); @@ -338,7 +291,6 @@ public class FusionReactor { return false; } } - return true; } @@ -353,17 +305,14 @@ public class FusionReactor { }; for (int[] coords : positions) { - TileEntity tile = centre.clone().translate(coords[0], coords[1], coords[2]) - .getTileEntity(controller.getWorld()); + TileEntity tile = centre.clone().translate(coords[0], coords[1], coords[2]).getTileEntity(controller.getWorld()); if (LaserManager.isReceptor(tile, null) && !(coords[1] == 0 && (coords[0] == 0 || coords[2] == 0))) { return false; } - if (tile instanceof TileEntityReactorBlock) { reactorBlocks.add((TileEntityReactorBlock) tile); ((TileEntityReactorBlock) tile).setReactor(this); - if (tile instanceof IHeatTransfer) { heatTransfers.add((IHeatTransfer) tile); } @@ -371,7 +320,6 @@ public class FusionReactor { return false; } } - return true; } @@ -382,14 +330,12 @@ public class FusionReactor { Coord4D trans = centre.translate(x, y, z); IBlockState state = trans.getBlockState(controller.getWorld()); Block tile = state.getBlock(); - if (!tile.isAir(state, controller.getWorld(), trans.getPos())) { return false; } } } } - return true; } @@ -403,22 +349,17 @@ public class FusionReactor { public void setInjectionRate(int rate) { injectionRate = rate; - int capRate = Math.min(Math.max(1, rate), MAX_INJECTION); - capRate -= capRate % 2; controller.waterTank.setCapacity(TileEntityReactorController.MAX_WATER * capRate); controller.steamTank.setCapacity(TileEntityReactorController.MAX_STEAM * capRate); if (controller.waterTank.getFluid() != null) { - controller.waterTank.getFluid().amount = Math - .min(controller.waterTank.getFluid().amount, controller.waterTank.getCapacity()); + controller.waterTank.getFluid().amount = Math.min(controller.waterTank.getFluid().amount, controller.waterTank.getCapacity()); } - if (controller.steamTank.getFluid() != null) { - controller.steamTank.getFluid().amount = Math - .min(controller.steamTank.getFluid().amount, controller.steamTank.getCapacity()); + controller.steamTank.getFluid().amount = Math.min(controller.steamTank.getFluid().amount, controller.steamTank.getCapacity()); } } @@ -432,46 +373,37 @@ public class FusionReactor { public int getMinInjectionRate(boolean active) { double k = active ? caseWaterConductivity : 0; - double aMin = burnTemperature * burnRatio * plasmaCaseConductivity * (k + caseAirConductivity) / ( - MekanismConfig.current().generators.energyPerFusionFuel.val() * burnRatio * (plasmaCaseConductivity + k - + caseAirConductivity) - - plasmaCaseConductivity * (k + caseAirConductivity)); + double aMin = burnTemperature * burnRatio * plasmaCaseConductivity * (k + caseAirConductivity) / + (MekanismConfig.current().generators.energyPerFusionFuel.val() * burnRatio * (plasmaCaseConductivity + k + caseAirConductivity) - + plasmaCaseConductivity * (k + caseAirConductivity)); return (int) (2 * Math.ceil(aMin / 2D)); } public double getMaxPlasmaTemperature(boolean active) { double k = active ? caseWaterConductivity : 0; - return - injectionRate * MekanismConfig.current().generators.energyPerFusionFuel.val() / plasmaCaseConductivity * ( - plasmaCaseConductivity + k - + caseAirConductivity) / (k + caseAirConductivity); + return injectionRate * MekanismConfig.current().generators.energyPerFusionFuel.val() / plasmaCaseConductivity * + (plasmaCaseConductivity + k + caseAirConductivity) / (k + caseAirConductivity); } public double getMaxCasingTemperature(boolean active) { double k = active ? caseWaterConductivity : 0; - return injectionRate * MekanismConfig.current().generators.energyPerFusionFuel.val() / (k - + caseAirConductivity); + return injectionRate * MekanismConfig.current().generators.energyPerFusionFuel.val() / (k + caseAirConductivity); } public double getIgnitionTemperature(boolean active) { double k = active ? caseWaterConductivity : 0; - return burnTemperature * MekanismConfig.current().generators.energyPerFusionFuel.val() * burnRatio * ( - plasmaCaseConductivity + k - + caseAirConductivity) / ( - MekanismConfig.current().generators.energyPerFusionFuel.val() * burnRatio * (plasmaCaseConductivity + k - + caseAirConductivity) - - plasmaCaseConductivity * (k + caseAirConductivity)); + return burnTemperature * MekanismConfig.current().generators.energyPerFusionFuel.val() * burnRatio * (plasmaCaseConductivity + k + caseAirConductivity) / + (MekanismConfig.current().generators.energyPerFusionFuel.val() * burnRatio * (plasmaCaseConductivity + k + caseAirConductivity) - + plasmaCaseConductivity * (k + caseAirConductivity)); } public double getPassiveGeneration(boolean active, boolean current) { double temperature = current ? caseTemperature : getMaxCasingTemperature(active); - return thermocoupleEfficiency * caseAirConductivity * temperature; } public int getSteamPerTick(boolean current) { double temperature = current ? caseTemperature : getMaxCasingTemperature(true); - return (int) (steamTransferEfficiency * caseWaterConductivity * temperature / enthalpyOfVaporization); } @@ -498,7 +430,6 @@ public class FusionReactor { public double applyTemperatureChange() { caseTemperature += heatToAbsorb / caseHeatCapacity; heatToAbsorb = 0; - return caseTemperature; } @@ -513,4 +444,4 @@ public class FusionReactor { public NonNullList getInventory() { return isFormed() ? controller.inventory : null; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/GeneratorsBlocks.java b/src/main/java/mekanism/generators/common/GeneratorsBlocks.java index 48f96e6a3..b81e2e9dd 100644 --- a/src/main/java/mekanism/generators/common/GeneratorsBlocks.java +++ b/src/main/java/mekanism/generators/common/GeneratorsBlocks.java @@ -36,4 +36,4 @@ public class GeneratorsBlocks { public static Block init(Block block, String name) { return block.setTranslationKey(name).setRegistryName(new ResourceLocation(MekanismGenerators.MODID, name)); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/GeneratorsCommonProxy.java b/src/main/java/mekanism/generators/common/GeneratorsCommonProxy.java index b919d306d..ff41b8163 100644 --- a/src/main/java/mekanism/generators/common/GeneratorsCommonProxy.java +++ b/src/main/java/mekanism/generators/common/GeneratorsCommonProxy.java @@ -103,7 +103,6 @@ public class GeneratorsCommonProxy implements IGuiProvider { public void loadConfiguration() { MekanismConfig.local().generators.load(Mekanism.configuration); setGasGeneratorMaxEnergy(); - if (Mekanism.configuration.hasChanged()) { Mekanism.configuration.save(); } @@ -121,7 +120,6 @@ public class GeneratorsCommonProxy implements IGuiProvider { @Override public Container getServerGui(int ID, EntityPlayer player, World world, BlockPos pos) { TileEntity tileEntity = world.getTileEntity(pos); - switch (ID) { case 0: return new ContainerHeatGenerator(player.inventory, (TileEntityHeatGenerator) tileEntity); @@ -142,11 +140,10 @@ public class GeneratorsCommonProxy implements IGuiProvider { case 11: case 12: case 13: - return new ContainerNull(player, (TileEntityContainerBlock) tileEntity); case 15: return new ContainerNull(player, (TileEntityContainerBlock) tileEntity); } return null; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/GeneratorsGuiHandler.java b/src/main/java/mekanism/generators/common/GeneratorsGuiHandler.java index 0e4c950c9..5cc41c4c2 100644 --- a/src/main/java/mekanism/generators/common/GeneratorsGuiHandler.java +++ b/src/main/java/mekanism/generators/common/GeneratorsGuiHandler.java @@ -6,8 +6,7 @@ import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; /** - * Client and server GUI hander for Mekanism. Uses CommonProxy to get the server GUI and ClientProxy for the client - * GUI. + * Client and server GUI hander for Mekanism. Uses CommonProxy to get the server GUI and ClientProxy for the client GUI. * * @author AidanBrady */ @@ -22,4 +21,4 @@ public class GeneratorsGuiHandler implements IGuiHandler { public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { return MekanismGenerators.proxy.getClientGui(ID, player, world, new BlockPos(x, y, z)); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/GeneratorsItems.java b/src/main/java/mekanism/generators/common/GeneratorsItems.java index fbb349f91..59c132b7a 100644 --- a/src/main/java/mekanism/generators/common/GeneratorsItems.java +++ b/src/main/java/mekanism/generators/common/GeneratorsItems.java @@ -34,4 +34,4 @@ public class GeneratorsItems { public static Item init(Item item, String name) { return item.setTranslationKey(name).setRegistryName(new ResourceLocation(MekanismGenerators.MODID, name)); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/MekanismGenerators.java b/src/main/java/mekanism/generators/common/MekanismGenerators.java index c97036b02..feeee9603 100644 --- a/src/main/java/mekanism/generators/common/MekanismGenerators.java +++ b/src/main/java/mekanism/generators/common/MekanismGenerators.java @@ -63,8 +63,7 @@ public class MekanismGenerators implements IModule { public static Version versionNumber = new Version(999, 999, 999); public static final int DATA_VERSION = 1; - public static MultiblockManager turbineManager = new MultiblockManager<>( - "industrialTurbine"); + public static MultiblockManager turbineManager = new MultiblockManager<>("industrialTurbine"); @SubscribeEvent public static void registerBlocks(RegistryEvent.Register event) { @@ -126,10 +125,8 @@ public class MekanismGenerators implements IModule { } } - BuildcraftFuelRegistry.fuel - .addFuel(MekanismFluids.Ethene.getFluid(), - (long) (240 * MekanismConfig.current().general.TO_RF.val() / 20 * MjAPI.MJ), - 40 * Fluid.BUCKET_VOLUME); + BuildcraftFuelRegistry.fuel.addFuel(MekanismFluids.Ethene.getFluid(), (long) (240 * MekanismConfig.current().general.TO_RF.val() / 20 * MjAPI.MJ), + 40 * Fluid.BUCKET_VOLUME); } } @@ -137,13 +134,10 @@ public class MekanismGenerators implements IModule { public static void registerRecipes(RegistryEvent.Register event) { //1mB hydrogen + 2*bioFuel/tick*200ticks/100mB * 20x efficiency bonus FuelHandler.addGas(MekanismFluids.Ethene, MekanismConfig.current().general.ETHENE_BURN_TIME.val(), - MekanismConfig.current().general.FROM_H2.val() - + MekanismConfig.current().generators.bioGeneration.val() * 2 - * MekanismConfig.current().general.ETHENE_BURN_TIME.val()); + MekanismConfig.current().general.FROM_H2.val() + MekanismConfig.current().generators.bioGeneration.val() * 2 * MekanismConfig.current().general.ETHENE_BURN_TIME.val()); for (ItemStack ore : OreDictionary.getOres("dustGold")) { - RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("CARBON"), 10, StackUtils.size(ore, 4), - GeneratorsItems.Hohlraum.getEmptyItem()); + RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("CARBON"), 10, StackUtils.size(ore, 4), GeneratorsItems.Hohlraum.getEmptyItem()); } } @@ -186,4 +180,4 @@ public class MekanismGenerators implements IModule { MekanismAPI.addBoxBlacklist(GeneratorsBlocks.Generator, 5); // Advanced Solar Generator MekanismAPI.addBoxBlacklist(GeneratorsBlocks.Generator, 6); // Wind Generator } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/block/BlockGenerator.java b/src/main/java/mekanism/generators/common/block/BlockGenerator.java index 794724e51..bd35a6547 100644 --- a/src/main/java/mekanism/generators/common/block/BlockGenerator.java +++ b/src/main/java/mekanism/generators/common/block/BlockGenerator.java @@ -61,9 +61,8 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; /** - * Block class for handling multiple generator block IDs. 0: Heat Generator 1: Solar Generator 3: Hydrogen Generator 4: - * Bio-Generator 5: Advanced Solar Generator 6: Wind Generator 7: Turbine Rotor 8: Rotational Complex 9: Electromagnetic - * Coil 10: Turbine Casing 11: Turbine Valve 12: Turbine Vent 13: Saturating Condenser + * Block class for handling multiple generator block IDs. 0: Heat Generator 1: Solar Generator 3: Hydrogen Generator 4: Bio-Generator 5: Advanced Solar Generator 6: Wind + * Generator 7: Turbine Rotor 8: Rotational Complex 9: Electromagnetic Coil 10: Turbine Casing 11: Turbine Valve 12: Turbine Vent 13: Saturating Condenser * * @author AidanBrady */ @@ -71,7 +70,6 @@ public abstract class BlockGenerator extends BlockMekanismContainer { private static final AxisAlignedBB SOLAR_BOUNDS = new AxisAlignedBB(0.0F, 0.0F, 0.0F, 1.0F, 0.7F, 1.0F); private static final AxisAlignedBB ROTOR_BOUNDS = new AxisAlignedBB(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F); - public Random machineRand = new Random(); public BlockGenerator() { super(Material.IRON); @@ -102,7 +100,6 @@ public abstract class BlockGenerator extends BlockMekanismContainer { @Deprecated public IBlockState getStateFromMeta(int meta) { GeneratorType type = GeneratorType.get(getGeneratorBlock(), meta & 0xF); - return getDefaultState().withProperty(getTypeProperty(), type); } @@ -117,29 +114,23 @@ public abstract class BlockGenerator extends BlockMekanismContainer { @Deprecated public IBlockState getActualState(@Nonnull IBlockState state, IBlockAccess worldIn, BlockPos pos) { TileEntity tile = MekanismUtils.getTileEntitySafe(worldIn, pos); - if (tile instanceof TileEntityBasicBlock && ((TileEntityBasicBlock) tile).facing != null) { state = state.withProperty(BlockStateFacing.facingProperty, ((TileEntityBasicBlock) tile).facing); } - if (tile instanceof IActiveState) { state = state.withProperty(BlockStateGenerator.activeProperty, ((IActiveState) tile).getActive()); } - return state; } @Override @Deprecated - public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, - BlockPos neighborPos) { + public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, BlockPos neighborPos) { if (!world.isRemote) { TileEntity tileEntity = world.getTileEntity(pos); - if (tileEntity instanceof IMultiblock) { ((IMultiblock) tileEntity).doUpdate(); } - if (tileEntity instanceof TileEntityBasicBlock) { ((TileEntityBasicBlock) tileEntity).onNeighborChange(neighborBlock); } @@ -147,8 +138,7 @@ public abstract class BlockGenerator extends BlockMekanismContainer { } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase entityliving, - ItemStack itemstack) { + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase entityliving, ItemStack itemstack) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock) world.getTileEntity(pos); int side = MathHelper.floor((double) (entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; @@ -182,11 +172,9 @@ public abstract class BlockGenerator extends BlockMekanismContainer { tileEntity.setFacing((short) change); tileEntity.redstone = world.getRedstonePowerFromNeighbors(pos) > 0; - if (tileEntity instanceof IBoundingBlock) { ((IBoundingBlock) tileEntity).onPlace(); } - if (!world.isRemote && tileEntity instanceof IMultiblock) { ((IMultiblock) tileEntity).doUpdate(); } @@ -196,14 +184,12 @@ public abstract class BlockGenerator extends BlockMekanismContainer { public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) { if (MekanismConfig.current().client.enableAmbientLighting.val()) { TileEntity tileEntity = MekanismUtils.getTileEntitySafe(world, pos); - if (tileEntity instanceof IActiveState && !(tileEntity instanceof TileEntitySolarGenerator)) { if (((IActiveState) tileEntity).getActive() && ((IActiveState) tileEntity).lightUpdate()) { return MekanismConfig.current().client.ambientLightingLevel.val(); } } } - return 0; } @@ -215,12 +201,9 @@ public abstract class BlockGenerator extends BlockMekanismContainer { @Override @Deprecated - public float getPlayerRelativeBlockHardness(IBlockState state, @Nonnull EntityPlayer player, @Nonnull World world, - @Nonnull BlockPos pos) { + public float getPlayerRelativeBlockHardness(IBlockState state, @Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos) { TileEntity tile = world.getTileEntity(pos); - - return SecurityUtils.canAccess(player, tile) ? super.getPlayerRelativeBlockHardness(state, player, world, pos) - : 0.0F; + return SecurityUtils.canAccess(player, tile) ? super.getPlayerRelativeBlockHardness(state, player, world, pos) : 0.0F; } @Override @@ -248,14 +231,11 @@ public abstract class BlockGenerator extends BlockMekanismContainer { if (tileEntity.facing == EnumFacing.WEST) { switch (type) { case HEAT_GENERATOR: - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double) (xRandom + iRandom), - (double) yRandom, (double) (zRandom - jRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle(EnumParticleTypes.FLAME, (double) (xRandom + iRandom), (double) yRandom, - (double) (zRandom - jRandom), 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double) (xRandom + iRandom), (double) yRandom, (double) (zRandom - jRandom), 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.FLAME, (double) (xRandom + iRandom), (double) yRandom, (double) (zRandom - jRandom), 0.0D, 0.0D, 0.0D); break; case BIO_GENERATOR: - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + .25, pos.getY() + .2, - pos.getZ() + .5, 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + .25, pos.getY() + .2, pos.getZ() + .5, 0.0D, 0.0D, 0.0D); break; default: break; @@ -263,14 +243,11 @@ public abstract class BlockGenerator extends BlockMekanismContainer { } else if (tileEntity.facing == EnumFacing.EAST) { switch (type) { case HEAT_GENERATOR: - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double) (xRandom + iRandom), - (double) yRandom + 0.5F, (double) (zRandom - jRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle(EnumParticleTypes.FLAME, (double) (xRandom + iRandom), - (double) yRandom + 0.5F, (double) (zRandom - jRandom), 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double) (xRandom + iRandom), (double) yRandom + 0.5F, (double) (zRandom - jRandom), 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.FLAME, (double) (xRandom + iRandom), (double) yRandom + 0.5F, (double) (zRandom - jRandom), 0.0D, 0.0D, 0.0D); break; case BIO_GENERATOR: - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + .75, pos.getY() + .2, - pos.getZ() + .5, 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + .75, pos.getY() + .2, pos.getZ() + .5, 0.0D, 0.0D, 0.0D); break; default: break; @@ -278,14 +255,11 @@ public abstract class BlockGenerator extends BlockMekanismContainer { } else if (tileEntity.facing == EnumFacing.NORTH) { switch (type) { case HEAT_GENERATOR: - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double) (xRandom - jRandom), - (double) yRandom + 0.5F, (double) (zRandom - iRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle(EnumParticleTypes.FLAME, (double) (xRandom - jRandom), - (double) yRandom + 0.5F, (double) (zRandom - iRandom), 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double) (xRandom - jRandom), (double) yRandom + 0.5F, (double) (zRandom - iRandom), 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.FLAME, (double) (xRandom - jRandom), (double) yRandom + 0.5F, (double) (zRandom - iRandom), 0.0D, 0.0D, 0.0D); break; case BIO_GENERATOR: - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + .5, pos.getY() + .2, - pos.getZ() + .25, 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + .5, pos.getY() + .2, pos.getZ() + .25, 0.0D, 0.0D, 0.0D); break; default: break; @@ -293,14 +267,11 @@ public abstract class BlockGenerator extends BlockMekanismContainer { } else if (tileEntity.facing == EnumFacing.SOUTH) { switch (type) { case HEAT_GENERATOR: - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double) (xRandom - jRandom), - (double) yRandom + 0.5F, (double) (zRandom + iRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle(EnumParticleTypes.FLAME, (double) (xRandom - jRandom), - (double) yRandom + 0.5F, (double) (zRandom + iRandom), 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double) (xRandom - jRandom), (double) yRandom + 0.5F, (double) (zRandom + iRandom), 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.FLAME, (double) (xRandom - jRandom), (double) yRandom + 0.5F, (double) (zRandom + iRandom), 0.0D, 0.0D, 0.0D); break; case BIO_GENERATOR: - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + .5, pos.getY() + .2, - pos.getZ() + .75, 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + .5, pos.getY() + .2, pos.getZ() + .75, 0.0D, 0.0D, 0.0D); break; default: break; @@ -312,19 +283,15 @@ public abstract class BlockGenerator extends BlockMekanismContainer { @Override public void breakBlock(World world, @Nonnull BlockPos pos, @Nonnull IBlockState state) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock) world.getTileEntity(pos); - if (!world.isRemote && tileEntity instanceof TileEntityTurbineRotor) { int amount = ((TileEntityTurbineRotor) tileEntity).getHousedBlades(); - if (amount > 0) { spawnAsEntity(world, pos, new ItemStack(GeneratorsItems.TurbineBlade, amount)); } } - if (tileEntity instanceof IBoundingBlock) { ((IBoundingBlock) tileEntity).onBreak(); } - super.breakBlock(world, pos, state); } @@ -334,7 +301,6 @@ public abstract class BlockGenerator extends BlockMekanismContainer { if (world.isRemote) { return true; } - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock) world.getTileEntity(pos); int metadata = state.getBlock().getMetaFromState(state); ItemStack stack = entityplayer.getHeldItem(hand); @@ -346,47 +312,39 @@ public abstract class BlockGenerator extends BlockMekanismContainer { if (wrenchHandler.canUseWrench(entityplayer, hand, stack, raytrace)) { if (SecurityUtils.canAccess(entityplayer, tileEntity)) { wrenchHandler.wrenchUsed(entityplayer, hand, stack, raytrace); - if (entityplayer.isSneaking()) { MekanismUtils.dismantleBlock(this, state, world, pos); return true; } - if (tileEntity != null) { int change = tileEntity.facing.rotateY().ordinal(); - tileEntity.setFacing((short) change); world.notifyNeighborsOfStateChange(pos, this, true); } } else { SecurityUtils.displayNoAccess(entityplayer); } - return true; } } } - if (metadata == GeneratorType.TURBINE_CASING.meta || metadata == GeneratorType.TURBINE_VALVE.meta - || metadata == GeneratorType.TURBINE_VENT.meta) { + if (metadata == GeneratorType.TURBINE_CASING.meta || metadata == GeneratorType.TURBINE_VALVE.meta || metadata == GeneratorType.TURBINE_VENT.meta) { return ((IMultiblock) tileEntity).onActivate(entityplayer, hand, stack); } if (metadata == GeneratorType.TURBINE_ROTOR.meta) { TileEntityTurbineRotor rod = (TileEntityTurbineRotor) tileEntity; - if (!entityplayer.isSneaking()) { if (!stack.isEmpty() && stack.getItem() == GeneratorsItems.TurbineBlade) { if (rod.addBlade()) { if (!entityplayer.capabilities.isCreativeMode) { stack.shrink(1); - if (stack.getCount() == 0) { entityplayer.setHeldItem(hand, ItemStack.EMPTY); } } } - return true; } } else if (stack.isEmpty()) { @@ -406,7 +364,6 @@ public abstract class BlockGenerator extends BlockMekanismContainer { } } } - return true; } @@ -419,22 +376,18 @@ public abstract class BlockGenerator extends BlockMekanismContainer { } else { SecurityUtils.displayNoAccess(entityplayer); } - return true; } } - return false; } @Override public TileEntity createTileEntity(@Nonnull World world, @Nonnull IBlockState state) { int metadata = state.getBlock().getMetaFromState(state); - if (GeneratorType.get(getGeneratorBlock(), metadata) == null) { return null; } - return GeneratorType.get(getGeneratorBlock(), metadata).create(); } @@ -475,7 +428,6 @@ public abstract class BlockGenerator extends BlockMekanismContainer { @Deprecated public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { GeneratorType type = GeneratorType.get(state); - switch (type) { case SOLAR_GENERATOR: return SOLAR_BOUNDS; @@ -495,14 +447,11 @@ public abstract class BlockGenerator extends BlockMekanismContainer { if (itemStack.getTagCompound() == null && !(tileEntity instanceof TileEntityMultiblock)) { itemStack.setTagCompound(new NBTTagCompound()); } - if (tileEntity == null) { return ItemStack.EMPTY; } - if (tileEntity instanceof ISecurityTile) { ISecurityItem securityItem = (ISecurityItem) itemStack.getItem(); - if (securityItem.hasSecurity(itemStack)) { securityItem.setOwnerUUID(itemStack, ((ISecurityTile) tileEntity).getSecurity().getOwnerUUID()); securityItem.setSecurity(itemStack, ((ISecurityTile) tileEntity).getSecurity().getMode()); @@ -513,26 +462,21 @@ public abstract class BlockGenerator extends BlockMekanismContainer { IEnergizedItem electricItem = (IEnergizedItem) itemStack.getItem(); electricItem.setEnergy(itemStack, ((TileEntityElectricBlock) tileEntity).electricityStored); } - - if (tileEntity instanceof TileEntityContainerBlock && ((TileEntityContainerBlock) tileEntity) - .handleInventory()) { + if (tileEntity instanceof TileEntityContainerBlock && ((TileEntityContainerBlock) tileEntity).handleInventory()) { ISustainedInventory inventory = (ISustainedInventory) itemStack.getItem(); inventory.setInventory(((TileEntityContainerBlock) tileEntity).getInventory(), itemStack); } - if (tileEntity instanceof ISustainedData) { ((ISustainedData) tileEntity).writeSustainedData(itemStack); } - if (((ISustainedTank) itemStack.getItem()).hasTank(itemStack)) { if (tileEntity instanceof ISustainedTank) { - if (((ISustainedTank) tileEntity).getFluidStack() != null) { - ((ISustainedTank) itemStack.getItem()) - .setFluidStack(((ISustainedTank) tileEntity).getFluidStack(), itemStack); + ISustainedTank tank = (ISustainedTank) tileEntity; + if (tank.getFluidStack() != null) { + ((ISustainedTank) itemStack.getItem()).setFluidStack(tank.getFluidStack(), itemStack); } } } - return itemStack; } @@ -540,11 +484,7 @@ public abstract class BlockGenerator extends BlockMekanismContainer { @Deprecated public boolean isSideSolid(IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, EnumFacing side) { GeneratorType type = GeneratorType.get(getGeneratorBlock(), state.getBlock().getMetaFromState(state)); - - return type != GeneratorType.SOLAR_GENERATOR && - type != GeneratorType.ADVANCED_SOLAR_GENERATOR && - type != GeneratorType.WIND_GENERATOR && - type != GeneratorType.TURBINE_ROTOR; + return type != GeneratorType.SOLAR_GENERATOR && type != GeneratorType.ADVANCED_SOLAR_GENERATOR && type != GeneratorType.WIND_GENERATOR && type != GeneratorType.TURBINE_ROTOR; } @@ -552,33 +492,27 @@ public abstract class BlockGenerator extends BlockMekanismContainer { public EnumFacing[] getValidRotations(World world, @Nonnull BlockPos pos) { TileEntity tile = world.getTileEntity(pos); EnumFacing[] valid = new EnumFacing[6]; - if (tile instanceof TileEntityBasicBlock) { TileEntityBasicBlock basicTile = (TileEntityBasicBlock) tile; - for (EnumFacing dir : EnumFacing.VALUES) { if (basicTile.canSetFacing(dir.ordinal())) { valid[dir.ordinal()] = dir; } } } - return valid; } @Override public boolean rotateBlock(World world, @Nonnull BlockPos pos, @Nonnull EnumFacing axis) { TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileEntityBasicBlock) { TileEntityBasicBlock basicTile = (TileEntityBasicBlock) tile; - if (basicTile.canSetFacing(axis.ordinal())) { basicTile.setFacing((short) axis.ordinal()); return true; } } - return false; } @@ -587,30 +521,25 @@ public abstract class BlockGenerator extends BlockMekanismContainer { } @Override - public boolean canCreatureSpawn(@Nonnull IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, - EntityLiving.SpawnPlacementType type) { + public boolean canCreatureSpawn(@Nonnull IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, EntityLiving.SpawnPlacementType type) { int meta = state.getBlock().getMetaFromState(state); switch (meta) { case 10: // Turbine Casing case 11: // Turbine Valve case 12: // Turbine Vent - TileEntityMultiblock tileEntity = (TileEntityMultiblock) MekanismUtils - .getTileEntitySafe(world, pos); - + TileEntityMultiblock tileEntity = (TileEntityMultiblock) MekanismUtils.getTileEntitySafe(world, pos); if (tileEntity != null) { if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { if (tileEntity.structure != null) { return false; } - } else { - if (tileEntity.clientHasStructure) { - return false; - } + } else if (tileEntity.clientHasStructure) { + return false; } } default: return super.canCreatureSpawn(state, world, pos, type); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/block/BlockReactor.java b/src/main/java/mekanism/generators/common/block/BlockReactor.java index b5205f450..78103e5bf 100644 --- a/src/main/java/mekanism/generators/common/block/BlockReactor.java +++ b/src/main/java/mekanism/generators/common/block/BlockReactor.java @@ -63,15 +63,12 @@ public abstract class BlockReactor extends Block implements ITileEntityProvider @Deprecated public IBlockState getActualState(@Nonnull IBlockState state, IBlockAccess worldIn, BlockPos pos) { TileEntity tile = MekanismUtils.getTileEntitySafe(worldIn, pos); - if (tile instanceof TileEntityReactorController) { state = state.withProperty(BlockStateReactor.activeProperty, ((IActiveState) tile).getActive()); } - if (tile instanceof TileEntityReactorPort) { state = state.withProperty(BlockStateReactor.activeProperty, ((TileEntityReactorPort) tile).fluidEject); } - return state; } @@ -86,14 +83,12 @@ public abstract class BlockReactor extends Block implements ITileEntityProvider @Deprecated public IBlockState getStateFromMeta(int meta) { ReactorBlockType type = ReactorBlockType.get(getReactorBlock(), meta & 0xF); - return getDefaultState().withProperty(getTypeProperty(), type); } @Override public int getMetaFromState(IBlockState state) { - ReactorBlockType type = state.getValue(getTypeProperty()); - return type.meta; + return state.getValue(getTypeProperty()).meta; } @Override @@ -103,11 +98,9 @@ public abstract class BlockReactor extends Block implements ITileEntityProvider @Override @Deprecated - public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, - BlockPos neighborPos) { + public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, BlockPos neighborPos) { if (!world.isRemote) { TileEntity tileEntity = world.getTileEntity(pos); - if (tileEntity instanceof TileEntityBasicBlock) { ((TileEntityBasicBlock) tileEntity).onNeighborChange(neighborBlock); } @@ -115,8 +108,7 @@ public abstract class BlockReactor extends Block implements ITileEntityProvider } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, - EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (world.isRemote) { return true; } @@ -131,31 +123,24 @@ public abstract class BlockReactor extends Block implements ITileEntityProvider MekanismUtils.dismantleBlock(this, state, world, pos); return true; } - - ((IToolWrench) stack.getItem()).wrenchUsed(entityplayer, hand, stack, - new RayTraceResult(new Vec3d(hitX, hitY, hitZ), side, pos)); - + ((IToolWrench) stack.getItem()).wrenchUsed(entityplayer, hand, stack, new RayTraceResult(new Vec3d(hitX, hitY, hitZ), side, pos)); return true; } } if (tileEntity instanceof TileEntityReactorController) { if (!entityplayer.isSneaking()) { - entityplayer.openGui(MekanismGenerators.instance, ReactorBlockType.get(this, metadata).guiId, world, - pos.getX(), pos.getY(), pos.getZ()); + entityplayer.openGui(MekanismGenerators.instance, ReactorBlockType.get(this, metadata).guiId, world, pos.getX(), pos.getY(), pos.getZ()); return true; } } if (tileEntity instanceof TileEntityReactorLogicAdapter) { if (!entityplayer.isSneaking()) { - entityplayer.openGui(MekanismGenerators.instance, - BlockStateReactor.ReactorBlockType.get(this, metadata).guiId, world, pos.getX(), pos.getY(), - pos.getZ()); + entityplayer.openGui(MekanismGenerators.instance, BlockStateReactor.ReactorBlockType.get(this, metadata).guiId, world, pos.getX(), pos.getY(), pos.getZ()); return true; } } - return false; } @@ -171,11 +156,9 @@ public abstract class BlockReactor extends Block implements ITileEntityProvider @Override public TileEntity createTileEntity(@Nonnull World world, @Nonnull IBlockState state) { int metadata = state.getBlock().getMetaFromState(state); - if (ReactorBlockType.get(getReactorBlock(), metadata) == null) { return null; } - return ReactorBlockType.get(getReactorBlock(), metadata).create(); } @@ -213,11 +196,9 @@ public abstract class BlockReactor extends Block implements ITileEntityProvider @Override @Deprecated @SideOnly(Side.CLIENT) - public boolean shouldSideBeRendered(IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, - EnumFacing side) { + public boolean shouldSideBeRendered(IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, EnumFacing side) { int meta = state.getBlock().getMetaFromState(state); ReactorBlockType type = ReactorBlockType.get(getReactorBlock(), meta); - if (type == ReactorBlockType.REACTOR_GLASS || type == ReactorBlockType.LASER_FOCUS_MATRIX) { IBlockState stateOffset = world.getBlockState(pos.offset(side)); if (this == stateOffset.getBlock()) { @@ -228,7 +209,6 @@ public abstract class BlockReactor extends Block implements ITileEntityProvider } } } - return super.shouldSideBeRendered(state, world, pos, side); } @@ -236,11 +216,9 @@ public abstract class BlockReactor extends Block implements ITileEntityProvider @Deprecated public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { TileEntity tile = MekanismUtils.getTileEntitySafe(world, pos); - if (tile instanceof TileEntityReactorLogicAdapter) { return ((TileEntityReactorLogicAdapter) tile).checkMode() ? 15 : 0; } - return 0; } @@ -248,7 +226,6 @@ public abstract class BlockReactor extends Block implements ITileEntityProvider @Deprecated public boolean isSideSolid(IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, EnumFacing side) { ReactorBlockType type = ReactorBlockType.get(getReactorBlock(), state.getBlock().getMetaFromState(state)); - switch (type) { case REACTOR_FRAME: case REACTOR_PORT: @@ -262,11 +239,10 @@ public abstract class BlockReactor extends Block implements ITileEntityProvider @Override public boolean canConnectRedstone(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { ReactorBlockType type = BlockStateReactor.ReactorBlockType.get(this, state.getBlock().getMetaFromState(state)); - return type == ReactorBlockType.REACTOR_LOGIC_ADAPTER; } public PropertyEnum getTypeProperty() { return getReactorBlock().getProperty(); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/block/states/BlockStateGenerator.java b/src/main/java/mekanism/generators/common/block/states/BlockStateGenerator.java index 2f34d7a7f..32d6cc036 100644 --- a/src/main/java/mekanism/generators/common/block/states/BlockStateGenerator.java +++ b/src/main/java/mekanism/generators/common/block/states/BlockStateGenerator.java @@ -47,8 +47,7 @@ public class BlockStateGenerator extends ExtendedBlockState { public static final PropertyBool activeProperty = PropertyBool.create("active"); public BlockStateGenerator(BlockGenerator block, PropertyEnum typeProperty) { - super(block, new IProperty[]{BlockStateFacing.facingProperty, typeProperty, activeProperty}, - new IUnlistedProperty[]{}); + super(block, new IProperty[]{BlockStateFacing.facingProperty, typeProperty, activeProperty}, new IUnlistedProperty[]{}); } public enum GeneratorBlock { @@ -58,10 +57,8 @@ public class BlockStateGenerator extends ExtendedBlockState { public PropertyEnum getProperty() { if (generatorTypeProperty == null) { - generatorTypeProperty = PropertyEnum - .create("type", GeneratorType.class, new GeneratorBlockPredicate(this)); + generatorTypeProperty = PropertyEnum.create("type", GeneratorType.class, new GeneratorBlockPredicate(this)); } - return generatorTypeProperty; } @@ -74,33 +71,19 @@ public class BlockStateGenerator extends ExtendedBlockState { } public enum GeneratorType implements IStringSerializable, IBlockType { - HEAT_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 0, "HeatGenerator", 0, 160000, TileEntityHeatGenerator.class, - true, Plane.HORIZONTAL, false), - SOLAR_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 1, "SolarGenerator", 1, 96000, TileEntitySolarGenerator.class, - true, Plane.HORIZONTAL, false), - GAS_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 3, "GasGenerator", 3, - -1/*uses config, set after generators config loaded*/, - TileEntityGasGenerator.class, true, Plane.HORIZONTAL, false), - BIO_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 4, "BioGenerator", 4, 160000, TileEntityBioGenerator.class, - true, Plane.HORIZONTAL, false), - ADVANCED_SOLAR_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 5, "AdvancedSolarGenerator", 1, 200000, - TileEntityAdvancedSolarGenerator.class, true, Plane.HORIZONTAL, false), - WIND_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 6, "WindGenerator", 5, 200000, TileEntityWindGenerator.class, - true, Plane.HORIZONTAL, false), - TURBINE_ROTOR(GeneratorBlock.GENERATOR_BLOCK_1, 7, "TurbineRotor", -1, -1, TileEntityTurbineRotor.class, false, - Predicates.alwaysFalse(), false), - ROTATIONAL_COMPLEX(GeneratorBlock.GENERATOR_BLOCK_1, 8, "RotationalComplex", -1, -1, - TileEntityRotationalComplex.class, false, Predicates.alwaysFalse(), false), - ELECTROMAGNETIC_COIL(GeneratorBlock.GENERATOR_BLOCK_1, 9, "ElectromagneticCoil", -1, -1, - TileEntityElectromagneticCoil.class, false, Predicates.alwaysFalse(), false), - TURBINE_CASING(GeneratorBlock.GENERATOR_BLOCK_1, 10, "TurbineCasing", -1, -1, TileEntityTurbineCasing.class, - false, Predicates.alwaysFalse(), false), - TURBINE_VALVE(GeneratorBlock.GENERATOR_BLOCK_1, 11, "TurbineValve", -1, -1, TileEntityTurbineValve.class, false, - Predicates.alwaysFalse(), false), - TURBINE_VENT(GeneratorBlock.GENERATOR_BLOCK_1, 12, "TurbineVent", -1, -1, TileEntityTurbineVent.class, false, - Predicates.alwaysFalse(), false), - SATURATING_CONDENSER(GeneratorBlock.GENERATOR_BLOCK_1, 13, "SaturatingCondenser", -1, -1, - TileEntitySaturatingCondenser.class, false, Predicates.alwaysFalse(), false); + HEAT_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 0, "HeatGenerator", 0, 160000, TileEntityHeatGenerator.class, true, Plane.HORIZONTAL, false), + SOLAR_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 1, "SolarGenerator", 1, 96000, TileEntitySolarGenerator.class, true, Plane.HORIZONTAL, false), + GAS_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 3, "GasGenerator", 3, -1/*uses config, set after generators config loaded*/, TileEntityGasGenerator.class, true, Plane.HORIZONTAL, false), + BIO_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 4, "BioGenerator", 4, 160000, TileEntityBioGenerator.class, true, Plane.HORIZONTAL, false), + ADVANCED_SOLAR_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 5, "AdvancedSolarGenerator", 1, 200000, TileEntityAdvancedSolarGenerator.class, true, Plane.HORIZONTAL, false), + WIND_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 6, "WindGenerator", 5, 200000, TileEntityWindGenerator.class, true, Plane.HORIZONTAL, false), + TURBINE_ROTOR(GeneratorBlock.GENERATOR_BLOCK_1, 7, "TurbineRotor", -1, -1, TileEntityTurbineRotor.class, false, Predicates.alwaysFalse(), false), + ROTATIONAL_COMPLEX(GeneratorBlock.GENERATOR_BLOCK_1, 8, "RotationalComplex", -1, -1, TileEntityRotationalComplex.class, false, Predicates.alwaysFalse(), false), + ELECTROMAGNETIC_COIL(GeneratorBlock.GENERATOR_BLOCK_1, 9, "ElectromagneticCoil", -1, -1, TileEntityElectromagneticCoil.class, false, Predicates.alwaysFalse(), false), + TURBINE_CASING(GeneratorBlock.GENERATOR_BLOCK_1, 10, "TurbineCasing", -1, -1, TileEntityTurbineCasing.class, false, Predicates.alwaysFalse(), false), + TURBINE_VALVE(GeneratorBlock.GENERATOR_BLOCK_1, 11, "TurbineValve", -1, -1, TileEntityTurbineValve.class, false, Predicates.alwaysFalse(), false), + TURBINE_VENT(GeneratorBlock.GENERATOR_BLOCK_1, 12, "TurbineVent", -1, -1, TileEntityTurbineVent.class, false, Predicates.alwaysFalse(), false), + SATURATING_CONDENSER(GeneratorBlock.GENERATOR_BLOCK_1, 13, "SaturatingCondenser", -1, -1, TileEntitySaturatingCondenser.class, false, Predicates.alwaysFalse(), false); private static final List GENERATORS_FOR_CONFIG; @@ -124,8 +107,8 @@ public class BlockStateGenerator extends ExtendedBlockState { public Predicate facingPredicate; public boolean activable; - GeneratorType(GeneratorBlock block, int i, String s, int j, double k, Class tileClass, - boolean model, Predicate predicate, boolean hasActiveTexture) { + GeneratorType(GeneratorBlock block, int i, String s, int j, double k, Class tileClass, boolean model, Predicate predicate, + boolean hasActiveTexture) { blockType = block; meta = i; blockName = s; @@ -145,7 +128,6 @@ public class BlockStateGenerator extends ExtendedBlockState { if (state.getBlock() instanceof BlockGenerator) { return state.getValue(((BlockGenerator) state.getBlock()).getTypeProperty()); } - return null; } @@ -153,7 +135,6 @@ public class BlockStateGenerator extends ExtendedBlockState { if (block instanceof BlockGenerator) { return get(((BlockGenerator) block).getGeneratorBlock(), meta); } - return null; } @@ -163,7 +144,6 @@ public class BlockStateGenerator extends ExtendedBlockState { return type; } } - return null; } @@ -181,7 +161,6 @@ public class BlockStateGenerator extends ExtendedBlockState { if (meta > WIND_GENERATOR.meta) { return true; } - return MekanismConfig.current().generators.generatorsManager.isEnabled(this); } @@ -189,8 +168,7 @@ public class BlockStateGenerator extends ExtendedBlockState { try { return tileEntityClass.newInstance(); } catch (Exception e) { - Mekanism.logger.error("Unable to indirectly create tile entity."); - e.printStackTrace(); + Mekanism.logger.error("Unable to indirectly create tile entity.", e); return null; } } @@ -253,15 +231,12 @@ public class BlockStateGenerator extends ExtendedBlockState { if (type.hasRotations()) { EnumFacing facing = state.getValue(BlockStateFacing.facingProperty); - if (!type.canRotateTo(facing)) { facing = EnumFacing.NORTH; } - if (builder.length() > 0) { builder.append(","); } - builder.append(BlockStateFacing.facingProperty.getName()); builder.append("="); builder.append(facing.getName()); @@ -270,11 +245,9 @@ public class BlockStateGenerator extends ExtendedBlockState { if (builder.length() == 0) { builder.append("normal"); } - - ResourceLocation baseLocation = new ResourceLocation("mekanismgenerators", - nameOverride != null ? nameOverride : type.getName()); + ResourceLocation baseLocation = new ResourceLocation("mekanismgenerators", nameOverride != null ? nameOverride : type.getName()); return new ModelResourceLocation(baseLocation, builder.toString()); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/block/states/BlockStateReactor.java b/src/main/java/mekanism/generators/common/block/states/BlockStateReactor.java index 539709ec2..c078d1e99 100644 --- a/src/main/java/mekanism/generators/common/block/states/BlockStateReactor.java +++ b/src/main/java/mekanism/generators/common/block/states/BlockStateReactor.java @@ -44,10 +44,8 @@ public class BlockStateReactor extends ExtendedBlockState { public PropertyEnum getProperty() { if (predicatedProperty == null) { - predicatedProperty = PropertyEnum - .create("type", ReactorBlockType.class, new ReactorBlockPredicate(this)); + predicatedProperty = PropertyEnum.create("type", ReactorBlockType.class, new ReactorBlockPredicate(this)); } - return predicatedProperty; } @@ -64,15 +62,12 @@ public class BlockStateReactor extends ExtendedBlockState { } public enum ReactorBlockType implements IStringSerializable { - REACTOR_CONTROLLER(ReactorBlock.REACTOR_BLOCK, 0, "ReactorController", 10, TileEntityReactorController.class, - true), + REACTOR_CONTROLLER(ReactorBlock.REACTOR_BLOCK, 0, "ReactorController", 10, TileEntityReactorController.class, true), REACTOR_FRAME(ReactorBlock.REACTOR_BLOCK, 1, "ReactorFrame", -1, TileEntityReactorFrame.class, false), REACTOR_PORT(ReactorBlock.REACTOR_BLOCK, 2, "ReactorPort", -1, TileEntityReactorPort.class, true), - REACTOR_LOGIC_ADAPTER(ReactorBlock.REACTOR_BLOCK, 3, "ReactorLogicAdapter", 15, - TileEntityReactorLogicAdapter.class, false), + REACTOR_LOGIC_ADAPTER(ReactorBlock.REACTOR_BLOCK, 3, "ReactorLogicAdapter", 15, TileEntityReactorLogicAdapter.class, false), REACTOR_GLASS(ReactorBlock.REACTOR_GLASS, 0, "ReactorGlass", -1, TileEntityReactorGlass.class, false), - LASER_FOCUS_MATRIX(ReactorBlock.REACTOR_GLASS, 1, "ReactorLaserFocusMatrix", -1, - TileEntityReactorLaserFocusMatrix.class, false); + LASER_FOCUS_MATRIX(ReactorBlock.REACTOR_GLASS, 1, "ReactorLaserFocusMatrix", -1, TileEntityReactorLaserFocusMatrix.class, false); public ReactorBlock blockType; public int meta; @@ -81,8 +76,7 @@ public class BlockStateReactor extends ExtendedBlockState { public Class tileEntityClass; public boolean activable; - ReactorBlockType(ReactorBlock b, int i, String s, int j, Class tileClass, - boolean activeState) { + ReactorBlockType(ReactorBlock b, int i, String s, int j, Class tileClass, boolean activeState) { blockType = b; meta = i; name = s; @@ -95,7 +89,6 @@ public class BlockStateReactor extends ExtendedBlockState { if (block instanceof BlockReactor) { return get(((BlockReactor) block).getReactorBlock(), meta); } - return null; } @@ -105,7 +98,6 @@ public class BlockStateReactor extends ExtendedBlockState { return type; } } - return null; } @@ -117,8 +109,7 @@ public class BlockStateReactor extends ExtendedBlockState { try { return tileEntityClass.newInstance(); } catch (Exception e) { - Mekanism.logger.error("Unable to indirectly create tile entity."); - e.printStackTrace(); + Mekanism.logger.error("Unable to indirectly create tile entity.", e); return null; } } @@ -170,15 +161,11 @@ public class BlockStateReactor extends ExtendedBlockState { builder.append("="); builder.append(state.getValue(activeProperty)); } - if (builder.length() == 0) { builder.append("normal"); } - - ResourceLocation baseLocation = new ResourceLocation("mekanismgenerators", - nameOverride != null ? nameOverride : type.getName()); - + ResourceLocation baseLocation = new ResourceLocation("mekanismgenerators", nameOverride != null ? nameOverride : type.getName()); return new ModelResourceLocation(baseLocation, builder.toString()); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/content/turbine/SynchronizedTurbineData.java b/src/main/java/mekanism/generators/common/content/turbine/SynchronizedTurbineData.java index 1cd462548..2219c5e32 100644 --- a/src/main/java/mekanism/generators/common/content/turbine/SynchronizedTurbineData.java +++ b/src/main/java/mekanism/generators/common/content/turbine/SynchronizedTurbineData.java @@ -53,11 +53,9 @@ public class SynchronizedTurbineData extends SynchronizedData { if (nbtTags.hasKey("cachedFluid")) { fluid = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("cachedFluid")); } - electricity = nbtTags.getDouble("electricity"); dumpMode = GasMode.values()[nbtTags.getInteger("dumpMode")]; } @@ -40,8 +39,7 @@ public class TurbineCache extends MultiblockCache { if (fluid != null) { nbtTags.setTag("cachedFluid", fluid.writeToNBT(new NBTTagCompound())); } - nbtTags.setDouble("electricity", electricity); nbtTags.setInteger("dumpMode", dumpMode.ordinal()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/content/turbine/TurbineFluidTank.java b/src/main/java/mekanism/generators/common/content/turbine/TurbineFluidTank.java index 58b336850..b7f8213ca 100644 --- a/src/main/java/mekanism/generators/common/content/turbine/TurbineFluidTank.java +++ b/src/main/java/mekanism/generators/common/content/turbine/TurbineFluidTank.java @@ -30,59 +30,47 @@ public class TurbineFluidTank implements IFluidTank { if (resource == null || resource.getFluid() == null) { return 0; } - if (turbine.structure.fluidStored != null && !turbine.structure.fluidStored.isFluidEqual(resource)) { return 0; } - if (turbine.structure.fluidStored == null || turbine.structure.fluidStored.getFluid() == null) { if (resource.amount <= getCapacity()) { if (doFill) { turbine.structure.fluidStored = resource.copy(); - if (resource.amount > 0) { MekanismUtils.saveChunk(turbine); } } - return resource.amount; } else { if (doFill) { turbine.structure.fluidStored = resource.copy(); turbine.structure.fluidStored.amount = getCapacity(); - if (getCapacity() > 0) { MekanismUtils.saveChunk(turbine); } } - return getCapacity(); } } else if (resource.amount <= getNeeded()) { if (doFill) { turbine.structure.fluidStored.amount += resource.amount; - if (resource.amount > 0) { MekanismUtils.saveChunk(turbine); } } - return resource.amount; } else { int prevNeeded = getNeeded(); - if (doFill) { turbine.structure.fluidStored.amount = getCapacity(); - if (prevNeeded > 0) { MekanismUtils.saveChunk(turbine); } } - return prevNeeded; } } - return 0; } @@ -92,35 +80,26 @@ public class TurbineFluidTank implements IFluidTank { if (turbine.structure.fluidStored == null || turbine.structure.fluidStored.getFluid() == null) { return null; } - if (turbine.structure.fluidStored.amount <= 0) { return null; } - int used = maxDrain; - if (turbine.structure.fluidStored.amount < used) { used = turbine.structure.fluidStored.amount; } - if (doDrain) { turbine.structure.fluidStored.amount -= used; } - FluidStack drained = new FluidStack(turbine.structure.fluidStored.getFluid(), used); - if (turbine.structure.fluidStored.amount <= 0) { turbine.structure.fluidStored = null; } - if (drained.amount > 0 && doDrain) { MekanismUtils.saveChunk(turbine); turbine.sendPacketToRenderer(); } - return drained; } - return null; } @@ -133,7 +112,6 @@ public class TurbineFluidTank implements IFluidTank { if (turbine.structure != null) { return turbine.structure.fluidStored.amount; } - return 0; } @@ -141,4 +119,4 @@ public class TurbineFluidTank implements IFluidTank { public FluidTankInfo getInfo() { return new FluidTankInfo(this); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/content/turbine/TurbineUpdateProtocol.java b/src/main/java/mekanism/generators/common/content/turbine/TurbineUpdateProtocol.java index f4810d212..db5e08bd0 100644 --- a/src/main/java/mekanism/generators/common/content/turbine/TurbineUpdateProtocol.java +++ b/src/main/java/mekanism/generators/common/content/turbine/TurbineUpdateProtocol.java @@ -33,8 +33,7 @@ public class TurbineUpdateProtocol extends UpdateProtocol= Math.ceil((structure.volHeight - 2) / 4)) { int centerX = structure.minLocation.x + (structure.volLength - 1) / 2; int centerZ = structure.minLocation.z + (structure.volWidth - 1) / 2; @@ -104,11 +101,9 @@ public class TurbineUpdateProtocol extends UpdateProtocol structure.minLocation.y; y--) { TileEntity tile = pointer.getWorld().getTileEntity(new BlockPos(centerX, y, centerZ)); if (tile instanceof TileEntityTurbineRotor) { - TileEntityTurbineRotor rotor = (TileEntityTurbineRotor)tile; + TileEntityTurbineRotor rotor = (TileEntityTurbineRotor) tile; turbineHeight++; blades += rotor.getHousedBlades(); structure.internalLocations.add(Coord4D.get(tile)); @@ -169,8 +164,6 @@ public class TurbineUpdateProtocol extends UpdateProtocol= complex.y) { @@ -180,14 +173,11 @@ public class TurbineUpdateProtocol extends UpdateProtocol { @@ -26,8 +27,8 @@ public class ContainerBioGenerator extends ContainerFuelGenerator list, - @Nonnull ITooltipFlag flag) { + public void addInformation(@Nonnull ItemStack itemstack, World world, @Nonnull List list, @Nonnull ITooltipFlag flag) { GeneratorType type = GeneratorType.get(itemstack); if (type == null) { return; } - if (type.maxEnergy > -1) { if (!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) { - list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.INDIGO + GameSettings - .getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils - .localize("tooltip.forDetails") + "."); - list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + GameSettings - .getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils - .localize("tooltip.and") + " " + EnumColor.AQUA + GameSettings - .getKeyDisplayString(MekanismKeyHandler.modeSwitchKey.getKeyCode()) + EnumColor.GREY + " " - + LangUtils.localize("tooltip.forDesc") + "."); + list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.INDIGO + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + "."); + list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + + EnumColor.GREY + " " + LangUtils.localize("tooltip.and") + " " + EnumColor.AQUA + + GameSettings.getKeyDisplayString(MekanismKeyHandler.modeSwitchKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDesc") + "."); } else if (!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.modeSwitchKey)) { if (hasSecurity(itemstack)) { - list.add(SecurityUtils.getOwnerDisplay(Minecraft.getMinecraft().player, - MekanismClient.clientUUIDMap.get(getOwnerUUID(itemstack)))); - list.add(EnumColor.GREY + LangUtils.localize("gui.security") + ": " + SecurityUtils - .getSecurityDisplay(itemstack, Side.CLIENT)); - + list.add(SecurityUtils.getOwnerDisplay(Minecraft.getMinecraft().player, MekanismClient.clientUUIDMap.get(getOwnerUUID(itemstack)))); + list.add(EnumColor.GREY + LangUtils.localize("gui.security") + ": " + SecurityUtils.getSecurityDisplay(itemstack, Side.CLIENT)); if (SecurityUtils.isOverridden(itemstack, Side.CLIENT)) { list.add(EnumColor.RED + "(" + LangUtils.localize("gui.overridden") + ")"); } } list.add(EnumColor.BRIGHT_GREEN + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY - + MekanismUtils.getEnergyDisplay(getEnergy(itemstack), getMaxEnergy(itemstack))); + + MekanismUtils.getEnergyDisplay(getEnergy(itemstack), getMaxEnergy(itemstack))); if (hasTank(itemstack)) { if (getFluidStack(itemstack) != null) { - list.add(EnumColor.PINK + FluidRegistry.getFluidName(getFluidStack(itemstack)) + ": " - + EnumColor.GREY + getFluidStack(itemstack).amount + "mB"); + list.add(EnumColor.PINK + FluidRegistry.getFluidName(getFluidStack(itemstack)) + ": " + EnumColor.GREY + getFluidStack(itemstack).amount + "mB"); } } - list.add(EnumColor.AQUA + LangUtils.localize("tooltip.inventory") + ": " + EnumColor.GREY + LangUtils - .transYesNo(getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0)); + list.add(EnumColor.AQUA + LangUtils.localize("tooltip.inventory") + ": " + EnumColor.GREY + + LangUtils.transYesNo(getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0)); } else { list.addAll(MekanismUtils.splitTooltip(type.getDescription(), itemstack)); } } else { if (!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) { - list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.INDIGO + GameSettings - .getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils - .localize("tooltip.forDetails") + "."); + list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.INDIGO + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + "."); } else { list.addAll(MekanismUtils.splitTooltip(type.getDescription(), itemstack)); } @@ -160,8 +144,8 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp } @Override - public boolean placeBlockAt(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, World world, - @Nonnull BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, @Nonnull IBlockState state) { + public boolean placeBlockAt(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, World world, @Nonnull BlockPos pos, EnumFacing side, float hitX, float hitY, + float hitZ, @Nonnull IBlockState state) { boolean place = true; Block block = world.getBlockState(pos).getBlock(); @@ -169,7 +153,6 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp if (!(block.isReplaceable(world, pos) && world.isAirBlock(pos.add(0, 1, 0)))) { return false; } - outer: for (int xPos = -1; xPos <= 1; xPos++) { for (int zPos = -1; zPos <= 1; zPos++) { @@ -183,7 +166,6 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp if (!block.isReplaceable(world, pos)) { return false; } - for (int yPos = 1; yPos <= 4; yPos++) { if (!world.isAirBlock(pos.add(0, yPos, 0)) || pos.getY() + yPos > 255) { place = false; @@ -194,15 +176,12 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp if (place && super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, state)) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock) world.getTileEntity(pos); - if (tileEntity instanceof ISecurityTile) { ISecurityTile security = (ISecurityTile) tileEntity; security.getSecurity().setOwnerUUID(getOwnerUUID(stack)); - if (hasSecurity(stack)) { security.getSecurity().setMode(getSecurity(stack)); } - if (getOwnerUUID(stack) == null) { security.getSecurity().setOwnerUUID(player.getUniqueID()); } @@ -211,26 +190,21 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp if (tileEntity instanceof TileEntityElectricBlock) { ((TileEntityElectricBlock) tileEntity).electricityStored = getEnergy(stack); } - if (tileEntity instanceof ISustainedInventory) { ((ISustainedInventory) tileEntity).setInventory(getInventory(stack)); } - if (tileEntity instanceof ISustainedData) { if (stack.getTagCompound() != null) { ((ISustainedData) tileEntity).readSustainedData(stack); } } - if (tileEntity instanceof ISustainedTank) { if (hasTank(stack) && getFluidStack(stack) != null) { ((ISustainedTank) tileEntity).setFluidStack(getFluidStack(stack), stack); } } - return true; } - return false; } @@ -246,7 +220,6 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp if (data[0] instanceof ItemStack) { return ItemDataUtils.getList((ItemStack) data[0], "Items"); } - return null; } @@ -254,7 +227,6 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp public void setFluidStack(FluidStack fluidStack, Object... data) { if (data[0] instanceof ItemStack) { ItemStack itemStack = (ItemStack) data[0]; - if (fluidStack == null || fluidStack.amount == 0 || fluidStack.getFluid() == null) { ItemDataUtils.removeData(itemStack, "fluidTank"); } else { @@ -267,21 +239,17 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp public FluidStack getFluidStack(Object... data) { if (data[0] instanceof ItemStack) { ItemStack itemStack = (ItemStack) data[0]; - if (!ItemDataUtils.hasData(itemStack, "fluidTank")) { return null; } - return FluidStack.loadFluidStackFromNBT(ItemDataUtils.getCompound(itemStack, "fluidTank")); } - return null; } @Override public boolean hasTank(Object... data) { - return data[0] instanceof ItemStack && ((ItemStack) data[0]).getItem() instanceof ISustainedTank && ( - ((ItemStack) data[0]).getItemDamage() == 2); + return data[0] instanceof ItemStack && ((ItemStack) data[0]).getItem() instanceof ISustainedTank && (((ItemStack) data[0]).getItemDamage() == 2); } @Override @@ -322,14 +290,11 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp if (canReceive(theItem)) { double energyNeeded = getMaxEnergy(theItem) - getEnergy(theItem); double toReceive = Math.min(energy * MekanismConfig.current().general.FROM_RF.val(), energyNeeded); - if (!simulate) { setEnergy(theItem, getEnergy(theItem) + toReceive); } - return MekanismUtils.clampToInt(toReceive * MekanismConfig.current().general.TO_RF.val()); } - return 0; } @@ -338,15 +303,12 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp public int extractEnergy(ItemStack theItem, int energy, boolean simulate) { if (canSend(theItem)) { double energyRemaining = getEnergy(theItem); - double toSend = Math.min((energy * MekanismConfig.current().general.FROM_RF.val()), energyRemaining); - + double toSend = Math.min(energy * MekanismConfig.current().general.FROM_RF.val(), energyRemaining); if (!simulate) { setEnergy(theItem, getEnergy(theItem) - toSend); } - return MekanismUtils.clampToInt(toSend * MekanismConfig.current().general.TO_RF.val()); } - return 0; } @@ -373,7 +335,6 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp if (ItemDataUtils.hasData(stack, "ownerUUID")) { return UUID.fromString(ItemDataUtils.getString(stack, "ownerUUID")); } - return null; } @@ -383,7 +344,6 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp ItemDataUtils.removeData(stack, "ownerUUID"); return; } - ItemDataUtils.setString(stack, "ownerUUID", owner.toString()); } @@ -392,7 +352,6 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp if (!MekanismConfig.current().general.allowProtection.val()) { return SecurityMode.PUBLIC; } - return SecurityMode.values()[ItemDataUtils.getInt(stack, "security")]; } @@ -404,7 +363,6 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp @Override public boolean hasSecurity(ItemStack stack) { GeneratorType type = GeneratorType.get(stack); - return type != null && type.hasModel; } @@ -417,4 +375,4 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { return new ItemCapabilityWrapper(stack, new TeslaItemWrapper(), new ForgeEnergyItemWrapper()); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/item/ItemBlockReactor.java b/src/main/java/mekanism/generators/common/item/ItemBlockReactor.java index 78512249b..a32bc856f 100644 --- a/src/main/java/mekanism/generators/common/item/ItemBlockReactor.java +++ b/src/main/java/mekanism/generators/common/item/ItemBlockReactor.java @@ -38,15 +38,13 @@ public class ItemBlockReactor extends ItemBlock { @Override @SideOnly(Side.CLIENT) - public void addInformation(@Nonnull ItemStack itemstack, World world, @Nonnull List list, - @Nonnull ITooltipFlag flag) { + public void addInformation(@Nonnull ItemStack itemstack, World world, @Nonnull List list, @Nonnull ITooltipFlag flag) { ReactorBlockType type = ReactorBlockType.get(itemstack); if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.INDIGO + "shift" + EnumColor.GREY + " " - + LangUtils.localize("tooltip.forDetails") + "."); + list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.INDIGO + "shift" + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + "."); } else { list.addAll(MekanismUtils.splitTooltip(type.getDescription(), itemstack)); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/item/ItemHohlraum.java b/src/main/java/mekanism/generators/common/item/ItemHohlraum.java index 1b9e82d15..0a5265beb 100644 --- a/src/main/java/mekanism/generators/common/item/ItemHohlraum.java +++ b/src/main/java/mekanism/generators/common/item/ItemHohlraum.java @@ -34,14 +34,11 @@ public class ItemHohlraum extends ItemMekanism implements IGasItem { @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, World world, List list, ITooltipFlag flag) { GasStack gasStack = getGas(itemstack); - if (gasStack == null) { list.add(LangUtils.localize("tooltip.noGas") + "."); list.add(EnumColor.DARK_RED + LangUtils.localize("tooltip.insufficientFuel")); } else { - list.add(LangUtils.localize("tooltip.stored") + " " + gasStack.getGas().getLocalizedName() + ": " - + gasStack.amount); - + list.add(LangUtils.localize("tooltip.stored") + " " + gasStack.getGas().getLocalizedName() + ": " + gasStack.amount); if (gasStack.amount == getMaxGas(itemstack)) { list.add(EnumColor.DARK_GREEN + LangUtils.localize("tooltip.readyForReaction") + "!"); } else { @@ -65,14 +62,11 @@ public class ItemHohlraum extends ItemMekanism implements IGasItem { if (getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas()) { return 0; } - if (stack.getGas() != MekanismFluids.FusionFuel) { 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; } @@ -122,7 +116,6 @@ public class ItemHohlraum extends ItemMekanism implements IGasItem { } else { int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack))); GasStack gasStack = new GasStack(stack.getGas(), amount); - ItemDataUtils.setCompound(itemstack, "stored", gasStack.write(new NBTTagCompound())); } } @@ -130,7 +123,6 @@ public class ItemHohlraum extends ItemMekanism implements IGasItem { public ItemStack getEmptyItem() { ItemStack stack = new ItemStack(this); setGas(stack, null); - return stack; } @@ -142,9 +134,8 @@ public class ItemHohlraum extends ItemMekanism implements IGasItem { ItemStack empty = new ItemStack(this); setGas(empty, null); list.add(empty); - ItemStack filled = new ItemStack(this); setGas(filled, new GasStack(MekanismFluids.FusionFuel, ((IGasItem) filled.getItem()).getMaxGas(filled))); list.add(filled); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityAdvancedSolarGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityAdvancedSolarGenerator.java index 22207becc..dd6204f06 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityAdvancedSolarGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityAdvancedSolarGenerator.java @@ -10,8 +10,7 @@ import mekanism.common.util.MekanismUtils; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; -public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator implements IBoundingBlock, - IEvaporationSolar { +public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator implements IBoundingBlock, IEvaporationSolar { public TileEntityAdvancedSolarGenerator() { super("AdvancedSolarGenerator", 200000, MekanismConfig.current().generators.advancedSolarGeneration.val() * 2); @@ -31,7 +30,6 @@ public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator i public void onPlace() { Coord4D current = Coord4D.get(this); MekanismUtils.makeBoundingBlock(world, getPos().add(0, 1, 0), current); - for (int x = -1; x <= 1; x++) { for (int z = -1; z <= 1; z++) { MekanismUtils.makeBoundingBlock(world, getPos().add(x, 2, z), current); @@ -42,13 +40,11 @@ public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator i @Override public void onBreak() { world.setBlockToAir(getPos().add(0, 1, 0)); - for (int x = -1; x <= 1; x++) { for (int z = -1; z <= 1; z++) { world.setBlockToAir(getPos().add(x, 2, z)); } } - invalidate(); world.setBlockToAir(getPos()); } @@ -63,7 +59,6 @@ public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator i if (capability == Capabilities.EVAPORATION_SOLAR_CAPABILITY) { return Capabilities.EVAPORATION_SOLAR_CAPABILITY.cast(this); } - return super.getCapability(capability, side); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java index 47a634571..a03d20f15 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java @@ -29,8 +29,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler; public class TileEntityBioGenerator extends TileEntityGenerator implements IFluidHandlerWrapper, ISustainedData { - private static final String[] methods = new String[]{"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", - "getBioFuel", "getBioFuelNeeded"}; + private static final String[] methods = new String[]{"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getBioFuel", "getBioFuelNeeded"}; private static FluidTankInfo[] ALL_TANKS = new FluidTankInfo[0]; /** * The FluidSlot biofuel instance for this generator. @@ -48,27 +47,21 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui if (!inventory.get(0).isEmpty()) { ChargeUtils.charge(1, this); - FluidStack fluid = FluidUtil.getFluidContained(inventory.get(0)); - if (fluid != null && FluidRegistry.isFluidRegistered("bioethanol")) { if (fluid.getFluid() == FluidRegistry.getFluid("bioethanol")) { IFluidHandler handler = FluidUtil.getFluidHandler(inventory.get(0)); FluidStack drained = handler.drain(bioFuelSlot.MAX_FLUID - bioFuelSlot.fluidStored, true); - if (drained != null) { bioFuelSlot.fluidStored += drained.amount; } } } else { int fuel = getFuel(inventory.get(0)); - if (fuel > 0) { int fuelNeeded = bioFuelSlot.MAX_FLUID - bioFuelSlot.fluidStored; - if (fuel <= fuelNeeded) { bioFuelSlot.fluidStored += fuel; - if (!inventory.get(0).getItem().getContainerItem(inventory.get(0)).isEmpty()) { inventory.set(0, inventory.get(0).getItem().getContainerItem(inventory.get(0))); } else { @@ -78,18 +71,14 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui } } } - if (canOperate()) { if (!world.isRemote) { setActive(true); } - bioFuelSlot.setFluid(bioFuelSlot.fluidStored - 1); setEnergy(electricityStored + MekanismConfig.current().generators.bioGeneration.val()); - } else { - if (!world.isRemote) { - setActive(false); - } + } else if (!world.isRemote) { + setActive(false); } } @@ -98,20 +87,16 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui if (slotID == 0) { if (getFuel(itemstack) > 0) { return true; - } else { - if (FluidRegistry.isFluidRegistered("bioethanol")) { - FluidStack fluidContained = FluidUtil.getFluidContained(itemstack); - if (fluidContained != null) { - return fluidContained.getFluid() == FluidRegistry.getFluid("bioethanol"); - } + } else if (FluidRegistry.isFluidRegistered("bioethanol")) { + FluidStack fluidContained = FluidUtil.getFluidContained(itemstack); + if (fluidContained != null) { + return fluidContained.getFluid() == FluidRegistry.getFluid("bioethanol"); } - - return false; } + return false; } else if (slotID == 1) { return ChargeUtils.canBeCharged(itemstack); } - return true; } @@ -123,7 +108,6 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - bioFuelSlot.fluidStored = nbtTags.getInteger("bioFuelStored"); } @@ -131,9 +115,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setInteger("bioFuelStored", bioFuelSlot.fluidStored); - return nbtTags; } @@ -145,6 +127,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui * Gets the scaled fuel level for the GUI. * * @param i - multiplier + * * @return Scaled fuel level */ public int getScaledFuelLevel(int i) { @@ -165,7 +148,6 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { bioFuelSlot.fluidStored = dataStream.readInt(); } @@ -193,7 +175,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui case 2: return new Object[]{BASE_MAX_ENERGY}; case 3: - return new Object[]{(BASE_MAX_ENERGY - electricityStored)}; + return new Object[]{BASE_MAX_ENERGY - electricityStored}; case 4: return new Object[]{bioFuelSlot.fluidStored}; case 5: @@ -210,21 +192,17 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui int fuelTransfer; int fuelNeeded = bioFuelSlot.MAX_FLUID - bioFuelSlot.fluidStored; int attemptTransfer = resource.amount; - if (attemptTransfer <= fuelNeeded) { fuelTransfer = attemptTransfer; } else { fuelTransfer = fuelNeeded; } - if (doFill) { bioFuelSlot.setFluid(bioFuelSlot.fluidStored + fuelTransfer); } - return fuelTransfer; } } - return 0; } @@ -265,8 +243,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui @Override public boolean hasCapability(@Nonnull Capability capability, EnumFacing side) { - return (side != facing && capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) || super - .hasCapability(capability, side); + return (side != facing && capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) || super.hasCapability(capability, side); } @Override @@ -274,7 +251,6 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui if (side != facing && capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(new FluidHandlerWrapper(this, side)); } - return super.getCapability(capability, side); } @@ -282,4 +258,4 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui public FluidTankInfo[] getAllTanks() { return ALL_TANKS; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java index 2a9b0cd65..0227de9cb 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java @@ -28,8 +28,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler; public class TileEntityGasGenerator extends TileEntityGenerator implements IGasHandler, ISustainedData { - private static final String[] methods = new String[]{"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", - "getGas", "getGasNeeded"}; + private static final String[] methods = new String[]{"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getGas", "getGasNeeded"}; /** * The maximum amount of gas this block can store. */ @@ -44,8 +43,7 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH public int clientUsed; public TileEntityGasGenerator() { - super("gas", "GasGenerator", MekanismConfig.current().general.FROM_H2.val() * 100, - MekanismConfig.current().general.FROM_H2.val() * 2); + super("gas", "GasGenerator", MekanismConfig.current().general.FROM_H2.val() * 100, MekanismConfig.current().general.FROM_H2.val() * 2); inventory = NonNullList.withSize(2, ItemStack.EMPTY); fuelTank = new GasTank(MAX_GAS); } @@ -56,10 +54,8 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH if (!world.isRemote) { ChargeUtils.charge(1, this); - if (!inventory.get(0).isEmpty() && fuelTank.getStored() < MAX_GAS) { Gas gasType = null; - if (fuelTank.getGas() != null) { gasType = fuelTank.getGas().getGas(); } else if (!inventory.get(0).isEmpty() && inventory.get(0).getItem() instanceof IGasItem) { @@ -67,13 +63,10 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH gasType = ((IGasItem) inventory.get(0).getItem()).getGas(inventory.get(0)).getGas(); } } - if (gasType != null && FuelHandler.getFuel(gasType) != null) { GasStack removed = GasUtils.removeGas(inventory.get(0), gasType, fuelTank.getNeeded()); - boolean isTankEmpty = (fuelTank.getGas() == null); - + boolean isTankEmpty = fuelTank.getGas() == null; int fuelReceived = fuelTank.receive(removed, true); - if (fuelReceived > 0 && isTankEmpty) { output = FuelHandler.getFuel(fuelTank.getGas().getGas()).energyPerTick * 2; } @@ -81,38 +74,30 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH } boolean operate = canOperate(); - if (operate && getEnergy() + generationRate < getMaxEnergy()) { setActive(true); - - FuelGas fuel; - if (fuelTank.getStored() != 0) { - fuel = FuelHandler.getFuel(fuelTank.getGas().getGas()); + FuelGas fuel = FuelHandler.getFuel(fuelTank.getGas().getGas()); maxBurnTicks = fuel.burnTicks; generationRate = fuel.energyPerTick; } int toUse = getToUse(); - output = Math.max(MekanismConfig.current().general.FROM_H2.val() * 2, generationRate * getToUse() * 2); int total = burnTicks + fuelTank.getStored() * maxBurnTicks; total -= toUse; - setEnergy(getEnergy() + generationRate * toUse); if (fuelTank.getStored() > 0) { fuelTank.setGas(new GasStack(fuelTank.getGasType(), total / maxBurnTicks)); } - burnTicks = total % maxBurnTicks; clientUsed = toUse; } else { if (!operate) { reset(); } - clientUsed = 0; setActive(false); } @@ -130,11 +115,9 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH if (generationRate == 0 || fuelTank.getGas() == null) { return 0; } - int max = (int) Math.ceil(((float) fuelTank.getStored() / (float) fuelTank.getMaxGas()) * 256F); max = Math.min((fuelTank.getStored() * maxBurnTicks) + burnTicks, max); max = (int) Math.min((getMaxEnergy() - getEnergy()) / generationRate, max); - return max; } @@ -143,23 +126,19 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH if (slotID == 1) { return ChargeUtils.canBeOutputted(itemstack, true); } else if (slotID == 0) { - return (itemstack.getItem() instanceof IGasItem - && ((IGasItem) itemstack.getItem()).getGas(itemstack) == null); + return itemstack.getItem() instanceof IGasItem && ((IGasItem) itemstack.getItem()).getGas(itemstack) == null; } - return false; } @Override public boolean isItemValidForSlot(int slotID, @Nonnull ItemStack itemstack) { if (slotID == 0) { - return itemstack.getItem() instanceof IGasItem && ((IGasItem) itemstack.getItem()).getGas(itemstack) != null - && - FuelHandler.getFuel((((IGasItem) itemstack.getItem()).getGas(itemstack).getGas())) != null; + return itemstack.getItem() instanceof IGasItem && ((IGasItem) itemstack.getItem()).getGas(itemstack) != null && + FuelHandler.getFuel(((IGasItem) itemstack.getItem()).getGas(itemstack).getGas()) != null; } else if (slotID == 1) { return ChargeUtils.canBeCharged(itemstack); } - return true; } @@ -178,6 +157,7 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH * Gets the scaled gas level for the GUI. * * @param i - multiplier + * * @return Scaled gas level */ public int getScaledGasLevel(int i) { @@ -215,7 +195,6 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { TileUtils.readTankData(dataStream, fuelTank); - generationRate = dataStream.readDouble(); output = dataStream.readDouble(); clientUsed = dataStream.readInt(); @@ -225,30 +204,23 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - TileUtils.addTankData(data, fuelTank); - data.add(generationRate); data.add(output); data.add(clientUsed); - return data; } @Override public int receiveGas(EnumFacing side, GasStack stack, boolean doTransfer) { - boolean isTankEmpty = (fuelTank.getGas() == null); - + boolean isTankEmpty = fuelTank.getGas() == null; if (canReceiveGas(side, stack.getGas()) && (isTankEmpty || fuelTank.getGas().isGasEqual(stack))) { int fuelReceived = fuelTank.receive(stack, doTransfer); - if (doTransfer && isTankEmpty && fuelReceived > 0) { output = FuelHandler.getFuel(fuelTank.getGas().getGas()).energyPerTick * 2; } - return fuelReceived; } - return 0; } @@ -261,12 +233,9 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - fuelTank.read(nbtTags.getCompoundTag("fuelTank")); - - boolean isTankEmpty = (fuelTank.getGas() == null); - FuelGas fuel = (isTankEmpty) ? null : FuelHandler.getFuel(fuelTank.getGas().getGas()); - + boolean isTankEmpty = fuelTank.getGas() == null; + FuelGas fuel = isTankEmpty ? null : FuelHandler.getFuel(fuelTank.getGas().getGas()); if (fuel != null) { output = fuel.energyPerTick * 2; } @@ -276,9 +245,7 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setTag("fuelTank", fuelTank.write(new NBTTagCompound())); - return nbtTags; } @@ -312,7 +279,6 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH } else if (capability == Capabilities.GAS_HANDLER_CAPABILITY) { return Capabilities.GAS_HANDLER_CAPABILITY.cast(this); } - return super.getCapability(capability, side); } @@ -335,14 +301,12 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH public void readSustainedData(ItemStack itemStack) { if (ItemDataUtils.hasData(itemStack, "fuelTank")) { fuelTank.read(ItemDataUtils.getCompound(itemStack, "fuelTank")); - - boolean isTankEmpty = (fuelTank.getGas() == null); + boolean isTankEmpty = fuelTank.getGas() == null; //Update energy output based on any existing fuel in tank - FuelGas fuel = (isTankEmpty) ? null : FuelHandler.getFuel(fuelTank.getGas().getGas()); - + FuelGas fuel = isTankEmpty ? null : FuelHandler.getFuel(fuelTank.getGas().getGas()); if (fuel != null) { output = fuel.energyPerTick * 2; } } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java index 46a4cae0a..3637be7d1 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java @@ -22,8 +22,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public abstract class TileEntityGenerator extends TileEntityEffectsBlock implements IComputerIntegration, - IRedstoneControl, ISecurityTile { +public abstract class TileEntityGenerator extends TileEntityEffectsBlock implements IComputerIntegration, IRedstoneControl, ISecurityTile { /** * Output per tick this generator can transfer. @@ -38,15 +37,13 @@ public abstract class TileEntityGenerator extends TileEntityEffectsBlock impleme public TileComponentSecurity securityComponent = new TileComponentSecurity(this); /** - * Generator -- a block that produces energy. It has a certain amount of fuel it can store as well as an output - * rate. + * 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 + * @param name - full name of this generator * @param maxEnergy - how much energy this generator can store */ public TileEntityGenerator(String soundPath, String name, double maxEnergy, double out) { super("gen." + soundPath, name, maxEnergy); - output = out; controlType = RedstoneControl.DISABLED; } @@ -54,20 +51,15 @@ public abstract class TileEntityGenerator extends TileEntityEffectsBlock impleme @Override public void onUpdate() { super.onUpdate(); - if (!world.isRemote) { - if (!world.isRemote && MekanismConfig.current().general.destroyDisabledBlocks.val()) { + if (MekanismConfig.current().general.destroyDisabledBlocks.val()) { GeneratorType type = BlockStateGenerator.GeneratorType.get(getBlockType(), getBlockMetadata()); - if (type != null && !type.isEnabled()) { - Mekanism.logger - .info("Destroying generator of type '" + type.blockName + "' at coords " + Coord4D.get(this) - + " as according to config."); + Mekanism.logger.info("Destroying generator of type '" + type.blockName + "' at coords " + Coord4D.get(this) + " as according to config."); world.setBlockToAir(getPos()); return; } } - if (MekanismUtils.canFunction(this)) { CableUtils.emit(this); } @@ -113,16 +105,13 @@ public abstract class TileEntityGenerator extends TileEntityEffectsBlock impleme @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(controlType.ordinal()); - return data; } @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; } @@ -130,9 +119,7 @@ public abstract class TileEntityGenerator extends TileEntityEffectsBlock impleme @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setInteger("controlType", controlType.ordinal()); - return nbtTags; } @@ -173,4 +160,4 @@ public abstract class TileEntityGenerator extends TileEntityEffectsBlock impleme public TileComponentSecurity getSecurity() { return securityComponent; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java index de3cb9553..b0a167e17 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java @@ -37,11 +37,9 @@ import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fml.common.FMLCommonHandler; -public class TileEntityHeatGenerator extends TileEntityGenerator implements IFluidHandlerWrapper, ISustainedData, - IHeatTransfer { +public class TileEntityHeatGenerator extends TileEntityGenerator implements IFluidHandlerWrapper, ISustainedData, IHeatTransfer { - private static final String[] methods = new String[]{"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", - "getFuel", "getFuelNeeded"}; + private static final String[] methods = new String[]{"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getFuel", "getFuelNeeded"}; /** * The FluidTank for this generator. */ @@ -65,21 +63,15 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu if (!world.isRemote) { ChargeUtils.charge(1, this); - if (!inventory.get(0).isEmpty()) { if (FluidContainerUtils.isFluidContainer(inventory.get(0))) { - lavaTank.fill(FluidContainerUtils - .extractFluid(lavaTank, this, 0, FluidChecker.check(FluidRegistry.LAVA)), true); + lavaTank.fill(FluidContainerUtils.extractFluid(lavaTank, this, 0, FluidChecker.check(FluidRegistry.LAVA)), true); } else { int fuel = getFuel(inventory.get(0)); - if (fuel > 0) { - int fuelNeeded = - lavaTank.getCapacity() - (lavaTank.getFluid() != null ? lavaTank.getFluid().amount : 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.get(0).getItem().getContainerItem(inventory.get(0)).isEmpty()) { inventory.set(0, inventory.get(0).getItem().getContainerItem(inventory.get(0))); } else { @@ -91,12 +83,9 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu } double prev = getEnergy(); - transferHeatTo(getBoost()); - if (canOperate()) { setActive(true); - lavaTank.drain(10, true); transferHeatTo(MekanismConfig.current().generators.heatGeneration.val()); } else { @@ -105,10 +94,8 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu double[] loss = simulateHeat(); applyTemperatureChange(); - lastTransferLoss = loss[0]; lastEnvironmentLoss = loss[1]; - producingEnergy = getEnergy() - prev; } } @@ -124,20 +111,17 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu } else if (slotID == 1) { return ChargeUtils.canBeCharged(itemstack); } - return true; } @Override public boolean canOperate() { - return electricityStored < BASE_MAX_ENERGY && lavaTank.getFluid() != null && lavaTank.getFluid().amount >= 10 - && MekanismUtils.canFunction(this); + return electricityStored < BASE_MAX_ENERGY && 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")); } @@ -147,11 +131,9 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - if (lavaTank.getFluid() != null) { nbtTags.setTag("lavaTank", lavaTank.writeToNBT(new NBTTagCompound())); } - return nbtTags; } @@ -162,26 +144,21 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu } else if (slotID == 0) { return FluidUtil.getFluidContained(itemstack) == null; } - return false; } public double getBoost() { int lavaBoost = 0; double netherBoost = 0D; - for (EnumFacing side : EnumFacing.VALUES) { Coord4D coord = Coord4D.get(this).offset(side); - if (isLava(coord.getPos())) { lavaBoost++; } } - if (world.provider.getDimension() == -1) { netherBoost = MekanismConfig.current().generators.heatGenerationNether.val(); } - return (MekanismConfig.current().generators.heatGenerationLava.val() * lavaBoost) + netherBoost; } @@ -203,6 +180,7 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu * Gets the scaled fuel level for the GUI. * * @param i - multiplier + * * @return Scaled fuel level */ public int getScaledFuelLevel(int i) { @@ -226,14 +204,10 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(producingEnergy); - data.add(lastTransferLoss); data.add(lastEnvironmentLoss); - TileUtils.addTankData(data, lavaTank); - return data; } @@ -252,12 +226,11 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu case 2: return new Object[]{BASE_MAX_ENERGY}; case 3: - return new Object[]{(BASE_MAX_ENERGY - electricityStored)}; + return new Object[]{BASE_MAX_ENERGY - electricityStored}; case 4: return new Object[]{lavaTank.getFluid() != null ? lavaTank.getFluid().amount : 0}; case 5: - return new Object[]{ - lavaTank.getCapacity() - (lavaTank.getFluid() != null ? lavaTank.getFluid().amount : 0)}; + return new Object[]{lavaTank.getCapacity() - (lavaTank.getFluid() != null ? lavaTank.getFluid().amount : 0)}; default: throw new NoSuchMethodException(); } @@ -268,7 +241,6 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu if (resource != null && resource.getFluid() == FluidRegistry.LAVA && from != facing) { return lavaTank.fill(resource, doFill); } - return 0; } @@ -297,7 +269,6 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu if (from == facing) { return PipeUtils.EMPTY; } - return new FluidTankInfo[]{lavaTank.getInfo()}; } @@ -347,7 +318,6 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu transferHeatTo(-heatLost); setEnergy(getEnergy() + workDone); } - return HeatUtils.simulate(this); } @@ -368,20 +338,17 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu public IHeatTransfer getAdjacent(EnumFacing side) { if (canConnectHeat(side)) { TileEntity adj = Coord4D.get(this).offset(side).getTileEntity(world); - if (CapabilityUtils.hasCapability(adj, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite())) { return CapabilityUtils.getCapability(adj, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite()); } } - return null; } @Override public boolean hasCapability(@Nonnull Capability capability, EnumFacing side) { - return capability == Capabilities.HEAT_TRANSFER_CAPABILITY || - (side != facing && capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) || super - .hasCapability(capability, side); + return capability == Capabilities.HEAT_TRANSFER_CAPABILITY || (side != facing && capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) || + super.hasCapability(capability, side); } @Override @@ -389,11 +356,9 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu if (capability == Capabilities.HEAT_TRANSFER_CAPABILITY) { return Capabilities.HEAT_TRANSFER_CAPABILITY.cast(this); } - if (side != facing && capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(new FluidHandlerWrapper(this, side)); } - return super.getCapability(capability, side); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java index ec3841a43..0bfe280e2 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java @@ -15,8 +15,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler; public class TileEntitySolarGenerator extends TileEntityGenerator { - private static final String[] methods = new String[]{"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", - "getSeesSun"}; + private static final String[] methods = new String[]{"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getSeesSun"}; private boolean seesSun; private boolean needsRainCheck = true; @@ -50,7 +49,6 @@ public class TileEntitySolarGenerator extends TileEntityGenerator { @Override public void validate() { super.validate(); - Biome b = world.provider.getBiomeForCoords(getPos()); // Consider the best temperature to be 0.8; biomes that are higher than that @@ -71,10 +69,8 @@ public class TileEntitySolarGenerator extends TileEntityGenerator { @Override public void onUpdate() { super.onUpdate(); - if (!world.isRemote) { ChargeUtils.charge(0, this); - // Sort out if the generator can see the sun; we no longer check if it's raining here, // since under the new rules, we can still generate power when it's raining, albeit at a // significant penalty. @@ -94,7 +90,6 @@ public class TileEntitySolarGenerator extends TileEntityGenerator { if (slotID == 0) { return ChargeUtils.canBeOutputted(itemstack, true); } - return false; } @@ -103,7 +98,6 @@ public class TileEntitySolarGenerator extends TileEntityGenerator { if (slotID == 0) { return ChargeUtils.canBeCharged(itemstack); } - return true; } @@ -116,7 +110,6 @@ public class TileEntitySolarGenerator extends TileEntityGenerator { // Get the brightness of the sun; note that there are some implementations that depend on the base // brightness function which doesn't take into account the fact that rain can't occur in some biomes. float brightness = world.getSunBrightnessFactor(1.0f); - if (MekanismUtils.existsAndInstance(world.provider, "micdoodle8.mods.galacticraft.api.world.ISolarLevel")) { brightness *= ((ISolarLevel) world.provider).getSolarEnergyMultiplier(); } @@ -128,7 +121,6 @@ public class TileEntitySolarGenerator extends TileEntityGenerator { if (needsRainCheck && (world.isRaining() || world.isThundering())) { production *= 0.2; } - return production; } @@ -151,7 +143,7 @@ public class TileEntitySolarGenerator extends TileEntityGenerator { case 2: return new Object[]{BASE_MAX_ENERGY}; case 3: - return new Object[]{(BASE_MAX_ENERGY - electricityStored)}; + return new Object[]{BASE_MAX_ENERGY - electricityStored}; case 4: return new Object[]{seesSun}; default: @@ -162,7 +154,6 @@ public class TileEntitySolarGenerator extends TileEntityGenerator { @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { seesSun = dataStream.readBoolean(); } @@ -198,4 +189,4 @@ public class TileEntitySolarGenerator extends TileEntityGenerator { public double getMaxOutput() { return peakOutput; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityWindGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityWindGenerator.java index a7b53a779..0abc75da8 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityWindGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityWindGenerator.java @@ -18,8 +18,7 @@ public class TileEntityWindGenerator extends TileEntityGenerator implements IBou public static final float SPEED = 32F; public static final float SPEED_SCALED = 256F / SPEED; - static final String[] methods = new String[]{"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", - "getMultiplier"}; + static final String[] methods = new String[]{"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getMultiplier"}; private double angle; private float currentMultiplier; @@ -37,8 +36,7 @@ public class TileEntityWindGenerator extends TileEntityGenerator implements IBou // Check the blacklist and force an update if we're in the blacklist. Otherwise, we'll never send // an initial activity status and the client (in MP) will show the windmills turning while not // generating any power - isBlacklistDimension = MekanismConfig.current().generators.windGenerationDimBlacklist.val() - .contains(world.provider.getDimension()); + isBlacklistDimension = MekanismConfig.current().generators.windGenerationDimBlacklist.val().contains(world.provider.getDimension()); if (isBlacklistDimension) { setActive(false); } @@ -50,26 +48,20 @@ public class TileEntityWindGenerator extends TileEntityGenerator implements IBou if (!world.isRemote) { ChargeUtils.charge(0, this); - // If we're in a blacklisted dimension, there's nothing more to do if (isBlacklistDimension) { return; } - if (ticker % 20 == 0) { // Recalculate the current multiplier once a second currentMultiplier = getMultiplier(); setActive(currentMultiplier > 0); } - if (getActive()) { - setEnergy(electricityStored + (MekanismConfig.current().generators.windGenerationMin.val() - * currentMultiplier)); - } - } else { - if (getActive()) { - angle = (angle + (getPos().getY() + 4F) / SPEED_SCALED) % 360; + setEnergy(electricityStored + (MekanismConfig.current().generators.windGenerationMin.val() * currentMultiplier)); } + } else if (getActive()) { + angle = (angle + (getPos().getY() + 4F) / SPEED_SCALED) % 360; } } @@ -86,10 +78,8 @@ public class TileEntityWindGenerator extends TileEntityGenerator implements IBou @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(currentMultiplier); data.add(isBlacklistDimension); - return data; } @@ -102,17 +92,13 @@ public class TileEntityWindGenerator extends TileEntityGenerator implements IBou final float maxY = (float) MekanismConfig.current().generators.windGenerationMaxY.val(); final float minG = (float) MekanismConfig.current().generators.windGenerationMin.val(); final float maxG = (float) MekanismConfig.current().generators.windGenerationMax.val(); - final float slope = (maxG - minG) / (maxY - minY); final float intercept = minG - slope * minY; - final float clampedY = Math.min(maxY, Math.max(minY, (float) (getPos().getY() + 4))); final float toGen = slope * clampedY + intercept; - return toGen / minG; - } else { - return 0; } + return 0; } @Override @@ -130,7 +116,7 @@ public class TileEntityWindGenerator extends TileEntityGenerator implements IBou case 2: return new Object[]{BASE_MAX_ENERGY}; case 3: - return new Object[]{(BASE_MAX_ENERGY - electricityStored)}; + return new Object[]{BASE_MAX_ENERGY - electricityStored}; case 4: return new Object[]{getMultiplier()}; default: @@ -150,10 +136,8 @@ public class TileEntityWindGenerator extends TileEntityGenerator implements IBou MekanismUtils.makeBoundingBlock(world, getPos().offset(EnumFacing.UP, 2), current); MekanismUtils.makeBoundingBlock(world, getPos().offset(EnumFacing.UP, 3), current); MekanismUtils.makeBoundingBlock(world, getPos().offset(EnumFacing.UP, 4), current); - // Check to see if the placement is happening in a blacklisted dimension - isBlacklistDimension = MekanismConfig.current().generators.windGenerationDimBlacklist.val() - .contains(world.provider.getDimension()); + isBlacklistDimension = MekanismConfig.current().generators.windGenerationDimBlacklist.val().contains(world.provider.getDimension()); } @Override @@ -162,7 +146,6 @@ public class TileEntityWindGenerator extends TileEntityGenerator implements IBou world.setBlockToAir(getPos().add(0, 2, 0)); world.setBlockToAir(getPos().add(0, 3, 0)); world.setBlockToAir(getPos().add(0, 4, 0)); - world.setBlockToAir(getPos()); } @@ -198,4 +181,4 @@ public class TileEntityWindGenerator extends TileEntityGenerator implements IBou public boolean isItemValidForSlot(int slot, @Nonnull ItemStack stack) { return ChargeUtils.canBeCharged(stack); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorBlock.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorBlock.java index 407eb3367..920f4c69e 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorBlock.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorBlock.java @@ -40,14 +40,12 @@ public abstract class TileEntityReactorBlock extends TileEntityElectricBlock { if (reactor != fusionReactor) { changed = true; } - fusionReactor = reactor; } @Override public void invalidate() { super.invalidate(); - if (getReactor() != null) { getReactor().formMultiblock(false); } @@ -56,15 +54,12 @@ public abstract class TileEntityReactorBlock extends TileEntityElectricBlock { @Override public void onUpdate() { super.onUpdate(); - if (changed) { changed = false; } - if (!world.isRemote && ticker == 5 && !attempted && (getReactor() == null || !getReactor().isFormed())) { updateController(); } - attempted = false; } @@ -81,7 +76,6 @@ public abstract class TileEntityReactorBlock extends TileEntityElectricBlock { @Override public void onChunkUnload() { super.onChunkUnload(); - if (!(this instanceof TileEntityReactorController) && getReactor() != null) { getReactor().formMultiblock(true); } @@ -90,7 +84,6 @@ public abstract class TileEntityReactorBlock extends TileEntityElectricBlock { @Override public void onAdded() { super.onAdded(); - if (!world.isRemote) { if (getReactor() != null) { getReactor().formMultiblock(false); @@ -103,7 +96,6 @@ public abstract class TileEntityReactorBlock extends TileEntityElectricBlock { public void updateController() { if (!(this instanceof TileEntityReactorController)) { TileEntityReactorController found = new ControllerFinder().find(); - if (found != null && (found.getReactor() == null || !found.getReactor().isFormed())) { found.formMultiblock(false); } @@ -136,18 +128,14 @@ public abstract class TileEntityReactorBlock extends TileEntityElectricBlock { } iterated.add(pos); - for (EnumFacing side : EnumFacing.VALUES) { Coord4D coord = pos.offset(side); - if (!iterated.contains(coord) && coord.getTileEntity(world) instanceof TileEntityReactorBlock) { ((TileEntityReactorBlock) coord.getTileEntity(world)).attempted = true; - if (coord.getTileEntity(world) instanceof TileEntityReactorController) { found = (TileEntityReactorController) coord.getTileEntity(world); return; } - loop(coord); } } @@ -155,8 +143,7 @@ public abstract class TileEntityReactorBlock extends TileEntityElectricBlock { public TileEntityReactorController find() { loop(Coord4D.get(TileEntityReactorBlock.this)); - return found; } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java index 6f87f982e..e8d0577f6 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java @@ -68,13 +68,13 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen } public void radiateNeutrons(int neutrons) { - } //future impl + //future impl + } public void formMultiblock(boolean keepBurning) { if (getReactor() == null) { setReactor(new FusionReactor(this)); } - getReactor().formMultiblock(keepBurning); } @@ -82,7 +82,6 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen if (getReactor() == null || !getReactor().isFormed()) { return 0; } - return getReactor().getPlasmaTemp(); } @@ -90,26 +89,19 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen if (getReactor() == null || !getReactor().isFormed()) { return 0; } - return getReactor().getCaseTemp(); } @Override public void onUpdate() { super.onUpdate(); - if (world.isRemote) { updateSound(); } - if (isFormed()) { getReactor().simulate(); - - if (!world.isRemote && (getReactor().isBurning() != clientBurning - || Math.abs(getReactor().getPlasmaTemp() - clientTemp) > 1000000)) { - Mekanism.packetHandler.sendToAllAround( - new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - Coord4D.get(this).getTargetPoint(50D)); + if (!world.isRemote && (getReactor().isBurning() != clientBurning || Math.abs(getReactor().getPlasmaTemp() - clientTemp) > 1000000)) { + Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), Coord4D.get(this).getTargetPoint(50D)); clientBurning = getReactor().isBurning(); clientTemp = getReactor().getPlasmaTemp(); } @@ -122,7 +114,6 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen if (!MekanismConfig.current().client.enableMachineSounds.val()) { return; } - if (isBurning() && !isInvalid()) { // If sounds are being muted, we can attempt to start them on every tick, only to have them // denied by the event bus, so use a cooldown period that ensures we're only trying once every @@ -130,24 +121,20 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen if (--playSoundCooldown > 0) { return; } - if (activeSound == null || !Minecraft.getMinecraft().getSoundHandler().isSoundPlaying(activeSound)) { activeSound = SoundHandler.startTileSound(soundEvent.getSoundName(), 1.0f, getPos()); playSoundCooldown = 20; } - } else { - if (activeSound != null) { - SoundHandler.stopTileSound(getPos()); - activeSound = null; - playSoundCooldown = 0; - } + } else if (activeSound != null) { + SoundHandler.stopTileSound(getPos()); + activeSound = null; + playSoundCooldown = 0; } } @Override public void invalidate() { super.invalidate(); - if (world.isRemote) { updateSound(); } @@ -156,14 +143,12 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen @Override public void onChunkUnload() { super.onChunkUnload(); - formMultiblock(true); } @Override public void onAdded() { super.onAdded(); - formMultiblock(false); } @@ -171,9 +156,7 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen @Override public NBTTagCompound writeToNBT(NBTTagCompound tag) { super.writeToNBT(tag); - tag.setBoolean("formed", isFormed()); - if (isFormed()) { tag.setDouble("plasmaTemp", getReactor().getPlasmaTemp()); tag.setDouble("caseTemp", getReactor().getCaseTemp()); @@ -185,22 +168,18 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen tag.setInteger("injectionRate", 0); tag.setBoolean("burning", false); } - tag.setTag("fuelTank", fuelTank.write(new NBTTagCompound())); tag.setTag("deuteriumTank", deuteriumTank.write(new NBTTagCompound())); tag.setTag("tritiumTank", tritiumTank.write(new NBTTagCompound())); tag.setTag("waterTank", waterTank.writeToNBT(new NBTTagCompound())); tag.setTag("steamTank", steamTank.writeToNBT(new NBTTagCompound())); - return tag; } @Override public void readFromNBT(NBTTagCompound tag) { super.readFromNBT(tag); - boolean formed = tag.getBoolean("formed"); - if (formed) { setReactor(new FusionReactor(this)); getReactor().setPlasmaTemp(tag.getDouble("plasmaTemp")); @@ -209,7 +188,6 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen getReactor().setBurning(tag.getBoolean("burning")); getReactor().updateTemperatures(); } - fuelTank.read(tag.getCompoundTag("fuelTank")); deuteriumTank.read(tag.getCompoundTag("deuteriumTank")); tritiumTank.read(tag.getCompoundTag("tritiumTank")); @@ -220,9 +198,7 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(getReactor() != null && getReactor().isFormed()); - if (getReactor() != null) { data.add(getReactor().getPlasmaTemp()); data.add(getReactor().getCaseTemp()); @@ -234,7 +210,6 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen TileUtils.addTankData(data, waterTank); TileUtils.addTankData(data, steamTank); } - return data; } @@ -242,13 +217,11 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen public void handlePacketData(ByteBuf dataStream) { if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { int type = dataStream.readInt(); - if (type == 0) { if (getReactor() != null) { getReactor().setInjectionRate(dataStream.readInt()); } } - return; } @@ -256,14 +229,11 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { boolean formed = dataStream.readBoolean(); - if (formed) { if (getReactor() == null || !getReactor().formed) { BlockPos corner = getPos().subtract(new Vec3i(2, 4, 2)); - Mekanism.proxy.doMultiblockSparkle(this, corner, 5, 5, 6, - tile -> tile instanceof TileEntityReactorBlock); + Mekanism.proxy.doMultiblockSparkle(this, corner, 5, 5, 6, tile -> tile instanceof TileEntityReactorBlock); } - if (getReactor() == null) { setReactor(new FusionReactor(this)); MekanismUtils.updateBlock(world, getPos()); @@ -321,10 +291,8 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen @SideOnly(Side.CLIENT) public AxisAlignedBB getRenderBoundingBox() { if (box == null) { - box = new AxisAlignedBB(getPos().getX() - 1, getPos().getY() - 3, getPos().getZ() - 1, getPos().getX() + 2, - getPos().getY(), getPos().getZ() + 2); + box = new AxisAlignedBB(getPos().getX() - 1, getPos().getY() - 3, getPos().getZ() - 1, getPos().getX() + 2, getPos().getY(), getPos().getZ() + 2); } - return box; } @@ -347,4 +315,4 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen } return super.isCapabilityDisabled(capability, side); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorFrame.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorFrame.java index f47c62777..3ccfa051c 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorFrame.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorFrame.java @@ -6,4 +6,4 @@ public class TileEntityReactorFrame extends TileEntityReactorBlock { public boolean isFrame() { return true; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorGlass.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorGlass.java index 76a867f69..dd191a940 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorGlass.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorGlass.java @@ -6,4 +6,4 @@ public class TileEntityReactorGlass extends TileEntityReactorBlock { public boolean isFrame() { return false; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLaserFocusMatrix.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLaserFocusMatrix.java index 5a025d8e8..d5d44a912 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLaserFocusMatrix.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLaserFocusMatrix.java @@ -35,7 +35,6 @@ public class TileEntityReactorLaserFocusMatrix extends TileEntityReactorBlock im if (capability == Capabilities.LASER_RECEPTOR_CAPABILITY) { return Capabilities.LASER_RECEPTOR_CAPABILITY.cast(this); } - return super.getCapability(capability, side); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLogicAdapter.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLogicAdapter.java index 8a1619bef..16d007670 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLogicAdapter.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLogicAdapter.java @@ -12,10 +12,9 @@ import net.minecraftforge.fml.common.FMLCommonHandler; public class TileEntityReactorLogicAdapter extends TileEntityReactorBlock implements IComputerIntegration { - private static final String[] methods = new String[]{"isIgnited", "canIgnite", "getPlasmaHeat", "getMaxPlasmaHeat", - "getCaseHeat", "getMaxCaseHeat", "getInjectionRate", "setInjectionRate", "hasFuel", "getProducing", - "getIgnitionTemp", - "getEnergy", "getMaxEnergy", "getWater", "getSteam", "getFuel", "getDeuterium", "getTritium"}; + private static final String[] methods = new String[]{"isIgnited", "canIgnite", "getPlasmaHeat", "getMaxPlasmaHeat", "getCaseHeat", "getMaxCaseHeat", + "getInjectionRate", "setInjectionRate", "hasFuel", "getProducing", "getIgnitionTemp", "getEnergy", + "getMaxEnergy", "getWater", "getSteam", "getFuel", "getDeuterium", "getTritium"}; public ReactorLogic logicType = ReactorLogic.DISABLED; public boolean activeCooled; public boolean prevOutputting; @@ -28,14 +27,11 @@ public class TileEntityReactorLogicAdapter extends TileEntityReactorBlock implem @Override public void onUpdate() { super.onUpdate(); - if (!world.isRemote) { boolean outputting = checkMode(); - if (outputting != prevOutputting) { world.notifyNeighborsOfStateChange(getPos(), getBlockType(), true); } - prevOutputting = outputting; } } @@ -48,11 +44,9 @@ public class TileEntityReactorLogicAdapter extends TileEntityReactorBlock implem if (world.isRemote) { return prevOutputting; } - if (getReactor() == null || !getReactor().isFormed()) { return false; } - switch (logicType) { case DISABLED: return false; @@ -62,7 +56,7 @@ public class TileEntityReactorLogicAdapter extends TileEntityReactorBlock implem return getReactor().getPlasmaTemp() >= getReactor().getMaxPlasmaTemperature(activeCooled); case DEPLETED: return (getReactor().getDeuteriumTank().getStored() < getReactor().getInjectionRate() / 2) || - (getReactor().getTritiumTank().getStored() < getReactor().getInjectionRate() / 2); + (getReactor().getTritiumTank().getStored() < getReactor().getInjectionRate() / 2); default: return false; } @@ -71,7 +65,6 @@ public class TileEntityReactorLogicAdapter extends TileEntityReactorBlock implem @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - logicType = ReactorLogic.values()[nbtTags.getInteger("logicType")]; activeCooled = nbtTags.getBoolean("activeCooled"); } @@ -80,10 +73,8 @@ public class TileEntityReactorLogicAdapter extends TileEntityReactorBlock implem @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setInteger("logicType", logicType.ordinal()); nbtTags.setBoolean("activeCooled", activeCooled); - return nbtTags; } @@ -91,13 +82,11 @@ public class TileEntityReactorLogicAdapter extends TileEntityReactorBlock implem public void handlePacketData(ByteBuf dataStream) { if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { int type = dataStream.readInt(); - if (type == 0) { activeCooled = !activeCooled; } else if (type == 1) { logicType = ReactorLogic.values()[dataStream.readInt()]; } - return; } @@ -113,11 +102,9 @@ public class TileEntityReactorLogicAdapter extends TileEntityReactorBlock implem @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(logicType.ordinal()); data.add(activeCooled); data.add(prevOutputting); - return data; } @@ -131,7 +118,6 @@ public class TileEntityReactorLogicAdapter extends TileEntityReactorBlock implem if (getReactor() == null || !getReactor().isFormed()) { return new Object[]{"Unformed."}; } - switch (method) { case 0: return new Object[]{getReactor().isBurning()}; @@ -151,13 +137,11 @@ public class TileEntityReactorLogicAdapter extends TileEntityReactorBlock implem if (arguments[0] instanceof Double) { getReactor().setInjectionRate(((Double) arguments[0]).intValue()); return new Object[]{"Injection rate set."}; - } else { - return new Object[]{"Invalid parameters."}; } + return new Object[]{"Invalid parameters."}; case 8: - return new Object[]{ - (getReactor().getDeuteriumTank().getStored() >= getReactor().getInjectionRate() / 2) && - (getReactor().getTritiumTank().getStored() >= getReactor().getInjectionRate() / 2)}; + return new Object[]{(getReactor().getDeuteriumTank().getStored() >= getReactor().getInjectionRate() / 2) && + (getReactor().getTritiumTank().getStored() >= getReactor().getInjectionRate() / 2)}; case 9: return new Object[]{getReactor().getPassiveGeneration(false, true)}; case 10: @@ -207,4 +191,4 @@ public class TileEntityReactorLogicAdapter extends TileEntityReactorBlock implem return LangUtils.localize("reactor." + name + ".desc"); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java index 729f8ab53..54fc81d2a 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java @@ -45,21 +45,18 @@ import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.items.CapabilityItemHandler; -public class TileEntityReactorPort extends TileEntityReactorBlock implements IFluidHandlerWrapper, IGasHandler, - IHeatTransfer, IConfigurable { +public class TileEntityReactorPort extends TileEntityReactorBlock implements IFluidHandlerWrapper, IGasHandler, IHeatTransfer, IConfigurable { public boolean fluidEject; public TileEntityReactorPort() { super("name", 1); - inventory = NonNullList.withSize(0, ItemStack.EMPTY); } @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - fluidEject = nbtTags.getBoolean("fluidEject"); } @@ -67,9 +64,7 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - nbtTags.setBoolean("fluidEject", fluidEject); - return nbtTags; } @@ -85,21 +80,14 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl } super.onUpdate(); - if (!world.isRemote) { CableUtils.emit(this); - if (fluidEject && getReactor() != null && getReactor().getSteamTank().getFluid() != null) { IFluidTank tank = getReactor().getSteamTank(); - for (EnumFacing side : EnumFacing.values()) { TileEntity tile = Coord4D.get(this).offset(side).getTileEntity(world); - - if (tile != null && !(tile instanceof TileEntityReactorPort) && CapabilityUtils - .hasCapability(tile, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite())) { - IFluidHandler handler = CapabilityUtils - .getCapability(tile, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite()); - + if (tile != null && !(tile instanceof TileEntityReactorPort) && CapabilityUtils.hasCapability(tile, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite())) { + IFluidHandler handler = CapabilityUtils.getCapability(tile, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite()); if (PipeUtils.canFill(handler, tank.getFluid())) { tank.drain(handler.fill(tank.getFluid(), true), true); } @@ -114,7 +102,6 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl if (resource != null && resource.getFluid() == FluidRegistry.WATER && getReactor() != null && !fluidEject) { return getReactor().getWaterTank().fill(resource, doFill); } - return 0; } @@ -123,7 +110,6 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl if (resource != null && resource.getFluid() == FluidRegistry.getFluid("steam") && getReactor() != null) { getReactor().getSteamTank().drain(resource.amount, doDrain); } - return null; } @@ -132,7 +118,6 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl if (getReactor() != null) { return getReactor().getSteamTank().drain(maxDrain, doDrain); } - return null; } @@ -151,7 +136,6 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl if (getReactor() == null) { return PipeUtils.EMPTY; } - return new FluidTankInfo[]{getReactor().getWaterTank().getInfo(), getReactor().getSteamTank().getInfo()}; } @@ -171,7 +155,6 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl return getReactor().getFuelTank().receive(stack, doTransfer); } } - return 0; } @@ -182,8 +165,7 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl @Override public boolean canReceiveGas(EnumFacing side, Gas type) { - return (type == MekanismFluids.Deuterium || type == MekanismFluids.Tritium - || type == MekanismFluids.FusionFuel); + return type == MekanismFluids.Deuterium || type == MekanismFluids.Tritium || type == MekanismFluids.FusionFuel; } @Override @@ -194,8 +176,7 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl @Nonnull @Override public GasTankInfo[] getTankInfo() { - return getReactor() != null ? new GasTankInfo[]{getReactor().getDeuteriumTank(), getReactor().getTritiumTank(), - getReactor().getFuelTank()} : IGasHandler.NONE; + return getReactor() != null ? new GasTankInfo[]{getReactor().getDeuteriumTank(), getReactor().getTritiumTank(), getReactor().getFuelTank()} : IGasHandler.NONE; } @Override @@ -203,10 +184,8 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl if (isCapabilityDisabled(capability, side)) { return false; } - return capability == Capabilities.GAS_HANDLER_CAPABILITY - || capability == Capabilities.HEAT_TRANSFER_CAPABILITY - || capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY - || capability == Capabilities.CONFIGURABLE_CAPABILITY || super.hasCapability(capability, side); + return capability == Capabilities.GAS_HANDLER_CAPABILITY || capability == Capabilities.HEAT_TRANSFER_CAPABILITY || + capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || capability == Capabilities.CONFIGURABLE_CAPABILITY || super.hasCapability(capability, side); } @Override @@ -214,15 +193,12 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl if (isCapabilityDisabled(capability, side)) { return null; } - if (capability == Capabilities.GAS_HANDLER_CAPABILITY || capability == Capabilities.HEAT_TRANSFER_CAPABILITY - || capability == Capabilities.CONFIGURABLE_CAPABILITY) { + if (capability == Capabilities.GAS_HANDLER_CAPABILITY || capability == Capabilities.HEAT_TRANSFER_CAPABILITY || capability == Capabilities.CONFIGURABLE_CAPABILITY) { return (T) this; } - if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(new FluidHandlerWrapper(this, side)); } - return super.getCapability(capability, side); } @@ -235,9 +211,8 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl public double getEnergy() { if (getReactor() == null) { return 0; - } else { - return getReactor().getBufferedEnergy(); } + return getReactor().getBufferedEnergy(); } @Override @@ -251,9 +226,8 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl public double getMaxEnergy() { if (getReactor() == null) { return 0; - } else { - return getReactor().getBufferSize(); } + return getReactor().getBufferSize(); } @Override @@ -276,7 +250,6 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl if (getReactor() != null) { return getReactor().getTemp(); } - return 0; } @@ -290,7 +263,6 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl if (getReactor() != null) { return getReactor().getInsulationCoefficient(side); } - return 0; } @@ -311,7 +283,6 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl if (getReactor() != null) { return getReactor().applyTemperatureChange(); } - return 0; } @@ -323,21 +294,18 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl @Override public IHeatTransfer getAdjacent(EnumFacing side) { TileEntity adj = Coord4D.get(this).offset(side).getTileEntity(world); - if (CapabilityUtils.hasCapability(adj, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite())) { if (!(adj instanceof TileEntityReactorBlock)) { return CapabilityUtils.getCapability(adj, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite()); } } - return null; } @Nonnull @Override public ItemStack getStackInSlot(int slotID) { - return getReactor() != null && getReactor().isFormed() ? getReactor().getInventory().get(slotID) - : ItemStack.EMPTY; + return getReactor() != null && getReactor().isFormed() ? getReactor().getInventory().get(slotID) : ItemStack.EMPTY; } @Override @@ -349,7 +317,6 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl public void setInventorySlotContents(int slotID, @Nonnull ItemStack itemstack) { if (getReactor() != null && getReactor().isFormed()) { getReactor().getInventory().set(slotID, itemstack); - if (!itemstack.isEmpty() && itemstack.getCount() > getInventoryStackLimit()) { itemstack.setCount(getInventoryStackLimit()); } @@ -377,11 +344,8 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl public boolean isItemValidForSlot(int slotID, @Nonnull ItemStack itemstack) { if (getReactor() != null && getReactor().isFormed() && itemstack.getItem() instanceof ItemHohlraum) { ItemHohlraum hohlraum = (ItemHohlraum) itemstack.getItem(); - - return hohlraum.getGas(itemstack) != null && hohlraum.getGas(itemstack).amount == hohlraum - .getMaxGas(itemstack); + return hohlraum.getGas(itemstack) != null && hohlraum.getGas(itemstack).amount == hohlraum.getMaxGas(itemstack); } - return false; } @@ -389,21 +353,17 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl public boolean canExtractItem(int slotID, @Nonnull ItemStack itemstack, @Nonnull EnumFacing side) { if (getReactor() != null && getReactor().isFormed() && itemstack.getItem() instanceof ItemHohlraum) { ItemHohlraum hohlraum = (ItemHohlraum) itemstack.getItem(); - return hohlraum.getGas(itemstack) == null; } - return false; } @Override public void handlePacketData(ByteBuf dataStream) { super.handlePacketData(dataStream); - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { boolean prevEject = fluidEject; fluidEject = dataStream.readBoolean(); - if (prevEject != fluidEject) { MekanismUtils.updateBlock(world, getPos()); } @@ -413,9 +373,7 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl @Override public TileNetworkList getNetworkedData(TileNetworkList data) { super.getNetworkedData(data); - data.add(fluidEject); - return data; } @@ -423,17 +381,12 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl public EnumActionResult onSneakRightClick(EntityPlayer player, EnumFacing side) { if (!world.isRemote) { fluidEject = !fluidEject; - String modeText = " " + (fluidEject ? EnumColor.DARK_RED : EnumColor.DARK_GREEN) + LangUtils - .transOutputInput(fluidEject) + "."; - player.sendMessage( - new TextComponentString(EnumColor.DARK_BLUE + Mekanism.LOG_TAG + " " + EnumColor.GREY + LangUtils - .localize("tooltip.configurator.reactorPortEject") + modeText)); - Mekanism.packetHandler - .sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), - new Range4D(Coord4D.get(this))); + String modeText = " " + (fluidEject ? EnumColor.DARK_RED : EnumColor.DARK_GREEN) + LangUtils.transOutputInput(fluidEject) + "."; + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + Mekanism.LOG_TAG + " " + EnumColor.GREY + + LangUtils.localize("tooltip.configurator.reactorPortEject") + modeText)); + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this))); markDirty(); } - return EnumActionResult.SUCCESS; } @@ -441,4 +394,4 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl public EnumActionResult onRightClick(EntityPlayer player, EnumFacing side) { return EnumActionResult.PASS; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityElectromagneticCoil.java b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityElectromagneticCoil.java index 5a6e1541d..09ec69cba 100644 --- a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityElectromagneticCoil.java +++ b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityElectromagneticCoil.java @@ -7,4 +7,4 @@ public class TileEntityElectromagneticCoil extends TileEntityBasicBlock { @Override public void onUpdate() { } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityRotationalComplex.java b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityRotationalComplex.java index fb3202f7e..8f9e8f774 100644 --- a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityRotationalComplex.java +++ b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityRotationalComplex.java @@ -18,9 +18,8 @@ public class TileEntityRotationalComplex extends TileEntityInternalMultiblock { Coord4D coord = Coord4D.get(this).offset(EnumFacing.DOWN); TileEntity tile = coord.getTileEntity(world); - if (tile instanceof TileEntityTurbineRotor) { ((TileEntityTurbineRotor) tile).updateRotors(); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/tile/turbine/TileEntitySaturatingCondenser.java b/src/main/java/mekanism/generators/common/tile/turbine/TileEntitySaturatingCondenser.java index 88d3a2265..c603660ef 100644 --- a/src/main/java/mekanism/generators/common/tile/turbine/TileEntitySaturatingCondenser.java +++ b/src/main/java/mekanism/generators/common/tile/turbine/TileEntitySaturatingCondenser.java @@ -7,4 +7,4 @@ public class TileEntitySaturatingCondenser extends TileEntityBasicBlock { @Override public void onUpdate() { } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineCasing.java b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineCasing.java index d48359a41..ee5b94876 100644 --- a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineCasing.java +++ b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineCasing.java @@ -30,8 +30,7 @@ import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.items.CapabilityItemHandler; -public class TileEntityTurbineCasing extends TileEntityMultiblock implements - IStrictEnergyStorage { +public class TileEntityTurbineCasing extends TileEntityMultiblock implements IStrictEnergyStorage { public TileEntityTurbineCasing() { this("TurbineCasing"); @@ -61,29 +60,20 @@ public class TileEntityTurbineCasing extends TileEntityMultiblock 0 && getEnergy() < structure.getEnergyCapacity()) { - double energyMultiplier = (MekanismConfig.current().general.maxEnergyPerSteam.val() - / TurbineUpdateProtocol.MAX_BLADES) * Math - .min(structure.blades, - structure.coils * MekanismConfig.current().generators.turbineBladesPerCoil.val()); - double rate = - structure.lowerVolume * (structure.getDispersers() * MekanismConfig - .current().generators.turbineDisperserGasFlow.val()); - rate = Math.min(rate, - structure.vents * MekanismConfig.current().generators.turbineVentGasFlow.val()); + double energyMultiplier = (MekanismConfig.current().general.maxEnergyPerSteam.val() / TurbineUpdateProtocol.MAX_BLADES) * + Math.min(structure.blades, structure.coils * MekanismConfig.current().generators.turbineBladesPerCoil.val()); + double rate = structure.lowerVolume * (structure.getDispersers() * MekanismConfig.current().generators.turbineDisperserGasFlow.val()); + rate = Math.min(rate, structure.vents * MekanismConfig.current().generators.turbineVentGasFlow.val()); double origRate = rate; - - rate = Math.min(Math.min(stored, rate), (getMaxEnergy() - getEnergy()) / energyMultiplier) - * proportion; + rate = Math.min(Math.min(stored, rate), (getMaxEnergy() - getEnergy()) / energyMultiplier) * proportion; flowRate = rate / origRate; - setEnergy(getEnergy() + ((int) rate) * energyMultiplier); + setEnergy(getEnergy() + (int) rate * energyMultiplier); structure.fluidStored.amount -= rate; structure.clientFlow = (int) rate; - structure.flowRemaining = Math.min((int) rate, - structure.condensers * MekanismConfig.current().generators.condenserRate.val()); - + structure.flowRemaining = Math.min((int) rate, structure.condensers * MekanismConfig.current().generators.condenserRate.val()); if (structure.fluidStored.amount == 0) { structure.fluidStored = null; } @@ -92,9 +82,7 @@ public class TileEntityTurbineCasing extends TileEntityMultiblock teslaManager = new CapabilityWrapperManager<>( - IEnergyWrapper.class, TeslaIntegration.class); - private CapabilityWrapperManager forgeEnergyManager = new CapabilityWrapperManager<>( - IEnergyWrapper.class, ForgeEnergyIntegration.class); + private CapabilityWrapperManager teslaManager = new CapabilityWrapperManager<>(IEnergyWrapper.class, TeslaIntegration.class); + private CapabilityWrapperManager forgeEnergyManager = new CapabilityWrapperManager<>(IEnergyWrapper.class, ForgeEnergyIntegration.class); public TileEntityTurbineValve() { super("TurbineValve"); @@ -74,7 +71,6 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I if (structure != null) { return !structure.locations.contains(Coord4D.get(this).offset(side)); } - return false; } @@ -87,7 +83,6 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I public void register() { if (!world.isRemote) { IEnergyTile registered = EnergyNet.instance.getTile(world, getPos()); - if (registered != this) { if (registered != null && ic2Registered) { MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(registered)); @@ -104,7 +99,6 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I public void deregister() { if (!world.isRemote) { IEnergyTile registered = EnergyNet.instance.getTile(world, getPos()); - if (registered != null && ic2Registered) { MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(registered)); ic2Registered = false; @@ -120,7 +114,6 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I @Override public void onAdded() { super.onAdded(); - if (MekanismUtils.useIC2()) { register(); } @@ -131,14 +124,12 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I if (MekanismUtils.useIC2()) { deregister(); } - super.onChunkUnload(); } @Override public void invalidate() { super.invalidate(); - if (MekanismUtils.useIC2()) { deregister(); } @@ -154,16 +145,12 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I @Method(modid = MekanismHooks.REDSTONEFLUX_MOD_ID) public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate) { if (sideIsOutput(from)) { - double toSend = Math.min(getEnergy(), - Math.min(getMaxOutput(), maxExtract * MekanismConfig.current().general.FROM_RF.val())); - + double toSend = Math.min(getEnergy(), Math.min(getMaxOutput(), maxExtract * MekanismConfig.current().general.FROM_RF.val())); if (!simulate) { setEnergy(getEnergy() - toSend); } - return MekanismUtils.clampToInt(toSend * MekanismConfig.current().general.TO_RF.val()); } - return 0; } @@ -296,22 +283,18 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I @Override public double pullEnergy(EnumFacing side, double amount, boolean simulate) { double toGive = Math.min(getEnergy(), amount); - if (toGive < 0.0001 || (side != null && !sideIsOutput(side))) { return 0; } - if (!simulate) { setEnergy(getEnergy() - toGive); } - return toGive; } @Override public FluidTankInfo[] getTankInfo(EnumFacing from) { - return ((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) ? new FluidTankInfo[]{ - fluidTank.getInfo()} : PipeUtils.EMPTY; + return ((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) ? new FluidTankInfo[]{fluidTank.getInfo()} : PipeUtils.EMPTY; } @Override @@ -324,17 +307,13 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I if (resource == null || !canFill(from, resource)) { return 0; } - int filled = fluidTank.fill(resource, doFill); - if (doFill) { structure.newSteamInput += filled; } - if (filled < structure.getFluidCapacity() && structure.dumpMode != GasMode.IDLE) { filled = Math.min(structure.getFluidCapacity(), resource.amount); } - return filled; } @@ -351,9 +330,8 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I @Override public boolean canFill(EnumFacing from, @Nullable FluidStack fluid) { if (fluid != null && fluid.getFluid().equals(FluidRegistry.getFluid("steam"))) { - return ((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)); + return (!world.isRemote && structure != null) || (world.isRemote && clientHasStructure); } - return false; } @@ -381,65 +359,50 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I if (structure == null) { return new Object[]{"Unformed"}; } - switch (method) { case 1: return new Object[]{structure.fluidStored != null ? structure.fluidStored.amount : 0}; case 2: return new Object[]{structure.clientFlow}; case 3: - double rate = - structure.lowerVolume * (structure.clientDispersers * MekanismConfig - .current().generators.turbineDisperserGasFlow.val()); - rate = Math - .min(rate, structure.vents * MekanismConfig.current().generators.turbineVentGasFlow.val()); + double rate = structure.lowerVolume * (structure.clientDispersers * MekanismConfig.current().generators.turbineDisperserGasFlow.val()); + rate = Math.min(rate, structure.vents * MekanismConfig.current().generators.turbineVentGasFlow.val()); return new Object[]{rate}; case 4: return new Object[]{structure.lastSteamInput}; } } - throw new NoSuchMethodException(); } @Override public boolean hasCapability(@Nonnull Capability capability, EnumFacing side) { if ((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) { - if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY - || capability == Capabilities.ENERGY_STORAGE_CAPABILITY - || capability == Capabilities.ENERGY_OUTPUTTER_CAPABILITY - || capability == Capabilities.TESLA_HOLDER_CAPABILITY - || (capability == Capabilities.TESLA_PRODUCER_CAPABILITY && sideIsOutput(facing)) - || capability == CapabilityEnergy.ENERGY) { + if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || capability == Capabilities.ENERGY_STORAGE_CAPABILITY + || capability == Capabilities.ENERGY_OUTPUTTER_CAPABILITY || capability == Capabilities.TESLA_HOLDER_CAPABILITY + || (capability == Capabilities.TESLA_PRODUCER_CAPABILITY && sideIsOutput(facing)) || capability == CapabilityEnergy.ENERGY) { return true; } } - return super.hasCapability(capability, side); } @Override public T getCapability(@Nonnull Capability capability, EnumFacing side) { if ((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) { - if (capability == Capabilities.ENERGY_STORAGE_CAPABILITY - || capability == Capabilities.ENERGY_OUTPUTTER_CAPABILITY) { + if (capability == Capabilities.ENERGY_STORAGE_CAPABILITY || capability == Capabilities.ENERGY_OUTPUTTER_CAPABILITY) { return (T) this; } - if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(new FluidHandlerWrapper(this, side)); } - - if (capability == Capabilities.TESLA_HOLDER_CAPABILITY - || (capability == Capabilities.TESLA_PRODUCER_CAPABILITY && sideIsOutput(facing))) { + if (capability == Capabilities.TESLA_HOLDER_CAPABILITY || (capability == Capabilities.TESLA_PRODUCER_CAPABILITY && sideIsOutput(facing))) { return (T) teslaManager.getWrapper(this, facing); } - if (capability == CapabilityEnergy.ENERGY) { return CapabilityEnergy.ENERGY.cast(forgeEnergyManager.getWrapper(this, facing)); } } - return super.getCapability(capability, side); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineVent.java b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineVent.java index 382eca594..8d7b92f57 100644 --- a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineVent.java +++ b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineVent.java @@ -27,18 +27,12 @@ public class TileEntityTurbineVent extends TileEntityTurbineCasing implements IF @Override public void onUpdate() { super.onUpdate(); - if (structure != null && structure.flowRemaining > 0) { FluidStack fluidStack = new FluidStack(FluidRegistry.WATER, structure.flowRemaining); - for (EnumFacing side : EnumFacing.VALUES) { TileEntity tile = Coord4D.get(this).offset(side).getTileEntity(world); - - if (CapabilityUtils - .hasCapability(tile, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite())) { - IFluidHandler handler = CapabilityUtils - .getCapability(tile, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite()); - + if (CapabilityUtils.hasCapability(tile, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite())) { + IFluidHandler handler = CapabilityUtils.getCapability(tile, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite()); if (PipeUtils.canFill(handler, fluidStack)) { structure.flowRemaining -= handler.fill(fluidStack, true); } @@ -49,8 +43,7 @@ public class TileEntityTurbineVent extends TileEntityTurbineCasing implements IF @Override public FluidTankInfo[] getTankInfo(EnumFacing from) { - return ((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) ? new FluidTankInfo[]{ - fakeInfo} : PipeUtils.EMPTY; + return ((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) ? new FluidTankInfo[]{fakeInfo} : PipeUtils.EMPTY; } @Override @@ -90,7 +83,6 @@ public class TileEntityTurbineVent extends TileEntityTurbineCasing implements IF return true; } } - return super.hasCapability(capability, side); } @@ -101,7 +93,6 @@ public class TileEntityTurbineVent extends TileEntityTurbineCasing implements IF return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(new FluidHandlerWrapper(this, side)); } } - return super.getCapability(capability, side); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/tools/client/ToolsClientProxy.java b/src/main/java/mekanism/tools/client/ToolsClientProxy.java index c2347d4c9..d7d820a47 100644 --- a/src/main/java/mekanism/tools/client/ToolsClientProxy.java +++ b/src/main/java/mekanism/tools/client/ToolsClientProxy.java @@ -92,4 +92,4 @@ public class ToolsClientProxy extends ToolsCommonProxy { public void registerItemRender(Item item) { MekanismRenderer.registerItemRender("mekanismtools", item); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/tools/client/gui/GuiToolsConfig.java b/src/main/java/mekanism/tools/client/gui/GuiToolsConfig.java index 338c6eaf3..19931b8d9 100644 --- a/src/main/java/mekanism/tools/client/gui/GuiToolsConfig.java +++ b/src/main/java/mekanism/tools/client/gui/GuiToolsConfig.java @@ -22,18 +22,14 @@ import net.minecraftforge.fml.relauncher.SideOnly; public class GuiToolsConfig extends GuiConfig { public GuiToolsConfig(GuiScreen parent) { - super(parent, getConfigElements(), - "MekanismTools", false, false, "MekanismTools"); + super(parent, getConfigElements(), "MekanismTools", false, false, "MekanismTools"); } private static List getConfigElements() { List list = new ArrayList<>(); - list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.tools.general"), - "mekanism.configgui.ctgy.tools.general", GeneralEntry.class)); - list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.tools.armor"), - "mekanism.configgui.ctgy.tools.armor", ArmorEntry.class)); - list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.tools.tools"), - "mekanism.configgui.ctgy.tools.tools", ToolsEntry.class)); + list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.tools.general"), "mekanism.configgui.ctgy.tools.general", GeneralEntry.class)); + list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.tools.armor"), "mekanism.configgui.ctgy.tools.armor", ArmorEntry.class)); + list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.tools.tools"), "mekanism.configgui.ctgy.tools.tools", ToolsEntry.class)); return list; } @@ -45,12 +41,9 @@ public class GuiToolsConfig extends GuiConfig { @Override protected GuiScreen buildChildScreen() { - return new GuiConfig(owningScreen, - new ConfigElement(Mekanism.configuration.getCategory("tools.general")).getChildElements(), - owningScreen.modID, Configuration.CATEGORY_GENERAL, - configElement.requiresWorldRestart() || owningScreen.allRequireWorldRestart, - configElement.requiresMcRestart() || owningScreen.allRequireMcRestart, - GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); + return new GuiConfig(owningScreen, new ConfigElement(Mekanism.configuration.getCategory("tools.general")).getChildElements(), owningScreen.modID, + Configuration.CATEGORY_GENERAL, configElement.requiresWorldRestart() || owningScreen.allRequireWorldRestart, + configElement.requiresMcRestart() || owningScreen.allRequireMcRestart, GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); } } @@ -62,12 +55,9 @@ public class GuiToolsConfig extends GuiConfig { @Override protected GuiScreen buildChildScreen() { - return new GuiConfig(owningScreen, - new ConfigElement(Mekanism.configuration.getCategory("tools.armor-balance")).getChildElements(), - owningScreen.modID, Configuration.CATEGORY_GENERAL, - configElement.requiresWorldRestart() || owningScreen.allRequireWorldRestart, - configElement.requiresMcRestart() || owningScreen.allRequireMcRestart, - GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); + return new GuiConfig(owningScreen, new ConfigElement(Mekanism.configuration.getCategory("tools.armor-balance")).getChildElements(), owningScreen.modID, + Configuration.CATEGORY_GENERAL, configElement.requiresWorldRestart() || owningScreen.allRequireWorldRestart, + configElement.requiresMcRestart() || owningScreen.allRequireMcRestart, GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); } } @@ -79,12 +69,9 @@ public class GuiToolsConfig extends GuiConfig { @Override protected GuiScreen buildChildScreen() { - return new GuiConfig(owningScreen, - new ConfigElement(Mekanism.configuration.getCategory("tools.tool-balance")).getChildElements(), - owningScreen.modID, Configuration.CATEGORY_GENERAL, - configElement.requiresWorldRestart() || owningScreen.allRequireWorldRestart, - configElement.requiresMcRestart() || owningScreen.allRequireMcRestart, - GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); + return new GuiConfig(owningScreen, new ConfigElement(Mekanism.configuration.getCategory("tools.tool-balance")).getChildElements(), owningScreen.modID, + Configuration.CATEGORY_GENERAL, configElement.requiresWorldRestart() || owningScreen.allRequireWorldRestart, + configElement.requiresMcRestart() || owningScreen.allRequireMcRestart, GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/tools/client/gui/ToolsGuiFactory.java b/src/main/java/mekanism/tools/client/gui/ToolsGuiFactory.java index d9e669010..ed03dfdf5 100644 --- a/src/main/java/mekanism/tools/client/gui/ToolsGuiFactory.java +++ b/src/main/java/mekanism/tools/client/gui/ToolsGuiFactory.java @@ -12,7 +12,6 @@ public class ToolsGuiFactory implements IModGuiFactory { @Override public void initialize(Minecraft minecraftInstance) { - } @Override @@ -29,5 +28,4 @@ public class ToolsGuiFactory implements IModGuiFactory { public GuiScreen createConfigGui(GuiScreen parentScreen) { return new GuiToolsConfig(parentScreen); } -} - +} \ No newline at end of file diff --git a/src/main/java/mekanism/tools/common/MekanismTools.java b/src/main/java/mekanism/tools/common/MekanismTools.java index 3ce669a1c..859c9905a 100644 --- a/src/main/java/mekanism/tools/common/MekanismTools.java +++ b/src/main/java/mekanism/tools/common/MekanismTools.java @@ -95,7 +95,6 @@ public class MekanismTools implements IModule { public void preInit(FMLPreInitializationEvent event) { //Load the config proxy.loadConfiguration(); - addItems(); } @@ -134,18 +133,12 @@ public class MekanismTools implements IModule { setAxeSpeedDamage(toolSTEEL, MekanismConfig.current().tools.toolSTEEL); //Armors - armorOBSIDIAN = getArmorMaterial("OBSIDIAN", MekanismConfig.current().tools.armorOBSIDIAN, - SoundEvents.ITEM_ARMOR_EQUIP_IRON); - armorLAZULI = getArmorMaterial("LAZULI", MekanismConfig.current().tools.armorLAZULI, - SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND); - armorOSMIUM = getArmorMaterial("OSMIUM", MekanismConfig.current().tools.armorOSMIUM, - SoundEvents.ITEM_ARMOR_EQUIP_IRON); - armorBRONZE = getArmorMaterial("BRONZE", MekanismConfig.current().tools.armorBRONZE, - SoundEvents.ITEM_ARMOR_EQUIP_IRON); - armorGLOWSTONE = getArmorMaterial("GLOWSTONE", MekanismConfig.current().tools.armorGLOWSTONE, - SoundEvents.ITEM_ARMOR_EQUIP_IRON); - armorSTEEL = getArmorMaterial("STEEL", MekanismConfig.current().tools.armorSTEEL, - SoundEvents.ITEM_ARMOR_EQUIP_IRON); + armorOBSIDIAN = getArmorMaterial("OBSIDIAN", MekanismConfig.current().tools.armorOBSIDIAN, SoundEvents.ITEM_ARMOR_EQUIP_IRON); + armorLAZULI = getArmorMaterial("LAZULI", MekanismConfig.current().tools.armorLAZULI, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND); + armorOSMIUM = getArmorMaterial("OSMIUM", MekanismConfig.current().tools.armorOSMIUM, SoundEvents.ITEM_ARMOR_EQUIP_IRON); + armorBRONZE = getArmorMaterial("BRONZE", MekanismConfig.current().tools.armorBRONZE, SoundEvents.ITEM_ARMOR_EQUIP_IRON); + armorGLOWSTONE = getArmorMaterial("GLOWSTONE", MekanismConfig.current().tools.armorGLOWSTONE, SoundEvents.ITEM_ARMOR_EQUIP_IRON); + armorSTEEL = getArmorMaterial("STEEL", MekanismConfig.current().tools.armorSTEEL, SoundEvents.ITEM_ARMOR_EQUIP_IRON); ToolsItems.initializeItems(); ToolsItems.setHarvestLevels(); @@ -168,7 +161,7 @@ public class MekanismTools implements IModule { settings.legsProtection.val(), settings.chestProtection.val(), settings.headProtection.val(), - }, settings.enchantability.val(), equipSoundEvent, settings.toughness.val()); + }, settings.enchantability.val(), equipSoundEvent, settings.toughness.val()); } @SubscribeEvent @@ -239,8 +232,7 @@ public class MekanismTools implements IModule { } } - private void setEntityArmorWithChance(Random random, EntityLivingBase entity, Item sword, Item helmet, - Item chestplate, Item leggings, Item boots) { + private void setEntityArmorWithChance(Random random, EntityLivingBase entity, Item sword, Item helmet, Item chestplate, Item leggings, Item boots) { if (entity instanceof EntityZombie && random.nextInt(100) < 50) { setStackIfEmpty(entity, EntityEquipmentSlot.MAINHAND, new ItemStack(sword)); } @@ -270,20 +262,20 @@ public class MekanismTools implements IModule { if (entity instanceof EntityZombie || entity instanceof EntitySkeleton) { if (armorType == 0) { - setEntityArmorWithChance(random, entity, ToolsItems.GlowstoneSword, ToolsItems.GlowstoneHelmet, - ToolsItems.GlowstoneChestplate, ToolsItems.GlowstoneLeggings, ToolsItems.GlowstoneBoots); + setEntityArmorWithChance(random, entity, ToolsItems.GlowstoneSword, ToolsItems.GlowstoneHelmet, ToolsItems.GlowstoneChestplate, + ToolsItems.GlowstoneLeggings, ToolsItems.GlowstoneBoots); } else if (armorType == 1) { - setEntityArmorWithChance(random, entity, ToolsItems.LazuliSword, ToolsItems.LazuliHelmet, - ToolsItems.LazuliChestplate, ToolsItems.LazuliLeggings, ToolsItems.LazuliBoots); + setEntityArmorWithChance(random, entity, ToolsItems.LazuliSword, ToolsItems.LazuliHelmet, ToolsItems.LazuliChestplate, + ToolsItems.LazuliLeggings, ToolsItems.LazuliBoots); } else if (armorType == 2) { - setEntityArmorWithChance(random, entity, ToolsItems.OsmiumSword, ToolsItems.OsmiumHelmet, - ToolsItems.OsmiumChestplate, ToolsItems.OsmiumLeggings, ToolsItems.OsmiumBoots); + setEntityArmorWithChance(random, entity, ToolsItems.OsmiumSword, ToolsItems.OsmiumHelmet, ToolsItems.OsmiumChestplate, + ToolsItems.OsmiumLeggings, ToolsItems.OsmiumBoots); } else if (armorType == 3) { - setEntityArmorWithChance(random, entity, ToolsItems.SteelSword, ToolsItems.SteelHelmet, - ToolsItems.SteelChestplate, ToolsItems.SteelLeggings, ToolsItems.SteelBoots); + setEntityArmorWithChance(random, entity, ToolsItems.SteelSword, ToolsItems.SteelHelmet, ToolsItems.SteelChestplate, + ToolsItems.SteelLeggings, ToolsItems.SteelBoots); } else if (armorType == 4) { - setEntityArmorWithChance(random, entity, ToolsItems.BronzeSword, ToolsItems.BronzeHelmet, - ToolsItems.BronzeChestplate, ToolsItems.BronzeLeggings, ToolsItems.BronzeBoots); + setEntityArmorWithChance(random, entity, ToolsItems.BronzeSword, ToolsItems.BronzeHelmet, ToolsItems.BronzeChestplate, + ToolsItems.BronzeLeggings, ToolsItems.BronzeBoots); } } } @@ -319,4 +311,4 @@ public class MekanismTools implements IModule { proxy.loadConfiguration(); } } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/tools/common/ToolUtils.java b/src/main/java/mekanism/tools/common/ToolUtils.java index 7813cf52a..b57170436 100644 --- a/src/main/java/mekanism/tools/common/ToolUtils.java +++ b/src/main/java/mekanism/tools/common/ToolUtils.java @@ -11,39 +11,30 @@ public class ToolUtils { public static boolean canPickaxeHarvest(@Nonnull IBlockState state, ToolMaterial toolMaterial) { Block block = state.getBlock(); - if (block == Blocks.OBSIDIAN) { return toolMaterial.getHarvestLevel() == 3; } - if (block == Blocks.DIAMOND_BLOCK || block == Blocks.DIAMOND_ORE) { return toolMaterial.getHarvestLevel() >= 2; } - if (block == Blocks.GOLD_BLOCK || block == Blocks.GOLD_ORE) { return toolMaterial.getHarvestLevel() >= 2; } - if (block == Blocks.IRON_BLOCK || block == Blocks.IRON_ORE) { return toolMaterial.getHarvestLevel() >= 1; } - if (block == Blocks.LAPIS_BLOCK || block == Blocks.LAPIS_ORE) { return toolMaterial.getHarvestLevel() >= 1; } - if (block == Blocks.REDSTONE_ORE || block == Blocks.LIT_REDSTONE_ORE) { return toolMaterial.getHarvestLevel() >= 2; } - if (block == Blocks.ANVIL) { return toolMaterial.getHarvestLevel() >= 0; } - if (state.getMaterial() == Material.ROCK) { return true; } - return state.getMaterial() == Material.IRON; } diff --git a/src/main/java/mekanism/tools/common/ToolsCommonProxy.java b/src/main/java/mekanism/tools/common/ToolsCommonProxy.java index 678710650..cd357467a 100644 --- a/src/main/java/mekanism/tools/common/ToolsCommonProxy.java +++ b/src/main/java/mekanism/tools/common/ToolsCommonProxy.java @@ -17,4 +17,4 @@ public class ToolsCommonProxy { public void registerItemRenders() { } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/tools/common/ToolsItems.java b/src/main/java/mekanism/tools/common/ToolsItems.java index 7bfb99f56..446379f8b 100644 --- a/src/main/java/mekanism/tools/common/ToolsItems.java +++ b/src/main/java/mekanism/tools/common/ToolsItems.java @@ -108,70 +108,50 @@ public class ToolsItems { GlowstoneShovel = init(new ItemMekanismShovel(MekanismTools.toolGLOWSTONE), "GlowstoneShovel"); GlowstoneHoe = init(new ItemMekanismHoe(MekanismTools.toolGLOWSTONE), "GlowstoneHoe"); GlowstoneSword = init(new ItemMekanismSword(MekanismTools.toolGLOWSTONE), "GlowstoneSword"); - GlowstoneHelmet = init(new ItemMekanismArmor(MekanismTools.armorGLOWSTONE, 0, EntityEquipmentSlot.HEAD), - "GlowstoneHelmet"); - GlowstoneChestplate = init(new ItemMekanismArmor(MekanismTools.armorGLOWSTONE, 1, EntityEquipmentSlot.CHEST), - "GlowstoneChestplate"); - GlowstoneLeggings = init(new ItemMekanismArmor(MekanismTools.armorGLOWSTONE, 2, EntityEquipmentSlot.LEGS), - "GlowstoneLeggings"); - GlowstoneBoots = init(new ItemMekanismArmor(MekanismTools.armorGLOWSTONE, 3, EntityEquipmentSlot.FEET), - "GlowstoneBoots"); + GlowstoneHelmet = init(new ItemMekanismArmor(MekanismTools.armorGLOWSTONE, 0, EntityEquipmentSlot.HEAD), "GlowstoneHelmet"); + GlowstoneChestplate = init(new ItemMekanismArmor(MekanismTools.armorGLOWSTONE, 1, EntityEquipmentSlot.CHEST), "GlowstoneChestplate"); + GlowstoneLeggings = init(new ItemMekanismArmor(MekanismTools.armorGLOWSTONE, 2, EntityEquipmentSlot.LEGS), "GlowstoneLeggings"); + GlowstoneBoots = init(new ItemMekanismArmor(MekanismTools.armorGLOWSTONE, 3, EntityEquipmentSlot.FEET), "GlowstoneBoots"); BronzePaxel = init(new ItemMekanismPaxel(MekanismTools.toolBRONZE2), "BronzePaxel"); BronzePickaxe = init(new ItemMekanismPickaxe(MekanismTools.toolBRONZE), "BronzePickaxe"); BronzeAxe = init(new ItemMekanismAxe(MekanismTools.toolBRONZE), "BronzeAxe"); BronzeShovel = init(new ItemMekanismShovel(MekanismTools.toolBRONZE), "BronzeShovel"); BronzeHoe = init(new ItemMekanismHoe(MekanismTools.toolBRONZE), "BronzeHoe"); BronzeSword = init(new ItemMekanismSword(MekanismTools.toolBRONZE), "BronzeSword"); - BronzeHelmet = init(new ItemMekanismArmor(MekanismTools.armorBRONZE, 0, EntityEquipmentSlot.HEAD), - "BronzeHelmet"); - BronzeChestplate = init(new ItemMekanismArmor(MekanismTools.armorBRONZE, 1, EntityEquipmentSlot.CHEST), - "BronzeChestplate"); - BronzeLeggings = init(new ItemMekanismArmor(MekanismTools.armorBRONZE, 2, EntityEquipmentSlot.LEGS), - "BronzeLeggings"); - BronzeBoots = init(new ItemMekanismArmor(MekanismTools.armorBRONZE, 3, EntityEquipmentSlot.FEET), - "BronzeBoots"); + BronzeHelmet = init(new ItemMekanismArmor(MekanismTools.armorBRONZE, 0, EntityEquipmentSlot.HEAD), "BronzeHelmet"); + BronzeChestplate = init(new ItemMekanismArmor(MekanismTools.armorBRONZE, 1, EntityEquipmentSlot.CHEST), "BronzeChestplate"); + BronzeLeggings = init(new ItemMekanismArmor(MekanismTools.armorBRONZE, 2, EntityEquipmentSlot.LEGS), "BronzeLeggings"); + BronzeBoots = init(new ItemMekanismArmor(MekanismTools.armorBRONZE, 3, EntityEquipmentSlot.FEET), "BronzeBoots"); OsmiumPaxel = init(new ItemMekanismPaxel(MekanismTools.toolOSMIUM2), "OsmiumPaxel"); OsmiumPickaxe = init(new ItemMekanismPickaxe(MekanismTools.toolOSMIUM), "OsmiumPickaxe"); OsmiumAxe = init(new ItemMekanismAxe(MekanismTools.toolOSMIUM), "OsmiumAxe"); OsmiumShovel = init(new ItemMekanismShovel(MekanismTools.toolOSMIUM), "OsmiumShovel"); OsmiumHoe = init(new ItemMekanismHoe(MekanismTools.toolOSMIUM), "OsmiumHoe"); OsmiumSword = init(new ItemMekanismSword(MekanismTools.toolOSMIUM), "OsmiumSword"); - OsmiumHelmet = init(new ItemMekanismArmor(MekanismTools.armorOSMIUM, 0, EntityEquipmentSlot.HEAD), - "OsmiumHelmet"); - OsmiumChestplate = init(new ItemMekanismArmor(MekanismTools.armorOSMIUM, 1, EntityEquipmentSlot.CHEST), - "OsmiumChestplate"); - OsmiumLeggings = init(new ItemMekanismArmor(MekanismTools.armorOSMIUM, 2, EntityEquipmentSlot.LEGS), - "OsmiumLeggings"); - OsmiumBoots = init(new ItemMekanismArmor(MekanismTools.armorOSMIUM, 3, EntityEquipmentSlot.FEET), - "OsmiumBoots"); + OsmiumHelmet = init(new ItemMekanismArmor(MekanismTools.armorOSMIUM, 0, EntityEquipmentSlot.HEAD), "OsmiumHelmet"); + OsmiumChestplate = init(new ItemMekanismArmor(MekanismTools.armorOSMIUM, 1, EntityEquipmentSlot.CHEST), "OsmiumChestplate"); + OsmiumLeggings = init(new ItemMekanismArmor(MekanismTools.armorOSMIUM, 2, EntityEquipmentSlot.LEGS), "OsmiumLeggings"); + OsmiumBoots = init(new ItemMekanismArmor(MekanismTools.armorOSMIUM, 3, EntityEquipmentSlot.FEET), "OsmiumBoots"); ObsidianPaxel = init(new ItemMekanismPaxel(MekanismTools.toolOBSIDIAN2), "ObsidianPaxel"); ObsidianPickaxe = init(new ItemMekanismPickaxe(MekanismTools.toolOBSIDIAN), "ObsidianPickaxe"); ObsidianAxe = init(new ItemMekanismAxe(MekanismTools.toolOBSIDIAN), "ObsidianAxe"); ObsidianShovel = init(new ItemMekanismShovel(MekanismTools.toolOBSIDIAN), "ObsidianShovel"); ObsidianHoe = init(new ItemMekanismHoe(MekanismTools.toolOBSIDIAN), "ObsidianHoe"); ObsidianSword = init(new ItemMekanismSword(MekanismTools.toolOBSIDIAN), "ObsidianSword"); - ObsidianHelmet = init(new ItemMekanismArmor(MekanismTools.armorOBSIDIAN, 0, EntityEquipmentSlot.HEAD), - "ObsidianHelmet"); - ObsidianChestplate = init(new ItemMekanismArmor(MekanismTools.armorOBSIDIAN, 1, EntityEquipmentSlot.CHEST), - "ObsidianChestplate"); - ObsidianLeggings = init(new ItemMekanismArmor(MekanismTools.armorOBSIDIAN, 2, EntityEquipmentSlot.LEGS), - "ObsidianLeggings"); - ObsidianBoots = init(new ItemMekanismArmor(MekanismTools.armorOBSIDIAN, 3, EntityEquipmentSlot.FEET), - "ObsidianBoots"); + ObsidianHelmet = init(new ItemMekanismArmor(MekanismTools.armorOBSIDIAN, 0, EntityEquipmentSlot.HEAD), "ObsidianHelmet"); + ObsidianChestplate = init(new ItemMekanismArmor(MekanismTools.armorOBSIDIAN, 1, EntityEquipmentSlot.CHEST), "ObsidianChestplate"); + ObsidianLeggings = init(new ItemMekanismArmor(MekanismTools.armorOBSIDIAN, 2, EntityEquipmentSlot.LEGS), "ObsidianLeggings"); + ObsidianBoots = init(new ItemMekanismArmor(MekanismTools.armorOBSIDIAN, 3, EntityEquipmentSlot.FEET), "ObsidianBoots"); LazuliPaxel = init(new ItemMekanismPaxel(MekanismTools.toolLAZULI2), "LapisLazuliPaxel"); LazuliPickaxe = init(new ItemMekanismPickaxe(MekanismTools.toolLAZULI), "LapisLazuliPickaxe"); LazuliAxe = init(new ItemMekanismAxe(MekanismTools.toolLAZULI), "LapisLazuliAxe"); LazuliShovel = init(new ItemMekanismShovel(MekanismTools.toolLAZULI), "LapisLazuliShovel"); LazuliHoe = init(new ItemMekanismHoe(MekanismTools.toolLAZULI), "LapisLazuliHoe"); LazuliSword = init(new ItemMekanismSword(MekanismTools.toolLAZULI), "LapisLazuliSword"); - LazuliHelmet = init(new ItemMekanismArmor(MekanismTools.armorLAZULI, 0, EntityEquipmentSlot.HEAD), - "LapisLazuliHelmet"); - LazuliChestplate = init(new ItemMekanismArmor(MekanismTools.armorLAZULI, 1, EntityEquipmentSlot.CHEST), - "LapisLazuliChestplate"); - LazuliLeggings = init(new ItemMekanismArmor(MekanismTools.armorLAZULI, 2, EntityEquipmentSlot.LEGS), - "LapisLazuliLeggings"); - LazuliBoots = init(new ItemMekanismArmor(MekanismTools.armorLAZULI, 3, EntityEquipmentSlot.FEET), - "LapisLazuliBoots"); + LazuliHelmet = init(new ItemMekanismArmor(MekanismTools.armorLAZULI, 0, EntityEquipmentSlot.HEAD), "LapisLazuliHelmet"); + LazuliChestplate = init(new ItemMekanismArmor(MekanismTools.armorLAZULI, 1, EntityEquipmentSlot.CHEST), "LapisLazuliChestplate"); + LazuliLeggings = init(new ItemMekanismArmor(MekanismTools.armorLAZULI, 2, EntityEquipmentSlot.LEGS), "LapisLazuliLeggings"); + LazuliBoots = init(new ItemMekanismArmor(MekanismTools.armorLAZULI, 3, EntityEquipmentSlot.FEET), "LapisLazuliBoots"); SteelPaxel = init(new ItemMekanismPaxel(MekanismTools.toolSTEEL2), "SteelPaxel"); SteelPickaxe = init(new ItemMekanismPickaxe(MekanismTools.toolSTEEL), "SteelPickaxe"); SteelAxe = init(new ItemMekanismAxe(MekanismTools.toolSTEEL), "SteelAxe"); @@ -179,10 +159,8 @@ public class ToolsItems { SteelHoe = init(new ItemMekanismHoe(MekanismTools.toolSTEEL), "SteelHoe"); SteelSword = init(new ItemMekanismSword(MekanismTools.toolSTEEL), "SteelSword"); SteelHelmet = init(new ItemMekanismArmor(MekanismTools.armorSTEEL, 0, EntityEquipmentSlot.HEAD), "SteelHelmet"); - SteelChestplate = init(new ItemMekanismArmor(MekanismTools.armorSTEEL, 1, EntityEquipmentSlot.CHEST), - "SteelChestplate"); - SteelLeggings = init(new ItemMekanismArmor(MekanismTools.armorSTEEL, 2, EntityEquipmentSlot.LEGS), - "SteelLeggings"); + SteelChestplate = init(new ItemMekanismArmor(MekanismTools.armorSTEEL, 1, EntityEquipmentSlot.CHEST), "SteelChestplate"); + SteelLeggings = init(new ItemMekanismArmor(MekanismTools.armorSTEEL, 2, EntityEquipmentSlot.LEGS), "SteelLeggings"); SteelBoots = init(new ItemMekanismArmor(MekanismTools.armorSTEEL, 3, EntityEquipmentSlot.FEET), "SteelBoots"); } @@ -314,4 +292,4 @@ public class ToolsItems { public static Item init(Item item, String name) { return item.setTranslationKey(name).setRegistryName(new ResourceLocation(MekanismTools.MODID, name)); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/tools/item/ItemMekanismArmor.java b/src/main/java/mekanism/tools/item/ItemMekanismArmor.java index 46e4a528f..c83a2b550 100644 --- a/src/main/java/mekanism/tools/item/ItemMekanismArmor.java +++ b/src/main/java/mekanism/tools/item/ItemMekanismArmor.java @@ -60,7 +60,6 @@ public class ItemMekanismArmor extends ItemArmor { } else if (getArmorMaterial() == MekanismTools.armorSTEEL) { return new ItemStack(MekanismItems.Ingot, 1, 4); } - return new ItemStack(getArmorMaterial().getRepairItem()); } @@ -69,11 +68,9 @@ public class ItemMekanismArmor extends ItemArmor { public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, ModelBiped _default) { if (itemStack.getItem() == ToolsItems.GlowstoneHelmet || itemStack.getItem() == ToolsItems.GlowstoneChestplate - || - itemStack.getItem() == ToolsItems.GlowstoneLeggings || itemStack.getItem() == ToolsItems.GlowstoneBoots) { + || itemStack.getItem() == ToolsItems.GlowstoneLeggings || itemStack.getItem() == ToolsItems.GlowstoneBoots) { return ModelCustomArmor.getGlow(armorSlot); } - return super.getArmorModel(entityLiving, itemStack, armorSlot, _default); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/tools/item/ItemMekanismAxe.java b/src/main/java/mekanism/tools/item/ItemMekanismAxe.java index bbb87c86a..a6fb01e62 100644 --- a/src/main/java/mekanism/tools/item/ItemMekanismAxe.java +++ b/src/main/java/mekanism/tools/item/ItemMekanismAxe.java @@ -28,7 +28,6 @@ public class ItemMekanismAxe extends ItemAxe { @Override public boolean getIsRepairable(ItemStack toRepair, @Nonnull ItemStack repair) { - return StackUtils.equalsWildcard(ItemMekanismTool.getRepairStack(toolMaterial), repair) || super - .getIsRepairable(toRepair, repair); + return StackUtils.equalsWildcard(ItemMekanismTool.getRepairStack(toolMaterial), repair) || super.getIsRepairable(toRepair, repair); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/tools/item/ItemMekanismHoe.java b/src/main/java/mekanism/tools/item/ItemMekanismHoe.java index 244802da6..ac4599e60 100644 --- a/src/main/java/mekanism/tools/item/ItemMekanismHoe.java +++ b/src/main/java/mekanism/tools/item/ItemMekanismHoe.java @@ -44,15 +44,13 @@ public class ItemMekanismHoe extends ItemMekanism { @Override public boolean getIsRepairable(ItemStack stack1, ItemStack stack2) { - return StackUtils.equalsWildcard(ItemMekanismTool.getRepairStack(toolMaterial), stack2) || super - .getIsRepairable(stack1, stack2); + return StackUtils.equalsWildcard(ItemMekanismTool.getRepairStack(toolMaterial), stack2) || super.getIsRepairable(stack1, stack2); } @Nonnull @Override @SuppressWarnings("incomplete-switch") - public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, - EnumFacing facing, float hitX, float hitY, float hitZ) { + public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = playerIn.getHeldItem(hand); if (!playerIn.canPlayerEdit(pos.offset(facing), facing, stack)) { @@ -71,27 +69,23 @@ public class ItemMekanismHoe extends ItemMekanism { setBlock(stack, playerIn, worldIn, pos, Blocks.FARMLAND.getDefaultState()); return EnumActionResult.SUCCESS; } - if (block == Blocks.DIRT) { switch (iblockstate.getValue(BlockDirt.VARIANT)) { case DIRT: setBlock(stack, playerIn, worldIn, pos, Blocks.FARMLAND.getDefaultState()); return EnumActionResult.SUCCESS; case COARSE_DIRT: - setBlock(stack, playerIn, worldIn, pos, Blocks.DIRT.getDefaultState() - .withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT)); + setBlock(stack, playerIn, worldIn, pos, Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT)); return EnumActionResult.SUCCESS; } } } - return EnumActionResult.PASS; } } protected void setBlock(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos, IBlockState state) { worldIn.playSound(player, pos, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F); - if (!worldIn.isRemote) { worldIn.setBlockState(pos, state, 11); stack.damageItem(1, player); @@ -100,24 +94,18 @@ public class ItemMekanismHoe extends ItemMekanism { @Nonnull @Override - public Multimap getAttributeModifiers(@Nonnull EntityEquipmentSlot equipmentSlot, - ItemStack stack) { + public Multimap getAttributeModifiers(@Nonnull EntityEquipmentSlot equipmentSlot, ItemStack stack) { Multimap multimap = super.getAttributeModifiers(equipmentSlot, stack); - if (equipmentSlot == EntityEquipmentSlot.MAINHAND) { - multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), - new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", 0.0D, 0)); - multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), - new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", (double) (this.speed - 4.0F), 0)); + multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", 0.0D, 0)); + multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", (double) (this.speed - 4.0F), 0)); } - return multimap; } @Override public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { stack.damageItem(1, attacker); - return true; } @@ -132,4 +120,4 @@ public class ItemMekanismHoe extends ItemMekanism { public boolean isFull3D() { return true; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/tools/item/ItemMekanismPickaxe.java b/src/main/java/mekanism/tools/item/ItemMekanismPickaxe.java index 9698b88bf..9edbdda46 100644 --- a/src/main/java/mekanism/tools/item/ItemMekanismPickaxe.java +++ b/src/main/java/mekanism/tools/item/ItemMekanismPickaxe.java @@ -12,13 +12,10 @@ import net.minecraft.item.ItemStack; public class ItemMekanismPickaxe extends ItemMekanismTool { - private static final Set EFFECTIVE_ON = Sets - .newHashSet(Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, - Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.DOUBLE_STONE_SLAB, Blocks.GOLDEN_RAIL, - Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, - Blocks.LAPIS_ORE, Blocks.LIT_REDSTONE_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, - Blocks.PACKED_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.RED_SANDSTONE, - Blocks.STONE, Blocks.STONE_SLAB, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE); + private static final Set EFFECTIVE_ON = Sets.newHashSet(Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, + Blocks.DIAMOND_ORE, Blocks.DOUBLE_STONE_SLAB, Blocks.GOLDEN_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, + Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.LIT_REDSTONE_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, + Blocks.SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.STONE_SLAB, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE); public ItemMekanismPickaxe(ToolMaterial toolMaterial) { super(1, -2.8F, toolMaterial, EFFECTIVE_ON); @@ -31,11 +28,9 @@ public class ItemMekanismPickaxe extends ItemMekanismTool { @Override public float getDestroySpeed(@Nonnull ItemStack itemstack, IBlockState blockState) { - if (blockState != null && (blockState.getMaterial() == Material.IRON - || blockState.getMaterial() == Material.ANVIL || blockState.getMaterial() == Material.ROCK)) { + if (blockState != null && (blockState.getMaterial() == Material.IRON || blockState.getMaterial() == Material.ANVIL || blockState.getMaterial() == Material.ROCK)) { return efficiency; - } else { - return super.getDestroySpeed(itemstack, blockState); } + return super.getDestroySpeed(itemstack, blockState); } } \ No newline at end of file diff --git a/src/main/java/mekanism/tools/item/ItemMekanismShovel.java b/src/main/java/mekanism/tools/item/ItemMekanismShovel.java index ed2d30586..de08d0bee 100644 --- a/src/main/java/mekanism/tools/item/ItemMekanismShovel.java +++ b/src/main/java/mekanism/tools/item/ItemMekanismShovel.java @@ -20,9 +20,8 @@ import net.minecraft.world.World; public class ItemMekanismShovel extends ItemMekanismTool { - private static final Set EFFECTIVE_ON = Sets - .newHashSet(Blocks.CLAY, Blocks.DIRT, Blocks.FARMLAND, Blocks.GRASS, Blocks.GRAVEL, Blocks.MYCELIUM, - Blocks.SAND, Blocks.SNOW, Blocks.SNOW_LAYER, Blocks.SOUL_SAND, Blocks.GRASS_PATH); + private static final Set EFFECTIVE_ON = Sets.newHashSet(Blocks.CLAY, Blocks.DIRT, Blocks.FARMLAND, Blocks.GRASS, Blocks.GRAVEL, Blocks.MYCELIUM, Blocks.SAND, + Blocks.SNOW, Blocks.SNOW_LAYER, Blocks.SOUL_SAND, Blocks.GRASS_PATH); public ItemMekanismShovel(ToolMaterial enumtoolmaterial) { super(1.5F, -3, enumtoolmaterial, EFFECTIVE_ON); @@ -35,30 +34,22 @@ public class ItemMekanismShovel extends ItemMekanismTool { @Nonnull @Override - public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, - EnumFacing facing, float hitX, float hitY, float hitZ) { + public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = playerIn.getHeldItem(hand); - if (!playerIn.canPlayerEdit(pos.offset(facing), facing, stack)) { return EnumActionResult.FAIL; - } else { - IBlockState iblockstate = worldIn.getBlockState(pos); - Block block = iblockstate.getBlock(); - - if (facing != EnumFacing.DOWN && worldIn.getBlockState(pos.up()).getMaterial() == Material.AIR - && block == Blocks.GRASS) { - IBlockState iblockstate1 = Blocks.GRASS_PATH.getDefaultState(); - worldIn.playSound(playerIn, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F); - - if (!worldIn.isRemote) { - worldIn.setBlockState(pos, iblockstate1, 11); - stack.damageItem(1, playerIn); - } - - return EnumActionResult.SUCCESS; - } else { - return EnumActionResult.PASS; - } } + IBlockState iblockstate = worldIn.getBlockState(pos); + Block block = iblockstate.getBlock(); + if (facing != EnumFacing.DOWN && worldIn.getBlockState(pos.up()).getMaterial() == Material.AIR && block == Blocks.GRASS) { + IBlockState iblockstate1 = Blocks.GRASS_PATH.getDefaultState(); + worldIn.playSound(playerIn, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F); + if (!worldIn.isRemote) { + worldIn.setBlockState(pos, iblockstate1, 11); + stack.damageItem(1, playerIn); + } + return EnumActionResult.SUCCESS; + } + return EnumActionResult.PASS; } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/tools/item/ItemMekanismSword.java b/src/main/java/mekanism/tools/item/ItemMekanismSword.java index 4f60b8d0a..43c443b89 100644 --- a/src/main/java/mekanism/tools/item/ItemMekanismSword.java +++ b/src/main/java/mekanism/tools/item/ItemMekanismSword.java @@ -30,7 +30,6 @@ public class ItemMekanismSword extends ItemSword { @Override public boolean getIsRepairable(ItemStack stack1, @Nonnull ItemStack stack2) { - return StackUtils.equalsWildcard(ItemMekanismTool.getRepairStack(toolMaterial), stack2) || super - .getIsRepairable(stack1, stack2); + return StackUtils.equalsWildcard(ItemMekanismTool.getRepairStack(toolMaterial), stack2) || super.getIsRepairable(stack1, stack2); } -} +} \ No newline at end of file diff --git a/src/main/java/mekanism/tools/item/ItemMekanismTool.java b/src/main/java/mekanism/tools/item/ItemMekanismTool.java index 30cc43829..70cad173d 100644 --- a/src/main/java/mekanism/tools/item/ItemMekanismTool.java +++ b/src/main/java/mekanism/tools/item/ItemMekanismTool.java @@ -38,7 +38,6 @@ public class ItemMekanismTool extends ItemTool { } else if (material == MekanismTools.toolSTEEL || material == MekanismTools.toolSTEEL2) { return new ItemStack(MekanismItems.Ingot, 1, 4); } - return material.getRepairItemStack(); } @@ -56,4 +55,4 @@ public class ItemMekanismTool extends ItemTool { private ItemStack getRepairStack() { return getRepairStack(toolMaterial); } -} +} \ No newline at end of file