From e3e8cf65dadb2762cb343cc5f31d9bf9a29f2188 Mon Sep 17 00:00:00 2001 From: BluSunrize Date: Sun, 8 Jul 2018 23:55:22 +0200 Subject: [PATCH] Formatted *everything* to the "official" codestyle --- CONTRIBUTING.md | 14 +- .../ImmersiveEngineering.java | 52 +- .../api/AdvancedAABB.java | 7 +- .../immersiveengineering/api/ApiUtils.java | 551 +++++++-------- .../api/ComparableItemStack.java | 19 +- .../api/DimensionBlockPos.java | 34 +- .../api/DimensionChunkCoords.java | 45 +- .../api/DirectionalBlockPos.java | 2 +- .../immersiveengineering/api/IEApi.java | 13 +- .../api/IEProperties.java | 29 +- .../immersiveengineering/api/IPostBlock.java | 8 +- .../immersiveengineering/api/Lib.java | 80 +-- .../api/ManualHelper.java | 6 +- .../api/ManualPageBlueprint.java | 8 +- .../api/ManualPageMultiblock.java | 123 ++-- .../api/MultiblockHandler.java | 16 +- .../api/TargetingInfo.java | 16 +- .../api/crafting/AlloyRecipe.java | 11 +- .../api/crafting/ArcFurnaceRecipe.java | 48 +- .../api/crafting/BlastFurnaceRecipe.java | 17 +- .../api/crafting/BlueprintCraftingRecipe.java | 41 +- .../api/crafting/BottlingMachineRecipe.java | 9 +- .../api/crafting/CokeOvenRecipe.java | 11 +- .../api/crafting/CrusherRecipe.java | 17 +- .../api/crafting/FermenterRecipe.java | 16 +- .../api/crafting/IJEIRecipe.java | 9 +- .../api/crafting/IMultiblockRecipe.java | 9 +- .../api/crafting/IngredientStack.java | 71 +- .../api/crafting/MetalPressRecipe.java | 23 +- .../api/crafting/MixerRecipe.java | 37 +- .../api/crafting/MultiblockRecipe.java | 24 +- .../api/crafting/RefineryRecipe.java | 33 +- .../api/crafting/SqueezerRecipe.java | 16 +- .../api/energy/DieselHandler.java | 25 +- .../api/energy/immersiveflux/FluxStorage.java | 24 +- .../immersiveflux/FluxStorageAdvanced.java | 19 +- .../energy/immersiveflux/IFluxConnection.java | 7 +- .../immersiveflux/IFluxContainerItem.java | 31 +- .../energy/immersiveflux/IFluxProvider.java | 20 +- .../energy/immersiveflux/IFluxReceiver.java | 20 +- .../energy/immersiveflux/IFluxStorage.java | 21 +- .../energy/immersiveflux/package-info.java | 7 +- .../api/energy/wires/IICProxy.java | 28 +- .../energy/wires/IImmersiveConnectable.java | 45 +- .../api/energy/wires/IWireCoil.java | 13 +- .../api/energy/wires/ImmersiveNetHandler.java | 344 +++++----- .../wires/TileEntityImmersiveConnectable.java | 118 ++-- .../api/energy/wires/WireApi.java | 45 +- .../api/energy/wires/WireType.java | 66 +- .../wires/redstone/IRedstoneConnector.java | 5 +- .../wires/redstone/RedstoneWireNetwork.java | 36 +- .../api/fluid/IFluidPipe.java | 1 + .../api/shader/CapabilityShader.java | 13 +- .../api/shader/ShaderCaseBalloon.java | 1 + .../api/shader/ShaderCaseChemthrower.java | 7 +- .../api/shader/ShaderCaseDrill.java | 13 +- .../api/shader/ShaderCaseItem.java | 1 + .../api/shader/ShaderCaseMinecart.java | 6 +- .../api/shader/ShaderCaseRailgun.java | 5 +- .../api/shader/ShaderCaseShield.java | 3 +- .../api/tool/BelljarHandler.java | 106 +-- .../api/tool/BulletHandler.java | 16 +- .../api/tool/ChemthrowerHandler.java | 61 +- .../api/tool/ConveyorHandler.java | 132 ++-- .../api/tool/ExternalHeaterHandler.java | 33 +- .../api/tool/IConfigurableTool.java | 17 +- .../api/tool/IDrillHead.java | 47 +- .../api/tool/IElectricEquipment.java | 14 +- .../api/tool/IInternalStorageItem.java | 6 +- .../api/tool/ITeslaEquipment.java | 2 +- .../api/tool/IUpgrade.java | 6 +- .../api/tool/IUpgradeableTool.java | 14 +- .../api/tool/RailgunHandler.java | 11 +- .../api/tool/ToolboxHandler.java | 47 +- .../api/tool/ZoomHandler.java | 5 +- .../client/ClientEventHandler.java | 8 +- .../client/ClientProxy.java | 2 +- .../client/ClientUtils.java | 633 +++++++++--------- .../client/IECustomStateMapper.java | 8 +- .../client/IEDefaultColourHandlers.java | 1 + .../client/IEItemFontRender.java | 80 ++- .../client/IENixieFontRender.java | 38 +- .../client/ImmersiveModelRegistry.java | 15 +- .../client/ShaderHelper.java | 109 +-- .../client/fx/ParticleFluidSplash.java | 18 +- .../client/fx/ParticleFractal.java | 4 +- .../client/fx/ParticleSparks.java | 8 +- .../client/gui/GuiAlloySmelter.java | 17 +- .../client/gui/GuiArcFurnace.java | 28 +- .../client/gui/GuiAssembler.java | 54 +- .../client/gui/GuiAutoWorkbench.java | 30 +- .../client/gui/GuiBelljar.java | 20 +- .../client/gui/GuiBlastFurnace.java | 17 +- .../client/gui/GuiCokeOven.java | 17 +- .../client/gui/GuiCrate.java | 6 +- .../client/gui/GuiFermenter.java | 15 +- .../client/gui/GuiFluidSorter.java | 49 +- .../client/gui/GuiMixer.java | 18 +- .../client/gui/GuiModWorkbench.java | 54 +- .../client/gui/GuiRefinery.java | 27 +- .../client/gui/GuiRevolver.java | 16 +- .../client/gui/GuiSorter.java | 44 +- .../client/gui/GuiSqueezer.java | 15 +- .../client/gui/GuiToolbox.java | 16 +- .../client/gui/GuiToolboxBlock.java | 16 +- .../client/gui/GuiTurret.java | 56 +- .../gui/elements/GuiButtonCheckbox.java | 6 +- .../client/gui/elements/GuiButtonIE.java | 18 +- .../client/gui/elements/GuiButtonItem.java | 13 +- .../client/gui/elements/GuiButtonState.java | 17 +- .../client/gui/elements/GuiReactiveList.java | 84 ++- .../client/gui/elements/GuiSliderIE.java | 21 +- .../client/manual/IEManualInstance.java | 158 +++-- .../client/manual/ManualPageShader.java | 60 +- .../client/models/IESmartObjModel.java | 211 +++--- .../client/models/IOBJModelCallback.java | 23 +- .../client/models/ModelConfigurableSides.java | 79 ++- .../client/models/ModelConveyor.java | 165 ++--- .../client/models/ModelCoresample.java | 93 +-- .../client/models/ModelEarmuffs.java | 33 +- .../client/models/ModelIEArmorBase.java | 62 +- .../models/ModelItemDynamicOverride.java | 12 +- .../client/models/ModelManeuverGear.java | 35 +- .../client/models/ModelPowerpack.java | 51 +- .../client/models/ModelShaderMinecart.java | 22 +- .../client/models/SmartLightingQuad.java | 32 +- .../client/models/obj/IEOBJLoader.java | 10 +- .../client/models/obj/IEOBJModel.java | 22 +- .../client/models/smart/ConnLoader.java | 27 +- .../client/models/smart/ConnModelReal.java | 91 ++- .../models/smart/FeedthroughLoader.java | 2 +- .../client/models/smart/FeedthroughModel.java | 75 ++- .../client/render/BakedModelTransformer.java | 10 +- .../render/EntityRenderChemthrowerShot.java | 18 +- .../render/EntityRenderFluorescentTube.java | 14 +- .../render/EntityRenderIEExplosive.java | 82 +-- .../render/EntityRenderRailgunShot.java | 96 +-- .../render/EntityRenderRevolvershot.java | 26 +- .../client/render/IEBipedLayerRenderer.java | 6 +- .../client/render/TileRenderArcFurnace.java | 63 +- .../render/TileRenderAutoWorkbench.java | 153 +++-- .../client/render/TileRenderBelljar.java | 9 +- .../render/TileRenderBottlingMachine.java | 66 +- .../client/render/TileRenderBucketWheel.java | 27 +- .../render/TileRenderChargingStation.java | 10 +- .../client/render/TileRenderCoresample.java | 8 +- .../client/render/TileRenderCrusher.java | 28 +- .../render/TileRenderDieselGenerator.java | 22 +- .../client/render/TileRenderMetalPress.java | 50 +- .../client/render/TileRenderMixer.java | 26 +- .../client/render/TileRenderSampleDrill.java | 12 +- .../render/TileRenderSheetmetalTank.java | 34 +- .../client/render/TileRenderSilo.java | 38 +- .../client/render/TileRenderSqueezer.java | 22 +- .../client/render/TileRenderTeslaCoil.java | 24 +- .../client/render/TileRenderTurret.java | 10 +- .../client/render/TileRenderWatermill.java | 12 +- .../client/render/TileRenderWindmill.java | 17 +- .../client/render/TileRenderWorkbench.java | 23 +- .../common/CommonProxy.java | 125 ++-- .../immersiveengineering/common/Config.java | 28 +- .../common/EventHandler.java | 180 ++--- .../common/IEContent.java | 2 +- .../common/IERecipes.java | 313 ++++----- .../common/IESaveData.java | 39 +- .../common/NameRemapper.java | 7 +- .../common/asm/IEClassTransformer.java | 15 +- .../common/blocks/BlockFakeLight.java | 39 +- .../common/blocks/BlockIEBase.java | 123 ++-- .../common/blocks/BlockIEFluid.java | 9 +- .../common/blocks/BlockIEFluidConcrete.java | 70 +- .../common/blocks/BlockIEScaffoldSlab.java | 30 +- .../common/blocks/BlockIESlab.java | 16 +- .../common/blocks/BlockIEStairs.java | 7 +- .../common/blocks/BlockIETileProvider.java | 160 ++--- .../common/blocks/BlockTypes_FakeLight.java | 4 +- .../common/blocks/BlockTypes_MetalsAll.java | 4 +- .../common/blocks/BlockTypes_MetalsIE.java | 4 +- .../common/blocks/BlockTypes_Ore.java | 4 +- .../common/blocks/IEBlockInterfaces.java | 77 ++- .../common/blocks/ItemBlockIEBase.java | 42 +- .../common/blocks/ItemBlockIESlabs.java | 30 +- .../common/blocks/ItemBlockIEStairs.java | 4 +- .../common/blocks/TileEntityIEBase.java | 38 +- .../common/blocks/TileEntityIESlab.java | 7 +- .../blocks/TileEntityMultiblockPart.java | 96 ++- .../common/blocks/cloth/BlockClothDevice.java | 10 +- .../blocks/cloth/BlockTypes_ClothDevice.java | 2 + .../blocks/cloth/ItemBlockClothDevice.java | 20 +- .../blocks/cloth/TileEntityBalloon.java | 74 +- .../blocks/cloth/TileEntityStripCurtain.java | 52 +- .../common/blocks/cloth/package-info.java | 1 + .../common/blocks/metal/BlockConnector.java | 2 - .../common/blocks/metal/BlockConveyor.java | 17 +- .../blocks/metal/BlockMetalDecoration0.java | 2 +- .../blocks/metal/BlockMetalDecoration1.java | 28 +- .../blocks/metal/BlockMetalDecoration2.java | 27 +- .../blocks/metal/BlockMetalDevice0.java | 5 +- .../blocks/metal/BlockMetalDevice1.java | 39 +- .../common/blocks/metal/BlockMetalLadder.java | 6 +- .../blocks/metal/BlockMetalMultiblocks.java | 37 +- .../blocks/metal/BlockTypes_Connector.java | 2 + .../blocks/metal/BlockTypes_Conveyor.java | 2 + .../metal/BlockTypes_MetalDecoration0.java | 2 + .../metal/BlockTypes_MetalDecoration1.java | 2 + .../metal/BlockTypes_MetalDecoration2.java | 2 + .../blocks/metal/BlockTypes_MetalDevice0.java | 2 + .../blocks/metal/BlockTypes_MetalDevice1.java | 2 + .../blocks/metal/BlockTypes_MetalLadder.java | 2 + .../metal/BlockTypes_MetalMultiblock.java | 8 +- .../blocks/metal/TileEntityArcFurnace.java | 290 ++++---- .../blocks/metal/TileEntityAssembler.java | 263 +++++--- .../blocks/metal/TileEntityAutoWorkbench.java | 66 +- .../blocks/metal/TileEntityBelljar.java | 122 ++-- .../TileEntityBlastFurnacePreheater.java | 41 +- .../metal/TileEntityBottlingMachine.java | 133 ++-- .../blocks/metal/TileEntityBreakerSwitch.java | 132 ++-- .../blocks/metal/TileEntityBucketWheel.java | 60 +- .../metal/TileEntityCapacitorCreative.java | 9 +- .../blocks/metal/TileEntityCapacitorHV.java | 2 + .../blocks/metal/TileEntityCapacitorLV.java | 42 +- .../blocks/metal/TileEntityCapacitorMV.java | 2 + .../metal/TileEntityChargingStation.java | 52 +- .../blocks/metal/TileEntityConnectorHV.java | 2 + .../blocks/metal/TileEntityConnectorLV.java | 113 ++-- .../blocks/metal/TileEntityConnectorMV.java | 4 +- .../metal/TileEntityConnectorProbe.java | 31 +- .../metal/TileEntityConnectorRedstone.java | 78 +-- .../metal/TileEntityConnectorStructural.java | 14 +- .../blocks/metal/TileEntityConveyorBelt.java | 36 +- .../metal/TileEntityConveyorVertical.java | 56 +- .../blocks/metal/TileEntityCrusher.java | 129 ++-- .../metal/TileEntityDieselGenerator.java | 221 +++--- .../common/blocks/metal/TileEntityDynamo.java | 14 +- .../metal/TileEntityElectricLantern.java | 70 +- .../blocks/metal/TileEntityEnergyMeter.java | 91 +-- .../blocks/metal/TileEntityExcavator.java | 161 +++-- .../blocks/metal/TileEntityFeedthrough.java | 67 +- .../blocks/metal/TileEntityFloodlight.java | 234 ++++--- .../blocks/metal/TileEntityFluidPipe.java | 270 ++++---- .../blocks/metal/TileEntityFluidPlacer.java | 67 +- .../blocks/metal/TileEntityFluidPump.java | 124 ++-- .../blocks/metal/TileEntityFurnaceHeater.java | 60 +- .../common/blocks/metal/TileEntityLadder.java | 9 +- .../blocks/metal/TileEntityLantern.java | 26 +- .../blocks/metal/TileEntityLightningrod.java | 112 ++-- .../blocks/metal/TileEntityMetalBarrel.java | 14 +- .../blocks/metal/TileEntityMetalPress.java | 69 +- .../common/blocks/metal/TileEntityMixer.java | 124 ++-- .../metal/TileEntityMultiblockMetal.java | 170 +++-- .../blocks/metal/TileEntityRazorWire.java | 72 +- .../metal/TileEntityRedstoneBreaker.java | 18 +- .../blocks/metal/TileEntityRefinery.java | 1 + .../blocks/metal/TileEntityRelayHV.java | 2 +- .../blocks/metal/TileEntitySampleDrill.java | 83 ++- .../metal/TileEntitySheetmetalTank.java | 57 +- .../common/blocks/metal/TileEntitySilo.java | 70 +- .../blocks/metal/TileEntitySqueezer.java | 131 ++-- .../blocks/metal/TileEntityStructuralArm.java | 9 +- .../blocks/metal/TileEntityTeslaCoil.java | 252 +++---- .../blocks/metal/TileEntityToolbox.java | 29 +- .../blocks/metal/TileEntityTransformer.java | 182 ++--- .../blocks/metal/TileEntityTransformerHV.java | 10 +- .../common/blocks/metal/TileEntityTurret.java | 134 ++-- .../blocks/metal/TileEntityTurretChem.java | 24 +- .../blocks/metal/TileEntityTurretGun.java | 37 +- .../blocks/metal/conveyors/ConveyorBasic.java | 6 +- .../metal/conveyors/ConveyorCovered.java | 52 +- .../blocks/metal/conveyors/ConveyorDrop.java | 12 +- .../blocks/metal/conveyors/ConveyorSplit.java | 36 +- .../metal/conveyors/ConveyorVertical.java | 104 +-- .../conveyors/ConveyorVerticalCovered.java | 42 +- .../common/blocks/metal/package-info.java | 1 + .../multiblocks/MultiblockAlloySmelter.java | 44 +- .../multiblocks/MultiblockArcFurnace.java | 123 ++-- .../multiblocks/MultiblockAssembler.java | 69 +- .../multiblocks/MultiblockAutoWorkbench.java | 68 +- .../multiblocks/MultiblockBlastFurnace.java | 43 +- .../MultiblockBlastFurnaceAdvanced.java | 57 +- .../MultiblockBottlingMachine.java | 80 ++- .../multiblocks/MultiblockBucketWheel.java | 55 +- .../multiblocks/MultiblockCokeOven.java | 44 +- .../blocks/multiblocks/MultiblockCrusher.java | 87 +-- .../MultiblockDieselGenerator.java | 62 +- .../multiblocks/MultiblockExcavator.java | 93 +-- .../multiblocks/MultiblockExcavatorDemo.java | 73 +- .../multiblocks/MultiblockFeedthrough.java | 34 +- .../multiblocks/MultiblockFermenter.java | 72 +- .../multiblocks/MultiblockLightningrod.java | 57 +- .../multiblocks/MultiblockMetalPress.java | 50 +- .../blocks/multiblocks/MultiblockMixer.java | 76 ++- .../multiblocks/MultiblockRefinery.java | 86 +-- .../multiblocks/MultiblockSheetmetalTank.java | 69 +- .../blocks/multiblocks/MultiblockSilo.java | 75 ++- .../multiblocks/MultiblockSqueezer.java | 74 +- .../blocks/multiblocks/package-info.java | 1 + .../common/blocks/package-info.java | 1 + .../common/blocks/plant/BlockIECrop.java | 95 ++- .../common/blocks/plant/BlockTypes_Hemp.java | 4 +- .../common/blocks/plant/package-info.java | 1 + .../common/blocks/stone/BlockStoneDevice.java | 19 +- .../stone/BlockTypes_StoneDecoration.java | 4 +- .../blocks/stone/BlockTypes_StoneDevices.java | 4 +- .../blocks/stone/TileEntityAlloySmelter.java | 69 +- .../blocks/stone/TileEntityBlastFurnace.java | 83 ++- .../stone/TileEntityBlastFurnaceAdvanced.java | 77 ++- .../blocks/stone/TileEntityCokeOven.java | 78 ++- .../blocks/stone/TileEntityCoresample.java | 18 +- .../common/blocks/stone/package-info.java | 1 + .../blocks/wooden/BlockTypes_TreatedWood.java | 2 + .../wooden/BlockTypes_WoodenDecoration.java | 2 + .../wooden/BlockTypes_WoodenDevice0.java | 2 + .../wooden/BlockTypes_WoodenDevice1.java | 2 + .../blocks/wooden/BlockWoodenDecoration.java | 25 +- .../blocks/wooden/BlockWoodenDevice0.java | 28 +- .../blocks/wooden/BlockWoodenDevice1.java | 47 +- .../blocks/wooden/TileEntityFluidSorter.java | 56 +- .../blocks/wooden/TileEntityModWorkbench.java | 34 +- .../blocks/wooden/TileEntityTurntable.java | 8 +- .../blocks/wooden/TileEntityWallmount.java | 23 +- .../blocks/wooden/TileEntityWatermill.java | 134 ++-- .../blocks/wooden/TileEntityWindmill.java | 63 +- .../blocks/wooden/TileEntityWoodenBarrel.java | 66 +- .../blocks/wooden/TileEntityWoodenCrate.java | 34 +- .../blocks/wooden/TileEntityWoodenPost.java | 83 +-- .../common/blocks/wooden/package-info.java | 1 + .../common/crafting/ArcRecyclingRecipe.java | 29 +- .../crafting/ArcRecyclingThreadHandler.java | 64 +- .../crafting/ConditionFactoryIEConfig.java | 6 +- .../crafting/ConditionFactoryOreExists.java | 6 +- .../IngredientFactoryStackableNBT.java | 3 +- .../common/crafting/IngredientFluidStack.java | 6 +- .../common/crafting/IngredientIngrStack.java | 10 +- .../common/crafting/IngredientMultiOre.java | 14 +- .../crafting/MetalPressPackingRecipe.java | 5 +- .../crafting/MetalPressUnpackingRecipe.java | 11 +- .../common/crafting/MixerRecipePotion.java | 15 +- .../common/crafting/RecipeBannerAdvanced.java | 25 +- .../common/crafting/RecipeEarmuffs.java | 64 +- .../RecipeFactoryShapedIngredient.java | 2 +- .../common/crafting/RecipeFlareBullets.java | 50 +- .../common/crafting/RecipeIEItemRepair.java | 29 +- .../common/crafting/RecipeJerrycan.java | 24 +- .../common/crafting/RecipePotionBullets.java | 26 +- .../common/crafting/RecipePowerpack.java | 30 +- .../common/crafting/RecipeRGBColouration.java | 50 +- .../common/crafting/RecipeRevolver.java | 20 +- .../common/crafting/RecipeShaderBags.java | 22 +- .../crafting/RecipeShapedIngredient.java | 46 +- .../crafting/RecipeShapelessIngredient.java | 24 +- .../common/crafting/RecipeSpeeloader.java | 4 +- .../datafixers/AssemblerPatternWalker.java | 4 +- .../datafixers/BottlingQueueWalker.java | 4 +- .../DataFixerHammerCutterDamage.java | 6 +- .../common/datafixers/IEDataFixers.java | 11 +- .../common/datafixers/IEItemFixWalker.java | 7 +- .../datafixers/MultiblockProcessWalker.java | 5 +- .../entities/EntityChemthrowerShot.java | 38 +- .../entities/EntityFluorescentTube.java | 25 +- .../common/entities/EntityIEExplosive.java | 22 +- .../common/entities/EntityIEProjectile.java | 101 +-- .../common/entities/EntityRailgunShot.java | 16 +- .../common/entities/EntityRevolvershot.java | 115 ++-- .../entities/EntityRevolvershotFlare.java | 54 +- .../entities/EntityRevolvershotHoming.java | 19 +- .../common/entities/EntitySkylineHook.java | 100 +-- .../common/entities/EntityWolfpackShot.java | 6 +- .../common/gui/ContainerAlloySmelter.java | 10 +- .../common/gui/ContainerArcFurnace.java | 30 +- .../common/gui/ContainerAssembler.java | 34 +- .../common/gui/ContainerAutoWorkbench.java | 25 +- .../common/gui/ContainerBelljar.java | 14 +- .../common/gui/ContainerBlastFurnace.java | 12 +- .../common/gui/ContainerCokeOven.java | 12 +- .../common/gui/ContainerCrate.java | 13 +- .../common/gui/ContainerFermenter.java | 18 +- .../common/gui/ContainerFluidSorter.java | 9 +- .../common/gui/ContainerIEBase.java | 50 +- .../gui/ContainerInternalStorageItem.java | 34 +- .../common/gui/ContainerMixer.java | 13 +- .../common/gui/ContainerModWorkbench.java | 56 +- .../common/gui/ContainerRefinery.java | 36 +- .../common/gui/ContainerRevolver.java | 83 +-- .../common/gui/ContainerSorter.java | 37 +- .../common/gui/ContainerSqueezer.java | 18 +- .../common/gui/ContainerToolbox.java | 28 +- .../common/gui/ContainerToolboxBlock.java | 32 +- .../common/gui/ContainerTurret.java | 12 +- .../common/gui/IESlot.java | 116 +++- .../common/gui/InventoryShader.java | 28 +- .../common/gui/InventoryTile.java | 18 +- .../common/items/IEItemInterfaces.java | 19 +- .../common/items/ItemBullet.java | 75 ++- .../common/items/ItemChemthrower.java | 48 +- .../common/items/ItemCoresample.java | 23 +- .../common/items/ItemDrill.java | 168 +++-- .../common/items/ItemDrillhead.java | 83 +-- .../common/items/ItemEarmuffs.java | 43 +- .../common/items/ItemEngineersBlueprint.java | 48 +- .../common/items/ItemFaradaySuit.java | 13 +- .../common/items/ItemFluorescentTube.java | 41 +- .../common/items/ItemGraphiteElectrode.java | 13 +- .../common/items/ItemIEBase.java | 27 +- .../common/items/ItemIESeed.java | 11 +- .../common/items/ItemIEShield.java | 65 +- .../common/items/ItemInternalStorage.java | 22 +- .../common/items/ItemJerrycan.java | 13 +- .../common/items/ItemMaterial.java | 2 +- .../common/items/ItemPowerpack.java | 18 +- .../common/items/ItemRailgun.java | 81 ++- .../common/items/ItemRevolver.java | 164 +++-- .../common/items/ItemShaderBag.java | 11 +- .../common/items/ItemSkyhook.java | 5 +- .../common/items/ItemSpeedloader.java | 22 +- .../common/items/ItemToolUpgrade.java | 46 +- .../common/items/ItemToolbox.java | 12 +- .../common/items/ItemUpgradeableTool.java | 18 +- .../common/items/ItemWireCoil.java | 31 +- .../common/util/ChatUtils.java | 6 +- .../common/util/EnergyHelper.java | 34 +- .../common/util/FakePlayerUtil.java | 8 +- .../common/util/IEDamageSources.java | 31 +- .../common/util/IEExplosion.java | 229 +++---- .../common/util/IEFluid.java | 18 +- .../common/util/IEItemFluidHandler.java | 8 +- .../common/util/IELootEntry.java | 8 +- .../common/util/IEPotions.java | 39 +- .../common/util/IESounds.java | 5 +- .../common/util/ItemNBTHelper.java | 54 +- .../common/util/ListUtils.java | 54 +- .../common/util/RotationUtil.java | 8 +- .../common/util/SkylineHelper.java | 22 +- .../common/util/Utils.java | 559 +++++++++------- .../util/advancements/MultiblockTrigger.java | 4 +- .../common/util/chickenbones/Matrix4.java | 254 ++++--- .../common/util/commands/CommandHandler.java | 29 +- .../common/util/commands/CommandMineral.java | 40 +- .../common/util/commands/CommandShaders.java | 6 +- .../util/compat/ActuallyAdditionsHelper.java | 2 +- .../common/util/compat/AlbedoHelper.java | 2 +- .../util/compat/AttainedDropsHelper.java | 20 +- .../util/compat/BetterWithModsHelper.java | 6 +- .../common/util/compat/BloodMagicHelper.java | 2 +- .../common/util/compat/BotaniaHelper.java | 16 +- .../util/compat/ChiselsAndBitsHelper.java | 12 +- .../common/util/compat/CoFHHelper.java | 14 +- .../common/util/compat/DenseOresHelper.java | 49 +- .../common/util/compat/ExtraUtilsHelper.java | 9 +- .../common/util/compat/ForestryHelper.java | 14 +- .../common/util/compat/FoundryHelper.java | 6 +- .../util/compat/GeneralComputerHelper.java | 4 +- .../util/compat/HarvestcraftHelper.java | 14 +- .../common/util/compat/IC2Helper.java | 8 +- .../common/util/compat/IECompatModule.java | 50 +- .../compat/MysticalAgricultureHelper.java | 17 +- .../common/util/compat/OneProbeHelper.java | 50 +- .../common/util/compat/RailcraftHelper.java | 34 +- .../common/util/compat/TConstructHelper.java | 2 - .../common/util/compat/ThaumcraftHelper.java | 35 +- .../util/compat/ThermalFoundationHelper.java | 34 +- .../compat/crafttweaker/AlloySmelter.java | 108 +-- .../util/compat/crafttweaker/ArcFurnace.java | 10 +- .../compat/crafttweaker/BlastFurnace.java | 12 +- .../util/compat/crafttweaker/Blueprint.java | 8 +- .../compat/crafttweaker/BottlingMachine.java | 6 +- .../util/compat/crafttweaker/CokeOven.java | 6 +- .../crafttweaker/CraftTweakerHelper.java | 23 +- .../util/compat/crafttweaker/Crusher.java | 16 +- .../compat/crafttweaker/DieselHelper.java | 234 +++---- .../util/compat/crafttweaker/Excavator.java | 10 +- .../util/compat/crafttweaker/Fermenter.java | 26 +- .../util/compat/crafttweaker/MetalPress.java | 10 +- .../util/compat/crafttweaker/Mixer.java | 10 +- .../util/compat/crafttweaker/Refinery.java | 8 +- .../util/compat/crafttweaker/Squeezer.java | 26 +- .../jei/AssemblerRecipeTransferHandler.java | 12 +- .../compat/jei/IEFluidTooltipCallback.java | 4 +- .../util/compat/jei/IERecipeCategory.java | 6 +- .../compat/jei/MultiblockRecipeWrapper.java | 4 + .../AlloySmelterRecipeCategory.java | 4 +- .../AlloySmelterRecipeWrapper.java | 3 +- .../arcfurnace/ArcFurnaceRecipeWrapper.java | 37 +- .../compat/jei/arcfurnace/package-info.java | 1 + .../BlastFurnaceFuelCategory.java | 4 +- .../BlastFurnaceRecipeCategory.java | 2 +- .../BlastFurnaceRecipeWrapper.java | 4 +- .../compat/jei/blastfurnace/package-info.java | 1 + .../BottlingMachineRecipeCategory.java | 8 +- .../BottlingMachineRecipeWrapper.java | 6 +- .../jei/bottlingmachine/package-info.java | 1 + .../jei/cokeoven/CokeOvenRecipeCategory.java | 8 +- .../jei/cokeoven/CokeOvenRecipeWrapper.java | 3 +- .../compat/jei/cokeoven/package-info.java | 1 + .../jei/crusher/CrusherRecipeCategory.java | 16 +- .../jei/crusher/CrusherRecipeWrapper.java | 11 +- .../util/compat/jei/crusher/package-info.java | 1 + .../fermenter/FermenterRecipeCategory.java | 8 +- .../compat/jei/fermenter/package-info.java | 1 + .../metalpress/MetalPressRecipeCategory.java | 5 +- .../compat/jei/metalpress/package-info.java | 1 + .../compat/jei/mixer/MixerRecipeCategory.java | 23 +- .../compat/jei/mixer/MixerRecipeWrapper.java | 3 +- .../util/compat/jei/mixer/package-info.java | 1 + .../common/util/compat/jei/package-info.java | 1 + .../jei/refinery/RefineryRecipeCategory.java | 14 +- .../compat/jei/refinery/package-info.java | 1 + .../jei/squeezer/SqueezerRecipeCategory.java | 8 +- .../compat/jei/squeezer/package-info.java | 1 + .../workbench/WorkbenchRecipeCategory.java | 5 +- .../jei/workbench/WorkbenchRecipeWrapper.java | 5 +- .../compat/jei/workbench/package-info.java | 1 + .../opencomputers/ArcFurnaceDriver.java | 29 +- .../compat/opencomputers/AssemblerDriver.java | 41 +- .../opencomputers/BottlingMachineDriver.java | 13 +- .../compat/opencomputers/CapacitorDriver.java | 2 +- .../compat/opencomputers/CrusherDriver.java | 13 +- .../compat/opencomputers/DieselGenDriver.java | 7 +- .../opencomputers/EnergyMeterDriver.java | 2 +- .../compat/opencomputers/ExcavatorDriver.java | 7 +- .../compat/opencomputers/FermenterDriver.java | 19 +- .../opencomputers/FloodlightDriver.java | 11 +- .../opencomputers/ManagedEnvironmentIE.java | 11 +- .../compat/opencomputers/MixerDriver.java | 23 +- .../compat/opencomputers/RefineryDriver.java | 11 +- .../opencomputers/SampleDrillDriver.java | 6 +- .../compat/opencomputers/SqueezerDriver.java | 19 +- .../compat/opencomputers/TeslaCoilDriver.java | 2 +- .../compat/waila/IEWailaDataProvider.java | 31 +- .../common/util/compat/waila/WailaHelper.java | 4 +- .../util/inventory/IEInventoryHandler.java | 27 +- .../util/inventory/IEItemStackHandler.java | 48 +- .../common/util/inventory/IIEInventory.java | 15 +- .../common/util/inventory/MultiFluidTank.java | 21 +- .../util/network/MessageBirthdayParty.java | 2 + .../network/MessageChemthrowerSwitch.java | 4 +- .../util/network/MessageMagnetEquip.java | 4 +- .../network/MessageMinecartShaderSync.java | 9 +- .../util/network/MessageMineralListSync.java | 17 +- .../network/MessageNoSpamChatComponents.java | 4 +- .../network/MessageObstructedConnection.java | 5 +- .../network/MessageRequestBlockUpdate.java | 5 +- .../util/network/MessageShaderManual.java | 15 +- .../util/network/MessageSkyhookSync.java | 5 +- .../util/network/MessageSpeedloaderSync.java | 2 + .../common/util/network/MessageTileSync.java | 8 +- .../common/util/sound/IEMuffledSound.java | 9 + .../util/sound/IEMuffledTickableSound.java | 12 + .../common/util/sound/IETileSound.java | 51 +- .../common/world/IEWorldGen.java | 44 +- .../common/world/VillageEngineersHouse.java | 197 +++--- .../blusunrize/lib/manual/IManualPage.java | 8 + .../blusunrize/lib/manual/ManualInstance.java | 89 ++- .../blusunrize/lib/manual/ManualPages.java | 59 +- .../blusunrize/lib/manual/ManualUtils.java | 49 +- .../lib/manual/gui/GuiButtonManual.java | 21 +- .../lib/manual/gui/GuiButtonManualLink.java | 17 +- .../manual/gui/GuiButtonManualNavigation.java | 13 +- .../lib/manual/gui/GuiClickableList.java | 40 +- .../blusunrize/lib/manual/gui/GuiManual.java | 208 +++--- .../advancements/main/secret_drillbreak.json | 25 + .../immersiveengineering/lang/en_us.lang | 2 + .../models/item/fake_icon/drillbreak.json | 6 + .../textures/items/fake_icon_drillbreak.png | Bin 0 -> 283 bytes 563 files changed, 12833 insertions(+), 9923 deletions(-) create mode 100644 src/main/resources/assets/immersiveengineering/advancements/main/secret_drillbreak.json create mode 100644 src/main/resources/assets/immersiveengineering/models/item/fake_icon/drillbreak.json create mode 100644 src/main/resources/assets/immersiveengineering/textures/items/fake_icon_drillbreak.png diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bf7e6deb3e..b6ec65a152 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,9 @@ -#### Issues -### General +### Pull requests +When wanting to contribute code to IE, please make sure to follow its inherent style of formatting. +A matching xml file for use with IntelliJ's codestyle feature can be found [here](https://gist.github.com/BluSunrize/5c05af8f29de9581426551d9b29b1809). + +### Issues +#### General - Make sure to use to the latest version of Immersive Engineering (IE for short). You can download it [here](http://minecraft.curseforge.com/projects/immersive-engineering). - IE will create a file for its coremod in your `mods` folder. This is a `.jar` file called `ImmersiveEngineering-0.12-x-core.jar` before IE build 81 and Forge build 2656 and a directory called `memory-repo` afterwards. This is normal and not something to worry about. It's Forge convention to place coremods in separate files. The file is not downloaded, it is shipped with IE and automatically unpacked by Forge. - Your bug report should contain answers to these questions (If adding screenshots makes answering one of these questions easier, add them): @@ -9,12 +13,12 @@ - Did this happen on a dedicated server (multiplayer servers), in LAN multiplayer or in singleplayer? E.g. "I first noticed this on a server, but it happens in singleplayer as well". - What other mods were installed when the bug happened? Crashlogs always contain a modlist, so you can skip this part if you already provided one. You can generate a crash and therefore a mod list by pressing and holding F3 and C for 10 seconds, then releasing. Example: "This happened when playing version 2.4.2 of the FTB Infinity modpack" or "A list of mods can be found here: ``" or "Only IE was installed when this happened". -### Crashlogs +#### Crashlogs If your Minecraft instance has crashed, a file will have been generated in the folder `crash-reports` of your minecraft folder. To understand what has happened, we need to know the content of that file. But please don't just put it directly in your report (that makes it hard to read), upload it to a site like [pastebin](http://pastebin.com) or [gist](http://gist.github.com) and put a link in the actuall bug report. There is one case where no crash log will be generated: If it wasn't MC that crashed but Java. There will be a file called `hs_err` and then some number in your minecraft folder. If that happens, make sure your Java version is up to date (But not Java 9, Minecraft isn't compatible with it). Also make sure that Minecraft is actually using that version, the vanilla launcher includes an old Java version (Java 8 update 25, published in autumn 2014). You can see what version Minecraft is using in the top right of the debug screen (F3). There is a known JVM crash that happens at random while browsing the engineer's manual but only with the old Java version. -### Other mods +#### Other mods Some mods are not officially supported by IE. They will probably work pretty well, but some thing might not work/look weird. If your modpack contains one or more of these mods and you encounter a bug, try removing the unsupported mods. If the bug/crash does not happen without those mods, don't report it since fixing interactions with those mods is usually impossible or extremely hard. The following mods are not officially supported: - **Optifine**: Optifine changes a lot of Minecraft's rendering code and it is not legally possible to check what those changes are. Another problem is that there is no `dev`/`deobf` version of Optifine which makes running Optifine in a development environment pretty much impossible. @@ -25,7 +29,7 @@ Some mods are not officially supported by IE. They will probably work pretty wel - **Torcherino** and other mods to speed up machines (not crops): If they cause a crash, report it. If they don't work on IE machines or cause rendering glitches, don't report it. -### Known issues +#### Known issues It is not unlikely that the issue you want to report has already been reported and maybe it has even been fixed for the next version of IE. Try searching for different terms related to your issue [here](https://github.com/Blusunrize/ImmersiveEngineering/issues?utf8=%E2%9C%93&q=is%3Aissue+). You can enter search terms in the box above the list of issues. Please always search for both open and closed issues as issues are closed when the fix has been written, not when a release containing a fix is published. If your issue has already been reported, please do not post comments like "I have the same crash: <link to crashlog>" unless someone specifically asks for additional crashlogs to help track down the issue. Example: Assume you experienced the crash described in [#1549](https://github.com/BluSunrize/ImmersiveEngineering/issues/1549). Some possible search terms are ["crash crafting wire cutter"](https://github.com/BluSunrize/ImmersiveEngineering/issues?utf8=%E2%9C%93&q=is%3Aissue%20crash%20crafting%20wire%20cutter%20), ["crafting crash"](https://github.com/BluSunrize/ImmersiveEngineering/issues?utf8=%E2%9C%93&q=is%3Aissue%20crafting%20crash) and ["voltmeter crash"](https://github.com/BluSunrize/ImmersiveEngineering/issues?utf8=%E2%9C%93&q=is%3Aissue%20voltmeter%20crash). \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/ImmersiveEngineering.java b/src/main/java/blusunrize/immersiveengineering/ImmersiveEngineering.java index 186902026a..468183065c 100644 --- a/src/main/java/blusunrize/immersiveengineering/ImmersiveEngineering.java +++ b/src/main/java/blusunrize/immersiveengineering/ImmersiveEngineering.java @@ -58,7 +58,7 @@ public class ImmersiveEngineering @Mod.Instance(MODID) public static ImmersiveEngineering instance = new ImmersiveEngineering(); - @SidedProxy(clientSide="blusunrize.immersiveengineering.client.ClientProxy", serverSide="blusunrize.immersiveengineering.common.CommonProxy") + @SidedProxy(clientSide = "blusunrize.immersiveengineering.client.ClientProxy", serverSide = "blusunrize.immersiveengineering.common.CommonProxy") public static CommonProxy proxy; public static final SimpleNetworkWrapper packetHandler = NetworkRegistry.INSTANCE.newSimpleChannel(MODID); @@ -83,20 +83,21 @@ public void preInit(FMLPreInitializationEvent event) for(int b : IEConfig.Ores.oreDimBlacklist) IEWorldGen.oreDimBlacklist.add(b); IEApi.modPreference = Arrays.asList(IEConfig.preferredOres); - IEApi.prefixToIngotMap.put("ingot", new Integer[]{1,1}); - IEApi.prefixToIngotMap.put("nugget", new Integer[]{1,9}); - IEApi.prefixToIngotMap.put("block", new Integer[]{9,1}); - IEApi.prefixToIngotMap.put("plate", new Integer[]{1,1}); - IEApi.prefixToIngotMap.put("wire", new Integer[]{1,1}); - IEApi.prefixToIngotMap.put("gear", new Integer[]{4,1}); - IEApi.prefixToIngotMap.put("rod", new Integer[]{2,1}); - IEApi.prefixToIngotMap.put("fence", new Integer[]{5,3}); + IEApi.prefixToIngotMap.put("ingot", new Integer[]{1, 1}); + IEApi.prefixToIngotMap.put("nugget", new Integer[]{1, 9}); + IEApi.prefixToIngotMap.put("block", new Integer[]{9, 1}); + IEApi.prefixToIngotMap.put("plate", new Integer[]{1, 1}); + IEApi.prefixToIngotMap.put("wire", new Integer[]{1, 1}); + IEApi.prefixToIngotMap.put("gear", new Integer[]{4, 1}); + IEApi.prefixToIngotMap.put("rod", new Integer[]{2, 1}); + IEApi.prefixToIngotMap.put("fence", new Integer[]{5, 3}); IECompatModule.doModulesPreInit(); new ThreadContributorSpecialsDownloader(); IEContent.preInitEnd(); } + @Mod.EventHandler public void init(FMLInitializationEvent event) { @@ -138,6 +139,7 @@ public void init(FMLInitializationEvent event) IEIMCHandler.init(); IEIMCHandler.handleIMCMessages(FMLInterModComms.fetchRuntimeMessages(instance)); } + @Mod.EventHandler public void postInit(FMLPostInitializationEvent event) { @@ -148,11 +150,13 @@ public void postInit(FMLPostInitializationEvent event) proxy.postInitEnd(); ShaderRegistry.compileWeight(); } + @Mod.EventHandler public void loadComplete(FMLLoadCompleteEvent event) { IECompatModule.doModulesLoadComplete(); } + @Mod.EventHandler public void modIDMapping(FMLModIdMappingEvent event) { @@ -167,17 +171,16 @@ public void modIDMapping(FMLModIdMappingEvent event) public void wrongSignature(FMLFingerprintViolationEvent event) { System.out.println("[Immersive Engineering/Error] THIS IS NOT AN OFFICIAL BUILD OF IMMERSIVE ENGINEERING! Found these fingerprints: "+event.getFingerprints()); - for (String altCert:alternativeCerts) - if (event.getFingerprints().contains(altCert)) + for(String altCert : alternativeCerts) + if(event.getFingerprints().contains(altCert)) { - System.out.println("[Immersive Engineering/Error] "+altCert+" is considered an alternative certificate (which may be ok to use in some cases). " + + System.out.println("[Immersive Engineering/Error] "+altCert+" is considered an alternative certificate (which may be ok to use in some cases). "+ "If you thought this was an official build you probably shouldn't use it."); break; } } - @Mod.EventHandler public void serverStarting(FMLServerStartingEvent event) { @@ -186,10 +189,11 @@ public void serverStarting(FMLServerStartingEvent event) if(IEConfig.Machines.arcfurnace_recycle) ArcRecyclingThreadHandler.doRecipeProfiling(); } + @Mod.EventHandler public void serverStarted(FMLServerStartedEvent event) { - if(FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) + if(FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER) { World world = FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld(); if(!world.isRemote) @@ -197,9 +201,9 @@ public void serverStarted(FMLServerStartedEvent event) IELogger.info("WorldData loading"); //Clear out any info from previous worlds - for (int dim: ImmersiveNetHandler.INSTANCE.getRelevantDimensions()) + for(int dim : ImmersiveNetHandler.INSTANCE.getRelevantDimensions()) ImmersiveNetHandler.INSTANCE.clearAllConnections(dim); - IESaveData worldData = (IESaveData) world.loadData(IESaveData.class, IESaveData.dataName); + IESaveData worldData = (IESaveData)world.loadData(IESaveData.class, IESaveData.dataName); if(worldData==null) { @@ -255,10 +259,11 @@ public ItemStack getTabIconItem() { return ItemStack.EMPTY; } + @Override public ItemStack getIconItemStack() { - return new ItemStack(IEContent.blockMetalDecoration0,1,0); + return new ItemStack(IEContent.blockMetalDecoration0, 1, 0); } }; @@ -278,13 +283,15 @@ public ThreadContributorSpecialsDownloader() public void run() { Gson gson = new Gson(); - try { + try + { IELogger.info("Attempting to download special revolvers from GitHub"); URL url = new URL("https://raw.githubusercontent.com/BluSunrize/ImmersiveEngineering/master/contributorRevolvers.json"); JsonStreamParser parser = new JsonStreamParser(new InputStreamReader(url.openStream())); while(parser.hasNext()) { - try{ + try + { JsonElement je = parser.next(); ItemRevolver.SpecialRevolver revolver = gson.fromJson(je, ItemRevolver.SpecialRevolver.class); if(revolver!=null) @@ -292,14 +299,15 @@ public void run() if(revolver.uuid!=null) for(String uuid : revolver.uuid) ItemRevolver.specialRevolvers.put(uuid, revolver); - ItemRevolver.specialRevolversByTag.put(!revolver.tag.isEmpty()?revolver.tag:revolver.flavour, revolver); + ItemRevolver.specialRevolversByTag.put(!revolver.tag.isEmpty()?revolver.tag: revolver.flavour, revolver); } - }catch(Exception excepParse) + } catch(Exception excepParse) { IELogger.warn("Error on parsing a SpecialRevolver"); } } - } catch(Exception e) { + } catch(Exception e) + { IELogger.info("Could not load contributor+special revolver list."); e.printStackTrace(); } diff --git a/src/main/java/blusunrize/immersiveengineering/api/AdvancedAABB.java b/src/main/java/blusunrize/immersiveengineering/api/AdvancedAABB.java index b18a4537f1..79e028d8c1 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/AdvancedAABB.java +++ b/src/main/java/blusunrize/immersiveengineering/api/AdvancedAABB.java @@ -14,28 +14,31 @@ /** * @author BluSunrize - 24.09.2015 - * + *

* Just an AABB with additional info, for use with pipes */ public class AdvancedAABB extends AxisAlignedBB { public EnumFacing fd; public Vec3d[][] drawOverride; + public AdvancedAABB(double xMin, double yMin, double zMin, double xMax, double yMax, double zMax, EnumFacing fd, Vec3d[]... drawOverride) { super(xMin, yMin, zMin, xMax, yMax, zMax); this.fd = fd; this.drawOverride = drawOverride; } - + public AdvancedAABB(double xMin, double yMin, double zMin, double xMax, double yMax, double zMax, EnumFacing fd) { this(xMin, yMin, zMin, xMax, yMax, zMax, fd, new Vec3d[0][]); } + public AdvancedAABB(double xMin, double yMin, double zMin, double xMax, double yMax, double zMax, Vec3d[]... drawOverride) { this(xMin, yMin, zMin, xMax, yMax, zMax, null, drawOverride); } + public AdvancedAABB(double xMin, double yMin, double zMin, double xMax, double yMax, double zMax) { this(xMin, yMin, zMin, xMax, yMax, zMax, null, new Vec3d[0][]); diff --git a/src/main/java/blusunrize/immersiveengineering/api/ApiUtils.java b/src/main/java/blusunrize/immersiveengineering/api/ApiUtils.java index 272bb283e1..ab033ea839 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/ApiUtils.java +++ b/src/main/java/blusunrize/immersiveengineering/api/ApiUtils.java @@ -10,15 +10,11 @@ import blusunrize.immersiveengineering.ImmersiveEngineering; import blusunrize.immersiveengineering.api.crafting.IngredientStack; -import blusunrize.immersiveengineering.api.energy.wires.IICProxy; -import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable; -import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler; +import blusunrize.immersiveengineering.api.energy.wires.*; import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection; -import blusunrize.immersiveengineering.api.energy.wires.IWireCoil; -import blusunrize.immersiveengineering.api.energy.wires.WireType; import blusunrize.immersiveengineering.common.EventHandler; -import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IGeneralMultiblock; import blusunrize.immersiveengineering.common.IESaveData; +import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IGeneralMultiblock; import blusunrize.immersiveengineering.common.util.ItemNBTHelper; import blusunrize.immersiveengineering.common.util.Utils; import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4; @@ -34,18 +30,13 @@ import net.minecraft.client.renderer.vertex.VertexFormatElement; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagInt; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.*; import net.minecraft.util.math.*; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; @@ -81,11 +72,12 @@ public static boolean compareToOreName(ItemStack stack, String oreName) if(!isExistingOreName(oreName)) return false; List s = OreDictionary.getOres(oreName); - for(ItemStack st:s) + for(ItemStack st : s) if(OreDictionary.itemMatches(st, stack, false)) return true; return false; } + public static boolean stackMatchesObject(ItemStack stack, Object o) { return stackMatchesObject(stack, o, false); @@ -94,28 +86,31 @@ public static boolean stackMatchesObject(ItemStack stack, Object o) public static boolean stackMatchesObject(ItemStack stack, Object o, boolean checkNBT) { if(o instanceof ItemStack) - return OreDictionary.itemMatches((ItemStack)o, stack, false) && (!checkNBT || ((ItemStack)o).getItemDamage() == OreDictionary.WILDCARD_VALUE || Utils.compareItemNBT((ItemStack)o, stack)); + return OreDictionary.itemMatches((ItemStack)o, stack, false)&&(!checkNBT||((ItemStack)o).getItemDamage()==OreDictionary.WILDCARD_VALUE||Utils.compareItemNBT((ItemStack)o, stack)); else if(o instanceof Collection) { for(Object io : (Collection)o) - if(io instanceof ItemStack && OreDictionary.itemMatches((ItemStack)io, stack, false) && (!checkNBT || ((ItemStack)io).getItemDamage() == OreDictionary.WILDCARD_VALUE || Utils.compareItemNBT((ItemStack)io, stack))) + if(io instanceof ItemStack&&OreDictionary.itemMatches((ItemStack)io, stack, false)&&(!checkNBT||((ItemStack)io).getItemDamage()==OreDictionary.WILDCARD_VALUE||Utils.compareItemNBT((ItemStack)io, stack))) return true; - } else if(o instanceof IngredientStack) + } + else if(o instanceof IngredientStack) return ((IngredientStack)o).matchesItemStack(stack); else if(o instanceof ItemStack[]) { for(ItemStack io : (ItemStack[])o) - if(OreDictionary.itemMatches(io, stack, false) && (!checkNBT || io.getItemDamage() == OreDictionary.WILDCARD_VALUE || Utils.compareItemNBT(io, stack))) + if(OreDictionary.itemMatches(io, stack, false)&&(!checkNBT||io.getItemDamage()==OreDictionary.WILDCARD_VALUE||Utils.compareItemNBT(io, stack))) return true; - } else if(o instanceof FluidStack) + } + else if(o instanceof FluidStack) { FluidStack fs = FluidUtil.getFluidContained(stack); - return fs != null && fs.containsFluid((FluidStack)o); + return fs!=null&&fs.containsFluid((FluidStack)o); } else if(o instanceof String) return compareToOreName(stack, (String)o); return false; } + public static ItemStack copyStackWithAmount(ItemStack stack, int amount) { if(stack.isEmpty()) @@ -124,6 +119,7 @@ public static ItemStack copyStackWithAmount(ItemStack stack, int amount) s2.setCount(amount); return s2; } + public static boolean stacksMatchIngredientList(List list, NonNullList stacks) { ArrayList queryList = new ArrayList(stacks.size()); @@ -146,21 +142,21 @@ public static boolean stacksMatchIngredientList(List list, NonN if(query.getCount() > amount) { query.shrink(amount); - amount=0; + amount = 0; } else { - amount-=query.getCount(); + amount -= query.getCount(); query.setCount(0); } } - if(query.getCount()<=0) + if(query.getCount() <= 0) it.remove(); - if(amount<=0) + if(amount <= 0) break; } } - if(amount>0) + if(amount > 0) return false; } return true; @@ -180,8 +176,9 @@ public static ComparableItemStack createComparableItemStack(ItemStack stack) public static ComparableItemStack createComparableItemStack(ItemStack stack, boolean copy) { - return createComparableItemStack(stack, copy, stack.hasTagCompound() && !stack.getTagCompound().hasNoTags()); + return createComparableItemStack(stack, copy, stack.hasTagCompound()&&!stack.getTagCompound().hasNoTags()); } + public static ComparableItemStack createComparableItemStack(ItemStack stack, boolean copy, boolean useNbt) { ComparableItemStack comp = new ComparableItemStack(stack, true, copy); @@ -201,11 +198,12 @@ public static boolean isMetalComponent(ItemStack stack, String componentType) { return getMetalComponentType(stack, componentType)!=null; } + public static String getMetalComponentType(ItemStack stack, String... componentTypes) { ItemStack comp = copyStackWithAmount(stack, 1); for(String oreName : OreDictionary.getOreNames())//This is super ugly, but I don't want to force the latest forge ._. - for(int iType=0; iType s = OreDictionary.getOres(oreName); @@ -215,11 +213,12 @@ public static String getMetalComponentType(ItemStack stack, String... componentT } return null; } + public static String[] getMetalComponentTypeAndMetal(ItemStack stack, String... componentTypes) { ItemStack comp = copyStackWithAmount(stack, 1); for(String oreName : OreDictionary.getOreNames())//This is super ugly, but I don't want to force the latest forge ._. - for(int iType=0; iType s = OreDictionary.getOres(oreName); @@ -229,14 +228,17 @@ public static String[] getMetalComponentTypeAndMetal(ItemStack stack, String... } return null; } + public static boolean isIngot(ItemStack stack) { return isMetalComponent(stack, "ingot"); } + public static boolean isPlate(ItemStack stack) { return isMetalComponent(stack, "plate"); } + public static int getComponentIngotWorth(ItemStack stack) { String[] keys = IEApi.prefixToIngotMap.keySet().toArray(new String[IEApi.prefixToIngotMap.size()]); @@ -244,7 +246,7 @@ public static int getComponentIngotWorth(ItemStack stack) if(key!=null) { Integer[] relation = IEApi.prefixToIngotMap.get(key); - if(relation!=null && relation.length>1) + if(relation!=null&&relation.length > 1) { double val = relation[0]/(double)relation[1]; return (int)val; @@ -252,6 +254,7 @@ public static int getComponentIngotWorth(ItemStack stack) } return 0; } + public static ItemStack breakStackIntoIngots(ItemStack stack) { String[] keys = IEApi.prefixToIngotMap.keySet().toArray(new String[IEApi.prefixToIngotMap.size()]); @@ -259,7 +262,7 @@ public static ItemStack breakStackIntoIngots(ItemStack stack) if(type!=null) { Integer[] relation = IEApi.prefixToIngotMap.get(type[0]); - if(relation!=null && relation.length>1) + if(relation!=null&&relation.length > 1) { double val = relation[0]/(double)relation[1]; return copyStackWithAmount(IEApi.getPreferredOreStack("ingot"+type[1]), (int)val); @@ -267,6 +270,7 @@ public static ItemStack breakStackIntoIngots(ItemStack stack) } return ItemStack.EMPTY; } + public static Object[] breakStackIntoPreciseIngots(ItemStack stack) { String[] keys = IEApi.prefixToIngotMap.keySet().toArray(new String[IEApi.prefixToIngotMap.size()]); @@ -274,10 +278,10 @@ public static Object[] breakStackIntoPreciseIngots(ItemStack stack) if(type!=null) { Integer[] relation = IEApi.prefixToIngotMap.get(type[0]); - if(relation!=null && relation.length>1) + if(relation!=null&&relation.length > 1) { double val = relation[0]/(double)relation[1]; - return new Object[]{IEApi.getPreferredOreStack("ingot"+type[1]),val}; + return new Object[]{IEApi.getPreferredOreStack("ingot"+type[1]), val}; } } return null; @@ -285,7 +289,7 @@ public static Object[] breakStackIntoPreciseIngots(ItemStack stack) public static boolean canInsertStackIntoInventory(TileEntity inventory, ItemStack stack, EnumFacing side) { - if(!stack.isEmpty() && inventory != null && inventory.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) + if(!stack.isEmpty()&&inventory!=null&&inventory.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) { IItemHandler handler = inventory.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side); ItemStack temp = ItemHandlerHelper.insertItem(handler, stack.copy(), true); @@ -296,11 +300,11 @@ public static boolean canInsertStackIntoInventory(TileEntity inventory, ItemStac public static ItemStack insertStackIntoInventory(TileEntity inventory, ItemStack stack, EnumFacing side) { - if(!stack.isEmpty() && inventory != null && inventory.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) + if(!stack.isEmpty()&&inventory!=null&&inventory.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) { IItemHandler handler = inventory.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side); ItemStack temp = ItemHandlerHelper.insertItem(handler, stack.copy(), true); - if(temp.isEmpty() || temp.getCount() < stack.getCount()) + if(temp.isEmpty()||temp.getCount() < stack.getCount()) return ItemHandlerHelper.insertItem(handler, stack, false); } return stack; @@ -308,7 +312,7 @@ public static ItemStack insertStackIntoInventory(TileEntity inventory, ItemStack public static ItemStack insertStackIntoInventory(TileEntity inventory, ItemStack stack, EnumFacing side, boolean simulate) { - if(inventory != null && !stack.isEmpty() && inventory.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) + if(inventory!=null&&!stack.isEmpty()&&inventory.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) { IItemHandler handler = inventory.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side); return ItemHandlerHelper.insertItem(handler, stack.copy(), simulate); @@ -322,10 +326,11 @@ public static BlockPos toBlockPos(Object object) return (BlockPos)object; if(object instanceof TileEntity) return ((TileEntity)object).getPos(); - if (object instanceof IICProxy) - return ((IICProxy) object).getPos(); + if(object instanceof IICProxy) + return ((IICProxy)object).getPos(); return null; } + public static IImmersiveConnectable toIIC(Object object, World world) { return toIIC(object, world, true); @@ -338,16 +343,16 @@ public static IImmersiveConnectable toIIC(Object object, World world, boolean al return (IImmersiveConnectable)object; else if(object instanceof BlockPos) { - if (world!=null && world.isBlockLoaded((BlockPos)object)) + if(world!=null&&world.isBlockLoaded((BlockPos)object)) { TileEntity te = world.getTileEntity((BlockPos)object); if(te instanceof IImmersiveConnectable) - return (IImmersiveConnectable) te; + return (IImmersiveConnectable)te; } - if (allowProxies) + if(allowProxies) { DimensionBlockPos pos = new DimensionBlockPos((BlockPos)object, world); - if (ImmersiveNetHandler.INSTANCE.proxies.containsKey(pos)) + if(ImmersiveNetHandler.INSTANCE.proxies.containsKey(pos)) return ImmersiveNetHandler.INSTANCE.proxies.get(pos); } } @@ -361,7 +366,7 @@ public static Vec3d getVecForIICAt(World world, BlockPos pos, Connection conn) IImmersiveConnectable iicPos = toIIC(pos, world, false); if(iicPos!=null) offset = iicPos.getConnectionOffset(conn); - if (pos.equals(conn.end)) + if(pos.equals(conn.end)) offset = offset.addVector(conn.end.getX()-conn.start.getX(), conn.end.getY()-conn.start.getY(), conn.end.getZ()-conn.start.getZ()); @@ -370,23 +375,24 @@ public static Vec3d getVecForIICAt(World world, BlockPos pos, Connection conn) public static Vec3d addVectors(Vec3d vec0, Vec3d vec1) { - return vec0.addVector(vec1.x,vec1.y,vec1.z); + return vec0.addVector(vec1.x, vec1.y, vec1.z); } - public static double acosh(double x) { + public static double acosh(double x) + { //See http://mathworld.wolfram.com/InverseHyperbolicCosine.html return Math.log(x+Math.sqrt(x+1)*Math.sqrt(x-1)); } public static Vec3d[] getConnectionCatenary(Connection connection, Vec3d start, Vec3d end) { - boolean vertical = end.x==start.x && end.z==start.z; + boolean vertical = end.x==start.x&&end.z==start.z; if(vertical) { Vec3d[] ret = new Vec3d[vertices+1]; double height = end.y-start.y; - for (int i = 0;i= Math.sqrt(k*k - dy*dy)/dw) + if(Math.sinh(l)/l >= Math.sqrt(k*k-dy*dy)/dw) break; } double a = dw/2/l; double offsetX = (0+dw-a*Math.log((k+dy)/(k-dy)))*0.5; double offsetY = (dy+0-k*Math.cosh(l)/Math.sinh(l))*0.5; - if (c!=null) + if(c!=null) { c.catOffsetX = offsetX; c.catOffsetY = offsetY; @@ -428,12 +434,12 @@ public static Vec3d[] getConnectionCatenary(Vec3d start, Vec3d end, double slack Vec3d[] vex = new Vec3d[vertices+1]; vex[0] = new Vec3d(start.x, start.y, start.z); - for(int i=1; i> shouldStop, @@ -471,6 +480,7 @@ public static boolean raytraceAlongCatenary(Connection conn, Predicate> shouldStop, Consumer> close, Vec3d vStart, Vec3d vEnd) { @@ -484,54 +494,54 @@ public static boolean raytraceAlongCatenaryRelative(Connection conn, Predicate= 0 && posRel <= 1 && handleVec(pos, pos, 0, halfScanned, done, shouldStop, near, conn.start)) + if(posRel >= 0&&posRel <= 1&&handleVec(pos, pos, 0, halfScanned, done, shouldStop, near, conn.start)) return false; } } } - for (Triple p : near) + for(Triple p : near) close.accept(p); - for (Map.Entry p : halfScanned.entrySet()) - if (shouldStop.test(new ImmutableTriple<>(p.getKey(), p.getValue(), p.getValue()))) + for(Map.Entry p : halfScanned.entrySet()) + if(shouldStop.test(new ImmutableTriple<>(p.getKey(), p.getValue(), p.getValue()))) return false; return true; } @@ -543,25 +553,25 @@ private static boolean handleVec(Vec3d pos, Vec3d origPos, int start, HashMap> shouldStop, HashSet> near) { final double DELTA_NEAR = .3; - if (!done.contains(posB)) + if(!done.contains(posB)) { - if (halfScanned.containsKey(posB)&&!pos.equals(halfScanned.get(posB))) + if(halfScanned.containsKey(posB)&&!pos.equals(halfScanned.get(posB))) { Triple added = new ImmutableTriple<>(posB, halfScanned.get(posB), pos); boolean stop = shouldStop.test(added); done.add(posB); halfScanned.remove(posB); near.removeIf((t) -> t.getLeft().equals(posB)); - if (stop) + if(stop) return true; - for (int i = 0;i<3;i++) + for(int i = 0; i < 3; i++) { double coord = getDim(pos, i); double diff = coord-Math.floor(coord); - if (diff(offsetDim(posB, i, -1), added.getMiddle(), added.getRight())); diff = Math.ceil(coord)-coord; - if (diff(offsetDim(posB, i, 1), added.getMiddle(), added.getRight())); } } @@ -615,140 +625,141 @@ public static WireType getWireTypeFromNBT(NBTTagCompound tag, String key) else return WireType.getValue(tag.getString(key)); } - + public static EnumActionResult doCoilUse(IWireCoil coil, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { - TileEntity tileEntity = world.getTileEntity(pos); - if(tileEntity instanceof IImmersiveConnectable && ((IImmersiveConnectable)tileEntity).canConnect()) + TileEntity tileEntity = world.getTileEntity(pos); + if(tileEntity instanceof IImmersiveConnectable&&((IImmersiveConnectable)tileEntity).canConnect()) + { + ItemStack stack = player.getHeldItem(hand); + TargetingInfo target = new TargetingInfo(side, hitX, hitY, hitZ); + WireType wire = coil.getWireType(stack); + BlockPos masterPos = ((IImmersiveConnectable)tileEntity).getConnectionMaster(wire, target); + Vec3i offset = pos.subtract(masterPos); + tileEntity = world.getTileEntity(masterPos); + if(!(tileEntity instanceof IImmersiveConnectable)||!((IImmersiveConnectable)tileEntity).canConnect()) + return EnumActionResult.PASS; + + if(!((IImmersiveConnectable)tileEntity).canConnectCable(wire, target, offset)||!coil.canConnectCable(stack, tileEntity)) { - ItemStack stack = player.getHeldItem(hand); - TargetingInfo target = new TargetingInfo(side, hitX,hitY,hitZ); - WireType wire = coil.getWireType(stack); - BlockPos masterPos = ((IImmersiveConnectable)tileEntity).getConnectionMaster(wire, target); - Vec3i offset = pos.subtract(masterPos); - tileEntity = world.getTileEntity(masterPos); - if( !(tileEntity instanceof IImmersiveConnectable) || !((IImmersiveConnectable)tileEntity).canConnect()) - return EnumActionResult.PASS; - - if( !((IImmersiveConnectable)tileEntity).canConnectCable(wire, target, offset) || !coil.canConnectCable(stack, tileEntity)) + if(!world.isRemote) + player.sendStatusMessage(new TextComponentTranslation(Lib.CHAT_WARN+"wrongCable"), true); + return EnumActionResult.FAIL; + } + + if(!world.isRemote) + if(!ItemNBTHelper.hasKey(stack, "linkingPos")) { - if (!world.isRemote) - player.sendStatusMessage(new TextComponentTranslation(Lib.CHAT_WARN+"wrongCable"), true); - return EnumActionResult.FAIL; + ItemNBTHelper.setIntArray(stack, "linkingPos", new int[]{world.provider.getDimension(), masterPos.getX(), masterPos.getY(), masterPos.getZ(), + offset.getX(), offset.getY(), offset.getZ()}); + NBTTagCompound targetNbt = new NBTTagCompound(); + target.writeToNBT(targetNbt); + ItemNBTHelper.setTagCompound(stack, "targettingInfo", targetNbt); } - - if(!world.isRemote) - if(!ItemNBTHelper.hasKey(stack, "linkingPos")) - { - ItemNBTHelper.setIntArray(stack, "linkingPos", new int[]{world.provider.getDimension(),masterPos.getX(),masterPos.getY(),masterPos.getZ(), - offset.getX(), offset.getY(), offset.getZ()}); - NBTTagCompound targetNbt = new NBTTagCompound(); - target.writeToNBT(targetNbt); - ItemNBTHelper.setTagCompound(stack, "targettingInfo", targetNbt); - } + else + { + int[] array = ItemNBTHelper.getIntArray(stack, "linkingPos"); + BlockPos linkPos = new BlockPos(array[1], array[2], array[3]); + Vec3i offsetLink = BlockPos.NULL_VECTOR; + if(array.length==7) + offsetLink = new Vec3i(array[4], array[5], array[6]); + TileEntity tileEntityLinkingPos = world.getTileEntity(linkPos); + int distanceSq = (int)Math.ceil(linkPos.distanceSq(masterPos)); + int maxLengthSq = coil.getMaxLength(stack); //not squared yet + maxLengthSq *= maxLengthSq; + if(array[0]!=world.provider.getDimension()) + player.sendStatusMessage(new TextComponentTranslation(Lib.CHAT_WARN+"wrongDimension"), true); + else if(linkPos.equals(masterPos)) + player.sendStatusMessage(new TextComponentTranslation(Lib.CHAT_WARN+"sameConnection"), true); + else if(distanceSq > maxLengthSq) + player.sendStatusMessage(new TextComponentTranslation(Lib.CHAT_WARN+"tooFar"), true); else { - int[] array = ItemNBTHelper.getIntArray(stack, "linkingPos"); - BlockPos linkPos = new BlockPos(array[1],array[2],array[3]); - Vec3i offsetLink = BlockPos.NULL_VECTOR; - if (array.length==7) - offsetLink = new Vec3i(array[4], array[5], array[6]); - TileEntity tileEntityLinkingPos = world.getTileEntity(linkPos); - int distanceSq = (int) Math.ceil( linkPos.distanceSq(masterPos) ); - int maxLengthSq = coil.getMaxLength(stack); //not squared yet - maxLengthSq *= maxLengthSq; - if(array[0]!=world.provider.getDimension()) - player.sendStatusMessage(new TextComponentTranslation(Lib.CHAT_WARN+"wrongDimension"), true); - else if(linkPos.equals(masterPos)) - player.sendStatusMessage(new TextComponentTranslation(Lib.CHAT_WARN+"sameConnection"), true); - else if( distanceSq > maxLengthSq) - player.sendStatusMessage(new TextComponentTranslation(Lib.CHAT_WARN+"tooFar"), true); + TargetingInfo targetLink = TargetingInfo.readFromNBT(ItemNBTHelper.getTagCompound(stack, "targettingInfo")); + if(!(tileEntityLinkingPos instanceof IImmersiveConnectable)|| + !((IImmersiveConnectable)tileEntityLinkingPos).canConnectCable(wire, targetLink, offsetLink)|| + !((IImmersiveConnectable)tileEntityLinkingPos).getConnectionMaster(wire, targetLink).equals(linkPos)|| + !coil.canConnectCable(stack, tileEntityLinkingPos)) + player.sendStatusMessage(new TextComponentTranslation(Lib.CHAT_WARN+"invalidPoint"), true); else { - TargetingInfo targetLink = TargetingInfo.readFromNBT(ItemNBTHelper.getTagCompound(stack, "targettingInfo")); - if(!(tileEntityLinkingPos instanceof IImmersiveConnectable)|| - !((IImmersiveConnectable) tileEntityLinkingPos).canConnectCable(wire, targetLink, offsetLink)|| - !((IImmersiveConnectable) tileEntityLinkingPos).getConnectionMaster(wire, targetLink).equals(linkPos)|| - !coil.canConnectCable(stack, tileEntityLinkingPos)) - player.sendStatusMessage(new TextComponentTranslation(Lib.CHAT_WARN+"invalidPoint"), true); + IImmersiveConnectable nodeHere = (IImmersiveConnectable)tileEntity; + IImmersiveConnectable nodeLink = (IImmersiveConnectable)tileEntityLinkingPos; + boolean connectionExists = false; + Set outputs = ImmersiveNetHandler.INSTANCE.getConnections(world, Utils.toCC(nodeHere)); + if(outputs!=null) + for(Connection con : outputs) + { + if(con.end.equals(Utils.toCC(nodeLink))) + connectionExists = true; + } + if(connectionExists) + player.sendStatusMessage(new TextComponentTranslation(Lib.CHAT_WARN+"connectionExists"), true); else { - IImmersiveConnectable nodeHere = (IImmersiveConnectable)tileEntity; - IImmersiveConnectable nodeLink = (IImmersiveConnectable)tileEntityLinkingPos; - boolean connectionExists = false; - Set outputs = ImmersiveNetHandler.INSTANCE.getConnections(world, Utils.toCC(nodeHere)); - if(outputs!=null) - for(Connection con : outputs) + Set ignore = new HashSet<>(); + ignore.addAll(nodeHere.getIgnored(nodeLink)); + ignore.addAll(nodeLink.getIgnored(nodeHere)); + Connection tmpConn = new Connection(Utils.toCC(nodeHere), Utils.toCC(nodeLink), wire, + (int)Math.sqrt(distanceSq)); + Vec3d start = nodeHere.getConnectionOffset(tmpConn, target, pos.subtract(masterPos)); + Vec3d end = nodeLink.getConnectionOffset(tmpConn, targetLink, offsetLink).addVector(linkPos.getX()-masterPos.getX(), + linkPos.getY()-masterPos.getY(), + linkPos.getZ()-masterPos.getZ()); + BlockPos.MutableBlockPos failedReason = new BlockPos.MutableBlockPos(); + boolean canSee = ApiUtils.raytraceAlongCatenaryRelative(tmpConn, (p) -> { + if(ignore.contains(p.getLeft())) + return false; + IBlockState state = world.getBlockState(p.getLeft()); + if(ApiUtils.preventsConnection(world, p.getLeft(), state, p.getMiddle(), p.getRight())) { - if(con.end.equals(Utils.toCC(nodeLink))) - connectionExists = true; + failedReason.setPos(p.getLeft()); + return true; } - if(connectionExists) - player.sendStatusMessage(new TextComponentTranslation(Lib.CHAT_WARN+"connectionExists"), true); + return false; + }, (p) -> { + }, start, end); + if(canSee) + { + Connection conn = ImmersiveNetHandler.INSTANCE.addAndGetConnection(world, Utils.toCC(nodeHere), Utils.toCC(nodeLink), + (int)Math.sqrt(distanceSq), wire); + + + nodeHere.connectCable(wire, target, nodeLink, offset); + nodeLink.connectCable(wire, targetLink, nodeHere, offsetLink); + ImmersiveNetHandler.INSTANCE.addBlockData(world, conn); + IESaveData.setDirty(world.provider.getDimension()); + Utils.unlockIEAdvancement(player, "main/connect_wire"); + + if(!player.capabilities.isCreativeMode) + coil.consumeWire(stack, (int)Math.sqrt(distanceSq)); + ((TileEntity)nodeHere).markDirty(); + world.addBlockEvent(masterPos, ((TileEntity)nodeHere).getBlockType(), -1, 0); + IBlockState state = world.getBlockState(masterPos); + world.notifyBlockUpdate(masterPos, state, state, 3); + ((TileEntity)nodeLink).markDirty(); + world.addBlockEvent(linkPos, ((TileEntity)nodeLink).getBlockType(), -1, 0); + state = world.getBlockState(linkPos); + world.notifyBlockUpdate(linkPos, state, state, 3); + } else { - Set ignore = new HashSet<>(); - ignore.addAll(nodeHere.getIgnored(nodeLink)); - ignore.addAll(nodeLink.getIgnored(nodeHere)); - Connection tmpConn = new Connection(Utils.toCC(nodeHere), Utils.toCC(nodeLink), wire, - (int)Math.sqrt(distanceSq)); - Vec3d start = nodeHere.getConnectionOffset(tmpConn, target, pos.subtract(masterPos)); - Vec3d end = nodeLink.getConnectionOffset(tmpConn, targetLink, offsetLink).addVector(linkPos.getX()-masterPos.getX(), - linkPos.getY()-masterPos.getY(), - linkPos.getZ()-masterPos.getZ()); - BlockPos.MutableBlockPos failedReason = new BlockPos.MutableBlockPos(); - boolean canSee = ApiUtils.raytraceAlongCatenaryRelative(tmpConn, (p)->{ - if (ignore.contains(p.getLeft())) - return false; - IBlockState state = world.getBlockState(p.getLeft()); - if (ApiUtils.preventsConnection(world, p.getLeft(), state, p.getMiddle(), p.getRight())) - { - failedReason.setPos(p.getLeft()); - return true; - } - return false; - }, (p)->{}, start, end); - if(canSee) - { - Connection conn = ImmersiveNetHandler.INSTANCE.addAndGetConnection(world, Utils.toCC(nodeHere), Utils.toCC(nodeLink), - (int)Math.sqrt(distanceSq), wire); - - - nodeHere.connectCable(wire, target, nodeLink, offset); - nodeLink.connectCable(wire, targetLink, nodeHere, offsetLink); - ImmersiveNetHandler.INSTANCE.addBlockData(world, conn); - IESaveData.setDirty(world.provider.getDimension()); - Utils.unlockIEAdvancement(player, "main/connect_wire"); - - if(!player.capabilities.isCreativeMode) - coil.consumeWire(stack, (int)Math.sqrt(distanceSq)); - ((TileEntity)nodeHere).markDirty(); - world.addBlockEvent(masterPos, ((TileEntity) nodeHere).getBlockType(), -1, 0); - IBlockState state = world.getBlockState(masterPos); - world.notifyBlockUpdate(masterPos, state,state, 3); - ((TileEntity)nodeLink).markDirty(); - world.addBlockEvent(linkPos, ((TileEntity) nodeLink).getBlockType(), -1, 0); - state = world.getBlockState(linkPos); - world.notifyBlockUpdate(linkPos, state,state, 3); - } - else - { - player.sendStatusMessage(new TextComponentTranslation(Lib.CHAT_WARN+"cantSee"), true); - ImmersiveEngineering.packetHandler.sendToAllAround(new MessageObstructedConnection(tmpConn, failedReason, player.world), + player.sendStatusMessage(new TextComponentTranslation(Lib.CHAT_WARN+"cantSee"), true); + ImmersiveEngineering.packetHandler.sendToAllAround(new MessageObstructedConnection(tmpConn, failedReason, player.world), new NetworkRegistry.TargetPoint(player.world.provider.getDimension(), player.posX, player.posY, player.posZ, - 64)); - } + 64)); } } } - ItemNBTHelper.remove(stack, "linkingPos"); - ItemNBTHelper.remove(stack, "targettingInfo"); } - return EnumActionResult.SUCCESS; - } + ItemNBTHelper.remove(stack, "linkingPos"); + ItemNBTHelper.remove(stack, "targettingInfo"); + } + return EnumActionResult.SUCCESS; + } return EnumActionResult.PASS; } - + public static Object convertToValidRecipeInput(Object input) { if(input instanceof ItemStack) @@ -782,31 +793,33 @@ else if(input instanceof ItemStack) else if(input instanceof Item) { if(preferWildcard) - return new IngredientStack(new ItemStack((Item)input,1,OreDictionary.WILDCARD_VALUE)); + return new IngredientStack(new ItemStack((Item)input, 1, OreDictionary.WILDCARD_VALUE)); return new IngredientStack(new ItemStack((Item)input)); } else if(input instanceof Block) { if(preferWildcard) - return new IngredientStack(new ItemStack((Block)input,1,OreDictionary.WILDCARD_VALUE)); + return new IngredientStack(new ItemStack((Block)input, 1, OreDictionary.WILDCARD_VALUE)); return new IngredientStack(new ItemStack((Block)input)); - } else if(input instanceof List && !((List)input).isEmpty()) + } + else if(input instanceof List&&!((List)input).isEmpty()) { if(((List)input).get(0) instanceof ItemStack) - return new IngredientStack(((List) input)); + return new IngredientStack(((List)input)); else if(((List)input).get(0) instanceof String) { ArrayList itemList = new ArrayList(); - for(String s : ((List) input)) + for(String s : ((List)input)) itemList.addAll(OreDictionary.getOres(s)); return new IngredientStack(itemList); } - } else if(input instanceof ItemStack[]) - return new IngredientStack(Arrays.asList((ItemStack[]) input)); + } + else if(input instanceof ItemStack[]) + return new IngredientStack(Arrays.asList((ItemStack[])input)); else if(input instanceof String[]) { ArrayList itemList = new ArrayList(); - for(String s : ((String[]) input)) + for(String s : ((String[])input)) itemList.addAll(OreDictionary.getOres(s)); return new IngredientStack(itemList); } @@ -816,6 +829,7 @@ else if(input instanceof FluidStack) return new IngredientStack((FluidStack)input); throw new RuntimeException("Recipe Ingredients must always be ItemStack, Item, Block, List, String (OreDictionary name) or FluidStack; "+input+" is invalid"); } + public static IngredientStack createIngredientStack(Object input) { return createIngredientStack(input, false); @@ -858,18 +872,19 @@ public static boolean hasPlayerIngredient(EntityPlayer player, IngredientStack i return true; } } - for(int i=0; i sortMap(Map map, boolean inverse) { - TreeMap sortedMap = new TreeMap(new ValueComparator(map, inverse)); + TreeMap sortedMap = new TreeMap(new ValueComparator(map, inverse)); sortedMap.putAll(map); return sortedMap; } - public static void checkForNeedlessTicking(T te) + public static void checkForNeedlessTicking(T te) { - if (!te.getWorld().isRemote&&te.isLogicDummy()) + if(!te.getWorld().isRemote&&te.isLogicDummy()) EventHandler.REMOVE_FROM_TICKING.add(te); } public static boolean preventsConnection(World worldIn, BlockPos pos, IBlockState state, Vec3d a, Vec3d b) { - if (state.getBlock().canCollideCheck(state, false)) + if(state.getBlock().canCollideCheck(state, false)) { List aabbs = new ArrayList<>(1); state.addCollisionBoxToList(worldIn, pos, Block.FULL_BLOCK_AABB.offset(pos), aabbs, null, false); - for (AxisAlignedBB aabb:aabbs) + for(AxisAlignedBB aabb : aabbs) { aabb = aabb.offset(-pos.getX(), -pos.getY(), -pos.getZ()).grow(1e-5); - if (aabb.contains(a) || aabb.contains(b)) + if(aabb.contains(a)||aabb.contains(b)) return true; } RayTraceResult rayResult = state.collisionRayTrace(worldIn, pos, a.addVector(pos.getX(), pos.getY(), pos.getZ()), b.addVector(pos.getX(), pos.getY(), pos.getZ())); - return rayResult != null && rayResult.typeOfHit == RayTraceResult.Type.BLOCK; + return rayResult!=null&&rayResult.typeOfHit==RayTraceResult.Type.BLOCK; } return false; } @@ -941,18 +956,18 @@ public static boolean preventsConnection(World worldIn, BlockPos pos, IBlockStat public static void knockbackNoSource(EntityLivingBase entity, double strength, double xRatio, double zRatio) { entity.isAirBorne = true; - float factor = MathHelper.sqrt(xRatio * xRatio + zRatio * zRatio); + float factor = MathHelper.sqrt(xRatio*xRatio+zRatio*zRatio); entity.motionX /= 2; entity.motionZ /= 2; - entity.motionX -= xRatio / (double)factor * strength; - entity.motionZ -= zRatio / (double)factor * strength; + entity.motionX -= xRatio/(double)factor*strength; + entity.motionZ -= zRatio/(double)factor*strength; - if (entity.onGround) + if(entity.onGround) { entity.motionY /= 2; entity.motionY += strength; - if (entity.motionY > 0.4) + if(entity.motionY > 0.4) { entity.motionY = 0.4; } @@ -968,18 +983,18 @@ public static Connection getTargetConnection(World world, EntityPlayer player, C .lookup(player.dimension); AtomicReference ret = new AtomicReference<>(); AtomicDouble minDistSq = new AtomicDouble(Double.POSITIVE_INFINITY); - Utils.rayTrace(start, end, world, (pos)-> + Utils.rayTrace(start, end, world, (pos) -> { - if (inDim != null && inDim.containsKey(pos)) + if(inDim!=null&&inDim.containsKey(pos)) { ImmersiveNetHandler.BlockWireInfo info = inDim.get(pos); - for (int i = 0; i < 2; i++) + for(int i = 0; i < 2; i++) { - Set> conns = i == 0 ? info.in : info.near; - for (Triple conn : conns) + Set> conns = i==0?info.in: info.near; + for(Triple conn : conns) { Connection c = conn.getLeft(); - if (ignored == null || !c.hasSameConnectors(ignored)) + if(ignored==null||!c.hasSameConnectors(ignored)) { Vec3d startRelative = start.addVector(-pos.getX(), -pos.getY(), -pos.getZ()); Vec3d across = conn.getRight().subtract(conn.getMiddle()); @@ -987,7 +1002,7 @@ public static Connection getTargetConnection(World world, EntityPlayer player, C t = MathHelper.clamp(0, t, 1); Vec3d closest = conn.getMiddle().addVector(t*across.x, t*across.y, t*across.z); double distSq = closest.squareDistanceTo(startRelative); - if (distSq { Map base; boolean inverse; + public ValueComparator(Map base, boolean inverse) { this.base = base; this.inverse = inverse; } + @Override public int compare(String s0, String s1)//Cant return equal to keys separate { if(inverse) { - if (base.get(s0) <= base.get(s1)) + if(base.get(s0) <= base.get(s1)) return -1; else return 1; } else { - if (base.get(s0) >= base.get(s1)) + if(base.get(s0) >= base.get(s1)) return -1; else return 1; @@ -1050,8 +1067,8 @@ public boolean equals(Object obj) { if(!(obj instanceof ValueComparator)) return false; - ValueComparator other = (ValueComparator) obj; - return other.base == base && other.inverse == inverse; + ValueComparator other = (ValueComparator)obj; + return other.base==base&&other.inverse==inverse; } } @@ -1066,6 +1083,7 @@ public static TextureAtlasSprite getRegisterSprite(TextureMap map, String path) } return sprite; } + @SideOnly(Side.CLIENT) public static TextureAtlasSprite getRegisterSprite(TextureMap map, ResourceLocation path) { @@ -1085,14 +1103,14 @@ public static Function transformQuad(Matrix4 mat, VertexFo int posPos = -1; int normPos = -1; int colorPos = -1; - for (int i = 0;i> 16 & 255) / 255.0F; - float g = (float) (multiplier >> 8 & 255) / 255.0F; - float b = (float) (multiplier & 255) / 255.0F; + float r = (float)(multiplier >> 16&255)/255.0F; + float g = (float)(multiplier >> 8&255)/255.0F; + float b = (float)(multiplier&255)/255.0F; float[] oldData = data; data = new float[4]; - data[0] = oldData[0] * r; - data[1] = oldData[1] * g; - data[2] = oldData[2] * b; + data[0] = oldData[0]*r; + data[1] = oldData[1]*g; + data[2] = oldData[2]*b; data[3] = oldData[3]; } } @@ -1177,7 +1196,7 @@ else if (element==colorPosFinal) ref.get().put(element, data); } }; - return (q)->{ + return (q) -> { ref.set(new UnpackedBakedQuad.Builder(f)); q.pipe(transformer); return ref.get().build(); diff --git a/src/main/java/blusunrize/immersiveengineering/api/ComparableItemStack.java b/src/main/java/blusunrize/immersiveengineering/api/ComparableItemStack.java index f953f93735..c1e8f87d81 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/ComparableItemStack.java +++ b/src/main/java/blusunrize/immersiveengineering/api/ComparableItemStack.java @@ -16,22 +16,24 @@ public class ComparableItemStack { public ItemStack stack; public boolean useNBT; - public int oreID=-1; + public int oreID = -1; public ComparableItemStack(ItemStack stack) { this(stack, true); } + public ComparableItemStack(ItemStack stack, boolean matchOre) { this(stack, matchOre, true); } + public ComparableItemStack(ItemStack stack, boolean matchOre, boolean copy) { if(stack==null) throw new RuntimeException("You cannot instantiate a ComparableItemStack with null for an Item!"); this.stack = stack; - if (copy) + if(copy) copy(); if(matchOre) { @@ -57,6 +59,7 @@ public ComparableItemStack setUseNBT(boolean useNBT) this.useNBT = useNBT; return this; } + public ComparableItemStack setOreID(int oid) { this.oreID = oid; @@ -68,13 +71,14 @@ public String toString() { return "ComparableStack: {"+this.stack.toString()+"}; oreID: "+this.oreID+"; checkNBT: "+this.useNBT; } + @Override public int hashCode() { if(this.oreID!=-1) return this.oreID; - int hash = (stack.getItemDamage()&0xffff)*31 + stack.getItem().hashCode()*31; - if(this.useNBT && stack.hasTagCompound()) + int hash = (stack.getItemDamage()&0xffff)*31+stack.getItem().hashCode()*31; + if(this.useNBT&&stack.hasTagCompound()) hash += stack.getTagCompound().hashCode()*31; return hash; } @@ -85,11 +89,11 @@ public boolean equals(Object object) if(!(object instanceof ComparableItemStack)) return false; - if(this.oreID!=-1 && ((ComparableItemStack)object).oreID!=-1) - return this.oreID == ((ComparableItemStack)object).oreID; + if(this.oreID!=-1&&((ComparableItemStack)object).oreID!=-1) + return this.oreID==((ComparableItemStack)object).oreID; ItemStack otherStack = ((ComparableItemStack)object).stack; - if(!OreDictionary.itemMatches(stack,otherStack, false)) + if(!OreDictionary.itemMatches(stack, otherStack, false)) return false; if(this.useNBT) return ItemStack.areItemStackTagsEqual(stack, otherStack); @@ -108,6 +112,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) } return nbt; } + public static ComparableItemStack readFromNBT(NBTTagCompound nbt) { if(nbt.hasKey("oreID")) diff --git a/src/main/java/blusunrize/immersiveengineering/api/DimensionBlockPos.java b/src/main/java/blusunrize/immersiveengineering/api/DimensionBlockPos.java index 6263797595..9068c30550 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/DimensionBlockPos.java +++ b/src/main/java/blusunrize/immersiveengineering/api/DimensionBlockPos.java @@ -8,7 +8,6 @@ package blusunrize.immersiveengineering.api; -import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -18,19 +17,23 @@ public class DimensionBlockPos extends BlockPos { public int dimension; + public DimensionBlockPos(int x, int y, int z, int dim) { super(x, y, z); dimension = dim; } + public DimensionBlockPos(int x, int y, int z, World w) { this(x, y, z, w.provider.getDimension()); } + public DimensionBlockPos(BlockPos pos, World w) { this(pos.getX(), pos.getY(), pos.getZ(), w.provider.getDimension()); } + public DimensionBlockPos(BlockPos pos, int dim) { this(pos.getX(), pos.getY(), pos.getZ(), dim); @@ -46,33 +49,36 @@ public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + dimension; - result = prime * result + getX(); - result = prime * result + getY(); - result = prime * result + getZ(); + result = prime*result+dimension; + result = prime*result+getX(); + result = prime*result+getY(); + result = prime*result+getZ(); return result; } + @Override public boolean equals(Object obj) { - if (this == obj) + if(this==obj) return true; - if (obj == null) + if(obj==null) return false; - if (getClass() != obj.getClass()) + if(getClass()!=obj.getClass()) return false; - DimensionBlockPos other = (DimensionBlockPos) obj; - if (dimension != other.dimension) + DimensionBlockPos other = (DimensionBlockPos)obj; + if(dimension!=other.dimension) return false; - if (getX() != other.getX()) + if(getX()!=other.getX()) return false; - if (getY() != other.getY()) + if(getY()!=other.getY()) return false; - return getZ() == other.getZ(); + return getZ()==other.getZ(); } + @Nonnull @Override - public String toString() { + public String toString() + { return "Dimension: "+dimension+" Pos: "+super.toString(); } } diff --git a/src/main/java/blusunrize/immersiveengineering/api/DimensionChunkCoords.java b/src/main/java/blusunrize/immersiveengineering/api/DimensionChunkCoords.java index 1920d877c7..c3621fd1c3 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/DimensionChunkCoords.java +++ b/src/main/java/blusunrize/immersiveengineering/api/DimensionChunkCoords.java @@ -14,32 +14,34 @@ public class DimensionChunkCoords extends ChunkPos { public int dimension; + public DimensionChunkCoords(int dimension, int x, int z) { - super(x,z); - this.dimension=dimension; + super(x, z); + this.dimension = dimension; } @Override - public boolean equals(Object o) - { - if (this == o) - return true; - else if (!(o instanceof DimensionChunkCoords)) - return false; - else - { - DimensionChunkCoords coordPair = (DimensionChunkCoords)o; - return this.dimension==coordPair.dimension && this.x==coordPair.x && this.z==coordPair.z; - } - } + public boolean equals(Object o) + { + if(this==o) + return true; + else if(!(o instanceof DimensionChunkCoords)) + return false; + else + { + DimensionChunkCoords coordPair = (DimensionChunkCoords)o; + return this.dimension==coordPair.dimension&&this.x==coordPair.x&&this.z==coordPair.z; + } + } + @Override - public String toString() - { - return "[dim:"+ this.dimension+ "; " +this.x+ ", " +this.z + "]"; - } + public String toString() + { + return "[dim:"+this.dimension+"; "+this.x+", "+this.z+"]"; + } - public DimensionChunkCoords withOffset(int offsetX, int offsetZ) + public DimensionChunkCoords withOffset(int offsetX, int offsetZ) { return new DimensionChunkCoords(this.dimension, this.x+offsetX, this.z+offsetZ); } @@ -52,10 +54,11 @@ public NBTTagCompound writeToNBT() tag.setInteger("z", this.z); return tag; } + public static DimensionChunkCoords readFromNBT(NBTTagCompound tag) { - if(tag.hasKey("dim",3)&&tag.hasKey("x",3)&&tag.hasKey("z",3)) - return new DimensionChunkCoords(tag.getInteger("dim"),tag.getInteger("x"),tag.getInteger("z")); + if(tag.hasKey("dim", 3)&&tag.hasKey("x", 3)&&tag.hasKey("z", 3)) + return new DimensionChunkCoords(tag.getInteger("dim"), tag.getInteger("x"), tag.getInteger("z")); return null; } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/api/DirectionalBlockPos.java b/src/main/java/blusunrize/immersiveengineering/api/DirectionalBlockPos.java index a1e5447bb6..8c506bbb7a 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/DirectionalBlockPos.java +++ b/src/main/java/blusunrize/immersiveengineering/api/DirectionalBlockPos.java @@ -37,7 +37,7 @@ public DirectionalBlockPos(int x, int y, int z, EnumFacing direction) @Override public String toString() { - return MoreObjects.toStringHelper(this).add("x", this.getX()).add("y", this.getY()).add("z", this.getZ()).add("direction", this.direction.toString()).toString(); + return MoreObjects.toStringHelper(this).add("x", this.getX()).add("y", this.getY()).add("z", this.getZ()).add("direction", this.direction.toString()).toString(); } public TileEntity getTile(World world) diff --git a/src/main/java/blusunrize/immersiveengineering/api/IEApi.java b/src/main/java/blusunrize/immersiveengineering/api/IEApi.java index c52fe3fcdb..8eb2ec3323 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/IEApi.java +++ b/src/main/java/blusunrize/immersiveengineering/api/IEApi.java @@ -23,7 +23,7 @@ /** * @author BluSunrize - 13.08.2015 - * + *

* An API class, for features that should be accessible in compatibility */ public class IEApi @@ -77,8 +77,9 @@ public static ItemStack getPreferredOreStack(String oreName) return preferredStack; } ItemStack s = oreOutputPreference.get(oreName); - return s == null ? ItemStack.EMPTY : s.copy(); + return s==null?ItemStack.EMPTY: s.copy(); } + public static ItemStack getPreferredStackbyMod(Collection list) { ItemStack preferredStack = ItemStack.EMPTY; @@ -91,7 +92,7 @@ public static ItemStack getPreferredStackbyMod(Collection list) { String modId = rl.getResourceDomain(); int idx = modId==null||modId.isEmpty()?-1: modPreference.indexOf(modId); - if(preferredStack.isEmpty() || (idx>=0 && (lastPref<0 || idx= 0&&(lastPref < 0||idx < lastPref))) { preferredStack = stack; lastPref = idx; @@ -100,14 +101,16 @@ public static ItemStack getPreferredStackbyMod(Collection list) } return preferredStack.copy(); } + public static ItemStack getPreferredStackbyMod(ItemStack[] array) { return getPreferredStackbyMod(Lists.newArrayList(array)); } + public static boolean isAllowedInCrate(ItemStack stack) { - for (Predicate check:forbiddenInCrates) - if (check.test(stack)) + for(Predicate check : forbiddenInCrates) + if(check.test(stack)) return false; return true; } diff --git a/src/main/java/blusunrize/immersiveengineering/api/IEProperties.java b/src/main/java/blusunrize/immersiveengineering/api/IEProperties.java index 771efd1731..35c05c4317 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/IEProperties.java +++ b/src/main/java/blusunrize/immersiveengineering/api/IEProperties.java @@ -14,7 +14,6 @@ import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.properties.PropertyHelper; import net.minecraft.block.properties.PropertyInteger; -import net.minecraft.block.state.IBlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.property.IUnlistedProperty; @@ -31,8 +30,8 @@ public class IEProperties public static final PropertyBoolInverted MULTIBLOCKSLAVE = PropertyBoolInverted.create("_0multiblockslave");//Name starts with '_0' to ensure priority when overriding models public static final PropertyBoolInverted DYNAMICRENDER = PropertyBoolInverted.create("_1dynamicrender");//Name starts with '_1' to ensure priority over anything but the multiblockslave property public static final PropertySet CONNECTIONS = new PropertySet("conns"); - -// public static final PropertyEnum[] SIDECONFIG = { + + // public static final PropertyEnum[] SIDECONFIG = { // PropertyEnum.create("sideconfig_down", IEEnums.SideConfig.class), // PropertyEnum.create("sideconfig_up", IEEnums.SideConfig.class), // PropertyEnum.create("sideconfig_north", IEEnums.SideConfig.class), @@ -63,31 +62,36 @@ public class IEProperties PropertyBoolInverted.create("boolean1"), PropertyBoolInverted.create("boolean2") }; - public static final PropertyInteger INT_4 = PropertyInteger.create("int_4", 0,3); - public static final PropertyInteger INT_16 = PropertyInteger.create("int_16", 0,15); + public static final PropertyInteger INT_4 = PropertyInteger.create("int_4", 0, 3); + public static final PropertyInteger INT_16 = PropertyInteger.create("int_16", 0, 15); public static class ProperySideConfig implements IUnlistedProperty { final String name; + public ProperySideConfig(String name) { this.name = name; } + @Override public String getName() { return name; } + @Override public boolean isValid(SideConfig value) { return true; } + @Override public Class getType() { return IEEnums.SideConfig.class; } + @Override public String valueToString(SideConfig value) { @@ -102,43 +106,52 @@ public String getName() { return "obj_texture_remap"; } + @Override public boolean isValid(HashMap value) { return true; } + @Override - public Class getType() { + public Class getType() + { return HashMap.class; } + @Override public String valueToString(HashMap value) { return value.toString(); } }; - + public static class PropertyBoolInverted extends PropertyHelper { private static final ImmutableList ALLOWED_VALUES = ImmutableList.of(false, true); + protected PropertyBoolInverted(String name) { super(name, Boolean.class); } + @Override public Collection getAllowedValues() { return ALLOWED_VALUES; } + @Override public Optional parseValue(String value) { return Optional.of(Boolean.parseBoolean(value)); } + public static PropertyBoolInverted create(String name) { return new PropertyBoolInverted(name); } + @Override public String getName(Boolean value) { @@ -165,7 +178,7 @@ public String getName() @Override public boolean isValid(Set value) { - return value != null; + return value!=null; } @Override diff --git a/src/main/java/blusunrize/immersiveengineering/api/IPostBlock.java b/src/main/java/blusunrize/immersiveengineering/api/IPostBlock.java index cf1c6ff2db..ceb086e3b0 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/IPostBlock.java +++ b/src/main/java/blusunrize/immersiveengineering/api/IPostBlock.java @@ -16,8 +16,8 @@ */ public interface IPostBlock { - /** - * Returns true if a transformer should render attached to this post - */ - boolean canConnectTransformer(IBlockAccess world, BlockPos pos); + /** + * Returns true if a transformer should render attached to this post + */ + boolean canConnectTransformer(IBlockAccess world, BlockPos pos); } diff --git a/src/main/java/blusunrize/immersiveengineering/api/Lib.java b/src/main/java/blusunrize/immersiveengineering/api/Lib.java index d0c735626d..37ce727ea7 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/Lib.java +++ b/src/main/java/blusunrize/immersiveengineering/api/Lib.java @@ -9,8 +9,8 @@ package blusunrize.immersiveengineering.api; -import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item.ToolMaterial; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.common.util.EnumHelper; @@ -18,55 +18,57 @@ public class Lib { public static final String MODID = "immersiveengineering"; - public static final String[] METALS_IE = {"Copper","Aluminum","Lead","Silver","Nickel","Uranium","Constantan","Electrum","Steel"}; - public static final String[] METALS_ALL = {"Copper","Aluminum","Lead","Silver","Nickel","Uranium","Constantan","Electrum","Steel","Iron","Gold"}; + public static final String[] METALS_IE = {"Copper", "Aluminum", "Lead", "Silver", "Nickel", "Uranium", "Constantan", "Electrum", "Steel"}; + public static final String[] METALS_ALL = {"Copper", "Aluminum", "Lead", "Silver", "Nickel", "Uranium", "Constantan", "Electrum", "Steel", "Iron", "Gold"}; public static final String TOOL_HAMMER = "IE_HAMMER"; public static final String TOOL_WIRECUTTER = "IE_WIRECUTTER"; - public static final String CHAT = "chat." + MODID + "."; + public static final String CHAT = "chat."+MODID+"."; public static final String CHAT_WARN = CHAT+"warning."; public static final String CHAT_INFO = CHAT+"info."; public static final String CHAT_COMMAND = CHAT+"command."; - public static final String DESC = "desc." + MODID + "."; + public static final String DESC = "desc."+MODID+"."; public static final String DESC_INFO = DESC+"info."; public static final String DESC_FLAVOUR = DESC+"flavour."; - public static final String GUI = "gui." + MODID + "."; - public static final String GUI_CONFIG = "gui." + MODID + ".config."; + public static final String GUI = "gui."+MODID+"."; + public static final String GUI_CONFIG = "gui."+MODID+".config."; public static final int COLOUR_I_ImmersiveOrange = 0xfff78034; - public static final float[] COLOUR_F_ImmersiveOrange = {247 / 255f, 128 / 255f, 52 / 255f}; + public static final float[] COLOUR_F_ImmersiveOrange = {247/255f, 128/255f, 52/255f}; public static final int COLOUR_I_ImmersiveOrangeShadow = 0xff3e200d; public static final String MAGNET_PREVENT_NBT = "PreventRemoteMovement"; - /**Gui IDs*/ + /** + * Gui IDs + */ //Tiles public static final int GUIID_Base_Tile = 0; - public static final int GUIID_CokeOven = GUIID_Base_Tile +0; - public static final int GUIID_AlloySmelter = GUIID_Base_Tile +1; - public static final int GUIID_BlastFurnace = GUIID_Base_Tile +2; - public static final int GUIID_WoodenCrate = GUIID_Base_Tile +3; - public static final int GUIID_Workbench = GUIID_Base_Tile +4; - public static final int GUIID_Assembler = GUIID_Base_Tile +5; - public static final int GUIID_Sorter = GUIID_Base_Tile +6; - public static final int GUIID_Squeezer = GUIID_Base_Tile +7; - public static final int GUIID_Fermenter = GUIID_Base_Tile +8; - public static final int GUIID_Refinery = GUIID_Base_Tile +9; - public static final int GUIID_ArcFurnace = GUIID_Base_Tile +10; - public static final int GUIID_AutoWorkbench = GUIID_Base_Tile +11; - public static final int GUIID_Mixer = GUIID_Base_Tile +12; - public static final int GUIID_Turret = GUIID_Base_Tile +13; - public static final int GUIID_FluidSorter = GUIID_Base_Tile +14; - public static final int GUIID_Belljar = GUIID_Base_Tile +15; - public static final int GUIID_ToolboxBlock = GUIID_Base_Tile +16; + public static final int GUIID_CokeOven = GUIID_Base_Tile+0; + public static final int GUIID_AlloySmelter = GUIID_Base_Tile+1; + public static final int GUIID_BlastFurnace = GUIID_Base_Tile+2; + public static final int GUIID_WoodenCrate = GUIID_Base_Tile+3; + public static final int GUIID_Workbench = GUIID_Base_Tile+4; + public static final int GUIID_Assembler = GUIID_Base_Tile+5; + public static final int GUIID_Sorter = GUIID_Base_Tile+6; + public static final int GUIID_Squeezer = GUIID_Base_Tile+7; + public static final int GUIID_Fermenter = GUIID_Base_Tile+8; + public static final int GUIID_Refinery = GUIID_Base_Tile+9; + public static final int GUIID_ArcFurnace = GUIID_Base_Tile+10; + public static final int GUIID_AutoWorkbench = GUIID_Base_Tile+11; + public static final int GUIID_Mixer = GUIID_Base_Tile+12; + public static final int GUIID_Turret = GUIID_Base_Tile+13; + public static final int GUIID_FluidSorter = GUIID_Base_Tile+14; + public static final int GUIID_Belljar = GUIID_Base_Tile+15; + public static final int GUIID_ToolboxBlock = GUIID_Base_Tile+16; //Items public static final int GUIID_Base_Item = 64; - public static final int GUIID_Manual = GUIID_Base_Item +0; - public static final int GUIID_Revolver = GUIID_Base_Item +1; - public static final int GUIID_Toolbox = GUIID_Base_Item +2; + public static final int GUIID_Manual = GUIID_Base_Item+0; + public static final int GUIID_Revolver = GUIID_Base_Item+1; + public static final int GUIID_Toolbox = GUIID_Base_Item+2; public static final String NBT_Earmuffs = "IE:Earmuffs"; public static final String NBT_EarmuffColour = "IE:EarmuffColour"; @@ -75,24 +77,24 @@ public class Lib public static final int colour_nixieTubeText = 0xff9900; - public static String DMG_RevolverCasull="ieRevolver_casull"; - public static String DMG_RevolverAP="ieRevolver_armorPiercing"; - public static String DMG_RevolverBuck="ieRevolver_buckshot"; - public static String DMG_RevolverDragon="ieRevolver_dragonsbreath"; - public static String DMG_RevolverHoming="ieRevolver_homing"; - public static String DMG_RevolverWolfpack="ieRevolver_wolfpack"; + public static String DMG_RevolverCasull = "ieRevolver_casull"; + public static String DMG_RevolverAP = "ieRevolver_armorPiercing"; + public static String DMG_RevolverBuck = "ieRevolver_buckshot"; + public static String DMG_RevolverDragon = "ieRevolver_dragonsbreath"; + public static String DMG_RevolverHoming = "ieRevolver_homing"; + public static String DMG_RevolverWolfpack = "ieRevolver_wolfpack"; public static String DMG_RevolverSilver = "ieRevolver_silver"; public static String DMG_RevolverPotion = "ieRevolver_potion"; - public static String DMG_Crusher="ieCrushed"; - public static String DMG_Tesla="ieTesla"; - public static String DMG_Acid="ieAcid"; + public static String DMG_Crusher = "ieCrushed"; + public static String DMG_Tesla = "ieTesla"; + public static String DMG_Acid = "ieAcid"; public static String DMG_Railgun = "ieRailgun"; public static String DMG_Tesla_prim = "ieTeslaPrimary"; public static String DMG_RazorWire = "ieRazorWire"; public static String DMG_RazorShock = "ieRazorShock"; public static String DMG_WireShock = "ieWireShock"; - public static final ToolMaterial MATERIAL_Steel = EnumHelper.addToolMaterial( "IE:STEEL", 2, 641, 7.0f, 2.5f, 10); + public static final ToolMaterial MATERIAL_Steel = EnumHelper.addToolMaterial("IE:STEEL", 2, 641, 7.0f, 2.5f, 10); public static final EnumRarity RARITY_Masterwork = EnumHelper.addRarity("IE:MASTERWORK", TextFormatting.GOLD, "Masterwork"); public static boolean BAUBLES = false; diff --git a/src/main/java/blusunrize/immersiveengineering/api/ManualHelper.java b/src/main/java/blusunrize/immersiveengineering/api/ManualHelper.java index c5ff55ae07..caba41c2e0 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/ManualHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/api/ManualHelper.java @@ -13,7 +13,6 @@ /** * @author BluSunrize - 04.07.2015 - * */ public class ManualHelper { @@ -24,15 +23,16 @@ public class ManualHelper public static String CAT_TOOLS = "tools"; public static String CAT_HEAVYMACHINES = "heavymachines"; public static String CAT_UPDATE = "update"; - + public static ManualInstance ieManualInstance; public static ManualInstance getManual() { return ieManualInstance; } + /** - * Adds a new entry to the manual. if the Category is new, it will be added to the list of categories automatically + * Adds a new entry to the manual. if the Category is new, it will be added to the list of categories automatically */ public static void addEntry(String name, String category, IManualPage... pages) { diff --git a/src/main/java/blusunrize/immersiveengineering/api/ManualPageBlueprint.java b/src/main/java/blusunrize/immersiveengineering/api/ManualPageBlueprint.java index a866eec6f0..98c262ac41 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/ManualPageBlueprint.java +++ b/src/main/java/blusunrize/immersiveengineering/api/ManualPageBlueprint.java @@ -55,7 +55,7 @@ public void recalculateCraftingRecipes() { int h = (int)Math.ceil(recipe.inputs.length/2f); PositionedItemStack[] pIngredients = new PositionedItemStack[recipe.inputs.length+2]; - for(int i=0; i)stack.stack) { if(subStack.getDisplayName().toLowerCase(Locale.ENGLISH).contains(searchTag)) @@ -180,7 +181,8 @@ else if(stack.stack instanceof ItemStack) { if(((ItemStack)stack.stack).getDisplayName().toLowerCase(Locale.ENGLISH).contains(searchTag)) return true; - } else if(stack.stack instanceof String) + } + else if(stack.stack instanceof String) { if(ManualUtils.isExistingOreName((String)stack.stack)) for(ItemStack subStack : OreDictionary.getOres((String)stack.stack)) diff --git a/src/main/java/blusunrize/immersiveengineering/api/ManualPageMultiblock.java b/src/main/java/blusunrize/immersiveengineering/api/ManualPageMultiblock.java index d8e6b06722..2b18456d4e 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/ManualPageMultiblock.java +++ b/src/main/java/blusunrize/immersiveengineering/api/ManualPageMultiblock.java @@ -52,8 +52,8 @@ public class ManualPageMultiblock extends ManualPages float scale = 50f; float transX = 0; float transY = 0; - float rotX=0; - float rotY=0; + float rotX = 0; + float rotY = 0; List componentTooltip; MultiblockRenderInfo renderInfo; MultiblockBlockAccess blockAccess; @@ -87,26 +87,26 @@ public void initPage(GuiManual gui, int x, int y, List pageButtons) { this.renderInfo = new MultiblockRenderInfo(multiblock); this.blockAccess = new MultiblockBlockAccess(renderInfo); - transX = x+60 + renderInfo.structureWidth/2; - transY = y+35 + (float)Math.sqrt(renderInfo.structureHeight*renderInfo.structureHeight + renderInfo.structureWidth*renderInfo.structureWidth + renderInfo.structureLength*renderInfo.structureLength)/2; - rotX=25; - rotY=-45; + transX = x+60+renderInfo.structureWidth/2; + transY = y+35+(float)Math.sqrt(renderInfo.structureHeight*renderInfo.structureHeight+renderInfo.structureWidth*renderInfo.structureWidth+renderInfo.structureLength*renderInfo.structureLength)/2; + rotX = 25; + rotY = -45; scale = multiblock.getManualScale(); boolean canRenderFormed = multiblock.canRenderFormedStructure(); - yOff = (int)(transY+scale*Math.sqrt(renderInfo.structureHeight*renderInfo.structureHeight + renderInfo.structureWidth*renderInfo.structureWidth + renderInfo.structureLength*renderInfo.structureLength)/2); - pageButtons.add(new GuiButtonManualNavigation(gui, 100, x+4, (int)transY-(canRenderFormed?11:5), 10,10, 4)); + yOff = (int)(transY+scale*Math.sqrt(renderInfo.structureHeight*renderInfo.structureHeight+renderInfo.structureWidth*renderInfo.structureWidth+renderInfo.structureLength*renderInfo.structureLength)/2); + pageButtons.add(new GuiButtonManualNavigation(gui, 100, x+4, (int)transY-(canRenderFormed?11: 5), 10, 10, 4)); if(canRenderFormed) - pageButtons.add(new GuiButtonManualNavigation(gui, 103, x+4, (int)transY+1, 10,10, 6)); - if(this.renderInfo.structureHeight>1) + pageButtons.add(new GuiButtonManualNavigation(gui, 103, x+4, (int)transY+1, 10, 10, 6)); + if(this.renderInfo.structureHeight > 1) { - pageButtons.add(new GuiButtonManualNavigation(gui, 101, x+4, (int)transY-(canRenderFormed?14:8)-16, 10,16, 3)); - pageButtons.add(new GuiButtonManualNavigation(gui, 102, x+4, (int)transY+(canRenderFormed?14:8), 10,16, 2)); + pageButtons.add(new GuiButtonManualNavigation(gui, 101, x+4, (int)transY-(canRenderFormed?14: 8)-16, 10, 16, 3)); + pageButtons.add(new GuiButtonManualNavigation(gui, 102, x+4, (int)transY+(canRenderFormed?14: 8), 10, 16, 2)); } } IngredientStack[] totalMaterials = this.multiblock.getTotalMaterials(); - if(totalMaterials != null) + if(totalMaterials!=null) { componentTooltip = new ArrayList(); componentTooltip.add(I18n.format("desc.immersiveengineering.info.reqMaterial")); @@ -114,14 +114,14 @@ public void initPage(GuiManual gui, int x, int y, List pageButtons) boolean hasAnyItems = false; boolean[] hasItems = new boolean[totalMaterials.length]; for(int ss = 0; ss < totalMaterials.length; ss++) - if(totalMaterials[ss] != null) + if(totalMaterials[ss]!=null) { IngredientStack req = totalMaterials[ss]; int reqSize = req.inputSize; for(int slot = 0; slot < ManualUtils.mc().player.inventory.getSizeInventory(); slot++) { ItemStack inSlot = ManualUtils.mc().player.inventory.getStackInSlot(slot); - if(!inSlot.isEmpty() && req.matchesItemStackIgnoringSize(inSlot)) + if(!inSlot.isEmpty()&&req.matchesItemStackIgnoringSize(inSlot)) if((reqSize -= inSlot.getCount()) <= 0) break; } @@ -131,22 +131,22 @@ public void initPage(GuiManual gui, int x, int y, List pageButtons) if(!hasAnyItems) hasAnyItems = true; } - maxOff = Math.max(maxOff, ("" + req.inputSize).length()); + maxOff = Math.max(maxOff, (""+req.inputSize).length()); } for(int ss = 0; ss < totalMaterials.length; ss++) - if(totalMaterials[ss] != null) + if(totalMaterials[ss]!=null) { IngredientStack req = totalMaterials[ss]; - int indent = maxOff - ("" + req.inputSize).length(); + int indent = maxOff-(""+req.inputSize).length(); String sIndent = ""; if(indent > 0) for(int ii = 0; ii < indent; ii++) sIndent += "0"; - String s = hasItems[ss] ? (TextFormatting.GREEN + TextFormatting.BOLD.toString() + "\u2713" + TextFormatting.RESET + " ") : hasAnyItems ? (" ") : ""; - s += TextFormatting.GRAY + sIndent + req.inputSize + "x " + TextFormatting.RESET; + String s = hasItems[ss]?(TextFormatting.GREEN+TextFormatting.BOLD.toString()+"\u2713"+TextFormatting.RESET+" "): hasAnyItems?(" "): ""; + s += TextFormatting.GRAY+sIndent+req.inputSize+"x "+TextFormatting.RESET; ItemStack example = req.getExampleStack(); if(!example.isEmpty()) - s += example.getRarity().rarityColor + example.getDisplayName(); + s += example.getRarity().rarityColor+example.getDisplayName(); else s += "???"; componentTooltip.add(s); @@ -162,21 +162,22 @@ public void renderPage(GuiManual gui, int x, int y, int mx, int my) int stackDepth = GL11.glGetInteger(GL11.GL_MODELVIEW_STACK_DEPTH); try { - if(multiblock.getStructureManual() != null) + if(multiblock.getStructureManual()!=null) { if(!canTick) { // renderInfo.reset(); // renderInfo.setShowLayer(9); //LAYER CACHING!! - } else if(++tick % 20 == 0) + } + else if(++tick%20==0) renderInfo.step(); int structureLength = renderInfo.structureLength; int structureWidth = renderInfo.structureWidth; int structureHeight = renderInfo.structureHeight; - int yOffTotal = (int)(transY-y+scale*Math.sqrt(renderInfo.structureHeight*renderInfo.structureHeight + renderInfo.structureWidth*renderInfo.structureWidth + renderInfo.structureLength*renderInfo.structureLength)/2); + int yOffTotal = (int)(transY-y+scale*Math.sqrt(renderInfo.structureHeight*renderInfo.structureHeight+renderInfo.structureWidth*renderInfo.structureWidth+renderInfo.structureLength*renderInfo.structureLength)/2); GlStateManager.enableRescaleNormal(); GlStateManager.pushMatrix(); @@ -189,14 +190,14 @@ public void renderPage(GuiManual gui, int x, int y, int mx, int my) final BlockRendererDispatcher blockRender = Minecraft.getMinecraft().getBlockRendererDispatcher(); - float f = (float)Math.sqrt(structureHeight * structureHeight + structureWidth * structureWidth + structureLength * structureLength); + float f = (float)Math.sqrt(structureHeight*structureHeight+structureWidth*structureWidth+structureLength*structureLength); GlStateManager.translate(transX, transY, Math.max(structureHeight, Math.max(structureWidth, structureLength))); GlStateManager.scale(scale, -scale, 1); GlStateManager.rotate(rotX, 1, 0, 0); GlStateManager.rotate(90+rotY, 0, 1, 0); - GlStateManager.translate((float)structureLength / -2f, (float)structureHeight / -2f, (float)structureWidth / -2f); + GlStateManager.translate((float)structureLength/-2f, (float)structureHeight/-2f, (float)structureWidth/-2f); GlStateManager.disableLighting(); @@ -207,7 +208,7 @@ public void renderPage(GuiManual gui, int x, int y, int mx, int my) gui.mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); int idx = 0; - if(showCompleted && multiblock.canRenderFormedStructure()) + if(showCompleted&&multiblock.canRenderFormedStructure()) multiblock.renderFormedStructure(); else for(int h = 0; h < structureHeight; h++) @@ -243,28 +244,31 @@ public void renderPage(GuiManual gui, int x, int y, int mx, int my) RenderHelper.disableStandardItemLighting(); manual.fontRenderer.setUnicodeFlag(true); - if(localizedText != null && !localizedText.isEmpty()) - manual.fontRenderer.drawSplitString(localizedText, x, y + yOffTotal, 120, manual.getTextColour()); + if(localizedText!=null&&!localizedText.isEmpty()) + manual.fontRenderer.drawSplitString(localizedText, x, y+yOffTotal, 120, manual.getTextColour()); manual.fontRenderer.setUnicodeFlag(false); - if(componentTooltip != null) + if(componentTooltip!=null) { - manual.fontRenderer.drawString("?", x + 116, y + yOffTotal / 2 - 4, manual.getTextColour(), false); - if(mx >= x + 116 && mx < x + 122 && my >= y + yOffTotal / 2 - 4 && my < y + yOffTotal / 2 + 4) + manual.fontRenderer.drawString("?", x+116, y+yOffTotal/2-4, manual.getTextColour(), false); + if(mx >= x+116&&mx < x+122&&my >= y+yOffTotal/2-4&&my < y+yOffTotal/2+4) gui.drawHoveringText(componentTooltip, mx, my, manual.fontRenderer); } } - }catch(Exception e) + } catch(Exception e) { e.printStackTrace(); } if(openBuffer) - try{ + try + { Tessellator.getInstance().draw(); - }catch(Exception e){} + } catch(Exception e) + { + } int newStackDepth = GL11.glGetInteger(GL11.GL_MODELVIEW_STACK_DEPTH); - while (newStackDepth>stackDepth) + while(newStackDepth > stackDepth) { GlStateManager.popMatrix(); newStackDepth--; @@ -274,7 +278,7 @@ public void renderPage(GuiManual gui, int x, int y, int mx, int my) @Override public void mouseDragged(int x, int y, int clickX, int clickY, int mx, int my, int lastX, int lastY, int button) { - if((clickX>=40 && clickX<144 && mx>=20 && mx<164)&&(clickY>=30 && clickY<130 && my>=30 && my<180)) + if((clickX >= 40&&clickX < 144&&mx >= 20&&mx < 164)&&(clickY >= 30&&clickY < 130&&my >= 30&&my < 180)) { int dx = mx-lastX; int dy = my-lastY; @@ -289,15 +293,15 @@ public void buttonPressed(GuiManual gui, GuiButton button) if(button.id==100) { canTick = !canTick; - ((GuiButtonManualNavigation)button).type = ((GuiButtonManualNavigation)button).type == 4 ? 5 : 4; + ((GuiButtonManualNavigation)button).type = ((GuiButtonManualNavigation)button).type==4?5: 4; } else if(button.id==101) { - this.renderInfo.setShowLayer( Math.min(renderInfo.showLayer+1, renderInfo.structureHeight-1)); + this.renderInfo.setShowLayer(Math.min(renderInfo.showLayer+1, renderInfo.structureHeight-1)); } else if(button.id==102) { - this.renderInfo.setShowLayer( Math.max(renderInfo.showLayer-1, -1)); + this.renderInfo.setShowLayer(Math.max(renderInfo.showLayer-1, -1)); } else if(button.id==103) showCompleted = !showCompleted; @@ -330,7 +334,7 @@ public MultiblockBlockAccess(MultiblockRenderInfo data) private IBlockState convert(int index, ItemStack itemstack) { - if (itemstack == null) + if(itemstack==null) return Blocks.AIR.getDefaultState(); IBlockState state = data.multiblock.getBlockstateFromStack(index, itemstack); if(state!=null) @@ -349,7 +353,7 @@ public TileEntity getTileEntity(BlockPos pos) public int getCombinedLight(BlockPos pos, int lightValue) { // full brightness always - return 15 << 20 | 15 << 4; + return 15<<20|15<<4; } @Override @@ -359,11 +363,11 @@ public IBlockState getBlockState(BlockPos pos) int y = pos.getY(); int z = pos.getZ(); - if(y >= 0 && y < structure.length) - if(x >= 0 && x < structure[y].length) - if(z >= 0 && z < structure[y][x].length) + if(y >= 0&&y < structure.length) + if(x >= 0&&x < structure[y].length) + if(z >= 0&&z < structure[y][x].length) { - int index = y * (data.structureLength * data.structureWidth) + x * data.structureWidth + z; + int index = y*(data.structureLength*data.structureWidth)+x*data.structureWidth+z; if(index <= data.getLimiter()) return structure[y][x][z]; } @@ -373,14 +377,14 @@ public IBlockState getBlockState(BlockPos pos) @Override public boolean isAirBlock(BlockPos pos) { - return getBlockState(pos).getBlock() == Blocks.AIR; + return getBlockState(pos).getBlock()==Blocks.AIR; } @Override public Biome getBiome(BlockPos pos) { World world = Minecraft.getMinecraft().world; - if (world!=null) + if(world!=null) return world.getBiome(pos); else return Biomes.BIRCH_FOREST; @@ -397,7 +401,7 @@ public WorldType getWorldType() { World world = Minecraft.getMinecraft().world; - if (world!=null) + if(world!=null) return world.getWorldType(); else return WorldType.DEFAULT; @@ -409,6 +413,7 @@ public boolean isSideSolid(BlockPos pos, EnumFacing side, boolean _default) return false; } } + //Stolen back from boni's StructureInfo static class MultiblockRenderInfo { @@ -428,7 +433,7 @@ public MultiblockRenderInfo(IMultiblock multiblock) { this.multiblock = multiblock; init(multiblock.getStructureManual()); - maxBlockIndex = blockIndex = structureHeight * structureLength * structureWidth; + maxBlockIndex = blockIndex = structureHeight*structureLength*structureWidth; } public void init(ItemStack[][][] structure) @@ -450,7 +455,7 @@ public void init(ItemStack[][][] structure) if(structure[h][l].length > structureWidth) structureWidth = structure[h][l].length; for(ItemStack ss : structure[h][l]) - if(ss != null && !ss.isEmpty()) + if(ss!=null&&!ss.isEmpty()) perLvl++; } countPerLevel[h] = perLvl; @@ -461,10 +466,10 @@ public void init(ItemStack[][][] structure) public void setShowLayer(int layer) { showLayer = layer; - if(layer<0) + if(layer < 0) reset(); else - blockIndex = (layer + 1) * (structureLength * structureWidth) - 1; + blockIndex = (layer+1)*(structureLength*structureWidth)-1; } public void reset() @@ -480,18 +485,18 @@ public void step() if(++blockIndex >= maxBlockIndex) blockIndex = 0; } - while(isEmpty(blockIndex) && blockIndex != start); + while(isEmpty(blockIndex)&&blockIndex!=start); } private boolean isEmpty(int index) { - int y = index / (structureLength * structureWidth); - int r = index % (structureLength * structureWidth); - int x = r / structureWidth; - int z = r % structureWidth; + int y = index/(structureLength*structureWidth); + int r = index%(structureLength*structureWidth); + int x = r/structureWidth; + int z = r%structureWidth; ItemStack stack = data[y][x][z]; - return stack == null || stack.isEmpty(); + return stack==null||stack.isEmpty(); } public int getLimiter() diff --git a/src/main/java/blusunrize/immersiveengineering/api/MultiblockHandler.java b/src/main/java/blusunrize/immersiveengineering/api/MultiblockHandler.java index 37108d1880..87ae394870 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/MultiblockHandler.java +++ b/src/main/java/blusunrize/immersiveengineering/api/MultiblockHandler.java @@ -37,6 +37,7 @@ public static void registerMultiblock(IMultiblock multiblock) { multiblocks.add(multiblock); } + public static ArrayList getMultiblocks() { return multiblocks; @@ -49,7 +50,7 @@ public interface IMultiblock * returns name of the Multiblock. This is used for the interdiction NBT system on the hammer, so this name /must/ be unique. */ String getUniqueName(); - + /** * Check whether the given block can be used to trigger the structure creation of the multiblock.
* Basically, a less resource-intensive preliminary check to avoid checking every structure. @@ -58,6 +59,7 @@ public interface IMultiblock /** * This method checks the structure and sets the new one. + * * @return if the structure was valid and transformed */ boolean createStructure(World world, BlockPos pos, EnumFacing side, EntityPlayer player); @@ -69,16 +71,16 @@ public interface IMultiblock default IBlockState getBlockstateFromStack(int index, ItemStack stack) { - if(!stack.isEmpty() && stack.getItem() instanceof ItemBlock) + if(!stack.isEmpty()&&stack.getItem() instanceof ItemBlock) return ((ItemBlock)stack.getItem()).getBlock().getStateFromMeta(stack.getItemDamage()); return null; } - + /** * An array of ItemStacks that summarizes the total amount of materials needed for the structure. Will be rendered in the Engineer's Manual */ IngredientStack[] getTotalMaterials(); - + /** * Use this to overwrite the rendering of a Multiblock's Component */ @@ -89,12 +91,13 @@ default IBlockState getBlockstateFromStack(int index, ItemStack stack) * returns the scale modifier to be applied when rendering the structure in the IE manual */ float getManualScale(); - + /** * returns true to add a button that will switch between the assembly of multiblocks and the finished render */ @SideOnly(Side.CLIENT) boolean canRenderFormedStructure(); + /** * use this function to render the complete multiblock */ @@ -119,6 +122,7 @@ public static class MultiblockFormEvent extends PlayerEvent private final IMultiblock multiblock; private final BlockPos clickedBlock; private final ItemStack hammer; + public MultiblockFormEvent(EntityPlayer player, IMultiblock multiblock, BlockPos clickedBlock, ItemStack hammer) { super(player); @@ -131,10 +135,12 @@ public IMultiblock getMultiblock() { return multiblock; } + public BlockPos getClickedBlock() { return clickedBlock; } + public ItemStack getHammer() { return hammer; diff --git a/src/main/java/blusunrize/immersiveengineering/api/TargetingInfo.java b/src/main/java/blusunrize/immersiveengineering/api/TargetingInfo.java index 52fc306009..b52f16ddb4 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/TargetingInfo.java +++ b/src/main/java/blusunrize/immersiveengineering/api/TargetingInfo.java @@ -13,7 +13,7 @@ /** * @author BluSunrize - 11.03.2015 - * + *

* Similar too MovingObjectPosition.class, but this is specifically designed for sub-targets on a block */ public class TargetingInfo @@ -22,14 +22,15 @@ public class TargetingInfo public final float hitX; public final float hitY; public final float hitZ; + public TargetingInfo(EnumFacing side, float hitX, float hitY, float hitZ) { - this.side=side; - this.hitX=hitX; - this.hitY=hitY; - this.hitZ=hitZ; + this.side = side; + this.hitX = hitX; + this.hitY = hitY; + this.hitZ = hitZ; } - + public void writeToNBT(NBTTagCompound tag) { tag.setInteger("side", side.ordinal()); @@ -37,8 +38,9 @@ public void writeToNBT(NBTTagCompound tag) tag.setFloat("hitY", hitY); tag.setFloat("hitZ", hitZ); } + public static TargetingInfo readFromNBT(NBTTagCompound tag) { - return new TargetingInfo(EnumFacing.getFront(tag.getInteger("side")), tag.getFloat("hitX"),tag.getFloat("hitY"),tag.getFloat("hitZ") ); + return new TargetingInfo(EnumFacing.getFront(tag.getInteger("side")), tag.getFloat("hitX"), tag.getFloat("hitY"), tag.getFloat("hitZ")); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/api/crafting/AlloyRecipe.java b/src/main/java/blusunrize/immersiveengineering/api/crafting/AlloyRecipe.java index 1e5aa4ee1c..deca7d086b 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/crafting/AlloyRecipe.java +++ b/src/main/java/blusunrize/immersiveengineering/api/crafting/AlloyRecipe.java @@ -30,19 +30,21 @@ public class AlloyRecipe public AlloyRecipe(ItemStack output, Object input0, Object input1, int time) { - this.output=output; - this.input0=ApiUtils.createIngredientStack(input0); - this.input1=ApiUtils.createIngredientStack(input1); - this.time=time; + this.output = output; + this.input0 = ApiUtils.createIngredientStack(input0); + this.input1 = ApiUtils.createIngredientStack(input1); + this.time = time; } public static ArrayList recipeList = new ArrayList(); + public static void addRecipe(ItemStack output, Object input0, Object input1, int time) { AlloyRecipe recipe = new AlloyRecipe(output, input0, input1, time); if(recipe.input0!=null&&recipe.input1!=null) recipeList.add(recipe); } + public static AlloyRecipe findRecipe(ItemStack input0, ItemStack input1) { for(AlloyRecipe recipe : recipeList) @@ -50,6 +52,7 @@ public static AlloyRecipe findRecipe(ItemStack input0, ItemStack input1) return recipe; return null; } + public static List removeRecipes(ItemStack stack) { List list = new ArrayList(); diff --git a/src/main/java/blusunrize/immersiveengineering/api/crafting/ArcFurnaceRecipe.java b/src/main/java/blusunrize/immersiveengineering/api/crafting/ArcFurnaceRecipe.java index db934c0928..0baacdf37f 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/crafting/ArcFurnaceRecipe.java +++ b/src/main/java/blusunrize/immersiveengineering/api/crafting/ArcFurnaceRecipe.java @@ -56,16 +56,16 @@ public ArcFurnaceRecipe(ItemStack output, Object input, @Nonnull ItemStack slag, else { this.additives = new IngredientStack[additives.length]; - for(int i=0; i0) + if(this.additives.length > 0) this.inputList.addAll(Lists.newArrayList(this.additives)); this.outputList = ListUtils.fromItem(this.output); } - + @Override public void setupJEI() { @@ -87,7 +87,7 @@ public int getMultipleProcessTicks() public NBTTagCompound writeToNBT(NBTTagCompound nbt) { nbt.setTag("input", input.writeToNBT(new NBTTagCompound())); - if(this.additives.length>0) + if(this.additives.length > 0) { NBTTagList list = new NBTTagList(); for(IngredientStack add : this.additives) @@ -96,6 +96,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) } return nbt; } + public static ArcFurnaceRecipe loadFromNBT(NBTTagCompound nbt) { IngredientStack input = IngredientStack.readFromNBT(nbt.getCompoundTag("input")); @@ -104,21 +105,21 @@ public static ArcFurnaceRecipe loadFromNBT(NBTTagCompound nbt) { NBTTagList list = nbt.getTagList("additives", 10); additives = new IngredientStack[list.tagCount()]; - for(int i=0; i getOutputs(ItemStack input, NonNullList outputs.add(output); return outputs; } + public boolean matches(ItemStack input, NonNullList additives) { - if(this.input!=null && this.input.matches(input)) + if(this.input!=null&&this.input.matches(input)) { ArrayList qAdd = new ArrayList(additives.size()); for(ItemStack s : additives) @@ -157,7 +159,7 @@ public boolean matches(ItemStack input, NonNullList additives) if(query.getCount() > addAmount) { query.shrink(addAmount); - addAmount=0; + addAmount = 0; } else { @@ -167,29 +169,32 @@ public boolean matches(ItemStack input, NonNullList additives) } if(query.getCount() <= 0) it.remove(); - if(addAmount<=0) + if(addAmount <= 0) break; } } - if(addAmount>0) + if(addAmount > 0) return false; } return true; } return false; } + public boolean isValidInput(ItemStack stack) { - return this.input!=null && this.input.matches(stack); + return this.input!=null&&this.input.matches(stack); } + public boolean isValidAdditive(ItemStack stack) { for(IngredientStack add : additives) - if(add!=null && add.matches(stack)) + if(add!=null&&add.matches(stack)) return true; return false; } + public ArcFurnaceRecipe setSpecialRecipeType(String type) { this.specialRecipeType = type; @@ -205,13 +210,15 @@ public static ArcFurnaceRecipe addRecipe(ItemStack output, Object input, @Nonnul recipeList.add(recipe); return recipe; } + public static ArcFurnaceRecipe findRecipe(ItemStack input, NonNullList additives) { for(ArcFurnaceRecipe recipe : recipeList) - if(recipe!=null && recipe.matches(input, additives)) + if(recipe!=null&&recipe.matches(input, additives)) return recipe; return null; } + public static List removeRecipes(ItemStack stack) { List list = new ArrayList(); @@ -231,19 +238,21 @@ public static List removeRecipes(ItemStack stack) public static boolean isValidRecipeInput(ItemStack stack) { for(ArcFurnaceRecipe recipe : recipeList) - if(recipe!=null && recipe.isValidInput(stack)) + if(recipe!=null&&recipe.isValidInput(stack)) return true; return false; } + public static boolean isValidRecipeAdditive(ItemStack stack) { for(ArcFurnaceRecipe recipe : recipeList) - if(recipe!=null && recipe.isValidAdditive(stack)) + if(recipe!=null&&recipe.isValidAdditive(stack)) return true; return false; } public static ArrayList recyclingAllowed = new ArrayList(); + /** * Set an item/oredict-entry to be considered for recycling in the arc furnace. Tools and Armor should usually be auto-detected */ @@ -253,6 +262,7 @@ public static void allowItemForRecycling(Object stack) } public static ArrayList invalidRecyclingOutput = new ArrayList(); + /** * Set an item/oredict-entry to be an invalid output for the recycling process. Used for magical ingots that should be reclaimable or similar */ diff --git a/src/main/java/blusunrize/immersiveengineering/api/crafting/BlastFurnaceRecipe.java b/src/main/java/blusunrize/immersiveengineering/api/crafting/BlastFurnaceRecipe.java index 093b05ac60..c4eed2ffb0 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/crafting/BlastFurnaceRecipe.java +++ b/src/main/java/blusunrize/immersiveengineering/api/crafting/BlastFurnaceRecipe.java @@ -32,19 +32,21 @@ public class BlastFurnaceRecipe public BlastFurnaceRecipe(ItemStack output, Object input, int time, @Nonnull ItemStack slag) { - this.output=output; - this.input=ApiUtils.convertToValidRecipeInput(input); - this.time=time; - this.slag=slag; + this.output = output; + this.input = ApiUtils.convertToValidRecipeInput(input); + this.time = time; + this.slag = slag; } public static ArrayList recipeList = new ArrayList(); + public static void addRecipe(ItemStack output, Object input, int time, @Nonnull ItemStack slag) { BlastFurnaceRecipe recipe = new BlastFurnaceRecipe(output, input, time, slag); if(recipe.input!=null) recipeList.add(recipe); } + public static BlastFurnaceRecipe findRecipe(ItemStack input) { for(BlastFurnaceRecipe recipe : recipeList) @@ -54,6 +56,7 @@ public static BlastFurnaceRecipe findRecipe(ItemStack input) } return null; } + public static List removeRecipes(ItemStack stack) { List list = new ArrayList(); @@ -71,6 +74,7 @@ public static List removeRecipes(ItemStack stack) } public static ArrayList blastFuels = new ArrayList(); + public static class BlastFurnaceFuel { public final IngredientStack input; @@ -82,12 +86,14 @@ public BlastFurnaceFuel(IngredientStack input, int burnTime) this.burnTime = burnTime; } } + public static BlastFurnaceFuel addBlastFuel(Object fuel, int burnTime) { BlastFurnaceFuel entry = new BlastFurnaceFuel(ApiUtils.createIngredientStack(fuel), burnTime); blastFuels.add(entry); return entry; } + public static int getBlastFuelTime(ItemStack stack) { for(BlastFurnaceFuel e : blastFuels) @@ -95,8 +101,9 @@ public static int getBlastFuelTime(ItemStack stack) return e.burnTime; return 0; } + public static boolean isValidBlastFuel(ItemStack stack) { - return getBlastFuelTime(stack)>0; + return getBlastFuelTime(stack) > 0; } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/api/crafting/BlueprintCraftingRecipe.java b/src/main/java/blusunrize/immersiveengineering/api/crafting/BlueprintCraftingRecipe.java index b5a5ee195d..1d143bf563 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/crafting/BlueprintCraftingRecipe.java +++ b/src/main/java/blusunrize/immersiveengineering/api/crafting/BlueprintCraftingRecipe.java @@ -51,7 +51,7 @@ public BlueprintCraftingRecipe(String blueprintCategory, ItemStack output, Objec this.blueprintCategory = blueprintCategory; this.output = output; this.inputs = new IngredientStack[inputs.length]; - for(int io=0; io query) // } // if(inputList.isEmpty()) // return true; - return getMaxCrafted(query)>0; + return getMaxCrafted(query) > 0; } + public int getMaxCrafted(NonNullList query) { HashMap queryAmount = new HashMap(); @@ -163,19 +164,19 @@ public int getMaxCrafted(NonNullList query) if(ingr.matchesItemStackIgnoringSize(compStack)) { int taken = e.getValue()/req; - if(taken>0) + if(taken > 0) { e.setValue(e.getValue()-taken*req); - if(e.getValue()<=0) + if(e.getValue() <= 0) queryIt.remove(); supplied += taken; } } } - if(supplied<=0) + if(supplied <= 0) return 0; else - maxCrafted = maxCrafted==0?supplied:Math.min(maxCrafted, supplied); + maxCrafted = maxCrafted==0?supplied: Math.min(maxCrafted, supplied); } return maxCrafted; } @@ -194,7 +195,7 @@ public NonNullList consumeInputs(NonNullList query, int cr IngredientStack ingr = inputIt.next(); int inputSize = ingr.inputSize*crafted; - for(int i = 0; i< query.size(); i++) + for(int i = 0; i < query.size(); i++) { ItemStack queryStack = query.get(i); if(!queryStack.isEmpty()) @@ -202,7 +203,7 @@ public NonNullList consumeInputs(NonNullList query, int cr { int taken = Math.min(queryStack.getCount(), inputSize); consumed.add(ApiUtils.copyStackWithAmount(queryStack, taken)); - if(taken>=queryStack.getCount() && queryStack.getItem().hasContainerItem(queryStack)) + if(taken >= queryStack.getCount()&&queryStack.getItem().hasContainerItem(queryStack)) query.set(i, queryStack.getItem().getContainerItem(queryStack)); else queryStack.shrink(taken); @@ -218,6 +219,7 @@ public NonNullList consumeInputs(NonNullList query, int cr } return consumed; } + public ArrayList getFormattedInputs() { ArrayList formattedInputs = new ArrayList(); @@ -227,20 +229,20 @@ public ArrayList getFormattedInputs() boolean isNew = true; for(IngredientStack formatted : formattedInputs) { - if(ingr.oreName!=null && ingr.oreName.equals(formatted.oreName)) - isNew=false; - else if(ingr.stackList!=null && formatted.stackList!=null) + if(ingr.oreName!=null&&ingr.oreName.equals(formatted.oreName)) + isNew = false; + else if(ingr.stackList!=null&&formatted.stackList!=null) { for(ItemStack iStack : ingr.stackList) for(ItemStack iStack2 : formatted.stackList) if(OreDictionary.itemMatches(iStack, iStack2, false)) { - isNew=false; + isNew = false; break; } } - else if(!ingr.stack.isEmpty() && OreDictionary.itemMatches(ingr.stack, formatted.stack, false)) - isNew=false; + else if(!ingr.stack.isEmpty()&&OreDictionary.itemMatches(ingr.stack, formatted.stack, false)) + isNew = false; if(!isNew) formatted.inputSize += ingr.inputSize; } @@ -263,6 +265,7 @@ public static void addRecipe(String blueprintCategory, ItemStack output, Object. if(!blueprintCategories.contains(blueprintCategory)) blueprintCategories.add(blueprintCategory); } + public static BlueprintCraftingRecipe[] findRecipes(String blueprintCategory) { if(recipeList.containsKey(blueprintCategory)) @@ -286,6 +289,7 @@ public int getMultipleProcessTicks() { return 0; } + @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { @@ -296,20 +300,21 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) nbt.setString("blueprintCategory", this.blueprintCategory); return nbt; } + public static BlueprintCraftingRecipe loadFromNBT(NBTTagCompound nbt) { NBTTagList list = nbt.getTagList("inputs", 10); IngredientStack[] inputs = new IngredientStack[list.tagCount()]; - for(int i=0; i recipeList = BlueprintCraftingRecipe.recipeList.get(nbt.getString("blueprintCategory")); for(BlueprintCraftingRecipe recipe : recipeList) { boolean b = false; - for(int i=0; i recipeList = new ArrayList(); + public static void addRecipe(ItemStack output, Object input, FluidStack fluidInput) { BottlingMachineRecipe recipe = new BottlingMachineRecipe(output, input, fluidInput); if(recipe.input!=null) recipeList.add(recipe); } + public static BottlingMachineRecipe findRecipe(ItemStack input, FluidStack fluid) { - if(!input.isEmpty() && fluid!=null) + if(!input.isEmpty()&&fluid!=null) for(BottlingMachineRecipe recipe : recipeList) - if(ApiUtils.stackMatchesObject(input, recipe.input) && fluid.containsFluid(recipe.fluidInput)) + if(ApiUtils.stackMatchesObject(input, recipe.input)&&fluid.containsFluid(recipe.fluidInput)) return recipe; return null; } + public static List removeRecipes(ItemStack stack) { List list = new ArrayList(); @@ -84,6 +88,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) nbt.setTag("input", input.writeToNBT(new NBTTagCompound())); return nbt; } + public static BottlingMachineRecipe loadFromNBT(NBTTagCompound nbt) { IngredientStack input = IngredientStack.readFromNBT(nbt.getCompoundTag("input")); diff --git a/src/main/java/blusunrize/immersiveengineering/api/crafting/CokeOvenRecipe.java b/src/main/java/blusunrize/immersiveengineering/api/crafting/CokeOvenRecipe.java index 91cc48d50c..ea9266465c 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/crafting/CokeOvenRecipe.java +++ b/src/main/java/blusunrize/immersiveengineering/api/crafting/CokeOvenRecipe.java @@ -30,19 +30,21 @@ public class CokeOvenRecipe public CokeOvenRecipe(ItemStack output, Object input, int time, int creosoteOutput) { - this.output=output; - this.input=ApiUtils.convertToValidRecipeInput(input); - this.time=time; - this.creosoteOutput=creosoteOutput; + this.output = output; + this.input = ApiUtils.convertToValidRecipeInput(input); + this.time = time; + this.creosoteOutput = creosoteOutput; } public static ArrayList recipeList = new ArrayList(); + public static void addRecipe(ItemStack output, Object input, int time, int creosoteOutput) { CokeOvenRecipe recipe = new CokeOvenRecipe(output, input, time, creosoteOutput); if(recipe.input!=null) recipeList.add(recipe); } + public static CokeOvenRecipe findRecipe(ItemStack input) { for(CokeOvenRecipe recipe : recipeList) @@ -50,6 +52,7 @@ public static CokeOvenRecipe findRecipe(ItemStack input) return recipe; return null; } + public static List removeRecipes(ItemStack stack) { List list = new ArrayList(); diff --git a/src/main/java/blusunrize/immersiveengineering/api/crafting/CrusherRecipe.java b/src/main/java/blusunrize/immersiveengineering/api/crafting/CrusherRecipe.java index a7ece38d34..38739e5bea 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/crafting/CrusherRecipe.java +++ b/src/main/java/blusunrize/immersiveengineering/api/crafting/CrusherRecipe.java @@ -25,7 +25,7 @@ /** * @author BluSunrize - 01.05.2015 - * + *

* The recipe for the crusher */ public class CrusherRecipe extends MultiblockRecipe @@ -56,7 +56,7 @@ public NonNullList getActualItemOutputs(TileEntity tile) { NonNullList list = NonNullList.create(); list.add(output); - if(secondaryOutput != null && secondaryChance != null) + if(secondaryOutput!=null&&secondaryChance!=null) for(int i = 0; i < secondaryOutput.length; i++) if(Utils.RAND.nextFloat() < secondaryChance[i]) list.add(secondaryOutput[i]); @@ -74,12 +74,12 @@ public CrusherRecipe addToSecondaryOutput(Object... outputs) ArrayList newSecondaryOutput = new ArrayList(); ArrayList newSecondaryChance = new ArrayList(); if(secondaryOutput!=null) - for(int i=0; i recipeList = new ArrayList(); + public static CrusherRecipe addRecipe(ItemStack output, Object input, int energy) { CrusherRecipe r = new CrusherRecipe(output, input, energy); - if(r.input!=null && !r.output.isEmpty()) + if(r.input!=null&&!r.output.isEmpty()) recipeList.add(r); return r; } + public static CrusherRecipe findRecipe(ItemStack input) { for(CrusherRecipe recipe : recipeList) @@ -120,6 +122,7 @@ public static CrusherRecipe findRecipe(ItemStack input) return recipe; return null; } + public static List removeRecipesForOutput(ItemStack stack) { List list = new ArrayList(); @@ -135,6 +138,7 @@ public static List removeRecipesForOutput(ItemStack stack) } return list; } + public static List removeRecipesForInput(ItemStack stack) { List list = new ArrayList(); @@ -163,6 +167,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) nbt.setTag("input", input.writeToNBT(new NBTTagCompound())); return nbt; } + public static CrusherRecipe loadFromNBT(NBTTagCompound nbt) { IngredientStack input = IngredientStack.readFromNBT(nbt.getCompoundTag("input")); diff --git a/src/main/java/blusunrize/immersiveengineering/api/crafting/FermenterRecipe.java b/src/main/java/blusunrize/immersiveengineering/api/crafting/FermenterRecipe.java index 731fec095f..c6b6f4fdbe 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/crafting/FermenterRecipe.java +++ b/src/main/java/blusunrize/immersiveengineering/api/crafting/FermenterRecipe.java @@ -23,18 +23,19 @@ /** * @author BluSunrize - 01.03.2016 - * + *

* The recipe for the Fermenter */ public class FermenterRecipe extends MultiblockRecipe { public static float energyModifier = 1; public static float timeModifier = 1; - + public final IngredientStack input; public final FluidStack fluidOutput; @Nonnull public final ItemStack itemOutput; + public FermenterRecipe(FluidStack fluidOutput, @Nonnull ItemStack itemOutput, Object input, int energy) { this.fluidOutput = fluidOutput; @@ -47,19 +48,22 @@ public FermenterRecipe(FluidStack fluidOutput, @Nonnull ItemStack itemOutput, Ob this.fluidOutputList = Lists.newArrayList(this.fluidOutput); this.outputList = ListUtils.fromItem(this.itemOutput); } + public FermenterRecipe setInputSize(int size) { this.input.inputSize = size; return this; } - + public static ArrayList recipeList = new ArrayList(); + public static FermenterRecipe addRecipe(FluidStack fluidOutput, @Nonnull ItemStack itemOutput, Object input, int energy) { FermenterRecipe r = new FermenterRecipe(fluidOutput, itemOutput, input, energy); recipeList.add(r); return r; } + public static FermenterRecipe findRecipe(ItemStack input) { if(input.isEmpty()) @@ -93,13 +97,14 @@ public int getMultipleProcessTicks() { return 0; } - + @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { nbt.setTag("input", input.writeToNBT(new NBTTagCompound())); return nbt; } + public static FermenterRecipe loadFromNBT(NBTTagCompound nbt) { IngredientStack input = IngredientStack.readFromNBT(nbt.getCompoundTag("input")); @@ -108,11 +113,12 @@ public static FermenterRecipe loadFromNBT(NBTTagCompound nbt) return recipe; return null; } + public static Map getFluidValuesSorted(Fluid f, boolean inverse) { HashMap map = new HashMap(); for(FermenterRecipe recipe : recipeList) - if(recipe.fluidOutput!=null && recipe.fluidOutput.getFluid()==f) + if(recipe.fluidOutput!=null&&recipe.fluidOutput.getFluid()==f) { ItemStack is = recipe.input.getExampleStack(); map.put(is.getDisplayName(), recipe.fluidOutput.amount); diff --git a/src/main/java/blusunrize/immersiveengineering/api/crafting/IJEIRecipe.java b/src/main/java/blusunrize/immersiveengineering/api/crafting/IJEIRecipe.java index 74944e8eea..3039998717 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/crafting/IJEIRecipe.java +++ b/src/main/java/blusunrize/immersiveengineering/api/crafting/IJEIRecipe.java @@ -15,9 +15,16 @@ public interface IJEIRecipe { - default boolean listInJEI() { return true; } + default boolean listInJEI() + { + return true; + } + List getJEITotalItemInputs(); + List getJEITotalItemOutputs(); + List getJEITotalFluidInputs(); + List getJEITotalFluidOutputs(); } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/api/crafting/IMultiblockRecipe.java b/src/main/java/blusunrize/immersiveengineering/api/crafting/IMultiblockRecipe.java index f2a14bbfcc..af0a69af09 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/crafting/IMultiblockRecipe.java +++ b/src/main/java/blusunrize/immersiveengineering/api/crafting/IMultiblockRecipe.java @@ -26,13 +26,16 @@ public interface IMultiblockRecipe { List getItemInputs(); + List getFluidInputs(); + NonNullList getItemOutputs(); default NonNullList getActualItemOutputs(TileEntity tile) { return getItemOutputs(); } + List getFluidOutputs(); default ItemStack getDisplayStack(ItemStack input) @@ -47,10 +50,12 @@ default List getActualFluidOutputs(TileEntity tile) { return getFluidOutputs(); } - + int getTotalProcessTime(); + int getTotalProcessEnergy(); + int getMultipleProcessTicks(); - + NBTTagCompound writeToNBT(NBTTagCompound nbtTagCompound); } diff --git a/src/main/java/blusunrize/immersiveengineering/api/crafting/IngredientStack.java b/src/main/java/blusunrize/immersiveengineering/api/crafting/IngredientStack.java index 8a1fd028ae..04a2a51436 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/crafting/IngredientStack.java +++ b/src/main/java/blusunrize/immersiveengineering/api/crafting/IngredientStack.java @@ -40,28 +40,34 @@ public IngredientStack(ItemStack stack) this.stack = stack; this.inputSize = stack.getCount(); } + public IngredientStack(String oreName, int inputSize) { this.oreName = oreName; this.inputSize = inputSize; } + public IngredientStack(String oreName) { this(oreName, 1); } + public IngredientStack(List stackList, int inputSize) { this.stackList = stackList; this.inputSize = inputSize; } + public IngredientStack(List stackList) { this(stackList, 1); } + public IngredientStack(FluidStack fluid) { this.fluid = fluid; } + public IngredientStack(IngredientStack ingr) { this.stack = ingr.stack; @@ -84,7 +90,7 @@ public boolean matches(Object input) if(input==null) return false; if(input instanceof IngredientStack) - return this.equals(input) && this.inputSize <= ((IngredientStack)input).inputSize; + return this.equals(input)&&this.inputSize <= ((IngredientStack)input).inputSize; if(input instanceof ItemStack) { return matchesItemStack((ItemStack)input); @@ -116,6 +122,7 @@ public IngredientStack copyWithSize(int size) is.inputSize = size; return is; } + public IngredientStack copyWithMultipliedSize(double multiplier) { return copyWithSize((int)Math.floor(this.inputSize*multiplier)); @@ -153,13 +160,13 @@ else if(stackList!=null) public ItemStack getRandomizedExampleStack(long rand) { ItemStack ret = stack; - if(ret.isEmpty()&&stackList!=null&&stackList.size()>0) - ret = stackList.get((int)(rand / 20) % stackList.size()); + if(ret.isEmpty()&&stackList!=null&&stackList.size() > 0) + ret = stackList.get((int)(rand/20)%stackList.size()); if(ret.isEmpty()&&oreName!=null) { List ores = OreDictionary.getOres(oreName); - if(ores!=null&&ores.size()>0) - ret = ores.get((int)(rand / 20) % ores.size()); + if(ores!=null&&ores.size() > 0) + ret = ores.get((int)(rand/20)%ores.size()); } if(ret.isEmpty()&&fluid!=null&&ForgeModContainer.getInstance().universalBucket!=null) ret = UniversalBucket.getFilledBucket(ForgeModContainer.getInstance().universalBucket, fluid.getFluid()); @@ -169,22 +176,23 @@ public ItemStack getRandomizedExampleStack(long rand) public ItemStack getExampleStack() { ItemStack ret = stack; - if(ret.isEmpty() && stackList != null && stackList.size() > 0) + if(ret.isEmpty()&&stackList!=null&&stackList.size() > 0) ret = stackList.get(0); - if(ret.isEmpty() && oreName != null) + if(ret.isEmpty()&&oreName!=null) { List ores = OreDictionary.getOres(oreName); - if(ores != null && ores.size() > 0) + if(ores!=null&&ores.size() > 0) ret = ores.get(0); } - if(ret.isEmpty() && fluid != null && ForgeModContainer.getInstance().universalBucket != null) + if(ret.isEmpty()&&fluid!=null&&ForgeModContainer.getInstance().universalBucket!=null) ret = UniversalBucket.getFilledBucket(ForgeModContainer.getInstance().universalBucket, fluid.getFluid()); return ret; } + public Ingredient toRecipeIngredient() { - Ingredient ret = stack!=null?Ingredient.fromStacks(stack):null; - if(ret==null&&stackList!=null&&stackList.size()>0) + Ingredient ret = stack!=null?Ingredient.fromStacks(stack): null; + if(ret==null&&stackList!=null&&stackList.size() > 0) ret = ApiUtils.createIngredientFromList(stackList); if(ret==null&&oreName!=null) ret = new OreIngredient(oreName); @@ -200,24 +208,24 @@ public boolean matchesItemStack(ItemStack input) if(this.fluid!=null) { FluidStack fs = FluidUtil.getFluidContained(input); - if(fs!=null && fs.containsFluid(fluid)) + if(fs!=null&&fs.containsFluid(fluid)) return true; } if(this.oreName!=null) - return ApiUtils.compareToOreName(input, oreName) && this.inputSize <= input.getCount(); + return ApiUtils.compareToOreName(input, oreName)&&this.inputSize <= input.getCount(); if(this.stackList!=null) { for(ItemStack iStack : this.stackList) - if(OreDictionary.itemMatches(iStack, input, false) && this.inputSize <= input.getCount()) + if(OreDictionary.itemMatches(iStack, input, false)&&this.inputSize <= input.getCount()) return true; } - if(!OreDictionary.itemMatches(stack,input, false) || this.inputSize > input.getCount()) + if(!OreDictionary.itemMatches(stack, input, false)||this.inputSize > input.getCount()) return false; if(this.useNBT) { - if(this.stack.hasTagCompound() != input.hasTagCompound()) + if(this.stack.hasTagCompound()!=input.hasTagCompound()) return false; - if(!this.stack.hasTagCompound() && !input.hasTagCompound()) + if(!this.stack.hasTagCompound()&&!input.hasTagCompound()) return true; return this.stack.getTagCompound().equals(input.getTagCompound()); } @@ -231,7 +239,7 @@ public boolean matchesItemStackIgnoringSize(ItemStack input) if(this.fluid!=null) { FluidStack fs = FluidUtil.getFluidContained(input); - if(fs!=null && fs.containsFluid(fluid)) + if(fs!=null&&fs.containsFluid(fluid)) return true; } if(this.oreName!=null) @@ -242,13 +250,13 @@ public boolean matchesItemStackIgnoringSize(ItemStack input) if(OreDictionary.itemMatches(iStack, input, false)) return true; } - if(!OreDictionary.itemMatches(stack,input, false)) + if(!OreDictionary.itemMatches(stack, input, false)) return false; if(this.useNBT) { - if(this.stack.hasTagCompound() != input.hasTagCompound()) + if(this.stack.hasTagCompound()!=input.hasTagCompound()) return false; - if(!this.stack.hasTagCompound() && !input.hasTagCompound()) + if(!this.stack.hasTagCompound()&&!input.hasTagCompound()) return true; return this.stack.getTagCompound().equals(input.getTagCompound()); } @@ -260,28 +268,28 @@ public boolean equals(Object object) { if(!(object instanceof IngredientStack)) return false; - if(this.fluid!=null && ((IngredientStack)object).fluid!=null) + if(this.fluid!=null&&((IngredientStack)object).fluid!=null) return this.fluid.equals(((IngredientStack)object).fluid); - if(this.oreName!=null && ((IngredientStack)object).oreName!=null) + if(this.oreName!=null&&((IngredientStack)object).oreName!=null) return this.oreName.equals(((IngredientStack)object).oreName); - if(this.stackList != null && ((IngredientStack) object).stackList != null) + if(this.stackList!=null&&((IngredientStack)object).stackList!=null) { for(ItemStack iStack : this.stackList) - for(ItemStack iStack2 : ((IngredientStack) object).stackList) + for(ItemStack iStack2 : ((IngredientStack)object).stackList) if(OreDictionary.itemMatches(iStack, iStack2, false)) return true; return false; } - if(!this.stack.isEmpty() && !((IngredientStack)object).stack.isEmpty()) + if(!this.stack.isEmpty()&&!((IngredientStack)object).stack.isEmpty()) { ItemStack otherStack = ((IngredientStack)object).stack; - if(!OreDictionary.itemMatches(stack,otherStack, false)) + if(!OreDictionary.itemMatches(stack, otherStack, false)) return false; if(this.useNBT) { - if(this.stack.hasTagCompound() != otherStack.hasTagCompound()) + if(this.stack.hasTagCompound()!=otherStack.hasTagCompound()) return false; - if(!this.stack.hasTagCompound() && !otherStack.hasTagCompound()) + if(!this.stack.hasTagCompound()&&!otherStack.hasTagCompound()) return true; return this.stack.getTagCompound().equals(otherStack.getTagCompound()); } @@ -321,6 +329,7 @@ else if(this.stackList!=null) nbt.setInteger("inputSize", inputSize); return nbt; } + public static IngredientStack readFromNBT(NBTTagCompound nbt) { if(nbt.hasKey("nbtType")) @@ -335,13 +344,13 @@ public static IngredientStack readFromNBT(NBTTagCompound nbt) case 1: NBTTagList list = nbt.getTagList("stackList", 10); List stackList = new ArrayList(); - for(int i=0; i * The recipe for the metal press */ public class MetalPressRecipe extends MultiblockRecipe { public static float energyModifier = 1; public static float timeModifier = 1; - + public final IngredientStack input; public final ComparableItemStack mold; public final ItemStack output; + public MetalPressRecipe(ItemStack output, Object input, ComparableItemStack mold, int energy) { this.output = output; @@ -44,17 +45,19 @@ public MetalPressRecipe(ItemStack output, Object input, ComparableItemStack mold this.inputList = Lists.newArrayList(this.input); this.outputList = ListUtils.fromItem(this.output); } + public MetalPressRecipe setInputSize(int size) { this.input.inputSize = size; return this; } + @Override public void setupJEI() { super.setupJEI(); this.jeiItemInputList = new ArrayList[2]; - this.jeiItemInputList[0] =Lists.newArrayList(jeiTotalItemInputList); + this.jeiItemInputList[0] = Lists.newArrayList(jeiTotalItemInputList); this.jeiItemInputList[1] = Lists.newArrayList(mold.stack); this.jeiTotalItemInputList.add(mold.stack); } @@ -63,25 +66,29 @@ public boolean matches(ItemStack mold, ItemStack input) { return this.input.matches(input); } + public MetalPressRecipe getActualRecipe(ItemStack mold, ItemStack input) { return this; } public static ArrayListMultimap recipeList = ArrayListMultimap.create(); + public static MetalPressRecipe addRecipe(ItemStack output, Object input, ItemStack mold, int energy) { return addRecipe(output, input, ApiUtils.createComparableItemStack(mold, true), energy); } + public static MetalPressRecipe addRecipe(ItemStack output, Object input, ComparableItemStack mold, int energy) { MetalPressRecipe r = new MetalPressRecipe(output, input, mold, energy); recipeList.put(mold, r); return r; } + public static MetalPressRecipe findRecipe(ItemStack mold, ItemStack input) { - if(mold.isEmpty() || input.isEmpty()) + if(mold.isEmpty()||input.isEmpty()) return null; ComparableItemStack comp = ApiUtils.createComparableItemStack(mold, false); List list = recipeList.get(comp); @@ -90,6 +97,7 @@ public static MetalPressRecipe findRecipe(ItemStack mold, ItemStack input) return recipe.getActualRecipe(mold, input); return null; } + public static List removeRecipes(ItemStack output) { List list = new ArrayList(); @@ -109,6 +117,7 @@ public static List removeRecipes(ItemStack output) } return list; } + public static boolean isValidMold(ItemStack itemStack) { if(itemStack.isEmpty()) @@ -122,7 +131,8 @@ public int getMultipleProcessTicks() return 0; } - public static HashMap> deserializers = new HashMap<>(); + public static HashMap> deserializers = new HashMap<>(); + @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { @@ -130,9 +140,10 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) nbt.setTag("mold", mold.writeToNBT(new NBTTagCompound())); return nbt; } + public static MetalPressRecipe loadFromNBT(NBTTagCompound nbt) { - if(nbt.hasKey("type") && deserializers.containsKey(nbt.getString("type"))) + if(nbt.hasKey("type")&&deserializers.containsKey(nbt.getString("type"))) return deserializers.get(nbt.getString("type")).apply(nbt); IngredientStack input = IngredientStack.readFromNBT(nbt.getCompoundTag("input")); ComparableItemStack mold = ComparableItemStack.readFromNBT(nbt.getCompoundTag("mold")); diff --git a/src/main/java/blusunrize/immersiveengineering/api/crafting/MixerRecipe.java b/src/main/java/blusunrize/immersiveengineering/api/crafting/MixerRecipe.java index e6784d8ad3..5a665c4b30 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/crafting/MixerRecipe.java +++ b/src/main/java/blusunrize/immersiveengineering/api/crafting/MixerRecipe.java @@ -23,7 +23,7 @@ /** * @author BluSunrize - 20.02.2016 - * + *

* The recipe for the Squeezer */ public class MixerRecipe extends MultiblockRecipe @@ -35,24 +35,26 @@ public class MixerRecipe extends MultiblockRecipe public final FluidStack fluidInput; public final FluidStack fluidOutput; public final int fluidAmount; + public MixerRecipe(FluidStack fluidOutput, FluidStack fluidInput, Object[] itemInputs, int energy) { this.fluidOutput = fluidOutput; this.fluidAmount = fluidOutput.amount; this.fluidInput = fluidInput; - this.itemInputs = new IngredientStack[itemInputs==null?0:itemInputs.length]; + this.itemInputs = new IngredientStack[itemInputs==null?0: itemInputs.length]; if(itemInputs!=null) - for(int i=0; i recipeList = new ArrayList(); + public static MixerRecipe addRecipe(FluidStack fluidOutput, FluidStack fluidInput, Object[] itemInput, int energy) { MixerRecipe r = new MixerRecipe(fluidOutput, fluidInput, itemInput, energy); @@ -77,7 +79,7 @@ public FluidStack getFluidOutput(FluidStack input, NonNullList compon public boolean matches(FluidStack fluid, NonNullList components) { - if(fluid!=null && fluid.containsFluid(this.fluidInput)) + if(fluid!=null&&fluid.containsFluid(this.fluidInput)) { ArrayList queryList = new ArrayList(components.size()); @@ -99,7 +101,7 @@ public boolean matches(FluidStack fluid, NonNullList components) if(query.getCount() > addAmount) { query.shrink(addAmount); - addAmount=0; + addAmount = 0; } else { @@ -108,11 +110,11 @@ public boolean matches(FluidStack fluid, NonNullList components) } if(query.getCount() <= 0) it.remove(); - if(addAmount<=0) + if(addAmount <= 0) break; } } - if(addAmount>0) + if(addAmount > 0) return false; } return true; @@ -123,11 +125,11 @@ public boolean matches(FluidStack fluid, NonNullList components) public int[] getUsedSlots(FluidStack input, NonNullList components) { Set usedSlotSet = new HashSet(); - for(int i=0; i0) + if(this.itemInputs.length > 0) { NBTTagList list = new NBTTagList(); for(IngredientStack add : this.itemInputs) @@ -159,6 +161,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) } return nbt; } + public static MixerRecipe loadFromNBT(NBTTagCompound nbt) { FluidStack fluidInput = FluidStack.loadFluidStackFromNBT(nbt.getCompoundTag("fluidInput")); @@ -167,21 +170,21 @@ public static MixerRecipe loadFromNBT(NBTTagCompound nbt) { NBTTagList list = nbt.getTagList("itemInputs", 10); itemInputs = new IngredientStack[list.tagCount()]; - for(int i=0; i inputList; + @Override public List getItemInputs() { return inputList; } + protected NonNullList outputList; + @Override public NonNullList getItemOutputs() { return outputList; } + protected List fluidInputList; + @Override public List getFluidInputs() { return fluidInputList; } + protected List fluidOutputList; + @Override public List getFluidOutputs() { @@ -47,12 +54,15 @@ public List getFluidOutputs() } int totalProcessTime; + @Override public int getTotalProcessTime() { return this.totalProcessTime; } + int totalProcessEnergy; + @Override public int getTotalProcessEnergy() { @@ -76,7 +86,7 @@ public void setupJEI() { this.jeiItemInputList = new ArrayList[inputList.size()]; this.jeiTotalItemInputList = new ArrayList(); - for(int i=0; i list = Lists.newArrayList(!s.isEmpty()?s.copy():ItemStack.EMPTY); + ArrayList list = Lists.newArrayList(!s.isEmpty()?s.copy(): ItemStack.EMPTY); this.jeiItemOutputList[i] = list; this.jeiTotalItemOutputList.addAll(list); } @@ -112,7 +122,7 @@ else if(ingr.stackList!=null) if(fluidInputList!=null) { this.jeiFluidInputList = new ArrayList(); - for(int i=0; i getJEITotalItemInputs() { return jeiTotalItemInputList; } + @Override public List getJEITotalItemOutputs() { return jeiTotalItemOutputList; } + @Override public List getJEITotalFluidInputs() { return jeiFluidInputList; } + @Override public List getJEITotalFluidOutputs() { diff --git a/src/main/java/blusunrize/immersiveengineering/api/crafting/RefineryRecipe.java b/src/main/java/blusunrize/immersiveengineering/api/crafting/RefineryRecipe.java index 4800e9e2b4..6324618961 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/crafting/RefineryRecipe.java +++ b/src/main/java/blusunrize/immersiveengineering/api/crafting/RefineryRecipe.java @@ -17,7 +17,7 @@ /** * @author BluSunrize - 02.03.2016 - * + *

* The recipe for the Refinery */ public class RefineryRecipe extends MultiblockRecipe @@ -28,6 +28,7 @@ public class RefineryRecipe extends MultiblockRecipe public final FluidStack output; public final FluidStack input0; public final FluidStack input1; + public RefineryRecipe(FluidStack output, FluidStack input0, FluidStack input1, int energy) { this.output = output; @@ -36,69 +37,72 @@ public RefineryRecipe(FluidStack output, FluidStack input0, FluidStack input1, i this.totalProcessEnergy = (int)Math.floor(energy*energyModifier); this.totalProcessTime = (int)Math.floor(1*timeModifier); - this.fluidInputList = Lists.newArrayList(this.input0,this.input1); + this.fluidInputList = Lists.newArrayList(this.input0, this.input1); this.fluidOutputList = Lists.newArrayList(this.output); } public static ArrayList recipeList = new ArrayList(); + public static RefineryRecipe addRecipe(FluidStack output, FluidStack input0, FluidStack input1, int energy) { RefineryRecipe r = new RefineryRecipe(output, input0, input1, energy); recipeList.add(r); return r; } + public static RefineryRecipe findRecipe(FluidStack input0, FluidStack input1) { for(RefineryRecipe recipe : recipeList) { if(input0!=null) { - if(recipe.input0!=null && input0.containsFluid(recipe.input0)) + if(recipe.input0!=null&&input0.containsFluid(recipe.input0)) { - if((recipe.input1==null&&input1==null) || (recipe.input1!=null&&input1!=null&&input1.containsFluid(recipe.input1))) + if((recipe.input1==null&&input1==null)||(recipe.input1!=null&&input1!=null&&input1.containsFluid(recipe.input1))) return recipe; } - if(recipe.input1!=null && input0.containsFluid(recipe.input1)) + if(recipe.input1!=null&&input0.containsFluid(recipe.input1)) { - if((recipe.input0==null&&input1==null) || (recipe.input0!=null&&input1!=null&&input1.containsFluid(recipe.input0))) + if((recipe.input0==null&&input1==null)||(recipe.input0!=null&&input1!=null&&input1.containsFluid(recipe.input0))) return recipe; } } else if(input1!=null) { - if(recipe.input0!=null && input1.containsFluid(recipe.input0) && recipe.input1==null) + if(recipe.input0!=null&&input1.containsFluid(recipe.input0)&&recipe.input1==null) return recipe; - if(recipe.input1!=null && input1.containsFluid(recipe.input1) && recipe.input0==null) + if(recipe.input1!=null&&input1.containsFluid(recipe.input1)&&recipe.input0==null) return recipe; } } return null; } + public static List findIncompleteRefineryRecipe(FluidStack input0, FluidStack input1) { - if(input0==null && input1==null) + if(input0==null&&input1==null) return null; List list = Lists.newArrayList(); for(RefineryRecipe recipe : recipeList) { - if(input0!=null && input1==null) + if(input0!=null&&input1==null) { - if(input0.isFluidEqual(recipe.input0) || input0.isFluidEqual(recipe.input1)) + if(input0.isFluidEqual(recipe.input0)||input0.isFluidEqual(recipe.input1)) { list.add(recipe); break; } } - else if(input0==null && input1!=null) + else if(input0==null&&input1!=null) { - if(input1.isFluidEqual(recipe.input0) || input1.isFluidEqual(recipe.input1)) + if(input1.isFluidEqual(recipe.input0)||input1.isFluidEqual(recipe.input1)) { list.add(recipe); break; } } - else if( (input0.isFluidEqual(recipe.input0)&&input1.isFluidEqual(recipe.input1)) || (input0.isFluidEqual(recipe.input1)&&input1.isFluidEqual(recipe.input0)) ) + else if((input0.isFluidEqual(recipe.input0)&&input1.isFluidEqual(recipe.input1))||(input0.isFluidEqual(recipe.input1)&&input1.isFluidEqual(recipe.input0))) { list.add(recipe); break; @@ -120,6 +124,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) nbt.setTag("input1", input1.writeToNBT(new NBTTagCompound())); return nbt; } + public static RefineryRecipe loadFromNBT(NBTTagCompound nbt) { FluidStack input0 = FluidStack.loadFluidStackFromNBT(nbt.getCompoundTag("input0")); diff --git a/src/main/java/blusunrize/immersiveengineering/api/crafting/SqueezerRecipe.java b/src/main/java/blusunrize/immersiveengineering/api/crafting/SqueezerRecipe.java index 55f2145a92..1a58a69b3e 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/crafting/SqueezerRecipe.java +++ b/src/main/java/blusunrize/immersiveengineering/api/crafting/SqueezerRecipe.java @@ -23,18 +23,19 @@ /** * @author BluSunrize - 20.02.2016 - * + *

* The recipe for the Squeezer */ public class SqueezerRecipe extends MultiblockRecipe { public static float energyModifier = 1; public static float timeModifier = 1; - + public final IngredientStack input; public final FluidStack fluidOutput; @Nonnull public final ItemStack itemOutput; + public SqueezerRecipe(FluidStack fluidOutput, @Nonnull ItemStack itemOutput, Object input, int energy) { this.fluidOutput = fluidOutput; @@ -47,19 +48,22 @@ public SqueezerRecipe(FluidStack fluidOutput, @Nonnull ItemStack itemOutput, Obj this.fluidOutputList = Lists.newArrayList(this.fluidOutput); this.outputList = ListUtils.fromItem(this.itemOutput); } + public SqueezerRecipe setInputSize(int size) { this.input.inputSize = size; return this; } - + public static ArrayList recipeList = new ArrayList(); + public static SqueezerRecipe addRecipe(FluidStack fluidOutput, @Nonnull ItemStack itemOutput, Object input, int energy) { SqueezerRecipe r = new SqueezerRecipe(fluidOutput, itemOutput, input, energy); recipeList.add(r); return r; } + public static SqueezerRecipe findRecipe(ItemStack input) { if(input.isEmpty()) @@ -93,13 +97,14 @@ public int getMultipleProcessTicks() { return 0; } - + @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { nbt.setTag("input", input.writeToNBT(new NBTTagCompound())); return nbt; } + public static SqueezerRecipe loadFromNBT(NBTTagCompound nbt) { IngredientStack input = IngredientStack.readFromNBT(nbt.getCompoundTag("input")); @@ -108,11 +113,12 @@ public static SqueezerRecipe loadFromNBT(NBTTagCompound nbt) return recipe; return null; } + public static Map getFluidValuesSorted(Fluid f, boolean inverse) { HashMap map = new HashMap(); for(SqueezerRecipe recipe : recipeList) - if(recipe.fluidOutput!=null && recipe.fluidOutput.getFluid()==f) + if(recipe.fluidOutput!=null&&recipe.fluidOutput.getFluid()==f) { ItemStack is = recipe.input.getExampleStack(); map.put(is.getDisplayName(), recipe.fluidOutput.amount); diff --git a/src/main/java/blusunrize/immersiveengineering/api/energy/DieselHandler.java b/src/main/java/blusunrize/immersiveengineering/api/energy/DieselHandler.java index 0a457ab047..2fdf044e3d 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/energy/DieselHandler.java +++ b/src/main/java/blusunrize/immersiveengineering/api/energy/DieselHandler.java @@ -18,7 +18,7 @@ /** * @author BluSunrize - 23.04.2015 - * + *

* The Fuel Handler for the Diesel Generator. Use this to register custom fuels */ public class DieselHandler @@ -32,13 +32,13 @@ public class DieselHandler */ public static void registerFuel(Fluid fuel, int time) { - if(fuel != null) + if(fuel!=null) dieselGenBurnTime.put(fuel.getName(), time); } public static int getBurnTime(Fluid fuel) { - if(fuel != null) + if(fuel!=null) { String s = fuel.getName(); if(dieselGenBurnTime.containsKey(s)) @@ -49,7 +49,7 @@ public static int getBurnTime(Fluid fuel) public static boolean isValidFuel(Fluid fuel) { - if(fuel != null) + if(fuel!=null) return dieselGenBurnTime.containsKey(fuel.getName()); return false; } @@ -66,22 +66,25 @@ public static Map getFuelValuesSorted(boolean inverse) public static void registerDrillFuel(Fluid fuel) { - if(fuel != null) + if(fuel!=null) drillFuel.add(fuel); } public static boolean isValidDrillFuel(Fluid fuel) { - return fuel != null && drillFuel.contains(fuel); + return fuel!=null&&drillFuel.contains(fuel); } - - public static void removeFuel(Fluid fuel){ - if(fuel != null){ + + public static void removeFuel(Fluid fuel) + { + if(fuel!=null) + { dieselGenBurnTime.remove(fuel.getName()); } } - - public static void removeDrillFuel(Fluid fuel){ + + public static void removeDrillFuel(Fluid fuel) + { drillFuel.remove(fuel); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/FluxStorage.java b/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/FluxStorage.java index b749b486e1..5f20bc428b 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/FluxStorage.java +++ b/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/FluxStorage.java @@ -12,9 +12,8 @@ /** * A simple storage object for IF and an example implementation of {@link IFluxStorage}. - * + * * @author BluSunrize - 18.01.2016 - * */ public class FluxStorage implements IFluxStorage { @@ -29,10 +28,12 @@ public FluxStorage(int capacity, int limitReceive, int limitExtract) this.limitReceive = limitReceive; this.limitExtract = limitExtract; } + public FluxStorage(int capacity, int limitTransfer) { this(capacity, limitTransfer, limitTransfer); } + public FluxStorage(int capacity) { this(capacity, capacity, capacity); @@ -41,13 +42,14 @@ public FluxStorage(int capacity) public FluxStorage readFromNBT(NBTTagCompound nbt) { this.energy = nbt.getInteger("ifluxEnergy"); - if(energy>capacity) + if(energy > capacity) energy = capacity; return this; } + public NBTTagCompound writeToNBT(NBTTagCompound nbt) { - if(energy<0) + if(energy < 0) energy = 0; nbt.setInteger("ifluxEnergy", energy); return nbt; @@ -56,7 +58,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) public void setCapacity(int capacity) { this.capacity = capacity; - if(energy>capacity) + if(energy > capacity) energy = capacity; } @@ -65,10 +67,12 @@ public void setLimitTransfer(int limitTransfer) setLimitReceive(limitTransfer); setMaxExtract(limitTransfer); } + public void setLimitReceive(int limitReceive) { this.limitReceive = limitReceive; } + public void setMaxExtract(int limitExtract) { this.limitExtract = limitExtract; @@ -78,6 +82,7 @@ public int getLimitReceive() { return limitReceive; } + public int getLimitExtract() { return limitExtract; @@ -86,17 +91,18 @@ public int getLimitExtract() public void setEnergy(int energy) { this.energy = energy; - if (this.energy>capacity) + if(this.energy > capacity) this.energy = capacity; - else if (this.energy<0) + else if(this.energy < 0) this.energy = 0; } + public void modifyEnergyStored(int energy) { this.energy += energy; - if(this.energy>capacity) + if(this.energy > capacity) this.energy = capacity; - else if(this.energy<0) + else if(this.energy < 0) this.energy = 0; } diff --git a/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/FluxStorageAdvanced.java b/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/FluxStorageAdvanced.java index 1a47cb1b9b..f50d0c7515 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/FluxStorageAdvanced.java +++ b/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/FluxStorageAdvanced.java @@ -10,24 +10,25 @@ /** * An advanced implementation of {@link IFluxStorage}, keeps track of the average in/output to allow transfer evaluation. - * + * * @author BluSunrize - 02.02.2016 - * */ public class FluxStorageAdvanced extends FluxStorage { - int averageInsertion=0; - int averageExtraction=0; + int averageInsertion = 0; + int averageExtraction = 0; double averageDecayFactor = .5; - + public FluxStorageAdvanced(int capacity, int limitReceive, int limitExtract) { super(capacity, limitReceive, limitExtract); } + public FluxStorageAdvanced(int capacity, int limitTransfer) { super(capacity, limitTransfer); } + public FluxStorageAdvanced(int capacity) { super(capacity, capacity, capacity); @@ -36,9 +37,9 @@ public FluxStorageAdvanced(int capacity) @Override public int receiveEnergy(int energy, boolean simulate) { - int received = super.receiveEnergy(energy,simulate); + int received = super.receiveEnergy(energy, simulate); if(!simulate) - averageInsertion = (int)Math.round(averageInsertion*averageDecayFactor + received*(1-averageDecayFactor)); + averageInsertion = (int)Math.round(averageInsertion*averageDecayFactor+received*(1-averageDecayFactor)); return received; } @@ -47,7 +48,7 @@ public int extractEnergy(int energy, boolean simulate) { int extracted = super.extractEnergy(energy, simulate); if(!simulate) - averageExtraction = (int)Math.round(averageExtraction*averageDecayFactor + extracted*(1-averageDecayFactor)); + averageExtraction = (int)Math.round(averageExtraction*averageDecayFactor+extracted*(1-averageDecayFactor)); return extracted; } @@ -55,10 +56,12 @@ public int getAverageInsertion() { return averageInsertion; } + public int getAverageExtraction() { return averageExtraction; } + public FluxStorageAdvanced setDecayFactor(double factor) { this.averageDecayFactor = factor; diff --git a/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/IFluxConnection.java b/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/IFluxConnection.java index 82403edbe1..226d776844 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/IFluxConnection.java +++ b/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/IFluxConnection.java @@ -14,15 +14,14 @@ /** * An interface to be implemented by TileEntities that can connect to an IF network - * - * @author BluSunrize - 18.01.2016 * + * @author BluSunrize - 18.01.2016 */ public interface IFluxConnection { /** - * @param from The direction the check is performed from, null for unknown. - * @return If the TileEntity can connect. + * @param from The direction the check is performed from, null for unknown. + * @return If the TileEntity can connect. */ boolean canConnectEnergy(@Nullable EnumFacing from); } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/IFluxContainerItem.java b/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/IFluxContainerItem.java index f92ab1954a..75c607536c 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/IFluxContainerItem.java +++ b/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/IFluxContainerItem.java @@ -12,39 +12,40 @@ /** * An interface to be implemented by Items that can store IF and allow external modification of their storage. - * - * @author BluSunrize - 18.01.2016 * + * @author BluSunrize - 18.01.2016 */ public interface IFluxContainerItem { /** * Inserts energy into the Item. Returns the amount that was accepted. - * @param container The ItemStack of the container item - * @param energy Maximum amount of energy to be inserted. - * @param simulate If TRUE, the process is simulated and will not increase the storage. - * @return Amount of energy that was, or would have been, if simulated, accepted. + * + * @param container The ItemStack of the container item + * @param energy Maximum amount of energy to be inserted. + * @param simulate If TRUE, the process is simulated and will not increase the storage. + * @return Amount of energy that was, or would have been, if simulated, accepted. */ int receiveEnergy(ItemStack container, int energy, boolean simulate); - + /** * Extracts energy from the Item. Returns the amount that was extracted. - * @param container The ItemStack of the container item - * @param energy Maximum amount of energy to be extracted. - * @param simulate If TRUE, the process is simulated and will not decrease the storage. - * @return Amount of energy that was, or would have been, if simulated, extracted. + * + * @param container The ItemStack of the container item + * @param energy Maximum amount of energy to be extracted. + * @param simulate If TRUE, the process is simulated and will not decrease the storage. + * @return Amount of energy that was, or would have been, if simulated, extracted. */ int extractEnergy(ItemStack container, int energy, boolean simulate); /** - * @param container The ItemStack of the container item - * @return The amount of energy stored in the Tile. + * @param container The ItemStack of the container item + * @return The amount of energy stored in the Tile. */ int getEnergyStored(ItemStack container); /** - * @param container The ItemStack of the container item - * @return The maximum amount of energy that can be stored in the Tile. + * @param container The ItemStack of the container item + * @return The maximum amount of energy that can be stored in the Tile. */ int getMaxEnergyStored(ItemStack container); } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/IFluxProvider.java b/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/IFluxProvider.java index 12afc3a765..83feb9c437 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/IFluxProvider.java +++ b/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/IFluxProvider.java @@ -14,30 +14,30 @@ /** * An interface to be implemented by TileEntities that can provide IF. - * - * @author BluSunrize - 18.01.2016 * + * @author BluSunrize - 18.01.2016 */ public interface IFluxProvider extends IFluxConnection { /** * Extracts energy from the TileEntity. Returns the amount that was extracted. - * @param from The direction the energy is inserted from, null for unknown. Unknown directions should ALWAYS work. - * @param energy Maximum amount of energy to be extracted. - * @param simulate If TRUE, the process is simulated and will not decrease the storage. - * @return Amount of energy that was, or would have been, if simulated, extracted. + * + * @param from The direction the energy is inserted from, null for unknown. Unknown directions should ALWAYS work. + * @param energy Maximum amount of energy to be extracted. + * @param simulate If TRUE, the process is simulated and will not decrease the storage. + * @return Amount of energy that was, or would have been, if simulated, extracted. */ int extractEnergy(@Nullable EnumFacing from, int energy, boolean simulate); /** - * @param from The direction the check is performed from, null for unknown. - * @return The amount of energy stored in the Tile. + * @param from The direction the check is performed from, null for unknown. + * @return The amount of energy stored in the Tile. */ int getEnergyStored(@Nullable EnumFacing from); /** - * @param from The direction the check is performed from, null for unknown. - * @return The maximum amount of energy that can be stored in the Tile. + * @param from The direction the check is performed from, null for unknown. + * @return The maximum amount of energy that can be stored in the Tile. */ int getMaxEnergyStored(@Nullable EnumFacing from); } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/IFluxReceiver.java b/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/IFluxReceiver.java index 7f01cd81ba..99d5b202c0 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/IFluxReceiver.java +++ b/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/IFluxReceiver.java @@ -14,30 +14,30 @@ /** * An interface to be implemented by TileEntities that can receive IF. - * - * @author BluSunrize - 18.01.2016 * + * @author BluSunrize - 18.01.2016 */ public interface IFluxReceiver extends IFluxConnection { /** * Inserts energy into the TileEntity. Returns the amount that was accepted. - * @param from The direction the energy is inserted from, null for unknown. Unknown directions should ALWAYS work. - * @param energy Maximum amount of energy to be inserted. - * @param simulate If TRUE, the process is simulated and will not increase the storage. - * @return Amount of energy that was, or would have been, if simulated, accepted. + * + * @param from The direction the energy is inserted from, null for unknown. Unknown directions should ALWAYS work. + * @param energy Maximum amount of energy to be inserted. + * @param simulate If TRUE, the process is simulated and will not increase the storage. + * @return Amount of energy that was, or would have been, if simulated, accepted. */ int receiveEnergy(@Nullable EnumFacing from, int energy, boolean simulate); /** - * @param from The direction the check is performed from, null for unknown. - * @return The amount of energy stored in the Tile. + * @param from The direction the check is performed from, null for unknown. + * @return The amount of energy stored in the Tile. */ int getEnergyStored(@Nullable EnumFacing from); /** - * @param from The direction the check is performed from, null for unknown. - * @return The maximum amount of energy that can be stored in the Tile. + * @param from The direction the check is performed from, null for unknown. + * @return The maximum amount of energy that can be stored in the Tile. */ int getMaxEnergyStored(@Nullable EnumFacing from); } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/IFluxStorage.java b/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/IFluxStorage.java index 17d950814b..75148938fc 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/IFluxStorage.java +++ b/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/IFluxStorage.java @@ -11,35 +11,36 @@ /** * An interface to implement for an object that stores ImmersiveFlux
* See {@link FluxStorage} for an example implementation - * + * * @author BluSunrize - 18.01.2016 - * */ public interface IFluxStorage { /** * Inserts energy into the storage. Returns the amount that was accepted. - * @param energy Maximum amount of energy to be inserted. - * @param simulate If TRUE, the process is simulated and will not increase the storage. - * @return Amount of energy that was, or would have been, if simulated, accepted. + * + * @param energy Maximum amount of energy to be inserted. + * @param simulate If TRUE, the process is simulated and will not increase the storage. + * @return Amount of energy that was, or would have been, if simulated, accepted. */ int receiveEnergy(int energy, boolean simulate); /** * Extracts energy from the storage. Returns the amount that was extracted. - * @param energy Maximum amount of energy to be extracted. - * @param simulate If TRUE, the process is simulated and will not decrease the storage. - * @return Amount of energy that was, or would have been, if simulated, extracted. + * + * @param energy Maximum amount of energy to be extracted. + * @param simulate If TRUE, the process is simulated and will not decrease the storage. + * @return Amount of energy that was, or would have been, if simulated, extracted. */ int extractEnergy(int energy, boolean simulate); /** - * @return The amount of energy stored. + * @return The amount of energy stored. */ int getEnergyStored(); /** - * @return The maximum amount of energy that can be stored. + * @return The maximum amount of energy that can be stored. */ int getMaxEnergyStored(); } diff --git a/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/package-info.java b/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/package-info.java index 88628eff0c..4c787b7580 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/package-info.java +++ b/src/main/java/blusunrize/immersiveengineering/api/energy/immersiveflux/package-info.java @@ -4,7 +4,6 @@ import net.minecraftforge.fml.common.API; /** -* Shoutout to Team CoFH for the amazing RedstoneFlux system.
-* Due to a lack of an official 1.8 version, IE has been move to its own, RF-inspired energy system, dubbed ImmersiveFlux. -* -*/ \ No newline at end of file + * Shoutout to Team CoFH for the amazing RedstoneFlux system.
+ * Due to a lack of an official 1.8 version, IE has been move to its own, RF-inspired energy system, dubbed ImmersiveFlux. + */ \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/api/energy/wires/IICProxy.java b/src/main/java/blusunrize/immersiveengineering/api/energy/wires/IICProxy.java index 62da8d0c3c..9af46530d9 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/energy/wires/IICProxy.java +++ b/src/main/java/blusunrize/immersiveengineering/api/energy/wires/IICProxy.java @@ -25,89 +25,106 @@ public class IICProxy implements IImmersiveConnectable private boolean canEnergyPass; private int dim; private BlockPos pos; + public IICProxy(boolean allowPass, int dimension, BlockPos _pos) { canEnergyPass = allowPass; dim = dimension; pos = _pos; } + public IICProxy(TileEntity te) { - if (!(te instanceof IImmersiveConnectable)) + if(!(te instanceof IImmersiveConnectable)) throw new IllegalArgumentException("Can't create an IICProxy for a null/non-IIC TileEntity"); dim = te.getWorld().provider.getDimension(); canEnergyPass = ((IImmersiveConnectable)te).allowEnergyToPass(null); pos = Utils.toCC(te); } + @Override public boolean allowEnergyToPass(Connection c) { return canEnergyPass; } + public BlockPos getPos() { return pos; } + public int getDimension() { return dim; } + @Override public void removeCable(Connection connection) { //this will load the chunk the TE is in for 1 tick since it needs to be notified about the removed wires World w = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(dim); - if (w==null) + if(w==null) { IELogger.warn("Tried to remove a wire in dimension "+dim+" which does not exist"); return; } TileEntity te = w.getTileEntity(pos); - if (!(te instanceof IImmersiveConnectable)) + if(!(te instanceof IImmersiveConnectable)) return; ((IImmersiveConnectable)te).removeCable(connection); } + @Override public boolean canConnect() { return false; } + @Override public boolean isEnergyOutput() { return false; } + @Override public int outputEnergy(int amount, boolean simulate, int energyType) { return 0; } + @Override public boolean canConnectCable(WireType cableType, TargetingInfo target, Vec3i offset) { return false; } + @Override public void connectCable(WireType cableType, TargetingInfo target, IImmersiveConnectable other) - {} + { + } + @Override public WireType getCableLimiter(TargetingInfo target) { return null; } + @Override public void onEnergyPassthrough(int amount) - {} + { + } @Override public Vec3d getConnectionOffset(Connection con) { return null; } + public static IICProxy readFromNBT(NBTTagCompound nbt) { return new IICProxy(nbt.getBoolean("pass"), nbt.getInteger("dim"), new BlockPos(nbt.getInteger("x"), nbt.getInteger("y"), nbt.getInteger("z"))); } + public NBTTagCompound writeToNBT() { NBTTagCompound ret = new NBTTagCompound(); @@ -118,6 +135,7 @@ public NBTTagCompound writeToNBT() ret.setBoolean("pass", canEnergyPass); return ret; } + @Override public BlockPos getConnectionMaster(WireType cableType, TargetingInfo target) { diff --git a/src/main/java/blusunrize/immersiveengineering/api/energy/wires/IImmersiveConnectable.java b/src/main/java/blusunrize/immersiveengineering/api/energy/wires/IImmersiveConnectable.java index 3dcc894ebe..cae17c0f5d 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/energy/wires/IImmersiveConnectable.java +++ b/src/main/java/blusunrize/immersiveengineering/api/energy/wires/IImmersiveConnectable.java @@ -25,9 +25,9 @@ /** * @author BluSunrize - 08.03.2015 - * + *

* An interface to be implemented by TileEntities, to allow them to connect to the IE net - * + *

* "Vec3i offset" parameters give the offset between this block and the one that was clicked on, see getConnectionMaster */ public interface IImmersiveConnectable @@ -36,15 +36,15 @@ public interface IImmersiveConnectable * @return if wires can directly connect to this */ boolean canConnect(); - + /** * @return if the tile can in or output energy from/to the network */ boolean isEnergyOutput(); - + /** - * @param amount The amount of power input, in RF - * @param simulate whether to actually perform the action or just simulate energy consumption + * @param amount The amount of power input, in RF + * @param simulate whether to actually perform the action or just simulate energy consumption * @param energyType 0 for RF, 1 for EU * @return the amount of power that was output */ @@ -60,6 +60,7 @@ default boolean canConnectCable(WireType cableType, TargetingInfo target) { return false; } + /** * @return whether you can connect the given CableType to the tile */ @@ -67,7 +68,7 @@ default boolean canConnectCable(WireType cableType, TargetingInfo target, Vec3i { return canConnectCable(cableType, target); } - + /** * fired when a cable is attached, use to limit the cables attached to one type */ @@ -75,20 +76,22 @@ default void connectCable(WireType cableType, TargetingInfo target, IImmersiveCo { connectCable(cableType, target, other); } + default void connectCable(WireType cableType, TargetingInfo target, IImmersiveConnectable other) { connectCable(cableType, target, other, null); } - + /** * get the CableType limiter of the tile */ WireType getCableLimiter(TargetingInfo target); - + /** * return false to stop checking for available outputs from this point onward + * * @param con: the connection through which energy enters. May be null, in that - * case true should be returned if and only if all connections allow energy to pass + * case true should be returned if and only if all connections allow energy to pass */ boolean allowEnergyToPass(Connection con); @@ -99,6 +102,7 @@ default void onEnergyPassthrough(int amount) { } + /** * fired for every not-simulated energy packet passing through. Used for energy meter and stuff */ @@ -111,12 +115,14 @@ default void onEnergyPassthrough(double amount) * Informs the connector/relay that there is a source of energy connected to it, and gives it a way to consume it. * This is valid for a single tick. * This can be used to add "pulling" consumers to the net or allow non-energy-outputs to consume energy (e.g. to damage entities) - * @param amount The amount available from this source + * + * @param amount The amount available from this source * @param consume Call this to consume the amount of energy in the parameter */ default void addAvailableEnergy(float amount, Consumer consume) - {} - + { + } + /** * used to reset the CableType limiter of the tile, provided it matches the given argument * acts as a wildcard, meaning if connection.CableType is null, you /always/ reset the limiter @@ -128,7 +134,8 @@ default void addAvailableEnergy(float amount, Consumer consume) * Raytracing was replaced by code following the catenary, using getConnectionOffset(Connection con, TargetingInfo target) */ @Deprecated - default Vec3d getRaytraceOffset(IImmersiveConnectable link) { + default Vec3d getRaytraceOffset(IImmersiveConnectable link) + { return new Vec3d(.5, .5, .5); } @@ -136,15 +143,18 @@ default Vec3d getRaytraceOffset(IImmersiveConnectable link) { * @return Where the cable should attach */ Vec3d getConnectionOffset(Connection con); + /** * A version of getConnectionOffset that works before the connection exists. * Should be identical to getConnectionOffset(Connection) once the connection is added + * * @return Where the cable should attach */ default Vec3d getConnectionOffset(Connection con, TargetingInfo target, Vec3i offsetLink) { return getConnectionOffset(con); } + /** * returns a set of Blocks to be ignored when raytracing */ @@ -166,13 +176,14 @@ default float getDamageAmount(Entity e, Connection c) * damaged after calling getDamageAmount */ default void processDamage(Entity e, float amount, Connection c) - {} + { + } default void onConnectivityUpdate(BlockPos pos, int dimension) { - if (INSTANCE.indirectConnections.containsKey(dimension)) + if(INSTANCE.indirectConnections.containsKey(dimension)) INSTANCE.indirectConnections.get(dimension).remove(pos); - if (INSTANCE.indirectConnectionsIgnoreOut.containsKey(dimension)) + if(INSTANCE.indirectConnectionsIgnoreOut.containsKey(dimension)) INSTANCE.indirectConnectionsIgnoreOut.get(dimension).remove(pos); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/api/energy/wires/IWireCoil.java b/src/main/java/blusunrize/immersiveengineering/api/energy/wires/IWireCoil.java index 84d8fadd42..eb17a92602 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/energy/wires/IWireCoil.java +++ b/src/main/java/blusunrize/immersiveengineering/api/energy/wires/IWireCoil.java @@ -13,23 +13,26 @@ /** * @author BluSunrize - 26.06.2015 - * + *

* An Interface to be implemented by Items that can be used to connect two connectors */ public interface IWireCoil { WireType getWireType(ItemStack stack); - public default boolean canConnectCable(ItemStack stack, TileEntity targetEntity) + + default boolean canConnectCable(ItemStack stack, TileEntity targetEntity) { return true; } - public default int getMaxLength(ItemStack stack) + + default int getMaxLength(ItemStack stack) { WireType wire = getWireType(stack); return wire.getMaxLength(); } - public default void consumeWire(ItemStack stack, int length) + + default void consumeWire(ItemStack stack, int length) { stack.shrink(1); - } + } } diff --git a/src/main/java/blusunrize/immersiveengineering/api/energy/wires/ImmersiveNetHandler.java b/src/main/java/blusunrize/immersiveengineering/api/energy/wires/ImmersiveNetHandler.java index 0e90e8d5c5..27f32f4ed8 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/energy/wires/ImmersiveNetHandler.java +++ b/src/main/java/blusunrize/immersiveengineering/api/energy/wires/ImmersiveNetHandler.java @@ -61,20 +61,21 @@ public class ImmersiveNetHandler public Map proxies = new ConcurrentHashMap<>(); public IntHashMap> blockWireMap = new IntHashMap<>(); - + private ConcurrentHashMap> getMultimap(int dimension) { - if (directConnections.get(dimension) == null) + if(directConnections.get(dimension)==null) { ConcurrentHashMap> mm = new ConcurrentHashMap>(); directConnections.put(dimension, mm); } return directConnections.get(dimension); } + public HashMap getTransferedRates(int dimension) { - if (!transferPerTick.containsKey(dimension)) - transferPerTick.put(dimension, new HashMap()); + if(!transferPerTick.containsKey(dimension)) + transferPerTick.put(dimension, new HashMap()); return transferPerTick.get(dimension); } @@ -82,22 +83,25 @@ public void addConnection(World world, BlockPos node, BlockPos connection, int d { addAndGetConnection(world, node, connection, distance, cableType); } + public Connection addAndGetConnection(World world, BlockPos node, BlockPos connection, int distance, WireType cableType) { Connection conn = new Connection(node, connection, cableType, distance); addConnection(world, node, conn); addConnection(world, connection, new Connection(connection, node, cableType, distance)); if(world.isBlockLoaded(node)) - world.addBlockEvent(node, world.getBlockState(node).getBlock(),-1,0); + world.addBlockEvent(node, world.getBlockState(node).getBlock(), -1, 0); if(world.isBlockLoaded(connection)) - world.addBlockEvent(connection, world.getBlockState(connection).getBlock(),-1,0); + world.addBlockEvent(connection, world.getBlockState(connection).getBlock(), -1, 0); return conn; } + public void addConnection(World world, BlockPos node, Connection con) { addConnection(world.provider.getDimension(), node, con); resetCachedIndirectConnections(world, node); } + public void addConnection(int world, BlockPos node, Connection con) { if(!getMultimap(world).containsKey(node)) @@ -109,8 +113,8 @@ public void addConnection(int world, BlockPos node, Connection con) public void onTEValidated(T te) { Set conns = getConnections(te.getWorld(), te.getPos()); - if (conns != null) - for (Connection con : conns) + if(conns!=null) + for(Connection con : conns) addBlockData(te.getWorld(), con); resetCachedIndirectConnections(te.getWorld(), te.getPos()); setProxy(new DimensionBlockPos(te), null); @@ -119,23 +123,23 @@ public void onTEValidated(T te) public void addBlockData(World world, Connection con) { int dimId = world.provider.getDimension(); - if (!blockWireMap.containsItem(dimId)) + if(!blockWireMap.containsItem(dimId)) blockWireMap.addKey(dimId, new ConcurrentHashMap<>()); Map mapForDim = blockWireMap.lookup(dimId); - if (mapForDim==null||!world.isBlockLoaded(con.end)) + if(mapForDim==null||!world.isBlockLoaded(con.end)) return; raytraceAlongCatenary(con, world, (p) -> { - if (!mapForDim.containsKey(p.getLeft())) + if(!mapForDim.containsKey(p.getLeft())) mapForDim.put(p.getLeft(), new BlockWireInfo()); - if (mapForDim.get(p.getLeft()).in.stream().noneMatch((c)->c.getLeft().hasSameConnectors(con))) + if(mapForDim.get(p.getLeft()).in.stream().noneMatch((c) -> c.getLeft().hasSameConnectors(con))) mapForDim.get(p.getLeft()).in.add(new ImmutableTriple<>(con, p.getMiddle(), p.getRight())); return false; }, (p) -> { - if (!mapForDim.containsKey(p.getLeft())) + if(!mapForDim.containsKey(p.getLeft())) mapForDim.put(p.getLeft(), new BlockWireInfo()); - if (mapForDim.get(p.getLeft()).near.stream().noneMatch((c)->c.getLeft().hasSameConnectors(con))) + if(mapForDim.get(p.getLeft()).near.stream().noneMatch((c) -> c.getLeft().hasSameConnectors(con))) mapForDim.get(p.getLeft()).near.add(new ImmutableTriple<>(con, p.getMiddle(), p.getRight())); }); } @@ -143,12 +147,12 @@ public void addBlockData(World world, Connection con) public void removeConnection(World world, Connection con) { - removeConnection(world, con, getVecForIICAt(world, con.start, con),getVecForIICAt(world, con.end, con)); + removeConnection(world, con, getVecForIICAt(world, con.start, con), getVecForIICAt(world, con.end, con)); } public void removeConnection(World world, Connection con, Vec3d vecStart, Vec3d vecEnd) { - if (con == null || world == null) + if(con==null||world==null) return; int dim = world.provider.getDimension(); resetCachedIndirectConnections(world, con.start); @@ -159,89 +163,97 @@ public void removeConnection(World world, Connection con, Vec3d vecStart, Vec3d reverseConns.removeIf(con::hasSameConnectors); forwardConns.removeIf(con::hasSameConnectors); Map mapForDim = blockWireMap.lookup(world.provider.getDimension()); - BiConsumer> handle = (p, map)-> { - if (mapForDim!=null) + BiConsumer> handle = (p, map) -> { + if(mapForDim!=null) { BlockWireInfo info = map.get(p); - if (info!=null) + if(info!=null) { - for (int i = 0;i<2;i++) + for(int i = 0; i < 2; i++) { - Set> s = i==0?info.in:info.near; - s.removeIf((t) -> t.getLeft().hasSameConnectors(con)); - if (s.isEmpty()) - map.remove(p); + Set> s = i==0?info.in: info.near; + s.removeIf((t) -> t.getLeft().hasSameConnectors(con)); + if(s.isEmpty()) + map.remove(p); } - if (info.near.isEmpty()&&info.in.isEmpty()) + if(info.near.isEmpty()&&info.in.isEmpty()) map.remove(p); } } }; - raytraceAlongCatenaryRelative(con, (p)->{ + raytraceAlongCatenaryRelative(con, (p) -> { handle.accept(p.getLeft(), mapForDim); return false; - }, (p)->handle.accept(p.getLeft(), mapForDim), vecStart, vecEnd); + }, (p) -> handle.accept(p.getLeft(), mapForDim), vecStart, vecEnd); IImmersiveConnectable iic = toIIC(con.end, world); - if (iic != null) + if(iic!=null) { iic.removeCable(con); back.ifPresent(iic::removeCable); } iic = toIIC(con.start, world); - if (iic != null) + if(iic!=null) { iic.removeCable(con); back.ifPresent(iic::removeCable); } - if (world.isBlockLoaded(con.start)) + if(world.isBlockLoaded(con.start)) world.addBlockEvent(con.start, world.getBlockState(con.start).getBlock(), -1, 0); - if (world.isBlockLoaded(con.end)) + if(world.isBlockLoaded(con.end)) world.addBlockEvent(con.end, world.getBlockState(con.end).getBlock(), -1, 0); IESaveData.setDirty(dim); } + public Set getRelevantDimensions() { return directConnections.keySet(); } + public Collection getAllConnections(int dimensionId) { Set ret = newSetFromMap(new ConcurrentHashMap()); - for (Set conlist : getMultimap(dimensionId).values()) + for(Set conlist : getMultimap(dimensionId).values()) ret.addAll(conlist); return ret; } + public Collection getAllConnections(World world) { return getAllConnections(world.provider.getDimension()); } + @Nullable public synchronized Set getConnections(World world, BlockPos node) { - if(world!=null && world.provider!=null) + if(world!=null&&world.provider!=null) { return getConnections(world.provider.getDimension(), node); } return null; } + @Nullable public synchronized Set getConnections(int world, BlockPos node) { ConcurrentHashMap> map = getMultimap(world); return map.get(node); } + public void clearAllConnections(World world) { clearAllConnections(world.provider.getDimension()); } + public void clearAllConnections(int world) { getMultimap(world).clear(); blockWireMap.removeObject(world); proxies.clear(); } + public void clearConnectionsOriginatingFrom(BlockPos node, World world) { resetCachedIndirectConnections(world, node); @@ -255,7 +267,7 @@ public void clearConnectionsOriginatingFrom(BlockPos node, World world) @Deprecated public void resetCachedIndirectConnections() { - if(FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) + if(FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER) { indirectConnections.clear(); indirectConnectionsIgnoreOut.clear(); @@ -267,25 +279,26 @@ public void resetCachedIndirectConnections() /** * Resets the cached energy connections for all connectors connected to an IIC. * Call this when there are "more" wires (before removing and after adding) - * @param w the world to reset the cache in + * + * @param w the world to reset the cache in * @param start the starting block. If this is null, all cached connections for the dimension will be reset */ public void resetCachedIndirectConnections(World w, @Nullable BlockPos start) { - if (FMLCommonHandler.instance().getEffectiveSide()!=Side.SERVER) + if(FMLCommonHandler.instance().getEffectiveSide()!=Side.SERVER) { ImmersiveEngineering.proxy.clearConnectionModelCache(); return; } int dimension = w.provider.getDimension(); - if (!directConnections.containsKey(dimension)) + if(!directConnections.containsKey(dimension)) return; - if (start==null) + if(start==null) { - for (BlockPos pos : directConnections.get(dimension).keySet()) + for(BlockPos pos : directConnections.get(dimension).keySet()) { IImmersiveConnectable iic = toIIC(pos, w); - if (iic != null) + if(iic!=null) { iic.onConnectivityUpdate(pos, dimension); } @@ -296,19 +309,19 @@ public void resetCachedIndirectConnections(World w, @Nullable BlockPos start) Set open = new HashSet<>(); open.add(start); Set closed = new HashSet<>(); - while (!open.isEmpty()) + while(!open.isEmpty()) { Iterator it = open.iterator(); BlockPos next = it.next(); it.remove(); closed.add(next); IImmersiveConnectable iic = toIIC(next, w); - if (iic!=null) + if(iic!=null) iic.onConnectivityUpdate(next, dimension); Set connsAtBlock = connsForDim.get(next); - if (connsAtBlock!=null) - for (Connection c:connsAtBlock) - if (!closed.contains(c.end)) + if(connsAtBlock!=null) + for(Connection c : connsAtBlock) + if(!closed.contains(c.end)) open.add(c.end); } } @@ -316,12 +329,12 @@ public void resetCachedIndirectConnections(World w, @Nullable BlockPos start) public void removeConnectionAndDrop(Connection conn, World world, @Nullable BlockPos dropPos) { removeConnection(world, conn); - if (dropPos != null) + if(dropPos!=null) { - double dx = dropPos.getX() + .5; - double dy = dropPos.getY() + .5; - double dz = dropPos.getZ() + .5; - if (world.getGameRules().getBoolean("doTileDrops")) + double dx = dropPos.getX()+.5; + double dy = dropPos.getY()+.5; + double dz = dropPos.getZ()+.5; + if(world.getGameRules().getBoolean("doTileDrops")) world.spawnEntity(new EntityItem(world, dx, dy, dz, conn.cableType.getWireCoil(conn))); } } @@ -330,26 +343,27 @@ public void clearAllConnectionsFor(BlockPos node, World world, boolean doDrops) { clearAllConnectionsFor(node, world, null, doDrops); } + /** * Clears all connections to and from this node. */ public void clearAllConnectionsFor(BlockPos node, World world, @Nullable IImmersiveConnectable iic, boolean doDrops) { - if (iic==null) + if(iic==null) iic = toIIC(node, world); - if (iic != null) + if(iic!=null) iic.removeCable(null); if(getMultimap(world.provider.getDimension()).containsKey(node)) { - for (Connection con : getMultimap(world.provider.getDimension()).get(node)) + for(Connection con : getMultimap(world.provider.getDimension()).get(node)) { - removeConnection(world, con, iic!=null?iic.getConnectionOffset(con):Vec3d.ZERO, + removeConnection(world, con, iic!=null?iic.getConnectionOffset(con): Vec3d.ZERO, getVecForIICAt(world, con.end, con)); - double dx = node.getX() + .5 + Math.signum(con.end.getX() - con.start.getX()); - double dy = node.getY() + .5 + Math.signum(con.end.getY() - con.start.getY()); - double dz = node.getZ() + .5 + Math.signum(con.end.getZ() - con.start.getZ()); - if (doDrops && world.getGameRules().getBoolean("doTileDrops")) + double dx = node.getX()+.5+Math.signum(con.end.getX()-con.start.getX()); + double dy = node.getY()+.5+Math.signum(con.end.getY()-con.start.getY()); + double dz = node.getZ()+.5+Math.signum(con.end.getZ()-con.start.getZ()); + if(doDrops&&world.getGameRules().getBoolean("doTileDrops")) world.spawnEntity(new EntityItem(world, dx, dy, dz, con.cableType.getWireCoil(con))); } } @@ -359,14 +373,15 @@ public void clearAllConnectionsFor(BlockPos node, World world, @Nullable IImmers public void setProxy(DimensionBlockPos pos, IICProxy p) { - if (p==null) + if(p==null) proxies.remove(pos); else proxies.put(pos, p); } + public void addProxy(IICProxy p) { - if (p==null) + if(p==null) return; setProxy(new DimensionBlockPos(p.getPos(), p.getDimension()), p); } @@ -385,19 +400,19 @@ public boolean clearAllConnectionsFor(BlockPos node, World world, @Nonnull Targe boolean ret = false; for(Connection con : getMultimap(world.provider.getDimension()).get(node)) { - if (con.cableType == type) + if(con.cableType==type) { removeConnection(world, con); - double dx = node.getX() + .5 + Math.signum(con.end.getX() - con.start.getX()); - double dy = node.getY() + .5 + Math.signum(con.end.getY() - con.start.getY()); - double dz = node.getZ() + .5 + Math.signum(con.end.getZ() - con.start.getZ()); - if (world.getGameRules().getBoolean("doTileDrops")) + double dx = node.getX()+.5+Math.signum(con.end.getX()-con.start.getX()); + double dy = node.getY()+.5+Math.signum(con.end.getY()-con.start.getY()); + double dz = node.getZ()+.5+Math.signum(con.end.getZ()-con.start.getZ()); + if(world.getGameRules().getBoolean("doTileDrops")) world.spawnEntity(new EntityItem(world, dx, dy, dz, con.cableType.getWireCoil(con))); ret = true; } } if(world.isBlockLoaded(node)) - world.addBlockEvent(node, world.getBlockState(node).getBlock(),-1,0); + world.addBlockEvent(node, world.getBlockState(node).getBlock(), -1, 0); IESaveData.setDirty(dim); return ret; @@ -467,25 +482,26 @@ public static List getValidEnergyOutputs(BlockPos node, W return closedList; } */ - + public Set getIndirectEnergyConnections(BlockPos node, World world) { return getIndirectEnergyConnections(node, world, false); } + public Set getIndirectEnergyConnections(BlockPos node, World world, boolean ignoreIsEnergyOutput) { int dimension = world.provider.getDimension(); if(!ignoreIsEnergyOutput&&indirectConnections.containsKey(dimension)&& indirectConnections.get(dimension).containsKey(node)) return indirectConnections.get(dimension).get(node); - else if(ignoreIsEnergyOutput&& indirectConnectionsIgnoreOut.containsKey(dimension)&& + else if(ignoreIsEnergyOutput&&indirectConnectionsIgnoreOut.containsKey(dimension)&& indirectConnectionsIgnoreOut.get(dimension).containsKey(node)) return indirectConnectionsIgnoreOut.get(dimension).get(node); PriorityQueue> queue = new PriorityQueue<>(Comparator.comparingDouble(Pair::getRight)); Set closedList = newSetFromMap(new ConcurrentHashMap()); List checked = new ArrayList<>(); - HashMap backtracker = new HashMap<>(); + HashMap backtracker = new HashMap<>(); checked.add(node); Set conL = getConnections(world, node); @@ -503,13 +519,13 @@ else if(ignoreIsEnergyOutput&& indirectConnectionsIgnoreOut.containsKey(dimensio IImmersiveConnectable next; final int closedListMax = 1200; - while(closedList.size() pair = queue.poll(); next = pair.getLeft(); float loss = pair.getRight(); BlockPos nextPos = toBlockPos(next); - if(!checked.contains(nextPos)&&queue.stream().noneMatch((p)->p.getLeft().equals(nextPos))) + if(!checked.contains(nextPos)&&queue.stream().noneMatch((p) -> p.getLeft().equals(nextPos))) { boolean isOutput = next.isEnergyOutput(); if(ignoreIsEnergyOutput||isOutput) @@ -532,7 +548,7 @@ else if(ignoreIsEnergyOutput&& indirectConnectionsIgnoreOut.containsKey(dimensio { connectionParts.add(0, conB); distance += conB.length; - if(minimumType==null || conB.cableType.getTransferRate()> existing = - queue.stream().filter((p)->p.getLeft()==end).findAny(); + queue.stream().filter((p) -> p.getLeft()==end).findAny(); float newLoss = con.getBaseLoss()+loss; - if(end!=null && !checked.contains(con.end) && existing.map(Pair::getRight).orElse(Float.MAX_VALUE)>newLoss) + if(end!=null&&!checked.contains(con.end)&&existing.map(Pair::getRight).orElse(Float.MAX_VALUE) > newLoss) { - existing.ifPresent(p1 -> queue.removeIf((p2) -> p1.getLeft() == p2.getLeft())); + existing.ifPresent(p1 -> queue.removeIf((p2) -> p1.getLeft()==p2.getLeft())); queue.add(new ImmutablePair<>(end, newLoss)); backtracker.put(con.end, toBlockPos(next)); } @@ -561,45 +577,46 @@ else if(ignoreIsEnergyOutput&& indirectConnectionsIgnoreOut.containsKey(dimensio checked.add(toBlockPos(next)); } } - if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) + if(FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER) { - if (ignoreIsEnergyOutput) + if(ignoreIsEnergyOutput) { - if (!indirectConnectionsIgnoreOut.containsKey(dimension)) + if(!indirectConnectionsIgnoreOut.containsKey(dimension)) indirectConnectionsIgnoreOut.put(dimension, new ConcurrentHashMap<>()); Map> conns = indirectConnectionsIgnoreOut.get(dimension); - if (!conns.containsKey(node)) + if(!conns.containsKey(node)) conns.put(node, newSetFromMap(new ConcurrentHashMap<>())); conns.get(node).addAll(closedList); } else { - if (!indirectConnections.containsKey(dimension)) + if(!indirectConnections.containsKey(dimension)) indirectConnections.put(dimension, new ConcurrentHashMap<>()); Map> conns = indirectConnections.get(dimension); - if (!conns.containsKey(node)) + if(!conns.containsKey(node)) conns.put(node, newSetFromMap(new ConcurrentHashMap<>())); conns.get(node).addAll(closedList); } } return closedList; } + //Called through ASM/coremod @SuppressWarnings("unused") public static void handleEntityCollision(BlockPos p, Entity e) { - if (!e.world.isRemote&&IEConfig.enableWireDamage&&e instanceof EntityLivingBase&& + if(!e.world.isRemote&&IEConfig.enableWireDamage&&e instanceof EntityLivingBase&& !e.isEntityInvulnerable(IEDamageSources.wireShock)&& - !(e instanceof EntityPlayer&&((EntityPlayer) e).capabilities.disableDamage)) + !(e instanceof EntityPlayer&&((EntityPlayer)e).capabilities.disableDamage)) { Map mapForDim = INSTANCE.blockWireMap.lookup(e.dimension); - if (mapForDim!=null) + if(mapForDim!=null) { BlockWireInfo info = mapForDim.get(p); - if (info!=null) + if(info!=null) { - handleMapForDamage(info.in, (EntityLivingBase) e, p); - handleMapForDamage(info.near, (EntityLivingBase) e, p); + handleMapForDamage(info.in, (EntityLivingBase)e, p); + handleMapForDamage(info.near, (EntityLivingBase)e, p); } } } @@ -608,33 +625,33 @@ public static void handleEntityCollision(BlockPos p, Entity e) private static void handleMapForDamage(Set> in, EntityLivingBase e, BlockPos here) { final double KNOCKBACK_PER_DAMAGE = 10; - if (!in.isEmpty()) + if(!in.isEmpty()) { AxisAlignedBB eAabb = e.getEntityBoundingBox(); - for (Triple conn : in) - if (conn.getLeft().cableType.canCauseDamage()) + for(Triple conn : in) + if(conn.getLeft().cableType.canCauseDamage()) { double extra = conn.getLeft().cableType.getDamageRadius(); AxisAlignedBB includingExtra = eAabb.grow(extra).offset(-here.getX(), -here.getY(), -here.getZ()); boolean endpointsInEntity = includingExtra.contains(conn.getMiddle())|| includingExtra.contains(conn.getRight()); - RayTraceResult rayRes = endpointsInEntity?null:includingExtra.calculateIntercept(conn.getMiddle(), conn.getRight()); - if (endpointsInEntity||(rayRes != null && rayRes.typeOfHit == RayTraceResult.Type.BLOCK)) + RayTraceResult rayRes = endpointsInEntity?null: includingExtra.calculateIntercept(conn.getMiddle(), conn.getRight()); + if(endpointsInEntity||(rayRes!=null&&rayRes.typeOfHit==RayTraceResult.Type.BLOCK)) { IImmersiveConnectable iic = toIIC(conn.getLeft().start, e.world); float damage = 0; - if (iic != null) + if(iic!=null) damage = iic.getDamageAmount(e, conn.getLeft()); - if (damage == 0) + if(damage==0) { iic = toIIC(conn.getLeft().end, e.world); - if (iic != null) + if(iic!=null) damage = iic.getDamageAmount(e, conn.getLeft()); } - if (damage != 0) + if(damage!=0) { IEDamageSources.ElectricDamageSource dmg = IEDamageSources.causeWireDamage(damage, conn.getLeft().cableType.getElectricSource()); - if (dmg.apply(e)) + if(dmg.apply(e)) { damage = dmg.dmg; Vec3d v = e.getLookVec(); @@ -673,15 +690,16 @@ public static class Connection implements Comparable public Connection(BlockPos start, BlockPos end, WireType cableType, int length) { - this.start=start; - this.end=end; - this.cableType=cableType; - this.length=length; + this.start = start; + this.end = end; + this.cableType = cableType; + this.length = length; } - public boolean hasSameConnectors(Connection con) { + public boolean hasSameConnectors(Connection con) + { boolean n0 = start.equals(con.start)&&end.equals(con.end); - boolean n1 =start.equals(con.end)&&end.equals(con.start); + boolean n1 = start.equals(con.end)&&end.equals(con.start); return n0||n1; } @@ -690,7 +708,7 @@ public Vec3d[] getSubVertices(Vec3d start, Vec3d end) if(catenaryVertices==null) { catenaryVertices = getConnectionCatenary(this, start, end); - vertical = start.x==end.x && start.z==end.z; + vertical = start.x==end.x&&start.z==end.z; } return catenaryVertices; } @@ -705,38 +723,39 @@ public Vec3d getVecAt(double pos, Vec3d vStart, Vec3d across, double lengthHor) { getSubVertices(vStart, vStart.add(across)); pos = MathHelper.clamp(pos, 0, 1); - if (vertical) + if(vertical) return vStart.add(across.scale(pos/across.lengthVector())); else - return vStart.addVector(pos*across.x, catA * Math.cosh((pos*lengthHor-catOffsetX)/catA)+catOffsetY, - pos*across.z); + return vStart.addVector(pos*across.x, catA*Math.cosh((pos*lengthHor-catOffsetX)/catA)+catOffsetY, + pos*across.z); } public NBTTagCompound writeToNBT() { NBTTagCompound tag = new NBTTagCompound(); if(start!=null) - tag.setIntArray("start", new int[]{start.getX(),start.getY(),start.getZ()}); + tag.setIntArray("start", new int[]{start.getX(), start.getY(), start.getZ()}); if(end!=null) - tag.setIntArray("end", new int[]{end.getX(),end.getY(),end.getZ()}); + tag.setIntArray("end", new int[]{end.getX(), end.getY(), end.getZ()}); tag.setString("cableType", cableType.getUniqueName()); tag.setInteger("length", length); return tag; } + public static Connection readFromNBT(NBTTagCompound tag) { if(tag==null) return null; int[] iStart = tag.getIntArray("start"); - BlockPos start = new BlockPos(iStart[0],iStart[1],iStart[2]); + BlockPos start = new BlockPos(iStart[0], iStart[1], iStart[2]); int[] iEnd = tag.getIntArray("end"); - BlockPos end = new BlockPos(iEnd[0],iEnd[1],iEnd[2]); + BlockPos end = new BlockPos(iEnd[0], iEnd[1], iEnd[2]); WireType type = ApiUtils.getWireTypeFromNBT(tag, "cableType"); - if(start!=null && end!=null && type!=null) - return new Connection(start,end, type, tag.getInteger("length")); + if(start!=null&&end!=null&&type!=null) + return new Connection(start, end, type, tag.getInteger("length")); return null; } @@ -749,26 +768,27 @@ public int compareTo(@Nonnull Connection o) int cableComp = -1*Integer.compare(cableType.getTransferRate(), o.cableType.getTransferRate()); if(cableComp!=0) return cableComp; - if (distComp!=0) + if(distComp!=0) return distComp; - if (start.getX()!=o.start.getX()) - return start.getX()>o.start.getX()?1:-1; - if (start.getY()!=o.start.getY()) - return start.getY()>o.start.getY()?1:-1; - if (start.getZ()!=o.start.getZ()) - return start.getZ()>o.start.getZ()?1:-1; - if (end.getX()!=o.end.getX()) - return end.getX()>o.end.getX()?1:-1; - if (end.getY()!=o.end.getY()) - return end.getY()>o.end.getY()?1:-1; - if (end.getZ()!=o.end.getZ()) - return end.getZ()>o.end.getZ()?1:-1; - return 0; + if(start.getX()!=o.start.getX()) + return start.getX() > o.start.getX()?1: -1; + if(start.getY()!=o.start.getY()) + return start.getY() > o.start.getY()?1: -1; + if(start.getZ()!=o.start.getZ()) + return start.getZ() > o.start.getZ()?1: -1; + if(end.getX()!=o.end.getX()) + return end.getX() > o.end.getX()?1: -1; + if(end.getY()!=o.end.getY()) + return end.getY() > o.end.getY()?1: -1; + if(end.getZ()!=o.end.getZ()) + return end.getZ() > o.end.getZ()?1: -1; + return 0; } + @Override public boolean equals(Object obj) { - if (!(obj instanceof Connection)) + if(!(obj instanceof Connection)) return false; return compareTo((Connection)obj)==0; } @@ -795,6 +815,7 @@ public static class AbstractConnection extends Connection { public Connection[] subConnections; public boolean isEnergyOutput; + public AbstractConnection(BlockPos start, BlockPos end, WireType cableType, int length, Connection... subConnections) { this(start, end, cableType, length, true, subConnections); @@ -802,9 +823,9 @@ public AbstractConnection(BlockPos start, BlockPos end, WireType cableType, int public AbstractConnection(BlockPos start, BlockPos end, WireType cableType, int length, boolean output, Connection... subConnections) { - super(start,end,cableType,length); + super(start, end, cableType, length); this.isEnergyOutput = output; - this.subConnections=subConnections; + this.subConnections = subConnections; } public float getPreciseLossRate(int energyInput, int connectorMaxInput) @@ -815,7 +836,7 @@ public float getPreciseLossRate(int energyInput, int connectorMaxInput) float mod = (((connectorMaxInput-energyInput)/(float)connectorMaxInput)/.25f)*.1f; f += c.getBaseLoss(mod); } - return Math.min(f,1); + return Math.min(f, 1); } public float getAverageLossRate() @@ -825,16 +846,16 @@ public float getAverageLossRate() { f += c.getBaseLoss(); } - return Math.min(f,1); + return Math.min(f, 1); } @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; - AbstractConnection that = (AbstractConnection) o; + if(this==o) return true; + if(o==null||getClass()!=o.getClass()) return false; + if(!super.equals(o)) return false; + AbstractConnection that = (AbstractConnection)o; return Arrays.equals(subConnections, that.subConnections); } @@ -842,7 +863,7 @@ public boolean equals(Object o) public int hashCode() { int result = super.hashCode(); - result = 31 * result + Arrays.hashCode(subConnections); + result = 31*result+Arrays.hashCode(subConnections); return result; } } @@ -861,24 +882,24 @@ public class BlockPlaceListener implements IWorldEventListener public void notifyBlockUpdate(@Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull IBlockState oldState, @Nonnull IBlockState newState, int flags) { Map worldMap = blockWireMap.lookup(worldIn.provider.getDimension()); - if (worldMap != null && !worldIn.isRemote && (flags & 1) != 0 && newState.getBlock().canCollideCheck(newState, false)) + if(worldMap!=null&&!worldIn.isRemote&&(flags&1)!=0&&newState.getBlock().canCollideCheck(newState, false)) { BlockWireInfo info = worldMap.get(pos); - if (info != null) + if(info!=null) { Set> conns = info.in; Set> toBreak = new HashSet<>(); - for (Triple conn : conns) + for(Triple conn : conns) { Vec3d[] verts = conn.getLeft().getSubVertices(worldIn); - if (!Utils.isVecInBlock(verts[0], pos, conn.getLeft().start) && + if(!Utils.isVecInBlock(verts[0], pos, conn.getLeft().start)&& !Utils.isVecInBlock(verts[verts.length-1], pos, conn.getLeft().start)) { BlockPos dropPos = pos; - if (ApiUtils.preventsConnection(worldIn, pos, newState, conn.getMiddle(), conn.getRight())) + if(ApiUtils.preventsConnection(worldIn, pos, newState, conn.getMiddle(), conn.getRight())) { - for (EnumFacing f : EnumFacing.VALUES) - if (worldIn.isAirBlock(pos.offset(f))) + for(EnumFacing f : EnumFacing.VALUES) + if(worldIn.isAirBlock(pos.offset(f))) { dropPos = dropPos.offset(f); break; @@ -887,7 +908,7 @@ public void notifyBlockUpdate(@Nonnull World worldIn, @Nonnull BlockPos pos, @No } } } - for (Pair b : toBreak) + for(Pair b : toBreak) removeConnectionAndDrop(b.getLeft(), worldIn, b.getRight()); } } @@ -895,46 +916,57 @@ public void notifyBlockUpdate(@Nonnull World worldIn, @Nonnull BlockPos pos, @No @Override public void notifyLightSet(@Nonnull BlockPos pos) - {} + { + } @Override public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2) - {} + { + } @Override public void playSoundToAllNearExcept(EntityPlayer player, @Nonnull SoundEvent soundIn, @Nonnull SoundCategory category, double x, double y, double z, float volume, float pitch) - {} + { + } @Override public void playRecord(@Nonnull SoundEvent soundIn, @Nonnull BlockPos pos) - {} + { + } @Override public void spawnParticle(int particleID, boolean ignoreRange, double xCoord, double yCoord, double zCoord, double xSpeed, double ySpeed, double zSpeed, @Nonnull int... parameters) - {} + { + } @Override public void spawnParticle(int id, boolean ignoreRange, boolean p_190570_3_, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, @Nonnull int... parameters) - {} + { + } @Override public void onEntityAdded(@Nonnull Entity entityIn) - {} + { + } @Override public void onEntityRemoved(@Nonnull Entity entityIn) - {} + { + } @Override public void broadcastSound(int soundID, @Nonnull BlockPos pos, int data) - {} + { + } @Override public void playEvent(EntityPlayer player, int type, @Nonnull BlockPos blockPosIn, int data) - {} + { + } @Override public void sendBlockBreakProgress(int breakerId, @Nonnull BlockPos pos, int progress) - {} + { + } } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/api/energy/wires/TileEntityImmersiveConnectable.java b/src/main/java/blusunrize/immersiveengineering/api/energy/wires/TileEntityImmersiveConnectable.java index 4420a3f990..fe2dab7d12 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/energy/wires/TileEntityImmersiveConnectable.java +++ b/src/main/java/blusunrize/immersiveengineering/api/energy/wires/TileEntityImmersiveConnectable.java @@ -17,7 +17,6 @@ import blusunrize.immersiveengineering.common.util.IELogger; import blusunrize.immersiveengineering.common.util.Utils; import com.google.common.collect.ImmutableSet; -import com.google.common.util.concurrent.ListenableFutureTask; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; @@ -34,7 +33,10 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.util.*; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; import java.util.function.Consumer; import static blusunrize.immersiveengineering.api.energy.wires.WireApi.canMix; @@ -48,14 +50,17 @@ protected boolean canTakeLV() { return false; } + protected boolean canTakeMV() { return false; } + protected boolean canTakeHV() { return false; } + protected boolean isRelay() { return false; @@ -65,6 +70,7 @@ protected boolean isRelay() public void onEnergyPassthrough(int amount) { } + @Override public boolean allowEnergyToPass(Connection con) { @@ -76,21 +82,25 @@ public boolean canConnect() { return true; } + @Override public boolean isEnergyOutput() { return false; } + @Override public int outputEnergy(int amount, boolean simulate, int energyType) { return 0; } + @Override public BlockPos getConnectionMaster(WireType cableType, TargetingInfo target) { return getPos(); - } + } + @Override public boolean canConnectCable(WireType cableType, TargetingInfo target, Vec3i offset) { @@ -98,53 +108,57 @@ public boolean canConnectCable(WireType cableType, TargetingInfo target, Vec3i o boolean foundAccepting = (HV_CATEGORY.equals(category)&&canTakeHV()) ||(MV_CATEGORY.equals(category)&&canTakeMV()) ||(LV_CATEGORY.equals(category)&&canTakeLV()); - if (!foundAccepting) + if(!foundAccepting) return false; - return limitType==null||(this.isRelay() && canMix(limitType, cableType)); + return limitType==null||(this.isRelay()&&canMix(limitType, cableType)); } + @Override public void connectCable(WireType cableType, TargetingInfo target, IImmersiveConnectable other) { this.limitType = cableType; } + @Override public WireType getCableLimiter(TargetingInfo target) { return this.limitType; } + @Override public void removeCable(Connection connection) { - WireType type = connection != null ? connection.cableType : null; + WireType type = connection!=null?connection.cableType: null; Set outputs = ImmersiveNetHandler.INSTANCE.getConnections(world, Utils.toCC(this)); - if(outputs == null || outputs.size() == 0) + if(outputs==null||outputs.size()==0) { - if(type == limitType || type == null) + if(type==limitType||type==null) this.limitType = null; } this.markDirty(); - if(world != null) + if(world!=null) { IBlockState state = world.getBlockState(pos); - world.notifyBlockUpdate(pos, state,state, 3); + world.notifyBlockUpdate(pos, state, state, 3); } } private List>> sources = new ArrayList<>(); private long lastSourceUpdate = 0; + @Override public void addAvailableEnergy(float amount, Consumer consume) { long currentTime = world.getTotalWorldTime(); - if (lastSourceUpdate!=currentTime) + if(lastSourceUpdate!=currentTime) { sources.clear(); Pair> own = getOwnEnergy(); - if (own!=null) + if(own!=null) sources.add(own); lastSourceUpdate = currentTime; } - if (amount>0&&consume!=null) + if(amount > 0&&consume!=null) sources.add(new ImmutablePair<>(amount, consume)); } @@ -159,12 +173,12 @@ public float getDamageAmount(Entity e, Connection c) { float baseDmg = getBaseDamage(c); float max = getMaxDamage(c); - if (baseDmg==0||world.getTotalWorldTime()-lastSourceUpdate>1) + if(baseDmg==0||world.getTotalWorldTime()-lastSourceUpdate > 1) return 0; float damage = 0; - for (int i = 0;i conL = ImmersiveNetHandler.INSTANCE.getConnections(world, Utils.toCC(this)); @@ -314,31 +335,31 @@ private void writeConnsToNBT(NBTTagCompound nbt) public Set genConnBlockstate() { Set conns = ImmersiveNetHandler.INSTANCE.getConnections(world, pos); - if (conns == null) + if(conns==null) return ImmutableSet.of(); Set ret = new HashSet() { @Override public boolean equals(Object o) { - if (o == this) + if(o==this) return true; - if (!(o instanceof HashSet)) + if(!(o instanceof HashSet)) return false; - HashSet other = (HashSet) o; - if (other.size() != this.size()) + HashSet other = (HashSet)o; + if(other.size()!=this.size()) return false; - for (Connection c : this) - if (!other.contains(c)) + for(Connection c : this) + if(!other.contains(c)) return false; return true; } }; //TODO thread safety! - for (Connection c : conns) + for(Connection c : conns) { IImmersiveConnectable end = ApiUtils.toIIC(c.end, world, false); - if (end==null) + if(end==null) continue; // generate subvertices c.getSubVertices(world); @@ -347,25 +368,28 @@ public boolean equals(Object o) return ret; } + @Override public void onChunkUnload() { super.onChunkUnload(); - if (!world.isRemote) + if(!world.isRemote) ImmersiveNetHandler.INSTANCE.addProxy(new IICProxy(this)); } + @Override public void validate() { super.validate(); - if (!world.isRemote) - ApiUtils.addFutureServerTask(world, ()->ImmersiveNetHandler.INSTANCE.onTEValidated(this)); + if(!world.isRemote) + ApiUtils.addFutureServerTask(world, () -> ImmersiveNetHandler.INSTANCE.onTEValidated(this)); } + @Override public void invalidate() { super.invalidate(); - if (world.isRemote&&!Minecraft.getMinecraft().isSingleplayer()) + if(world.isRemote&&!Minecraft.getMinecraft().isSingleplayer()) ImmersiveNetHandler.INSTANCE.clearAllConnectionsFor(pos, world, this, false); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/api/energy/wires/WireApi.java b/src/main/java/blusunrize/immersiveengineering/api/energy/wires/WireApi.java index 4aeb89ae67..6bccd2f0e7 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/energy/wires/WireApi.java +++ b/src/main/java/blusunrize/immersiveengineering/api/energy/wires/WireApi.java @@ -19,9 +19,11 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.util.*; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; import java.util.function.Function; import java.util.function.Predicate; @@ -33,10 +35,10 @@ public final class WireApi public static void registerConnectorForRender(String key, ResourceLocation baseModel, @Nullable ImmutableMap texReplacement) { - if (ConnLoader.baseModels.containsKey(key)) - IELogger.warn("Tried to register connector model for " + key + " twice. Active mod: " + Loader.instance().activeModContainer().getModId()); + if(ConnLoader.baseModels.containsKey(key)) + IELogger.warn("Tried to register connector model for "+key+" twice. Active mod: "+Loader.instance().activeModContainer().getModId()); ConnLoader.baseModels.put(key, baseModel); - if (texReplacement != null) + if(texReplacement!=null) ConnLoader.textureReplacements.put(key, texReplacement); } @@ -90,8 +92,8 @@ public static void registerFeedthroughForWiretype(WireType w, ResourceLocation m @Nullable public static WireType getWireType(IBlockState state) { - for (Map.Entry entry : INFOS.entrySet()) - if (entry.getValue().isValidConnector(state)) + for(Map.Entry entry : INFOS.entrySet()) + if(entry.getValue().isValidConnector(state)) return entry.getKey(); return null; } @@ -101,9 +103,9 @@ public static WireType getWireType(IBlockState state) public static void registerWireType(WireType w) { String category = w.getCategory(); - if (category != null) + if(category!=null) { - if (!WIRES_BY_CATEGORY.containsKey(category)) + if(!WIRES_BY_CATEGORY.containsKey(category)) WIRES_BY_CATEGORY.put(category, new HashSet<>()); WIRES_BY_CATEGORY.get(category).add(w); } @@ -112,12 +114,12 @@ public static void registerWireType(WireType w) public static boolean canMix(WireType a, WireType b) { String cat = a.getCategory(); - return cat != null && cat.equals(b.getCategory()); + return cat!=null&&cat.equals(b.getCategory()); } public static Set getWiresForType(@Nullable String category) { - if (category == null) + if(category==null) return ImmutableSet.of(); return WIRES_BY_CATEGORY.get(category); } @@ -148,7 +150,7 @@ public FeedthroughModelInfo(ResourceLocation model, ImmutableMap { modelLoc = model; this.texLoc = texLoc; - for (int i = 0; i < 4; i++) + for(int i = 0; i < 4; i++) this.uvs[i] = uvs[i]; texReplacements = texRepl; this.connLength = connLength; @@ -169,17 +171,17 @@ public FeedthroughModelInfo(ResourceLocation model, ImmutableMap public boolean isValidConnector(IBlockState state) { - if (matches != null) + if(matches!=null) { return matches.test(state); } else { - assert conn != null; - if (state.getBlock() != conn.getBlock()) + assert conn!=null; + if(state.getBlock()!=conn.getBlock()) return false; - for (IProperty p : state.getPropertyKeys()) - if (p != IEProperties.FACING_ALL && !state.getValue(p).equals(conn.getValue(p))) + for(IProperty p : state.getPropertyKeys()) + if(p!=IEProperties.FACING_ALL&&!state.getValue(p).equals(conn.getValue(p))) return false; return true; } @@ -197,16 +199,15 @@ public void onResourceReload(Function bake try { model = ModelLoaderRegistry.getModel(modelLoc); - } - catch (Exception e) + } catch(Exception e) { e.printStackTrace(); model = ModelLoaderRegistry.getMissingModel(); } - if (model instanceof OBJModel) + if(model instanceof OBJModel) { - OBJModel obj = (OBJModel) model; - obj = (OBJModel) obj.retexture(texReplacements); + OBJModel obj = (OBJModel)model; + obj = (OBJModel)obj.retexture(texReplacements); model = obj.process(ImmutableMap.of("flip-v", "true")); } this.model = model.bake(model.getDefaultState(), format, bakedTextureGetter); diff --git a/src/main/java/blusunrize/immersiveengineering/api/energy/wires/WireType.java b/src/main/java/blusunrize/immersiveengineering/api/energy/wires/WireType.java index 2a1cb1bca1..0487d58a70 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/energy/wires/WireType.java +++ b/src/main/java/blusunrize/immersiveengineering/api/energy/wires/WireType.java @@ -20,9 +20,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; import javax.annotation.Nullable; -import java.util.HashSet; import java.util.LinkedHashSet; -import java.util.Set; import static blusunrize.immersiveengineering.ImmersiveEngineering.MODID; import static blusunrize.immersiveengineering.api.energy.wires.WireApi.registerFeedthroughForWiretype; @@ -42,14 +40,16 @@ public abstract class WireType public static final String STRUCTURE_CATEGORY = "STRUCTURE"; public static final String REDSTONE_CATEGORY = "REDSTONE"; private static LinkedHashSet values = new LinkedHashSet(); + public static LinkedHashSet getValues() { return values; } + public static WireType getValue(String name) { - for(WireType type: values) - if(type!=null && type.getUniqueName().equals(name)) + for(WireType type : values) + if(type!=null&&type.getUniqueName().equals(name)) return type; return COPPER; } @@ -60,23 +60,39 @@ public WireType() } public abstract String getUniqueName(); + public abstract double getLossRatio(); + public abstract int getTransferRate(); - /**Try not to get to complex with determining colour here*/ + + /** + * Try not to get to complex with determining colour here + */ public abstract int getColour(Connection connection); - /**Determines how saggy the wire is*/ + + /** + * Determines how saggy the wire is + */ public abstract double getSlack(); + @SideOnly(Side.CLIENT) public abstract TextureAtlasSprite getIcon(Connection connection); + public abstract int getMaxLength(); + public abstract ItemStack getWireCoil(); + public ItemStack getWireCoil(Connection c) { return getWireCoil(); } + public abstract double getRenderDiameter(); + public abstract boolean isEnergyWire(); - public boolean canCauseDamage() { + + public boolean canCauseDamage() + { return false; } @@ -89,6 +105,7 @@ public String getCategory() { return null; } + /** * @return The radius around this wire where entities should be damaged if it is enabled in the config. Must be * less that DELTA_NEAR in blusunrize.immersiveengineering.api.ApiUtils.handleVec (currently .3) @@ -100,7 +117,7 @@ public double getDamageRadius() //THESE VALUES ARE FOR IE's OWN WIRES! public static String[] uniqueNames = {"COPPER", "ELECTRUM", "STEEL", "STRUCTURE_ROPE", "STRUCTURE_STEEL", "REDSTONE", - "COPPER_INS", "ELECTRUM_INS"}; + "COPPER_INS", "ELECTRUM_INS"}; public static double[] wireLossRatio; public static int[] wireTransferRate; public static int[] wireColouration; @@ -132,19 +149,19 @@ public static void init() registerFeedthroughForWiretype(COPPER, new ResourceLocation(MODID, "block/connector/connector_lv.obj"), new ResourceLocation(MODID, "blocks/connector_connector_lv"), new float[]{0, 4, 8, 12}, .5, IEContent.blockConnectors.getStateFromMeta(CONNECTOR_LV.getMeta()), - 8*2F/COPPER.getTransferRate(), 2, (f)->f); + 8*2F/COPPER.getTransferRate(), 2, (f) -> f); registerFeedthroughForWiretype(ELECTRUM, new ResourceLocation(MODID, "block/connector/connector_mv.obj"), new ResourceLocation(MODID, "blocks/connector_connector_mv"), new float[]{0, 4, 8, 12}, .5625, IEContent.blockConnectors.getStateFromMeta(CONNECTOR_MV.getMeta()), - 8*5F/ELECTRUM.getTransferRate(), 5, (f)->f); + 8*5F/ELECTRUM.getTransferRate(), 5, (f) -> f); registerFeedthroughForWiretype(STEEL, new ResourceLocation(MODID, "block/connector/connector_hv.obj"), new ResourceLocation(MODID, "blocks/connector_connector_hv"), new float[]{0, 4, 8, 12}, .75, IEContent.blockConnectors.getStateFromMeta(CONNECTOR_HV.getMeta()), - 8*15F/STEEL.getTransferRate(), 15, (f)->f); + 8*15F/STEEL.getTransferRate(), 15, (f) -> f); registerFeedthroughForWiretype(REDSTONE, new ResourceLocation(MODID, "block/connector/connector_redstone.obj.ie"), - ImmutableMap.of(), new ResourceLocation(MODID, "blocks/connector_connector_redstone"), new float[]{3, 8, 11, 16}, + ImmutableMap.of(), new ResourceLocation(MODID, "blocks/connector_connector_redstone"), new float[]{3, 8, 11, 16}, .5625, .5, IEContent.blockConnectors.getStateFromMeta(CONNECTOR_REDSTONE.getMeta()), - 0, 0, (f)->f); + 0, 0, (f) -> f); } public IElectricEquipment.ElectricSource getElectricSource() @@ -161,72 +178,83 @@ private static class IEBASE extends WireType { final int ordinal; private final IElectricEquipment.ElectricSource eSource; + public IEBASE(int ordinal) { super(); this.ordinal = ordinal; WireApi.registerWireType(this); - if (canCauseDamage()) + if(canCauseDamage()) eSource = new IElectricEquipment.ElectricSource(.5F*(1+ordinal)); else eSource = new IElectricEquipment.ElectricSource(-1); } + @Override public double getLossRatio() { return Math.abs(wireLossRatio[ordinal%6]); } + @Override public int getTransferRate() { return Math.abs(wireTransferRate[ordinal%6]); } + @Override public int getColour(Connection connection) { return wireColouration[ordinal]; } + @Override public double getSlack() { return 1.005; } + @Override @SideOnly(Side.CLIENT) public TextureAtlasSprite getIcon(Connection connection) { return iconDefaultWire; } + @Override public int getMaxLength() { return wireLength[ordinal%6]; } + @Override public ItemStack getWireCoil() { - return new ItemStack(ieWireCoil,1,ordinal); + return new ItemStack(ieWireCoil, 1, ordinal); } + @Override public String getUniqueName() { return uniqueNames[ordinal]; } + @Override public double getRenderDiameter() { return renderDiameter[ordinal%6]; } + @Override public boolean isEnergyWire() { - return ordinal%6<3; + return ordinal%6 < 3; } @Override public double getDamageRadius() { - switch (ordinal) + switch(ordinal) { case 0://LV return .05; @@ -241,14 +269,14 @@ public double getDamageRadius() @Override public boolean canCauseDamage() { - return ordinal<3; + return ordinal < 3; } @Nullable @Override public String getCategory() { - switch (ordinal) + switch(ordinal) { case 0: case 6: diff --git a/src/main/java/blusunrize/immersiveengineering/api/energy/wires/redstone/IRedstoneConnector.java b/src/main/java/blusunrize/immersiveengineering/api/energy/wires/redstone/IRedstoneConnector.java index 9dafd32b08..3c4bcf3e1d 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/energy/wires/redstone/IRedstoneConnector.java +++ b/src/main/java/blusunrize/immersiveengineering/api/energy/wires/redstone/IRedstoneConnector.java @@ -14,9 +14,11 @@ /** * Implement this interface to allow a block to interface with IE redstone wires */ -public interface IRedstoneConnector extends IImmersiveConnectable { +public interface IRedstoneConnector extends IImmersiveConnectable +{ /** * Sets the RedstoneWireNetwork this connector is connected to. DO NOT update output values in here, all output values will be updated in batch. + * * @param net the new network for this connector. */ void setNetwork(RedstoneWireNetwork net); @@ -39,6 +41,7 @@ public interface IRedstoneConnector extends IImmersiveConnectable { /** * Called when the RedstoneWireNetwork updates its RS input values. * As a general rule only stronger signals should override weaker signals, so you should never decrease the value of a channel in this method. + * * @param signals the values of the RS channels up to this point. Modify this array to change output values. */ void updateInput(byte[] signals); diff --git a/src/main/java/blusunrize/immersiveengineering/api/energy/wires/redstone/RedstoneWireNetwork.java b/src/main/java/blusunrize/immersiveengineering/api/energy/wires/redstone/RedstoneWireNetwork.java index 2c6e13de17..66f99dd795 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/energy/wires/redstone/RedstoneWireNetwork.java +++ b/src/main/java/blusunrize/immersiveengineering/api/energy/wires/redstone/RedstoneWireNetwork.java @@ -35,20 +35,20 @@ public RedstoneWireNetwork add(IRedstoneConnector connector) public void mergeNetwork(RedstoneWireNetwork wireNetwork) { List> conns = null; - if (connectors.size()>0) + if(connectors.size() > 0) conns = connectors; - else if (wireNetwork.connectors.size()>0) + else if(wireNetwork.connectors.size() > 0) conns = wireNetwork.connectors; - if (conns==null)//No connectors to merge + if(conns==null)//No connectors to merge return; IRedstoneConnector start = null; - for (WeakReference conn:conns) - if (conn.get()!=null) + for(WeakReference conn : conns) + if(conn.get()!=null) { start = conn.get(); break; } - if (start!=null) + if(start!=null) { BlockPos startPos = Utils.toCC(start); updateConnectors(startPos, start.getConnectorWorld(), this); @@ -60,11 +60,11 @@ public void removeFromNetwork(IRedstoneConnector removedConnector) { Iterator> iterator = connectors.iterator(); Set knownNets = new HashSet<>(); - while (iterator.hasNext()) + while(iterator.hasNext()) { WeakReference conn = iterator.next(); IRedstoneConnector start = conn.get(); - if (start != null && !knownNets.contains(start.getNetwork())) + if(start!=null&&!knownNets.contains(start.getNetwork())) { RedstoneWireNetwork newNet = new RedstoneWireNetwork(); updateConnectors(Utils.toCC(start), start.getConnectorWorld(), newNet); @@ -82,7 +82,7 @@ public static void updateConnectors(BlockPos start, World world, RedstoneWireNet open.add(start); Set closed = new HashSet<>(); network.connectors.clear(); - while (!open.isEmpty()) + while(!open.isEmpty()) { Iterator it = open.iterator(); BlockPos next = it.next(); @@ -90,16 +90,16 @@ public static void updateConnectors(BlockPos start, World world, RedstoneWireNet IImmersiveConnectable iic = ApiUtils.toIIC(next, world); closed.add(next); Set connsAtBlock = connsForDim.get(next); - if (iic instanceof IRedstoneConnector) + if(iic instanceof IRedstoneConnector) { - ((IRedstoneConnector) iic).setNetwork(network); + ((IRedstoneConnector)iic).setNetwork(network); network.connectors.add(new WeakReference<>((IRedstoneConnector)iic)); } - if (connsAtBlock != null && iic != null) - for (Connection c : connsAtBlock) + if(connsAtBlock!=null&&iic!=null) + for(Connection c : connsAtBlock) { - if (iic.allowEnergyToPass(c) && - REDSTONE_CATEGORY.equals(c.cableType.getCategory()) && + if(iic.allowEnergyToPass(c)&& + REDSTONE_CATEGORY.equals(c.cableType.getCategory())&& !closed.contains(c.end)) open.add(c.end); } @@ -115,7 +115,7 @@ public void updateValues() for(WeakReference connectorRef : connectors) { IRedstoneConnector connector = connectorRef.get(); - if(connector != null) + if(connector!=null) { // if (ProjectRedAPI.transmissionAPI != null) // { @@ -139,7 +139,7 @@ public void updateValues() for(WeakReference connectorRef : connectors) { IRedstoneConnector connector = connectorRef.get(); - if(connector != null) + if(connector!=null) connector.onChange(); } } @@ -154,7 +154,7 @@ public byte[] getByteValues() { byte[] values = new byte[16]; for(int i = 0; i < values.length; i++) - values[i] = (byte) (channelValues[i] * 16); + values[i] = (byte)(channelValues[i]*16); return values; } } diff --git a/src/main/java/blusunrize/immersiveengineering/api/fluid/IFluidPipe.java b/src/main/java/blusunrize/immersiveengineering/api/fluid/IFluidPipe.java index 77aa23bc3a..5cb777f27b 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/fluid/IFluidPipe.java +++ b/src/main/java/blusunrize/immersiveengineering/api/fluid/IFluidPipe.java @@ -13,5 +13,6 @@ public interface IFluidPipe { boolean canOutputPressurized(boolean consumePower); + boolean hasOutputConnection(EnumFacing side); } diff --git a/src/main/java/blusunrize/immersiveengineering/api/shader/CapabilityShader.java b/src/main/java/blusunrize/immersiveengineering/api/shader/CapabilityShader.java index 99d55f43a1..48f819c0db 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/shader/CapabilityShader.java +++ b/src/main/java/blusunrize/immersiveengineering/api/shader/CapabilityShader.java @@ -39,16 +39,19 @@ public ShaderWrapper(String type) { this.shaderType = type; } + public void setShaderType(String shaderType) { this.shaderType = shaderType; } + public String getShaderType() { return shaderType; } public abstract void setShaderItem(@Nonnull ItemStack shader); + @Nonnull public abstract ItemStack getShaderItem(); } @@ -77,12 +80,13 @@ public void setShaderItem(ItemStack shader) else container.getTagCompound().removeTag(SHADER_NBT_KEY); } + @Override @Nullable public ItemStack getShaderItem() { NBTTagCompound tagCompound = container.getTagCompound(); - if(tagCompound == null || !tagCompound.hasKey(SHADER_NBT_KEY)) + if(tagCompound==null||!tagCompound.hasKey(SHADER_NBT_KEY)) return ItemStack.EMPTY; return new ItemStack(tagCompound.getCompoundTag(SHADER_NBT_KEY)); } @@ -103,6 +107,7 @@ public void setShaderItem(@Nonnull ItemStack shader) { this.shader = shader; } + @Override @Nonnull public ItemStack getShaderItem() @@ -113,8 +118,9 @@ public ItemStack getShaderItem() @Override public boolean hasCapability(Capability capability, @Nullable EnumFacing facing) { - return capability == SHADER_CAPABILITY; + return capability==SHADER_CAPABILITY; } + @Override public T getCapability(Capability capability, @Nullable EnumFacing facing) { @@ -135,6 +141,7 @@ public NBTTagCompound serializeNBT() nbt.setString("IE:ShaderType", getShaderType()); return nbt; } + @Override public void deserializeNBT(NBTTagCompound nbt) { @@ -165,7 +172,7 @@ public NBTBase writeNBT(Capability capability, ShaderWrapper inst @Override public void readNBT(Capability capability, ShaderWrapper instance, EnumFacing side, NBTBase nbt) { - NBTTagCompound tags = (NBTTagCompound) nbt; + NBTTagCompound tags = (NBTTagCompound)nbt; instance.setShaderType(tags.getString("IE:ShaderType")); if(!tags.hasKey("IE:NoShader")) instance.setShaderItem(new ItemStack(tags)); diff --git a/src/main/java/blusunrize/immersiveengineering/api/shader/ShaderCaseBalloon.java b/src/main/java/blusunrize/immersiveengineering/api/shader/ShaderCaseBalloon.java index 4bce2afd32..b854656a27 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/shader/ShaderCaseBalloon.java +++ b/src/main/java/blusunrize/immersiveengineering/api/shader/ShaderCaseBalloon.java @@ -18,6 +18,7 @@ public ShaderCaseBalloon(ShaderLayer... layers) { super(layers); } + public ShaderCaseBalloon(Collection layers) { super(layers); diff --git a/src/main/java/blusunrize/immersiveengineering/api/shader/ShaderCaseChemthrower.java b/src/main/java/blusunrize/immersiveengineering/api/shader/ShaderCaseChemthrower.java index 92069537fe..6c9e14f370 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/shader/ShaderCaseChemthrower.java +++ b/src/main/java/blusunrize/immersiveengineering/api/shader/ShaderCaseChemthrower.java @@ -21,6 +21,7 @@ public ShaderCaseChemthrower(ShaderLayer... layers) { super(layers); } + public ShaderCaseChemthrower(Collection layers) { super(layers); @@ -46,12 +47,12 @@ public boolean renderModelPartForPass(ItemStack shader, ItemStack item, String m if(pass==0)//first pass is just for the grip return false; - if(pass==1 && "cage".equals(modelPart))//useful for a cage that is different from the base one + if(pass==1&&"cage".equals(modelPart))//useful for a cage that is different from the base one return renderCageOnBase; - if(tanksUncoloured && "tanks".equals(modelPart))//if tanks should be unaffected by colour and only render on overlay + if(tanksUncoloured&&"tanks".equals(modelPart))//if tanks should be unaffected by colour and only render on overlay return pass==getLayers().length-1; - if(!tanksUncoloured && "tanks".equals(modelPart))//if tanks should be coloured, the uncoloured pass must be ignored + if(!tanksUncoloured&&"tanks".equals(modelPart))//if tanks should be coloured, the uncoloured pass must be ignored return pass!=getLayers().length-1; return true; diff --git a/src/main/java/blusunrize/immersiveengineering/api/shader/ShaderCaseDrill.java b/src/main/java/blusunrize/immersiveengineering/api/shader/ShaderCaseDrill.java index 17063b79cb..83044536ec 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/shader/ShaderCaseDrill.java +++ b/src/main/java/blusunrize/immersiveengineering/api/shader/ShaderCaseDrill.java @@ -20,6 +20,7 @@ public ShaderCaseDrill(ShaderLayer... layers) { super(layers); } + public ShaderCaseDrill(Collection layers) { super(layers); @@ -40,23 +41,23 @@ public int getLayerInsertionIndex() @Override public boolean renderModelPartForPass(ItemStack shader, ItemStack item, String modelPart, int pass) { - if("drill_head".equals(modelPart) || "upgrade_damage0".equals(modelPart) || "upgrade_damage1".equals(modelPart) || "upgrade_damage2".equals(modelPart) || "upgrade_damage3".equals(modelPart) || "upgrade_damage4".equals(modelPart)) - return pass>=getLayers().length-headLayers; - if(pass>=getLayers().length-headLayers)//Last pass on drills is just for the head and augers + if("drill_head".equals(modelPart)||"upgrade_damage0".equals(modelPart)||"upgrade_damage1".equals(modelPart)||"upgrade_damage2".equals(modelPart)||"upgrade_damage3".equals(modelPart)||"upgrade_damage4".equals(modelPart)) + return pass >= getLayers().length-headLayers; + if(pass >= getLayers().length-headLayers)//Last pass on drills is just for the head and augers return false; - if("upgrade_speed".equals(modelPart) || "upgrade_waterproof".equals(modelPart))//Upgrades only render on the uncoloured pass + if("upgrade_speed".equals(modelPart)||"upgrade_waterproof".equals(modelPart))//Upgrades only render on the uncoloured pass return pass==getLayers().length-2; if("drill_grip".equals(modelPart)) return pass==0; - return pass != 0; + return pass!=0; } public ShaderCaseDrill addHeadLayers(ShaderLayer... addedLayers) { addLayers(layers.length, addedLayers); - headLayers+=addedLayers.length; + headLayers += addedLayers.length; return this; } diff --git a/src/main/java/blusunrize/immersiveengineering/api/shader/ShaderCaseItem.java b/src/main/java/blusunrize/immersiveengineering/api/shader/ShaderCaseItem.java index 660748faa3..732a45a297 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/shader/ShaderCaseItem.java +++ b/src/main/java/blusunrize/immersiveengineering/api/shader/ShaderCaseItem.java @@ -18,6 +18,7 @@ public ShaderCaseItem(ShaderLayer... layers) { super(layers); } + public ShaderCaseItem(Collection layers) { super(layers); diff --git a/src/main/java/blusunrize/immersiveengineering/api/shader/ShaderCaseMinecart.java b/src/main/java/blusunrize/immersiveengineering/api/shader/ShaderCaseMinecart.java index 29fdea247a..8b21667bcf 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/shader/ShaderCaseMinecart.java +++ b/src/main/java/blusunrize/immersiveengineering/api/shader/ShaderCaseMinecart.java @@ -26,6 +26,7 @@ public ShaderCaseMinecart(ShaderLayer... layers) super(layers); initBooleans(); } + public ShaderCaseMinecart(Collection layers) { super(layers); @@ -44,10 +45,10 @@ private void initBooleans() { mirrorSideForPass = new boolean[getLayers().length]; renderSides = new boolean[getLayers().length][7]; - for(int i=0; i layers) { super(layers); @@ -38,12 +39,12 @@ public int getLayerInsertionIndex() @Override public boolean renderModelPartForPass(ItemStack shader, ItemStack item, String modelPart, int pass) { - if("sled".equals(modelPart) || "wires".equals(modelPart) || "tubes".equals(modelPart))//these pieces only render on the uncoloured pass + if("sled".equals(modelPart)||"wires".equals(modelPart)||"tubes".equals(modelPart))//these pieces only render on the uncoloured pass return pass==getLayers().length-1; if("grip".equals(modelPart)) return pass==0; - return pass != 0; + return pass!=0; } diff --git a/src/main/java/blusunrize/immersiveengineering/api/shader/ShaderCaseShield.java b/src/main/java/blusunrize/immersiveengineering/api/shader/ShaderCaseShield.java index 7c1286e7a8..226be89a53 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/shader/ShaderCaseShield.java +++ b/src/main/java/blusunrize/immersiveengineering/api/shader/ShaderCaseShield.java @@ -18,6 +18,7 @@ public ShaderCaseShield(ShaderLayer... layers) { super(layers); } + public ShaderCaseShield(Collection layers) { super(layers); @@ -38,7 +39,7 @@ public int getLayerInsertionIndex() @Override public boolean renderModelPartForPass(ItemStack shader, ItemStack item, String modelPart, int pass) { - if("flash".equals(modelPart) || "shock".equals(modelPart)) + if("flash".equals(modelPart)||"shock".equals(modelPart)) return pass==getLayers().length-1; return true; } diff --git a/src/main/java/blusunrize/immersiveengineering/api/tool/BelljarHandler.java b/src/main/java/blusunrize/immersiveengineering/api/tool/BelljarHandler.java index 13df2eca1b..2726b26cdb 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/tool/BelljarHandler.java +++ b/src/main/java/blusunrize/immersiveengineering/api/tool/BelljarHandler.java @@ -40,8 +40,8 @@ /** * @author BluSunrize - 09.03.2017 - *

- * A handler for plantgrowth within the belljars/cloches + *

+ * A handler for plantgrowth within the belljars/cloches */ public class BelljarHandler { @@ -57,6 +57,7 @@ public static void registerHandler(IPlantHandler handler) { plantHandlers.add(handler); } + public static IPlantHandler getHandler(ItemStack seed) { if(seed.isEmpty()) @@ -71,6 +72,7 @@ public static void registerFluidFertilizer(FluidFertilizerHandler handler) { fluidFertilizers.add(handler); } + public static FluidFertilizerHandler getFluidFertilizerHandler(FluidStack fluid) { if(fluid==null) @@ -86,6 +88,7 @@ public static void registerItemFertilizer(ItemFertilizerHandler handler) { itemFertilizers.add(handler); } + public static ItemFertilizerHandler getItemFertilizerHandler(ItemStack itemStack) { if(itemStack.isEmpty()) @@ -95,6 +98,7 @@ public static ItemFertilizerHandler getItemFertilizerHandler(ItemStack itemStack return handler; return null; } + public static void registerBasicItemFertilizer(final ItemStack stack, final float growthMultiplier) { registerItemFertilizer(new ItemFertilizerHandler() @@ -104,6 +108,7 @@ public boolean isValid(@Nullable ItemStack fertilizer) { return OreDictionary.itemMatches(stack, fertilizer, false); } + @Override public float getGrowthMultiplier(ItemStack fertilizer, ItemStack seed, ItemStack soil, TileEntity tile) { @@ -114,33 +119,41 @@ public float getGrowthMultiplier(ItemStack fertilizer, ItemStack seed, ItemStack public static ResourceLocation getSoilTexture(ItemStack soil) { - return soilTextureMap.get(new ComparableItemStack(soil,false, false)); + return soilTextureMap.get(new ComparableItemStack(soil, false, false)); } public interface IPlantHandler extends IPlantRenderer { boolean isCorrectSoil(ItemStack seed, ItemStack soil); + float getGrowthStep(ItemStack seed, ItemStack soil, float growth, TileEntity tile, float fertilizer, boolean render); + ItemStack[] getOutput(ItemStack seed, ItemStack soil, TileEntity tile); + default float resetGrowth(ItemStack seed, ItemStack soil, float growth, TileEntity tile, boolean render) { return 0; } + default ResourceLocation getSoilTexture(ItemStack seed, ItemStack soil, TileEntity tile) { return null; } } + public interface IPlantRenderer { boolean isValid(ItemStack seed); + @SideOnly(Side.CLIENT) IBlockState[] getRenderedPlant(ItemStack seed, ItemStack soil, float growth, TileEntity tile); + @SideOnly(Side.CLIENT) default boolean overrideRender(ItemStack seed, ItemStack soil, float growth, TileEntity tile, BlockRendererDispatcher blockRenderer) { return false; } + @SideOnly(Side.CLIENT) default float getRenderSize(ItemStack seed, ItemStack soil, float growth, TileEntity tile) { @@ -151,11 +164,14 @@ default float getRenderSize(ItemStack seed, ItemStack soil, float growth, TileEn public interface FluidFertilizerHandler { boolean isValid(@Nullable FluidStack fertilizer); + float getGrowthMultiplier(FluidStack fertilizer, ItemStack seed, ItemStack soil, TileEntity tile); } + public interface ItemFertilizerHandler { boolean isValid(ItemStack fertilizer); + float getGrowthMultiplier(ItemStack fertilizer, ItemStack seed, ItemStack soil, TileEntity tile); } @@ -170,30 +186,33 @@ public abstract static class DefaultPlantHandler implements IPlantHandler @Override public boolean isValid(ItemStack seed) { - return seed!=null&&getSeedSet().contains(new ComparableItemStack(seed,false, false)); + return seed!=null&&getSeedSet().contains(new ComparableItemStack(seed, false, false)); } + @Override public boolean isCorrectSoil(ItemStack seed, ItemStack soil) { - IngredientStack reqSoil = seedSoilMap.get(new ComparableItemStack(seed,false, false)); + IngredientStack reqSoil = seedSoilMap.get(new ComparableItemStack(seed, false, false)); return reqSoil.matchesItemStack(soil); } + @Override public float getGrowthStep(ItemStack seed, ItemStack soil, float growth, TileEntity tile, float fertilizer, boolean render) { - return .003125f * fertilizer; + return .003125f*fertilizer; } + @Override public ItemStack[] getOutput(ItemStack seed, ItemStack soil, TileEntity tile) { - return seedOutputMap.get(new ComparableItemStack(seed,false, false)); + return seedOutputMap.get(new ComparableItemStack(seed, false, false)); } @Override @SideOnly(Side.CLIENT) public IBlockState[] getRenderedPlant(ItemStack seed, ItemStack soil, float growth, TileEntity tile) { - IBlockState[] states = seedRenderMap.get(new ComparableItemStack(seed,false, false)); + IBlockState[] states = seedRenderMap.get(new ComparableItemStack(seed, false, false)); if(states!=null) return states; return null; @@ -203,9 +222,10 @@ public void register(ItemStack seed, ItemStack[] output, Object soil, IBlockStat { register(seed, output, ApiUtils.createIngredientStack(soil), render); } + public void register(ItemStack seed, ItemStack[] output, IngredientStack soil, IBlockState... render) { - ComparableItemStack comp = new ComparableItemStack(seed,false, false); + ComparableItemStack comp = new ComparableItemStack(seed, false, false); getSeedSet().add(comp); seedSoilMap.put(comp, soil); seedOutputMap.put(comp, output); @@ -216,6 +236,7 @@ public void register(ItemStack seed, ItemStack[] output, IngredientStack soil, I public static DefaultPlantHandler cropHandler = new DefaultPlantHandler() { private HashSet validSeeds = new HashSet<>(); + @Override protected HashSet getSeedSet() { @@ -226,11 +247,11 @@ protected HashSet getSeedSet() @SideOnly(Side.CLIENT) public IBlockState[] getRenderedPlant(ItemStack seed, ItemStack soil, float growth, TileEntity tile) { - IBlockState[] states = seedRenderMap.get(new ComparableItemStack(seed,false, false)); + IBlockState[] states = seedRenderMap.get(new ComparableItemStack(seed, false, false)); if(states!=null) { IBlockState[] ret = new IBlockState[states.length]; - for(int i=0; i getSeedSet() @Override public float getGrowthStep(ItemStack seed, ItemStack soil, float growth, TileEntity tile, float fertilizer, boolean render) { - return (growth<.5?.00625f:.0015625f) * fertilizer; + return (growth < .5?.00625f: .0015625f)*fertilizer; } + @Override public float resetGrowth(ItemStack seed, ItemStack soil, float growth, TileEntity tile, boolean render) { @@ -283,34 +305,36 @@ public IBlockState[] getRenderedPlant(ItemStack seed, ItemStack soil, float grow { return new IBlockState[0]; } + @Override @SideOnly(Side.CLIENT) public float getRenderSize(ItemStack seed, ItemStack soil, float growth, TileEntity tile) { return 1f; } + @Override @SideOnly(Side.CLIENT) public boolean overrideRender(ItemStack seed, ItemStack soil, float growth, TileEntity tile, BlockRendererDispatcher blockRenderer) { - ComparableItemStack comp = new ComparableItemStack(seed,false, false); + ComparableItemStack comp = new ComparableItemStack(seed, false, false); IBlockState[] renderStates = seedRenderMap.get(comp); - if(renderStates.length>0 && renderStates[0]!=null && renderStates[0].getBlock() instanceof BlockStem) + if(renderStates.length > 0&&renderStates[0]!=null&&renderStates[0].getBlock() instanceof BlockStem) { - GlStateManager.rotate(-90,0,1,0); + GlStateManager.rotate(-90, 0, 1, 0); BlockStem stem = (BlockStem)renderStates[0].getBlock(); IBlockState state = stem.getDefaultState().withProperty(BlockStem.AGE, (int)(growth >= .5?7: 2*growth*7)); - if(growth>=.5) + if(growth >= .5) state = state.withProperty(BlockStem.FACING, EnumFacing.NORTH); IBakedModel model = blockRenderer.getModelForState(state); - GlStateManager.translate(.25f,.0625f,0); + GlStateManager.translate(.25f, .0625f, 0); GlStateManager.pushMatrix(); blockRenderer.getBlockModelRenderer().renderModelBrightness(model, state, 1, true); GlStateManager.popMatrix(); - if(growth>=.5) + if(growth >= .5) { - ItemStack[] fruit = seedOutputMap.get(new ComparableItemStack(seed,false, false)); - if(fruit!=null&&fruit.length>0&&!fruit[0].isEmpty()) + ItemStack[] fruit = seedOutputMap.get(new ComparableItemStack(seed, false, false)); + if(fruit!=null&&fruit.length > 0&&!fruit[0].isEmpty()) { Block fruitBlock = Block.getBlockFromItem(fruit[0].getItem()); if(fruitBlock!=null) @@ -333,6 +357,7 @@ public boolean overrideRender(ItemStack seed, ItemStack soil, float growth, Tile public static DefaultPlantHandler stackingHandler = new DefaultPlantHandler() { private HashSet validSeeds = new HashSet<>(); + @Override protected HashSet getSeedSet() { @@ -343,25 +368,27 @@ protected HashSet getSeedSet() @SideOnly(Side.CLIENT) public IBlockState[] getRenderedPlant(ItemStack seed, ItemStack soil, float growth, TileEntity tile) { - IBlockState[] states = seedRenderMap.get(new ComparableItemStack(seed,false, false)); + IBlockState[] states = seedRenderMap.get(new ComparableItemStack(seed, false, false)); if(states!=null) return states; return null; } + @Override @SideOnly(Side.CLIENT) public float getRenderSize(ItemStack seed, ItemStack soil, float growth, TileEntity tile) { - IBlockState[] states = seedRenderMap.get(new ComparableItemStack(seed,false, false)); - if(states!=null && states.length>2) + IBlockState[] states = seedRenderMap.get(new ComparableItemStack(seed, false, false)); + if(states!=null&&states.length > 2) return .6875f-(states.length)*.0625f; return .6875f; } + @Override @SideOnly(Side.CLIENT) public boolean overrideRender(ItemStack seed, ItemStack soil, float growth, TileEntity tile, BlockRendererDispatcher blockRenderer) { - IBlockState[] states = seedRenderMap.get(new ComparableItemStack(seed,false, false)); + IBlockState[] states = seedRenderMap.get(new ComparableItemStack(seed, false, false)); if(states!=null) GlStateManager.translate(0, (-1+growth)*(states.length-1), 0); return false; @@ -370,27 +397,27 @@ public boolean overrideRender(ItemStack seed, ItemStack soil, float growth, Tile public static void init() { - soilTextureMap.put(new ComparableItemStack(new ItemStack(Blocks.DIRT),false, false), new ResourceLocation("minecraft:blocks/farmland_wet")); + soilTextureMap.put(new ComparableItemStack(new ItemStack(Blocks.DIRT), false, false), new ResourceLocation("minecraft:blocks/farmland_wet")); registerHandler(cropHandler); registerHandler(stemHandler); registerHandler(stackingHandler); - cropHandler.register(new ItemStack(Items.WHEAT_SEEDS), new ItemStack[]{new ItemStack(Items.WHEAT, 2),new ItemStack(Items.WHEAT_SEEDS,1)}, new ItemStack(Blocks.DIRT), Blocks.WHEAT.getDefaultState()); - cropHandler.register(new ItemStack(Items.POTATO), new ItemStack[]{new ItemStack(Items.POTATO,2)}, new ItemStack(Blocks.DIRT), Blocks.POTATOES.getDefaultState()); - cropHandler.register(new ItemStack(Items.CARROT), new ItemStack[]{new ItemStack(Items.CARROT,2)}, new ItemStack(Blocks.DIRT), Blocks.CARROTS.getDefaultState()); - cropHandler.register(new ItemStack(Items.BEETROOT_SEEDS), new ItemStack[]{new ItemStack(Items.BEETROOT,2),new ItemStack(Items.BEETROOT_SEEDS,1)}, new ItemStack(Blocks.DIRT), Blocks.BEETROOTS.getDefaultState()); - cropHandler.register(new ItemStack(Items.NETHER_WART), new ItemStack[]{new ItemStack(Items.NETHER_WART,2)}, new ItemStack(Blocks.SOUL_SAND), Blocks.NETHER_WART.getDefaultState()); + cropHandler.register(new ItemStack(Items.WHEAT_SEEDS), new ItemStack[]{new ItemStack(Items.WHEAT, 2), new ItemStack(Items.WHEAT_SEEDS, 1)}, new ItemStack(Blocks.DIRT), Blocks.WHEAT.getDefaultState()); + cropHandler.register(new ItemStack(Items.POTATO), new ItemStack[]{new ItemStack(Items.POTATO, 2)}, new ItemStack(Blocks.DIRT), Blocks.POTATOES.getDefaultState()); + cropHandler.register(new ItemStack(Items.CARROT), new ItemStack[]{new ItemStack(Items.CARROT, 2)}, new ItemStack(Blocks.DIRT), Blocks.CARROTS.getDefaultState()); + cropHandler.register(new ItemStack(Items.BEETROOT_SEEDS), new ItemStack[]{new ItemStack(Items.BEETROOT, 2), new ItemStack(Items.BEETROOT_SEEDS, 1)}, new ItemStack(Blocks.DIRT), Blocks.BEETROOTS.getDefaultState()); + cropHandler.register(new ItemStack(Items.NETHER_WART), new ItemStack[]{new ItemStack(Items.NETHER_WART, 2)}, new ItemStack(Blocks.SOUL_SAND), Blocks.NETHER_WART.getDefaultState()); stemHandler.register(new ItemStack(Items.PUMPKIN_SEEDS), new ItemStack[]{new ItemStack(Blocks.PUMPKIN)}, new ItemStack(Blocks.DIRT), Blocks.PUMPKIN_STEM.getDefaultState()); stemHandler.register(new ItemStack(Items.MELON_SEEDS), new ItemStack[]{new ItemStack(Blocks.MELON_BLOCK)}, new ItemStack(Blocks.DIRT), Blocks.MELON_STEM.getDefaultState()); - stackingHandler.register(new ItemStack(Items.REEDS), new ItemStack[]{new ItemStack(Items.REEDS,2)}, "sand", Blocks.REEDS.getDefaultState(),Blocks.REEDS.getDefaultState()); - stackingHandler.register(new ItemStack(Blocks.CACTUS), new ItemStack[]{new ItemStack(Blocks.CACTUS,2)}, "sand", Blocks.CACTUS.getDefaultState(),Blocks.CACTUS.getDefaultState()); - stackingHandler.register(new ItemStack(Blocks.CHORUS_FLOWER), new ItemStack[]{new ItemStack(Items.CHORUS_FRUIT,1)}, new ItemStack(Blocks.END_STONE), Blocks.CHORUS_PLANT.getDefaultState().withProperty(BlockChorusPlant.DOWN,true).withProperty(BlockChorusPlant.UP,true),Blocks.CHORUS_PLANT.getDefaultState().withProperty(BlockChorusPlant.DOWN,true).withProperty(BlockChorusPlant.UP,true),Blocks.CHORUS_FLOWER.getDefaultState()); + stackingHandler.register(new ItemStack(Items.REEDS), new ItemStack[]{new ItemStack(Items.REEDS, 2)}, "sand", Blocks.REEDS.getDefaultState(), Blocks.REEDS.getDefaultState()); + stackingHandler.register(new ItemStack(Blocks.CACTUS), new ItemStack[]{new ItemStack(Blocks.CACTUS, 2)}, "sand", Blocks.CACTUS.getDefaultState(), Blocks.CACTUS.getDefaultState()); + stackingHandler.register(new ItemStack(Blocks.CHORUS_FLOWER), new ItemStack[]{new ItemStack(Items.CHORUS_FRUIT, 1)}, new ItemStack(Blocks.END_STONE), Blocks.CHORUS_PLANT.getDefaultState().withProperty(BlockChorusPlant.DOWN, true).withProperty(BlockChorusPlant.UP, true), Blocks.CHORUS_PLANT.getDefaultState().withProperty(BlockChorusPlant.DOWN, true).withProperty(BlockChorusPlant.UP, true), Blocks.CHORUS_FLOWER.getDefaultState()); - IngredientStack shroomSoil = new IngredientStack(ImmutableList.of(new ItemStack(Blocks.MYCELIUM), new ItemStack(Blocks.DIRT,1,2))); - cropHandler.register(new ItemStack(Blocks.RED_MUSHROOM), new ItemStack[]{new ItemStack(Blocks.RED_MUSHROOM,2)}, shroomSoil, Blocks.RED_MUSHROOM.getDefaultState()); - cropHandler.register(new ItemStack(Blocks.BROWN_MUSHROOM), new ItemStack[]{new ItemStack(Blocks.BROWN_MUSHROOM,2)}, shroomSoil, Blocks.BROWN_MUSHROOM.getDefaultState()); + IngredientStack shroomSoil = new IngredientStack(ImmutableList.of(new ItemStack(Blocks.MYCELIUM), new ItemStack(Blocks.DIRT, 1, 2))); + cropHandler.register(new ItemStack(Blocks.RED_MUSHROOM), new ItemStack[]{new ItemStack(Blocks.RED_MUSHROOM, 2)}, shroomSoil, Blocks.RED_MUSHROOM.getDefaultState()); + cropHandler.register(new ItemStack(Blocks.BROWN_MUSHROOM), new ItemStack[]{new ItemStack(Blocks.BROWN_MUSHROOM, 2)}, shroomSoil, Blocks.BROWN_MUSHROOM.getDefaultState()); registerFluidFertilizer(new FluidFertilizerHandler() { @@ -399,6 +426,7 @@ public boolean isValid(@Nullable FluidStack fertilizer) { return fertilizer!=null&&fertilizer.getFluid()==FluidRegistry.WATER; } + @Override public float getGrowthMultiplier(FluidStack fertilizer, ItemStack seed, ItemStack soil, TileEntity tile) { @@ -407,12 +435,14 @@ public float getGrowthMultiplier(FluidStack fertilizer, ItemStack seed, ItemStac }); registerItemFertilizer(new ItemFertilizerHandler() { - final ItemStack bonemeal = new ItemStack(Items.DYE,1,15); + final ItemStack bonemeal = new ItemStack(Items.DYE, 1, 15); + @Override public boolean isValid(ItemStack fertilizer) { - return !fertilizer.isEmpty()&&OreDictionary.itemMatches(bonemeal,fertilizer,true); + return !fertilizer.isEmpty()&&OreDictionary.itemMatches(bonemeal, fertilizer, true); } + @Override public float getGrowthMultiplier(ItemStack fertilizer, ItemStack seed, ItemStack soil, TileEntity tile) { diff --git a/src/main/java/blusunrize/immersiveengineering/api/tool/BulletHandler.java b/src/main/java/blusunrize/immersiveengineering/api/tool/BulletHandler.java index 237dda20e8..b45db2cd33 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/tool/BulletHandler.java +++ b/src/main/java/blusunrize/immersiveengineering/api/tool/BulletHandler.java @@ -26,8 +26,8 @@ /** * @author BluSunrize - 12.08.2016 - *

- * A registry for custom bullet types + *

+ * A registry for custom bullet types */ public class BulletHandler { @@ -45,11 +45,13 @@ public static void registerBullet(String name, IBullet bullet) { registry.put(name, bullet); } + public static IBullet getBullet(String name) { name = BulletHandler.handleLeagcyNames(name); return registry.get(name); } + public static String findRegistryName(IBullet bullet) { if(bullet!=null) @@ -70,9 +72,9 @@ public static ItemStack getBulletStack(String key) public static String handleLeagcyNames(final String key) { - if (key.equals("armorPiercing")) + if(key.equals("armorPiercing")) return "armor_piercing"; - if (key.equals("HE")) + if(key.equals("HE")) return "he"; return key; } @@ -105,7 +107,7 @@ default int getProjectileCount(@Nullable EntityPlayer shooter) * @param shooter * @param cartridge * @param projectile - * @param charged whether the revolver has the electron tube upgrade + * @param charged whether the revolver has the electron tube upgrade * @return the given or a custom entity */ default Entity getProjectile(@Nullable EntityPlayer shooter, ItemStack cartridge, Entity projectile, boolean charged) @@ -180,13 +182,13 @@ public DamagingBullet(Function damageSourceGetter, float float getDamage(boolean headshot) { - return this.damage * (headshot ? 1.5f : 1f); + return this.damage*(headshot?1.5f: 1f); } @Override public void onHitTarget(World world, RayTraceResult target, @Nullable EntityLivingBase shooter, Entity projectile, boolean headshot) { - if(!world.isRemote && target.entityHit != null && damageSourceGetter != null) + if(!world.isRemote&&target.entityHit!=null&&damageSourceGetter!=null) if(target.entityHit.attackEntityFrom(damageSourceGetter.apply(new Entity[]{projectile, shooter, target.entityHit}), getDamage(headshot))) { if(resetHurt) diff --git a/src/main/java/blusunrize/immersiveengineering/api/tool/ChemthrowerHandler.java b/src/main/java/blusunrize/immersiveengineering/api/tool/ChemthrowerHandler.java index 767da3f16e..c051cdbc52 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/tool/ChemthrowerHandler.java +++ b/src/main/java/blusunrize/immersiveengineering/api/tool/ChemthrowerHandler.java @@ -47,8 +47,9 @@ public class ChemthrowerHandler public static void registerEffect(Fluid fluid, ChemthrowerEffect effect) { if(fluid!=null) - registerEffect(fluid.getName(),effect); + registerEffect(fluid.getName(), effect); } + /** * registers a special effect to a fluid. Fluids without an effect simply do damage based on temperature */ @@ -56,12 +57,14 @@ public static void registerEffect(String fluidName, ChemthrowerEffect effect) { effectMap.put(fluidName, effect); } + public static ChemthrowerEffect getEffect(Fluid fluid) { if(fluid!=null) return getEffect(fluid.getName()); return null; } + public static ChemthrowerEffect getEffect(String fluidName) { return effectMap.get(fluidName); @@ -75,6 +78,7 @@ public static void registerFlammable(Fluid fluid) if(fluid!=null) registerFlammable(fluid.getName()); } + /** * registers a fluid to allow the chemical thrower to ignite it upon dispersal */ @@ -82,12 +86,14 @@ public static void registerFlammable(String fluidName) { flammableList.add(fluidName); } + public static boolean isFlammable(Fluid fluid) { if(fluid!=null) return flammableList.contains(fluid.getName()); return false; } + public static boolean isFlammable(String fluidName) { return flammableList.contains(fluidName); @@ -101,6 +107,7 @@ public static void registerGas(Fluid fluid) if(fluid!=null) registerGas(fluid.getName()); } + /** * registers a fluid to be dispersed like a gas. This is only necessary if the fluid itself isn't designated as a gas */ @@ -108,12 +115,14 @@ public static void registerGas(String fluidName) { gasList.add(fluidName); } + public static boolean isGas(Fluid fluid) { if(fluid!=null) return gasList.contains(fluid.getName()); return false; } + public static boolean isGas(String fluidName) { return gasList.contains(fluidName); @@ -125,23 +134,28 @@ public void applyToEntity(EntityLivingBase target, @Nullable EntityPlayer shoote { applyToEntity(target, shooter, thrower, fluid.getFluid()); } + public abstract void applyToEntity(EntityLivingBase target, @Nullable EntityPlayer shooter, ItemStack thrower, Fluid fluid); public void applyToBlock(World world, RayTraceResult mop, @Nullable EntityPlayer shooter, ItemStack thrower, FluidStack fluid) { applyToBlock(world, mop, shooter, thrower, fluid.getFluid()); } + public abstract void applyToBlock(World world, RayTraceResult mop, @Nullable EntityPlayer shooter, ItemStack thrower, Fluid fluid); } + public static class ChemthrowerEffect_Damage extends ChemthrowerEffect { DamageSource source; float damage; + public ChemthrowerEffect_Damage(DamageSource source, float damage) { this.source = source; this.damage = damage; } + @Override public void applyToEntity(EntityLivingBase target, @Nullable EntityPlayer shooter, ItemStack thrower, Fluid fluid) { @@ -150,35 +164,40 @@ public void applyToEntity(EntityLivingBase target, @Nullable EntityPlayer shoote if(target.attackEntityFrom(source, damage)) { target.hurtResistantTime = (int)(target.hurtResistantTime*.75); - if(source.isFireDamage() && !target.isImmuneToFire()) - target.setFire(fluid.isGaseous()?2:5); + if(source.isFireDamage()&&!target.isImmuneToFire()) + target.setFire(fluid.isGaseous()?2: 5); } } } + @Override public void applyToBlock(World world, RayTraceResult mop, @Nullable EntityPlayer shooter, ItemStack thrower, Fluid fluid) { } } + public static class ChemthrowerEffect_Potion extends ChemthrowerEffect_Damage { PotionEffect[] potionEffects; float[] effectChances; + public ChemthrowerEffect_Potion(DamageSource source, float damage, PotionEffect... effects) { super(source, damage); this.potionEffects = effects; this.effectChances = new float[potionEffects.length]; - for(int i=0; i=0 && effectIndex= 0&&effectIndex < this.effectChances.length) this.effectChances[effectIndex] = chance; return this; } @@ -187,35 +206,38 @@ public ChemthrowerEffect_Potion setEffectChance(int effectIndex, float chance) public void applyToEntity(EntityLivingBase target, @Nullable EntityPlayer shooter, ItemStack thrower, Fluid fluid) { super.applyToEntity(target, shooter, thrower, fluid); - if(this.potionEffects!=null && this.potionEffects.length>0) - for(int iEffect=0; iEffect 0) + for(int iEffect = 0; iEffect < this.potionEffects.length; iEffect++) if(target.getRNG().nextFloat() < this.effectChances[iEffect]) { PotionEffect e = this.potionEffects[iEffect]; - PotionEffect newEffect = new PotionEffect(e.getPotion(),e.getDuration(),e.getAmplifier()); + PotionEffect newEffect = new PotionEffect(e.getPotion(), e.getDuration(), e.getAmplifier()); newEffect.setCurativeItems(new ArrayList(e.getCurativeItems())); target.addPotionEffect(newEffect); } } } + public static class ChemthrowerEffect_Extinguish extends ChemthrowerEffect { private static DamageSource getPlayerDrownDamage(EntityPlayer player) { if(player==null) return DamageSource.DROWN; - return new EntityDamageSource(DamageSource.DROWN.getDamageType(),player).setDamageBypassesArmor(); + return new EntityDamageSource(DamageSource.DROWN.getDamageType(), player).setDamageBypassesArmor(); } + @Override public void applyToEntity(EntityLivingBase target, @Nullable EntityPlayer shooter, ItemStack thrower, Fluid fluid) { if(target.isBurning()) target.extinguish(); - if(target instanceof EntityBlaze || target instanceof EntityEnderman) + if(target instanceof EntityBlaze||target instanceof EntityEnderman) if(target.attackEntityFrom(getPlayerDrownDamage(shooter), 3)) target.hurtResistantTime = (int)(target.hurtResistantTime*.75); } + @Override public void applyToBlock(World world, RayTraceResult mop, @Nullable EntityPlayer shooter, ItemStack thrower, Fluid fluid) { @@ -224,30 +246,33 @@ public void applyToBlock(World world, RayTraceResult mop, @Nullable EntityPlayer world.setBlockToAir(mop.getBlockPos().offset(mop.sideHit)); } } + public static class ChemthrowerEffect_RandomTeleport extends ChemthrowerEffect_Damage { float chance; + public ChemthrowerEffect_RandomTeleport(DamageSource source, float damage, float chance) { super(source, damage); this.chance = chance; } + @Override public void applyToEntity(EntityLivingBase target, EntityPlayer shooter, ItemStack thrower, Fluid fluid) { super.applyToEntity(target, shooter, thrower, fluid); - if(Utils.RAND.nextFloat() boolean registerConveyorHandler(Resource public static IConveyorBelt getConveyor(ResourceLocation key, @Nullable TileEntity tile) { Function func = functionRegistry.get(key); - if(func != null) + if(func!=null) return func.apply(tile); return null; } @@ -97,13 +97,13 @@ public static boolean isConveyor(World world, BlockPos pos, String key, @Nullabl TileEntity tile = world.getTileEntity(pos); if(!(tile instanceof IConveyorTile)) return false; - if(facing != null && !facing.equals(((IConveyorTile) tile).getFacing())) + if(facing!=null&&!facing.equals(((IConveyorTile)tile).getFacing())) return false; - IConveyorBelt conveyor = ((IConveyorTile) tile).getConveyorSubtype(); - if(conveyor == null) + IConveyorBelt conveyor = ((IConveyorTile)tile).getConveyorSubtype(); + if(conveyor==null) return false; ResourceLocation rl = reverseClassRegistry.get(conveyor.getClass()); - return !(rl == null || !key.equalsIgnoreCase(rl.toString())); + return !(rl==null||!key.equalsIgnoreCase(rl.toString())); } /** @@ -114,7 +114,7 @@ public static boolean isConveyor(World world, BlockPos pos, String key, @Nullabl public static void registerMagnetSupression(BiConsumer function, @Nullable BiConsumer revert) { magnetSupressionFunctions.add(function); - if(revert != null) + if(revert!=null) magnetSupressionReverse.add(revert); } @@ -123,7 +123,7 @@ public static void registerMagnetSupression(BiConsumer fu */ public static void applyMagnetSupression(Entity entity, IConveyorTile tile) { - if(entity != null) + if(entity!=null) for(BiConsumer func : magnetSupressionFunctions) func.accept(entity, tile); } @@ -133,7 +133,7 @@ public static void applyMagnetSupression(Entity entity, IConveyorTile tile) */ public static void revertMagnetSupression(Entity entity, IConveyorTile tile) { - if(entity != null) + if(entity!=null) for(BiConsumer func : magnetSupressionReverse) func.accept(entity, tile); } @@ -150,12 +150,12 @@ public interface IConveyorBelt default String getModelCacheKey(TileEntity tile, EnumFacing facing) { String key = reverseClassRegistry.get(this.getClass()).toString(); - key += "f" + facing.ordinal(); - key += "d" + getConveyorDirection().ordinal(); - key += "a" + (isActive(tile) ? 1 : 0); - key += "w0" + (renderWall(tile, facing, 0) ? 1 : 0); - key += "w1" + (renderWall(tile, facing, 1) ? 1 : 0); - key += "c" + getDyeColour(); + key += "f"+facing.ordinal(); + key += "d"+getConveyorDirection().ordinal(); + key += "a"+(isActive(tile)?1: 0); + key += "w0"+(renderWall(tile, facing, 0)?1: 0); + key += "w1"+(renderWall(tile, facing, 1)?1: 0); + key += "c"+getDyeColour(); return key; } @@ -169,6 +169,7 @@ default ConveyorDirection getConveyorDirection() /** * Switch to the next possible ConveyorDirection + * * @return true if renderupdate should happen */ boolean changeConveyorDirection(); @@ -226,18 +227,18 @@ default boolean playerInteraction(TileEntity tile, EntityPlayer player, EnumHand */ default boolean renderWall(TileEntity tile, EnumFacing facing, int wall) { - if(getConveyorDirection() != ConveyorDirection.HORIZONTAL) + if(getConveyorDirection()!=ConveyorDirection.HORIZONTAL) return true; - EnumFacing side = wall == 0 ? facing.rotateYCCW() : facing.rotateY(); + EnumFacing side = wall==0?facing.rotateYCCW(): facing.rotateY(); BlockPos pos = tile.getPos().offset(side); TileEntity te = Utils.getExistingTileEntity(tile.getWorld(), pos); if(te instanceof IConveyorAttachable) { boolean b = false; for(EnumFacing f : ((IConveyorAttachable)te).sigOutputDirections()) - if(f == side.getOpposite()) + if(f==side.getOpposite()) b = true; - else if(f == EnumFacing.UP) + else if(f==EnumFacing.UP) b = false; return !b; } @@ -248,9 +249,9 @@ else if(f == EnumFacing.UP) { int b = 0; for(EnumFacing f : ((IConveyorAttachable)te).sigOutputDirections()) - if(f == side.getOpposite()) + if(f==side.getOpposite()) b++; - else if(f == EnumFacing.UP) + else if(f==EnumFacing.UP) b++; return b < 2; } @@ -263,9 +264,9 @@ else if(f == EnumFacing.UP) */ default EnumFacing[] sigTransportDirections(TileEntity conveyorTile, EnumFacing facing) { - if(getConveyorDirection() == ConveyorDirection.UP) + if(getConveyorDirection()==ConveyorDirection.UP) return new EnumFacing[]{facing, EnumFacing.UP}; - else if(getConveyorDirection() == ConveyorDirection.DOWN) + else if(getConveyorDirection()==ConveyorDirection.DOWN) return new EnumFacing[]{facing, EnumFacing.DOWN}; return new EnumFacing[]{facing}; } @@ -279,30 +280,31 @@ default Vec3d getDirection(TileEntity conveyorTile, Entity entity, EnumFacing fa BlockPos pos = conveyorTile.getPos(); double vBase = 1.15; - double vX = 0.1 * vBase * facing.getFrontOffsetX(); + double vX = 0.1*vBase*facing.getFrontOffsetX(); double vY = entity.motionY; - double vZ = 0.1 * vBase * facing.getFrontOffsetZ(); + double vZ = 0.1*vBase*facing.getFrontOffsetZ(); - if(conveyorDirection == ConveyorDirection.UP) - vY = 0.17D * vBase; - else if(conveyorDirection == ConveyorDirection.DOWN) - vY = -0.07 * vBase; + if(conveyorDirection==ConveyorDirection.UP) + vY = 0.17D*vBase; + else if(conveyorDirection==ConveyorDirection.DOWN) + vY = -0.07*vBase; - if(conveyorDirection != ConveyorDirection.HORIZONTAL) + if(conveyorDirection!=ConveyorDirection.HORIZONTAL) entity.onGround = false; - if(facing == EnumFacing.WEST || facing == EnumFacing.EAST) + if(facing==EnumFacing.WEST||facing==EnumFacing.EAST) { - if(entity.posZ > pos.getZ() + 0.55D) - vZ = -0.1D * vBase; - else if(entity.posZ < pos.getZ() + 0.45D) - vZ = 0.1D * vBase; - } else if(facing == EnumFacing.NORTH || facing == EnumFacing.SOUTH) + if(entity.posZ > pos.getZ()+0.55D) + vZ = -0.1D*vBase; + else if(entity.posZ < pos.getZ()+0.45D) + vZ = 0.1D*vBase; + } + else if(facing==EnumFacing.NORTH||facing==EnumFacing.SOUTH) { - if(entity.posX > pos.getX() + 0.55D) - vX = -0.1D * vBase; - else if(entity.posX < pos.getX() + 0.45D) - vX = 0.1D * vBase; + if(entity.posX > pos.getX()+0.55D) + vX = -0.1D*vBase; + else if(entity.posX < pos.getX()+0.45D) + vX = 0.1D*vBase; } return new Vec3d(vX, vY, vZ); @@ -314,8 +316,8 @@ default void onEntityCollision(TileEntity tile, Entity entity, EnumFacing facing return; BlockPos pos = tile.getPos(); ConveyorDirection conveyorDirection = getConveyorDirection(); - float heightLimit = conveyorDirection == ConveyorDirection.HORIZONTAL ? .25f : 1f; - if(entity != null && !entity.isDead && !(entity instanceof EntityPlayer && entity.isSneaking()) && entity.posY - pos.getY() >= 0 && entity.posY - pos.getY() < heightLimit) + float heightLimit = conveyorDirection==ConveyorDirection.HORIZONTAL?.25f: 1f; + if(entity!=null&&!entity.isDead&&!(entity instanceof EntityPlayer&&entity.isSneaking())&&entity.posY-pos.getY() >= 0&&entity.posY-pos.getY() < heightLimit) { Vec3d vec = this.getDirection(tile, entity, facing); if(entity.fallDistance < 3) @@ -323,29 +325,29 @@ default void onEntityCollision(TileEntity tile, Entity entity, EnumFacing facing entity.motionX = vec.x; entity.motionY = vec.y; entity.motionZ = vec.z; - double distX = Math.abs(pos.offset(facing).getX() + .5 - entity.posX); - double distZ = Math.abs(pos.offset(facing).getZ() + .5 - entity.posZ); + double distX = Math.abs(pos.offset(facing).getX()+.5-entity.posX); + double distZ = Math.abs(pos.offset(facing).getZ()+.5-entity.posZ); double treshold = .9; - boolean contact = facing.getAxis() == Axis.Z ? distZ < treshold : distX < treshold; - if(contact && conveyorDirection == ConveyorDirection.UP && !tile.getWorld().getBlockState(pos.offset(facing).up()).isFullBlock()) + boolean contact = facing.getAxis()==Axis.Z?distZ < treshold: distX < treshold; + if(contact&&conveyorDirection==ConveyorDirection.UP&&!tile.getWorld().getBlockState(pos.offset(facing).up()).isFullBlock()) { double move = .4; - entity.setPosition(entity.posX + move * facing.getFrontOffsetX(), entity.posY + 1 * move, entity.posZ + move * facing.getFrontOffsetZ()); + entity.setPosition(entity.posX+move*facing.getFrontOffsetX(), entity.posY+1*move, entity.posZ+move*facing.getFrontOffsetZ()); } if(!contact) - ConveyorHandler.applyMagnetSupression(entity, (IConveyorTile) tile); + ConveyorHandler.applyMagnetSupression(entity, (IConveyorTile)tile); else { BlockPos nextPos = tile.getPos().offset(facing); if(!(Utils.getExistingTileEntity(tile.getWorld(), nextPos) instanceof IConveyorTile)) - ConveyorHandler.revertMagnetSupression(entity, (IConveyorTile) tile); + ConveyorHandler.revertMagnetSupression(entity, (IConveyorTile)tile); } // In the first tick this could be an entity the conveyor belt just dropped, causing #3023 - if(entity instanceof EntityItem && entity.ticksExisted>1) + if(entity instanceof EntityItem&&entity.ticksExisted > 1) { - ((EntityItem) entity).setNoDespawn(); - handleInsertion(tile, (EntityItem) entity, facing, conveyorDirection, distX, distZ); + ((EntityItem)entity).setNoDespawn(); + handleInsertion(tile, (EntityItem)entity, facing, conveyorDirection, distX, distZ); } } } @@ -353,25 +355,27 @@ default void onEntityCollision(TileEntity tile, Entity entity, EnumFacing facing /** * Called when an item is inserted into the conveyor and deployed as an entity */ - default void onItemDeployed(TileEntity tile, EntityItem entity, EnumFacing facing){ } + default void onItemDeployed(TileEntity tile, EntityItem entity, EnumFacing facing) + { + } default void handleInsertion(TileEntity tile, EntityItem entity, EnumFacing facing, ConveyorDirection conDir, double distX, double distZ) { - BlockPos invPos = tile.getPos().offset(facing).add(0, (conDir == ConveyorDirection.UP ? 1 : conDir == ConveyorDirection.DOWN ? -1 : 0), 0); + BlockPos invPos = tile.getPos().offset(facing).add(0, (conDir==ConveyorDirection.UP?1: conDir==ConveyorDirection.DOWN?-1: 0), 0); World world = tile.getWorld(); TileEntity inventoryTile = Utils.getExistingTileEntity(world, invPos); - boolean contact = facing.getAxis() == Axis.Z ? distZ < .7 : distX < .7; - if (!tile.getWorld().isRemote) + boolean contact = facing.getAxis()==Axis.Z?distZ < .7: distX < .7; + if(!tile.getWorld().isRemote) { - if (contact && inventoryTile != null && !(inventoryTile instanceof IConveyorTile)) + if(contact&&inventoryTile!=null&&!(inventoryTile instanceof IConveyorTile)) { ItemStack stack = entity.getItem(); - if (!stack.isEmpty()) + if(!stack.isEmpty()) { ItemStack ret = ApiUtils.insertStackIntoInventory(inventoryTile, stack, facing.getOpposite()); - if (ret.isEmpty()) + if(ret.isEmpty()) entity.setDead(); - else if (ret.getCount() < stack.getCount()) + else if(ret.getCount() < stack.getCount()) entity.setItem(ret); } } @@ -393,7 +397,7 @@ default void onUpdate(TileEntity tile, EnumFacing facing) default List getSelectionBoxes(TileEntity tile, EnumFacing facing) { - return getConveyorDirection() == ConveyorDirection.HORIZONTAL ? Lists.newArrayList(conveyorBounds) : Lists.newArrayList(highConveyorBounds); + return getConveyorDirection()==ConveyorDirection.HORIZONTAL?Lists.newArrayList(conveyorBounds): Lists.newArrayList(highConveyorBounds); } default List getColisionBoxes(TileEntity tile, EnumFacing facing) @@ -418,7 +422,10 @@ default Matrix4f modifyBaseRotationMatrix(Matrix4f matrix, @Nullable TileEntity ResourceLocation getInactiveTexture(); @SideOnly(Side.CLIENT) - default ResourceLocation getColouredStripesTexture(){ return textureConveyorColour; } + default ResourceLocation getColouredStripesTexture() + { + return textureConveyorColour; + } @SideOnly(Side.CLIENT) default List modifyQuads(List baseModel, @Nullable TileEntity tile, EnumFacing facing) @@ -446,6 +453,7 @@ public interface IConveyorAttachable */ EnumFacing[] sigOutputDirections(); } + /** * This interface solely exists to mark a tile as conveyor, and have it ignored for insertion */ diff --git a/src/main/java/blusunrize/immersiveengineering/api/tool/ExternalHeaterHandler.java b/src/main/java/blusunrize/immersiveengineering/api/tool/ExternalHeaterHandler.java index d4d388f0fb..e1db3c655a 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/tool/ExternalHeaterHandler.java +++ b/src/main/java/blusunrize/immersiveengineering/api/tool/ExternalHeaterHandler.java @@ -28,34 +28,37 @@ public class ExternalHeaterHandler /** * @author BluSunrize - 09.12.2015 - * + *

* An interface to be implemented by TileEntities that want to allow direct interaction with the external heater */ public interface IExternalHeatable { - /** + /** * Called each tick
* Handle fueling as well as possible smelting speed increases here + * * @param energyAvailable the amount of RF the furnace heater has stored and can supply - * @param redstone whether a redstone signal is applied to the furnace heater. To keep the target warm, but not do speed increases + * @param redstone whether a redstone signal is applied to the furnace heater. To keep the target warm, but not do speed increases * @return the amount of RF consumed that tick. Should be lower or equal to "energyAvailable", obviously */ int doHeatTick(int energyAvailable, boolean redstone); } public static HashMap, HeatableAdapter> adapterMap = new HashMap, HeatableAdapter>(); + /** * @author BluSunrize - 09.12.2015 - * + *

* An adapter to appyl to TileEntities that can't implement the IExternalHeatable interface */ public abstract static class HeatableAdapter { - /** + /** * Called each tick
* Handle fueling as well as possible smelting speed increases here + * * @param energyAvailable the amount of RF the furnace heater has stored and can supply - * @param canHeat whether a redstone signal is applied to the furnace heater. To keep the target warm, but not do speed increases + * @param canHeat whether a redstone signal is applied to the furnace heater. To keep the target warm, but not do speed increases * @return the amount of RF consumed that tick. Should be lower or equal to "energyAvailable", obviously */ public abstract int doHeatTick(E tileEntity, int energyAvailable, boolean canHeat); @@ -68,13 +71,14 @@ public static void registerHeatableAdapter(Class c, Heatab { adapterMap.put(c, adapter); } + /** * @return a HeatableAdapter for the given TileEntity class */ public static HeatableAdapter getHeatableAdapter(Class c) { HeatableAdapter adapter = adapterMap.get(c); - if(adapter == null && c!=TileEntity.class && c.getSuperclass()!=TileEntity.class) + if(adapter==null&&c!=TileEntity.class&&c.getSuperclass()!=TileEntity.class) { adapter = getHeatableAdapter((Class)c.getSuperclass()); adapterMap.put(c, adapter); @@ -98,8 +102,8 @@ boolean canCook(TileEntityFurnace tileEntity) return true; if(!existingOutput.isItemEqual(output)) return false; - int stackSize = existingOutput.getCount() + output.getCount(); - return stackSize<=tileEntity.getInventoryStackLimit() && stackSize<=output.getMaxStackSize(); + int stackSize = existingOutput.getCount()+output.getCount(); + return stackSize <= tileEntity.getInventoryStackLimit()&&stackSize <= output.getMaxStackSize(); } @Override @@ -111,21 +115,21 @@ public int doHeatTick(TileEntityFurnace tileEntity, int energyAvailable, boolean { boolean burning = tileEntity.isBurning(); int burnTime = tileEntity.getField(0); - if(burnTime<200) + if(burnTime < 200) { int heatAttempt = 4; int heatEnergyRatio = Math.max(1, defaultFurnaceEnergyCost); int energyToUse = Math.min(energyAvailable, heatAttempt*heatEnergyRatio); int heat = energyToUse/heatEnergyRatio; - if(heat>0) + if(heat > 0) { tileEntity.setField(0, burnTime+heat); energyConsumed += heat*heatEnergyRatio; if(!burning) - updateFurnace(tileEntity, tileEntity.getField(0)>0); + updateFurnace(tileEntity, tileEntity.getField(0) > 0); } } - if(canCook&&tileEntity.getField(0)>=200&&tileEntity.getField(2)<199) + if(canCook&&tileEntity.getField(0) >= 200&&tileEntity.getField(2) < 199) { int energyToUse = defaultFurnaceSpeedupCost; if(energyAvailable-energyConsumed > energyToUse) @@ -137,6 +141,7 @@ public int doHeatTick(TileEntityFurnace tileEntity, int energyAvailable, boolean } return energyConsumed; } + public void updateFurnace(TileEntity tileEntity, boolean active) { Block containing = tileEntity.getBlockType(); @@ -151,7 +156,7 @@ public void updateFurnace(TileEntity tileEntity, boolean active) nbt.setBoolean("Active", active); tileEntity.readFromNBT(nbt); IBlockState state = tileEntity.getWorld().getBlockState(tileEntity.getPos()); - tileEntity.getWorld().notifyBlockUpdate(tileEntity.getPos(), state,state, 3); + tileEntity.getWorld().notifyBlockUpdate(tileEntity.getPos(), state, state, 3); } } } diff --git a/src/main/java/blusunrize/immersiveengineering/api/tool/IConfigurableTool.java b/src/main/java/blusunrize/immersiveengineering/api/tool/IConfigurableTool.java index 7a3f39c5b7..b35359a936 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/tool/IConfigurableTool.java +++ b/src/main/java/blusunrize/immersiveengineering/api/tool/IConfigurableTool.java @@ -14,60 +14,67 @@ /** * @author BluSunrize - 10.03.2016 - * + *

* Similar to upgradeable tools, configurable tools can be put in the workbench to change their options
*/ public interface IConfigurableTool { boolean canConfigure(ItemStack stack); - + /** * Boolean options are checkboxes where checked equals true */ ToolConfigBoolean[] getBooleanOptions(ItemStack stack); + /** * Float options are sliders */ ToolConfigFloat[] getFloatOptions(ItemStack stack); + /** * Apply and store the config option on the given stack */ void applyConfigOption(ItemStack stack, String key, Object value); - + /** * @return a TRANSLATED name for the config option. Try to keep this short. */ String fomatConfigName(ItemStack stack, ToolConfig config); + /** * @return a TRANSLATED name for the config option, displayed when hovering over it */ String fomatConfigDescription(ItemStack stack, ToolConfig config); - + abstract class ToolConfig { public int x; public int y; public String name; + protected ToolConfig(String name, int x, int y) { this.name = name; this.x = x; this.y = y; } - + public static class ToolConfigBoolean extends ToolConfig { public boolean value; + public ToolConfigBoolean(String name, int x, int y, boolean value) { super(name, x, y); this.value = value; } } + public static class ToolConfigFloat extends ToolConfig { public float value; + public ToolConfigFloat(String name, int x, int y, float value) { super(name, x, y); diff --git a/src/main/java/blusunrize/immersiveengineering/api/tool/IDrillHead.java b/src/main/java/blusunrize/immersiveengineering/api/tool/IDrillHead.java index 1ba022d564..8abbaa5010 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/tool/IDrillHead.java +++ b/src/main/java/blusunrize/immersiveengineering/api/tool/IDrillHead.java @@ -20,51 +20,62 @@ /** * @author BluSunrize - 28.05.2015 - * + *

* An interface for items to make custom drill heads */ public interface IDrillHead { - /**Called before a block is broken by the head + /** + * Called before a block is broken by the head * Return true to prevent the block from being broken */ boolean beforeBlockbreak(ItemStack drill, ItemStack head, EntityPlayer player); - - /**Called after a block is broken by the head + + /** + * Called after a block is broken by the head * Damage should not be applied here but in the specific method. */ void afterBlockbreak(ItemStack drill, ItemStack head, EntityPlayer player); - - /**@return A list of BlockPos that will be dug in addition to the targeted block + + /** + * @return A list of BlockPos that will be dug in addition to the targeted block */ ImmutableList getExtraBlocksDug(ItemStack head, World world, EntityPlayer player, RayTraceResult mop); - - /**@return The mining level of the drill + + /** + * @return The mining level of the drill */ int getMiningLevel(ItemStack head); - - /**@return The speed of the drill + + /** + * @return The speed of the drill */ float getMiningSpeed(ItemStack head); - - /**@return The damage the head does when equipped on the drill + + /** + * @return The damage the head does when equipped on the drill */ float getAttackDamage(ItemStack head); - /**@return The current damage of the drill head + /** + * @return The current damage of the drill head * Used to determine whether the head can be used */ int getHeadDamage(ItemStack head); - /**@return The maximum damage of the dril head + + /** + * @return The maximum damage of the dril head * Used to determine whether the head can be used */ int getMaximumHeadDamage(ItemStack head); - - /**Apply damage to the drill head here + + /** + * Apply damage to the drill head here */ void damageHead(ItemStack head, int damage); - - /**Return the texture of the drill head + + /** + * Return the texture of the drill head * Look at IE's default texture for the UV layout * This IIcon should be stitched in the item sheet */ diff --git a/src/main/java/blusunrize/immersiveengineering/api/tool/IElectricEquipment.java b/src/main/java/blusunrize/immersiveengineering/api/tool/IElectricEquipment.java index a66d58e89d..a5a00779b6 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/tool/IElectricEquipment.java +++ b/src/main/java/blusunrize/immersiveengineering/api/tool/IElectricEquipment.java @@ -21,12 +21,13 @@ public interface IElectricEquipment { /** * Called whenever an electric source attempts to damage the player, or is close to doing so - * @param s The current ItemStack + * + * @param s The current ItemStack * @param eqSlot The equipment slot the Item is in - * @param p The entity wearing/holding the item - * @param cache A way for different IElectricEquipment items to communicate with each other. It is empty when starting to check the equipment and is discarded after checking is done - * @param dmg The damage source that would be used. Set the amount to 0 to prevent any damage from being done. null if no damage would be done - * @param desc A description of the specific type of electric source. + * @param p The entity wearing/holding the item + * @param cache A way for different IElectricEquipment items to communicate with each other. It is empty when starting to check the equipment and is discarded after checking is done + * @param dmg The damage source that would be used. Set the amount to 0 to prevent any damage from being done. null if no damage would be done + * @param desc A description of the specific type of electric source. */ void onStrike(ItemStack s, EntityEquipmentSlot eqSlot, EntityLivingBase p, Map cache, @Nullable DamageSource dmg, ElectricSource desc); @@ -37,10 +38,11 @@ static void applyToEntity(EntityLivingBase entity, @Nullable DamageSource dmg, E for(EntityEquipmentSlot slot : EntityEquipmentSlot.values()) { ItemStack s = entity.getItemStackFromSlot(slot); - if (!s.isEmpty()&&s.getItem() instanceof IElectricEquipment) + if(!s.isEmpty()&&s.getItem() instanceof IElectricEquipment) ((IElectricEquipment)s.getItem()).onStrike(s, slot, entity, cache, dmg, source); } } + // this isn't just a float so it can be overridden, for special sources class ElectricSource { diff --git a/src/main/java/blusunrize/immersiveengineering/api/tool/IInternalStorageItem.java b/src/main/java/blusunrize/immersiveengineering/api/tool/IInternalStorageItem.java index b0df270916..8a69b5b233 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/tool/IInternalStorageItem.java +++ b/src/main/java/blusunrize/immersiveengineering/api/tool/IInternalStorageItem.java @@ -13,7 +13,7 @@ /** * @author BluSunrize - 27.10.2015 - * + *

* An item that contains an internal inventory, like drill or revolver * Deprecated in favor of capabilities */ @@ -21,8 +21,8 @@ public interface IInternalStorageItem { NonNullList getContainedItems(ItemStack stack); - + void setContainedItems(ItemStack stack, NonNullList stackList); - + int getInternalSlots(ItemStack stack); } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/api/tool/ITeslaEquipment.java b/src/main/java/blusunrize/immersiveengineering/api/tool/ITeslaEquipment.java index b56a909191..cee7be716d 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/tool/ITeslaEquipment.java +++ b/src/main/java/blusunrize/immersiveengineering/api/tool/ITeslaEquipment.java @@ -27,7 +27,7 @@ public interface ITeslaEquipment extends IElectricEquipment @Override default void onStrike(ItemStack s, EntityEquipmentSlot eqSlot, EntityLivingBase p, Map cache, @Nullable DamageSource dmg, ElectricSource desc) { - if (dmg!=null) + if(dmg!=null) onStrike(s, eqSlot, p, cache, dmg); } } diff --git a/src/main/java/blusunrize/immersiveengineering/api/tool/IUpgrade.java b/src/main/java/blusunrize/immersiveengineering/api/tool/IUpgrade.java index 38a6c8dbd9..312a4d6d18 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/tool/IUpgrade.java +++ b/src/main/java/blusunrize/immersiveengineering/api/tool/IUpgrade.java @@ -15,7 +15,7 @@ /** * @author BluSunrize - 29.05.2015 - * + *

* Upgrades for the drill (and possibly other items) are handled by this interface */ public interface IUpgrade @@ -25,13 +25,13 @@ public interface IUpgrade * Returns a set so an item can be used for multiple items */ Set getUpgradeTypes(ItemStack upgrade); - + /** * @return whether the upgrade can be applied to the parsed target item * This should fired after comparing UpradeTypes, so you don't have to account for that */ boolean canApplyUpgrades(ItemStack target, ItemStack upgrade); - + /** * Applies the modifications to a HashMap. Do NOT apply upgrades to the target directly
* Valid modifications you can apply are Byte, byte[], Boolean, Integer, int[], Float, Double, String diff --git a/src/main/java/blusunrize/immersiveengineering/api/tool/IUpgradeableTool.java b/src/main/java/blusunrize/immersiveengineering/api/tool/IUpgradeableTool.java index 132ec76976..ed41684c3c 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/tool/IUpgradeableTool.java +++ b/src/main/java/blusunrize/immersiveengineering/api/tool/IUpgradeableTool.java @@ -16,9 +16,9 @@ /** * @author BluSunrize - 27.10.2015 - * + *

* Upgradeable tools like Drill and Revolver implement this.
- * Since this is an interface, upgrade- and inventory-management need to be handled by the item implementing this + * Since this is an interface, upgrade- and inventory-management need to be handled by the item implementing this */ public interface IUpgradeableTool { @@ -27,11 +27,11 @@ public interface IUpgradeableTool * Examples include "speed" for the mining speed of the drill or "bullets" for extended magazines on the revolver */ NBTTagCompound getUpgrades(ItemStack stack); - + void clearUpgrades(ItemStack stack); void finishUpgradeRecalculation(ItemStack stack); - + /** * Iterate through the stored items and apply upgrades. For an example implementation, see ItemUpgradeableTool in the IE source */ @@ -41,11 +41,11 @@ public interface IUpgradeableTool * @return false to prevent this item from being removed from the workbench. Used by blueprints for example. */ boolean canTakeFromWorkbench(ItemStack stack); - + void removeFromWorkbench(EntityPlayer player, ItemStack stack); - + boolean canModify(ItemStack stack); - + /** * @return an array of Slots to display in the workbench when this item is placed in it */ diff --git a/src/main/java/blusunrize/immersiveengineering/api/tool/RailgunHandler.java b/src/main/java/blusunrize/immersiveengineering/api/tool/RailgunHandler.java index e09f7d1c94..ab82454883 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/tool/RailgunHandler.java +++ b/src/main/java/blusunrize/immersiveengineering/api/tool/RailgunHandler.java @@ -26,15 +26,17 @@ public static RailgunProjectileProperties registerProjectileProperties(Ingredien projectilePropertyMap.add(Pair.of(stack, properties)); return properties; } + public static RailgunProjectileProperties registerProjectileProperties(ItemStack stack, double damage, double gravity) { return registerProjectileProperties(ApiUtils.createIngredientStack(stack), damage, gravity); } + public static RailgunProjectileProperties getProjectileProperties(ItemStack stack) { for(Pair pair : projectilePropertyMap) - if(pair.getLeft().matchesItemStack(stack)) - return pair.getRight(); + if(pair.getLeft().matchesItemStack(stack)) + return pair.getRight(); return null; } @@ -42,7 +44,8 @@ public static class RailgunProjectileProperties { public double damage; public double gravity; - public int[][] colourMap = {{0x686868,0xa4a4a4,0xa4a4a4,0xa4a4a4,0x686868}}; + public int[][] colourMap = {{0x686868, 0xa4a4a4, 0xa4a4a4, 0xa4a4a4, 0x686868}}; + public RailgunProjectileProperties(double damage, double gravity) { this.damage = damage; @@ -54,7 +57,7 @@ public RailgunProjectileProperties setColourMap(int[][] map) this.colourMap = map; return this; } - + /** * @return true to cancel normal damage application */ diff --git a/src/main/java/blusunrize/immersiveengineering/api/tool/ToolboxHandler.java b/src/main/java/blusunrize/immersiveengineering/api/tool/ToolboxHandler.java index da6efaa056..c41eb9bf24 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/tool/ToolboxHandler.java +++ b/src/main/java/blusunrize/immersiveengineering/api/tool/ToolboxHandler.java @@ -22,53 +22,62 @@ import java.util.function.BiPredicate; import java.util.function.Predicate; -public class ToolboxHandler { +public class ToolboxHandler +{ private static final List> tools = new ArrayList<>(); private static final List> foods = new ArrayList<>(); private static final List> wiring = new ArrayList<>(); - static { - tools.add((s)->(s.getItem() instanceof ITool && ((ITool) s.getItem()).isTool(s))); - tools.add((s)->(s.getItem() instanceof ItemTool)); - foods.add((s)->(s.getItem() instanceof ItemFood)); - wiring.add((s, w)->(s.getItem() instanceof IWireCoil)); - wiring.add((s, w)-> - { - Block b = Block.getBlockFromItem(s.getItem()); - int meta = s.getItemDamage(); - IBlockState defaultState = b==null?null:b.getStateFromMeta(meta); - return b!=null&&b.hasTileEntity(defaultState)&&(b.createTileEntity(w, defaultState) instanceof IImmersiveConnectable); - } + + static + { + tools.add((s) -> (s.getItem() instanceof ITool&&((ITool)s.getItem()).isTool(s))); + tools.add((s) -> (s.getItem() instanceof ItemTool)); + foods.add((s) -> (s.getItem() instanceof ItemFood)); + wiring.add((s, w) -> (s.getItem() instanceof IWireCoil)); + wiring.add((s, w) -> + { + Block b = Block.getBlockFromItem(s.getItem()); + int meta = s.getItemDamage(); + IBlockState defaultState = b==null?null: b.getStateFromMeta(meta); + return b!=null&&b.hasTileEntity(defaultState)&&(b.createTileEntity(w, defaultState) instanceof IImmersiveConnectable); + } ); } + public static boolean isTool(ItemStack s) { - for (Predicate p:tools) - if (p.test(s)) + for(Predicate p : tools) + if(p.test(s)) return true; return false; } + public static void addToolType(Predicate in) { tools.add(in); } + public static boolean isFood(ItemStack s) { - for (Predicate p:foods) - if (p.test(s)) + for(Predicate p : foods) + if(p.test(s)) return true; return false; } + public static void addFoodType(Predicate in) { foods.add(in); } + public static boolean isWiring(ItemStack s, World w) { - for (BiPredicate p:wiring) - if (p.test(s, w)) + for(BiPredicate p : wiring) + if(p.test(s, w)) return true; return false; } + public static void addWiringType(BiPredicate in) { wiring.add(in); diff --git a/src/main/java/blusunrize/immersiveengineering/api/tool/ZoomHandler.java b/src/main/java/blusunrize/immersiveengineering/api/tool/ZoomHandler.java index d9d9ae1c11..baa600a91f 100644 --- a/src/main/java/blusunrize/immersiveengineering/api/tool/ZoomHandler.java +++ b/src/main/java/blusunrize/immersiveengineering/api/tool/ZoomHandler.java @@ -13,7 +13,7 @@ /** * @author BluSunrize - 25.12.2015 - * + *

* A handler for IZoomTool fucntionality, allowing items to function as providers for zooming in */ public class ZoomHandler @@ -23,7 +23,7 @@ public class ZoomHandler /** * @author BluSunrize - 25.12.2015 - * + *

* An interface to be implemented by items to allow zooming in */ public interface IZoomTool @@ -33,6 +33,7 @@ public interface IZoomTool * @return whether this item is valid for zooming in */ boolean canZoom(ItemStack stack, EntityPlayer player); + /** * @return the different steps of zoom the item has, sorted from low to high */ diff --git a/src/main/java/blusunrize/immersiveengineering/client/ClientEventHandler.java b/src/main/java/blusunrize/immersiveengineering/client/ClientEventHandler.java index 9926fc4df6..577d186318 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/ClientEventHandler.java +++ b/src/main/java/blusunrize/immersiveengineering/client/ClientEventHandler.java @@ -136,9 +136,9 @@ public void onResourceManagerReload(IResourceManager resourceManager) @SubscribeEvent public void onPlayerTick(TickEvent.PlayerTickEvent event) { - if(event.side.isClient()&&event.player!=null&&event.player==ClientUtils.mc().getRenderViewEntity()) - { - if(event.phase==Phase.START) + if(event.side.isClient()&&event.player!=null&&event.player==ClientUtils.mc().getRenderViewEntity()) + { + if(event.phase==Phase.START) { skyhookGrabableConnections.clear(); EntityPlayer player = event.player; @@ -1265,7 +1265,7 @@ public void onRenderWorldLastEvent(RenderWorldLastEvent event) tessellator.getBuffer().setTranslation(-px, -py, -pz); ParticleFractal part; - while((part = ParticleFractal.PARTICLE_FRACTAL_DEQUE.pollFirst()) != null) + while((part = ParticleFractal.PARTICLE_FRACTAL_DEQUE.pollFirst())!=null) part.render(tessellator, tessellator.getBuffer(), partial); tessellator.getBuffer().setTranslation(0, 0, 0); diff --git a/src/main/java/blusunrize/immersiveengineering/client/ClientProxy.java b/src/main/java/blusunrize/immersiveengineering/client/ClientProxy.java index 60b33209bc..3f99164d7d 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/ClientProxy.java +++ b/src/main/java/blusunrize/immersiveengineering/client/ClientProxy.java @@ -156,7 +156,7 @@ public class ClientProxy extends CommonProxy public void preInit() { Framebuffer fb = ClientUtils.mc().getFramebuffer(); - if (OpenGlHelper.framebufferSupported && IEConfig.stencilBufferEnabled && !fb.isStencilEnabled()) + if(OpenGlHelper.framebufferSupported&&IEConfig.stencilBufferEnabled&&!fb.isStencilEnabled()) { stencilBufferEnabled = fb.enableStencil();//Enabling FBO stencils } diff --git a/src/main/java/blusunrize/immersiveengineering/client/ClientUtils.java b/src/main/java/blusunrize/immersiveengineering/client/ClientUtils.java index 05c67570cc..3b345e7494 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/ClientUtils.java +++ b/src/main/java/blusunrize/immersiveengineering/client/ClientUtils.java @@ -95,34 +95,34 @@ public class ClientUtils // public static void tessellateConnection(Connection connection, IImmersiveConnectable start, IImmersiveConnectable end, TextureAtlasSprite sprite) { - if(connection == null || start == null || end == null) + if(connection==null||start==null||end==null) return; int col = connection.cableType.getColour(connection); - double r = connection.cableType.getRenderDiameter() / 2; - int[] rgba = new int[]{col >> 16 & 255, col >> 8 & 255, col & 255, 255}; + double r = connection.cableType.getRenderDiameter()/2; + int[] rgba = new int[]{col >> 16&255, col >> 8&255, col&255, 255}; tessellateConnection(connection, start, end, rgba, r, sprite); } public static void tessellateConnection(Connection connection, IImmersiveConnectable start, IImmersiveConnectable end, int[] rgba, double radius, TextureAtlasSprite sprite) { - if(connection == null || start == null || end == null || connection.end == null || connection.start == null) + if(connection==null||start==null||end==null||connection.end==null||connection.start==null) return; Vec3d startOffset = start.getConnectionOffset(connection); Vec3d endOffset = end.getConnectionOffset(connection); - if(startOffset == null) + if(startOffset==null) startOffset = new Vec3d(.5, .5, .5); - if(endOffset == null) + if(endOffset==null) endOffset = new Vec3d(.5, .5, .5); - double dx = (connection.end.getX() + endOffset.x) - (connection.start.getX() + startOffset.x); - double dy = (connection.end.getY() + endOffset.y) - (connection.start.getY() + startOffset.y); - double dz = (connection.end.getZ() + endOffset.z) - (connection.start.getZ() + startOffset.z); - double dw = Math.sqrt(dx * dx + dz * dz); - double d = Math.sqrt(dx * dx + dy * dy + dz * dz); - World world = ((TileEntity) start).getWorld(); + double dx = (connection.end.getX()+endOffset.x)-(connection.start.getX()+startOffset.x); + double dy = (connection.end.getY()+endOffset.y)-(connection.start.getY()+startOffset.y); + double dz = (connection.end.getZ()+endOffset.z)-(connection.start.getZ()+startOffset.z); + double dw = Math.sqrt(dx*dx+dz*dz); + double d = Math.sqrt(dx*dx+dy*dy+dz*dz); + World world = ((TileEntity)start).getWorld(); Tessellator tes = tes(); - double rmodx = dz / dw; - double rmodz = dx / dw; + double rmodx = dz/dw; + double rmodz = dx/dw; Vec3d[] vertex = connection.getSubVertices(world); // Vec3 initPos = new Vec3(connection.start.getX()+startOffset.xCoord, connection.start.getY()+startOffset.yCoord, connection.start.getZ()+startOffset.zCoord); @@ -132,9 +132,9 @@ public static void tessellateConnection(Connection connection, IImmersiveConnect double uMax = sprite.getMaxU(); double vMin = sprite.getMinV(); double vMax = sprite.getMaxV(); - double uD = uMax - uMin; - boolean vertical = connection.end.getX() == connection.start.getX() && connection.end.getZ() == connection.start.getZ(); - boolean b = (dx < 0 && dz <= 0) || (dz < 0 && dx <= 0) || (dz < 0 && dx > 0); + double uD = uMax-uMin; + boolean vertical = connection.end.getX()==connection.start.getX()&&connection.end.getZ()==connection.start.getZ(); + boolean b = (dx < 0&&dz <= 0)||(dz < 0&&dx <= 0)||(dz < 0&&dx > 0); BufferBuilder worldrenderer = tes.getBuffer(); @@ -149,79 +149,80 @@ public static void tessellateConnection(Connection connection, IImmersiveConnect worldrenderer.setTranslation(initPos.x, initPos.y, initPos.z); // tes.addVertexWithUV(0-radius, 0, 0, b?uMax-uShift:uMin,vMin); - worldrenderer.pos(0 - radius, 0, 0).tex(uMin, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(0-radius, 0, 0).tex(uMin, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); // tes.addVertexWithUV(dx-radius, dy, dz, b?uMin:uMin+uShift,vMin); - worldrenderer.pos(dx - radius, dy, dz).tex(uMax, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(dx-radius, dy, dz).tex(uMax, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); // tes.addVertexWithUV(dx+radius, dy, dz, b?uMin:uMin+uShift,vMax); - worldrenderer.pos(dx + radius, dy, dz).tex(uMax, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(dx+radius, dy, dz).tex(uMax, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); // tes.addVertexWithUV(0+radius, 0, 0, b?uMax-uShift:uMin,vMax); - worldrenderer.pos(0 + radius, 0, 0).tex(uMin, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(0+radius, 0, 0).tex(uMin, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); // tes.addVertexWithUV(dx-radius, dy, dz, b?uMin:uMin+uShift,vMin); - worldrenderer.pos(dx - radius, dy, dz).tex(uMax, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(dx-radius, dy, dz).tex(uMax, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); // tes.addVertexWithUV(0-radius, 0, 0, b?uMax-uShift:uMin,vMin); - worldrenderer.pos(0 - radius, 0, 0).tex(uMin, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(0-radius, 0, 0).tex(uMin, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); // tes.addVertexWithUV(0+radius, 0, 0, b?uMax-uShift:uMin,vMax); - worldrenderer.pos(0 + radius, 0, 0).tex(uMin, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(0+radius, 0, 0).tex(uMin, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); // tes.addVertexWithUV(dx+radius, dy, dz, b?uMin:uMin+uShift,vMax); - worldrenderer.pos(dx + radius, dy, dz).tex(uMax, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(dx+radius, dy, dz).tex(uMax, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); // tes.addVertexWithUV(0, 0, 0-radius, b?uMax-uShift:uMin,vMin); - worldrenderer.pos(0, 0, 0 - radius).tex(uMin, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(0, 0, 0-radius).tex(uMin, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); // tes.addVertexWithUV(dx, dy, dz-radius, b?uMin:uMin+uShift,vMin); - worldrenderer.pos(dx, dy, dz - radius).tex(uMax, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(dx, dy, dz-radius).tex(uMax, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); // tes.addVertexWithUV(dx, dy, dz+radius, b?uMin:uMin+uShift,vMax); - worldrenderer.pos(dx, dy, dz + radius).tex(uMax, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(dx, dy, dz+radius).tex(uMax, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); // tes.addVertexWithUV(0, 0, 0+radius, b?uMax-uShift:uMin,vMax); - worldrenderer.pos(0, 0, 0 + radius).tex(uMin, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(0, 0, 0+radius).tex(uMin, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); // tes.addVertexWithUV(dx, dy, dz-radius, b?uMin:uMin+uShift,vMin); - worldrenderer.pos(dx, dy, dz - radius).tex(uMax, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(dx, dy, dz-radius).tex(uMax, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); // tes.addVertexWithUV(0, 0, 0-radius, b?uMax-uShift:uMin,vMin); - worldrenderer.pos(0, 0, 0 - radius).tex(uMin, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(0, 0, 0-radius).tex(uMin, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); // tes.addVertexWithUV(0, 0, 0+radius, b?uMax-uShift:uMin,vMax); - worldrenderer.pos(0, 0, 0 + radius).tex(uMin, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(0, 0, 0+radius).tex(uMin, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); // tes.addVertexWithUV(dx, dy, dz+radius, b?uMin:uMin+uShift,vMax); - worldrenderer.pos(dx, dy, dz + radius).tex(uMax, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(dx, dy, dz+radius).tex(uMax, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); worldrenderer.setTranslation(0, 0, 0); - } else + } + else { double u0 = uMin; double u1 = uMin; - for(int i = b ? (vertex.length - 1) : 0; (b ? (i >= 0) : (i < vertex.length)); i += (b ? -1 : 1)) + for(int i = b?(vertex.length-1): 0; (b?(i >= 0): (i < vertex.length)); i += (b?-1: 1)) { - Vec3d v0 = i > 0 ? vertex[i - 1].subtract(connection.start.getX(), connection.start.getY(), connection.start.getZ()) : initPos; + Vec3d v0 = i > 0?vertex[i-1].subtract(connection.start.getX(), connection.start.getY(), connection.start.getZ()): initPos; Vec3d v1 = vertex[i].subtract(connection.start.getX(), connection.start.getY(), connection.start.getZ()); // double u0 = uMin; // double u1 = uMax; u0 = u1; - u1 = u0 + (v0.distanceTo(v1) / d) * uD; - if((dx < 0 && dz <= 0) || (dz < 0 && dx <= 0) || (dz < 0 && dx > 0)) + u1 = u0+(v0.distanceTo(v1)/d)*uD; + if((dx < 0&&dz <= 0)||(dz < 0&&dx <= 0)||(dz < 0&&dx > 0)) { u1 = uMin; u0 = uMax; } - worldrenderer.pos(v0.x, v0.y + radius, v0.z).tex(u0, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); - worldrenderer.pos(v1.x, v1.y + radius, v1.z).tex(u1, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); - worldrenderer.pos(v1.x, v1.y - radius, v1.z).tex(u1, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); - worldrenderer.pos(v0.x, v0.y - radius, v0.z).tex(u0, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); - - worldrenderer.pos(v1.x, v1.y + radius, v1.z).tex(u1, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); - worldrenderer.pos(v0.x, v0.y + radius, v0.z).tex(u0, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); - worldrenderer.pos(v0.x, v0.y - radius, v0.z).tex(u0, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); - worldrenderer.pos(v1.x, v1.y - radius, v1.z).tex(u1, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); - - worldrenderer.pos(v0.x - radius * rmodx, v0.y, v0.z + radius * rmodz).tex(u0, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); - worldrenderer.pos(v1.x - radius * rmodx, v1.y, v1.z + radius * rmodz).tex(u1, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); - worldrenderer.pos(v1.x + radius * rmodx, v1.y, v1.z - radius * rmodz).tex(u1, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); - worldrenderer.pos(v0.x + radius * rmodx, v0.y, v0.z - radius * rmodz).tex(u0, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); - - worldrenderer.pos(v1.x - radius * rmodx, v1.y, v1.z + radius * rmodz).tex(u1, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); - worldrenderer.pos(v0.x - radius * rmodx, v0.y, v0.z + radius * rmodz).tex(u0, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); - worldrenderer.pos(v0.x + radius * rmodx, v0.y, v0.z - radius * rmodz).tex(u0, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); - worldrenderer.pos(v1.x + radius * rmodx, v1.y, v1.z - radius * rmodz).tex(u1, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(v0.x, v0.y+radius, v0.z).tex(u0, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(v1.x, v1.y+radius, v1.z).tex(u1, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(v1.x, v1.y-radius, v1.z).tex(u1, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(v0.x, v0.y-radius, v0.z).tex(u0, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + + worldrenderer.pos(v1.x, v1.y+radius, v1.z).tex(u1, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(v0.x, v0.y+radius, v0.z).tex(u0, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(v0.x, v0.y-radius, v0.z).tex(u0, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(v1.x, v1.y-radius, v1.z).tex(u1, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + + worldrenderer.pos(v0.x-radius*rmodx, v0.y, v0.z+radius*rmodz).tex(u0, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(v1.x-radius*rmodx, v1.y, v1.z+radius*rmodz).tex(u1, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(v1.x+radius*rmodx, v1.y, v1.z-radius*rmodz).tex(u1, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(v0.x+radius*rmodx, v0.y, v0.z-radius*rmodz).tex(u0, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + + worldrenderer.pos(v1.x-radius*rmodx, v1.y, v1.z+radius*rmodz).tex(u1, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(v0.x-radius*rmodx, v0.y, v0.z+radius*rmodz).tex(u0, vMax).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(v0.x+radius*rmodx, v0.y, v0.z-radius*rmodz).tex(u0, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); + worldrenderer.pos(v1.x+radius*rmodx, v1.y, v1.z-radius*rmodz).tex(u1, vMin).color(rgba[0], rgba[1], rgba[2], rgba[3]).endVertex(); } } @@ -290,7 +291,7 @@ public static void bindAtlas() public static ResourceLocation getResource(String path) { - ResourceLocation rl = resourceMap.containsKey(path) ? resourceMap.get(path) : new ResourceLocation(path); + ResourceLocation rl = resourceMap.containsKey(path)?resourceMap.get(path): new ResourceLocation(path); if(!resourceMap.containsKey(path)) resourceMap.put(path, rl); return rl; @@ -339,12 +340,12 @@ public boolean containsFormat(TimestampFormat format) public long getTickCut() { - return this == D ? 1728000L : this == H ? 72000L : this == M ? 1200L : this == S ? 20L : 1; + return this==D?1728000L: this==H?72000L: this==M?1200L: this==S?20L: 1; } public String getLocalKey() { - return this == D ? "day" : this == H ? "hour" : this == M ? "minute" : this == S ? "second" : ""; + return this==D?"day": this==H?"hour": this==M?"minute": this==S?"second": ""; } } @@ -352,16 +353,16 @@ public static String fomatTimestamp(long timestamp, TimestampFormat format) { String s = ""; for(TimestampFormat core : TimestampFormat.coreValues) - if(format.containsFormat(core) && timestamp >= core.getTickCut()) + if(format.containsFormat(core)&×tamp >= core.getTickCut()) { - s += I18n.format(Lib.DESC_INFO + core.getLocalKey(), Long.toString(timestamp / core.getTickCut())); + s += I18n.format(Lib.DESC_INFO+core.getLocalKey(), Long.toString(timestamp/core.getTickCut())); timestamp %= core.getTickCut(); } if(s.isEmpty()) - for(int i = TimestampFormat.coreValues.length - 1; i >= 0; i--) + for(int i = TimestampFormat.coreValues.length-1; i >= 0; i--) if(format.containsFormat(TimestampFormat.coreValues[i])) { - s = I18n.format(Lib.DESC_INFO + TimestampFormat.coreValues[i].getLocalKey(), 0); + s = I18n.format(Lib.DESC_INFO+TimestampFormat.coreValues[i].getLocalKey(), 0); break; } return s; @@ -417,15 +418,15 @@ public static String fomatTimestamp(long timestamp, TimestampFormat format) public static int getFormattingColour(TextFormatting rarityColor) { - return rarityColor.ordinal() < 16 ? chatColours[rarityColor.ordinal()] : 0; + return rarityColor.ordinal() < 16?chatColours[rarityColor.ordinal()]: 0; } public static int getDarkenedTextColour(int colour) { - int r = (colour >> 16 & 255) / 4; - int g = (colour >> 8 & 255) / 4; - int b = (colour & 255) / 4; - return r << 16 | g << 8 | b; + int r = (colour >> 16&255)/4; + int g = (colour >> 8&255)/4; + int b = (colour&255)/4; + return r<<16|g<<8|b; } public static IETileSound generatePositionedIESound(SoundEvent soundEvent, float volume, float pitch, boolean repeat, int delay, BlockPos pos) @@ -440,7 +441,7 @@ public static ModelRenderer[] copyModelRenderers(ModelBase model, ModelRenderer. { ModelRenderer[] newRenderers = new ModelRenderer[oldRenderers.length]; for(int i = 0; i < newRenderers.length; i++) - if(oldRenderers[i] != null) + if(oldRenderers[i]!=null) { newRenderers[i] = new ModelRenderer(model, oldRenderers[i].boxName); int toX = oldRenderers[i].textureOffsetX; @@ -449,7 +450,7 @@ public static ModelRenderer[] copyModelRenderers(ModelBase model, ModelRenderer. newRenderers[i].mirror = oldRenderers[i].mirror; ArrayList newCubes = new ArrayList(); for(ModelBox cube : oldRenderers[i].cubeList) - newCubes.add(new ModelBox(newRenderers[i], toX, toY, cube.posX1, cube.posY1, cube.posZ1, (int) (cube.posX2 - cube.posX1), (int) (cube.posY2 - cube.posY1), (int) (cube.posZ2 - cube.posZ1), 0)); + newCubes.add(new ModelBox(newRenderers[i], toX, toY, cube.posX1, cube.posY1, cube.posZ1, (int)(cube.posX2-cube.posX1), (int)(cube.posY2-cube.posY1), (int)(cube.posZ2-cube.posZ1), 0)); newRenderers[i].cubeList = newCubes; newRenderers[i].setRotationPoint(oldRenderers[i].rotationPointX, oldRenderers[i].rotationPointY, oldRenderers[i].rotationPointZ); newRenderers[i].rotateAngleX = oldRenderers[i].rotateAngleX; @@ -475,17 +476,18 @@ public static void handleBipedRotations(ModelBiped model, Entity entity) ItemStack heldItem = player.getHeldItem(hand); if(!heldItem.isEmpty()) { - boolean right = (hand==EnumHand.MAIN_HAND) == (player.getPrimaryHand()==EnumHandSide.RIGHT); + boolean right = (hand==EnumHand.MAIN_HAND)==(player.getPrimaryHand()==EnumHandSide.RIGHT); if(heldItem.getItem() instanceof ItemRevolver) { if(right) { - model.bipedRightArm.rotateAngleX = -1.39626f + model.bipedHead.rotateAngleX; - model.bipedRightArm.rotateAngleY = -.08726f + model.bipedHead.rotateAngleY; - } else + model.bipedRightArm.rotateAngleX = -1.39626f+model.bipedHead.rotateAngleX; + model.bipedRightArm.rotateAngleY = -.08726f+model.bipedHead.rotateAngleY; + } + else { - model.bipedLeftArm.rotateAngleX = -1.39626f + model.bipedHead.rotateAngleX; - model.bipedLeftArm.rotateAngleY = .08726f + model.bipedHead.rotateAngleY; + model.bipedLeftArm.rotateAngleX = -1.39626f+model.bipedHead.rotateAngleX; + model.bipedLeftArm.rotateAngleY = .08726f+model.bipedHead.rotateAngleY; } } else if(heldItem.getItem() instanceof ItemDrill||heldItem.getItem() instanceof ItemChemthrower) @@ -1024,11 +1026,11 @@ else if(heldItem.getItem() instanceof ItemRailgun) //Cheers boni =P public static void drawBlockDamageTexture(Tessellator tessellatorIn, BufferBuilder worldRendererIn, Entity entityIn, float partialTicks, World world, Collection blocks) { - double d0 = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double) partialTicks; - double d1 = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double) partialTicks; - double d2 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double) partialTicks; + double d0 = entityIn.lastTickPosX+(entityIn.posX-entityIn.lastTickPosX)*(double)partialTicks; + double d1 = entityIn.lastTickPosY+(entityIn.posY-entityIn.lastTickPosY)*(double)partialTicks; + double d2 = entityIn.lastTickPosZ+(entityIn.posZ-entityIn.lastTickPosZ)*(double)partialTicks; TextureManager renderEngine = Minecraft.getMinecraft().renderEngine; - int progress = (int) (Minecraft.getMinecraft().playerController.curBlockDamageMP * 10f) - 1; // 0-10 + int progress = (int)(Minecraft.getMinecraft().playerController.curBlockDamageMP*10f)-1; // 0-10 if(progress < 0) return; renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); @@ -1047,18 +1049,18 @@ public static void drawBlockDamageTexture(Tessellator tessellatorIn, BufferBuild // worldRendererIn.markDirty(); for(BlockPos blockpos : blocks) { - double d3 = (double) blockpos.getX() - d0; - double d4 = (double) blockpos.getY() - d1; - double d5 = (double) blockpos.getZ() - d2; + double d3 = (double)blockpos.getX()-d0; + double d4 = (double)blockpos.getY()-d1; + double d5 = (double)blockpos.getZ()-d2; Block block = world.getBlockState(blockpos).getBlock(); TileEntity te = world.getTileEntity(blockpos); - boolean hasBreak = block instanceof BlockChest || block instanceof BlockEnderChest - || block instanceof BlockSign || block instanceof BlockSkull; - if(!hasBreak) hasBreak = te != null && te.canRenderBreaking(); + boolean hasBreak = block instanceof BlockChest||block instanceof BlockEnderChest + ||block instanceof BlockSign||block instanceof BlockSkull; + if(!hasBreak) hasBreak = te!=null&&te.canRenderBreaking(); if(!hasBreak) { IBlockState iblockstate = world.getBlockState(blockpos); - if(iblockstate.getMaterial() != Material.AIR) + if(iblockstate.getMaterial()!=Material.AIR) { TextureAtlasSprite textureatlassprite = destroyBlockIcons[progress]; BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher(); @@ -1088,10 +1090,10 @@ public static void drawColouredRect(int x, int y, int w, int h, int colour) Tessellator tessellator = Tessellator.getInstance(); BufferBuilder worldrenderer = tessellator.getBuffer(); worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); - worldrenderer.pos(x, y + h, 0).color(colour >> 16 & 255, colour >> 8 & 255, colour & 255, colour >> 24 & 255).endVertex(); - worldrenderer.pos(x + w, y + h, 0).color(colour >> 16 & 255, colour >> 8 & 255, colour & 255, colour >> 24 & 255).endVertex(); - worldrenderer.pos(x + w, y, 0).color(colour >> 16 & 255, colour >> 8 & 255, colour & 255, colour >> 24 & 255).endVertex(); - worldrenderer.pos(x, y, 0).color(colour >> 16 & 255, colour >> 8 & 255, colour & 255, colour >> 24 & 255).endVertex(); + worldrenderer.pos(x, y+h, 0).color(colour >> 16&255, colour >> 8&255, colour&255, colour >> 24&255).endVertex(); + worldrenderer.pos(x+w, y+h, 0).color(colour >> 16&255, colour >> 8&255, colour&255, colour >> 24&255).endVertex(); + worldrenderer.pos(x+w, y, 0).color(colour >> 16&255, colour >> 8&255, colour&255, colour >> 24&255).endVertex(); + worldrenderer.pos(x, y, 0).color(colour >> 16&255, colour >> 8&255, colour&255, colour >> 24&255).endVertex(); tessellator.draw(); GlStateManager.shadeModel(GL11.GL_FLAT); GlStateManager.disableBlend(); @@ -1101,14 +1103,14 @@ public static void drawColouredRect(int x, int y, int w, int h, int colour) public static void drawGradientRect(int x0, int y0, int x1, int y1, int colour0, int colour1) { - float f = (float) (colour0 >> 24 & 255) / 255.0F; - float f1 = (float) (colour0 >> 16 & 255) / 255.0F; - float f2 = (float) (colour0 >> 8 & 255) / 255.0F; - float f3 = (float) (colour0 & 255) / 255.0F; - float f4 = (float) (colour1 >> 24 & 255) / 255.0F; - float f5 = (float) (colour1 >> 16 & 255) / 255.0F; - float f6 = (float) (colour1 >> 8 & 255) / 255.0F; - float f7 = (float) (colour1 & 255) / 255.0F; + float f = (float)(colour0 >> 24&255)/255.0F; + float f1 = (float)(colour0 >> 16&255)/255.0F; + float f2 = (float)(colour0 >> 8&255)/255.0F; + float f3 = (float)(colour0&255)/255.0F; + float f4 = (float)(colour1 >> 24&255)/255.0F; + float f5 = (float)(colour1 >> 16&255)/255.0F; + float f6 = (float)(colour1 >> 8&255)/255.0F; + float f7 = (float)(colour1&255)/255.0F; GlStateManager.disableTexture2D(); GlStateManager.enableBlend(); GlStateManager.disableAlpha(); @@ -1133,16 +1135,16 @@ public static void drawTexturedRect(float x, float y, float w, float h, double.. Tessellator tessellator = Tessellator.getInstance(); BufferBuilder worldrenderer = tessellator.getBuffer(); worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - worldrenderer.pos(x, y + h, 0).tex(uv[0], uv[3]).endVertex(); - worldrenderer.pos(x + w, y + h, 0).tex(uv[1], uv[3]).endVertex(); - worldrenderer.pos(x + w, y, 0).tex(uv[1], uv[2]).endVertex(); + worldrenderer.pos(x, y+h, 0).tex(uv[0], uv[3]).endVertex(); + worldrenderer.pos(x+w, y+h, 0).tex(uv[1], uv[3]).endVertex(); + worldrenderer.pos(x+w, y, 0).tex(uv[1], uv[2]).endVertex(); worldrenderer.pos(x, y, 0).tex(uv[0], uv[2]).endVertex(); tessellator.draw(); } public static void drawTexturedRect(int x, int y, int w, int h, float picSize, int... uv) { - double[] d_uv = new double[]{uv[0] / picSize, uv[1] / picSize, uv[2] / picSize, uv[3] / picSize}; + double[] d_uv = new double[]{uv[0]/picSize, uv[1]/picSize, uv[2]/picSize, uv[3]/picSize}; drawTexturedRect(x, y, w, h, d_uv); } @@ -1150,74 +1152,76 @@ public static void drawRepeatedFluidSprite(FluidStack fluid, float x, float y, f { bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE.toString()); TextureAtlasSprite sprite = mc().getTextureMapBlocks().getAtlasSprite(fluid.getFluid().getStill(fluid).toString()); - if(sprite != null) + if(sprite!=null) { int col = fluid.getFluid().getColor(fluid); - GlStateManager.color((col>>16&255)/255.0f,(col>>8&255)/255.0f,(col&255)/255.0f, 1); + GlStateManager.color((col >> 16&255)/255.0f, (col >> 8&255)/255.0f, (col&255)/255.0f, 1); int iW = sprite.getIconWidth(); int iH = sprite.getIconHeight(); - if(iW > 0 && iH > 0) + if(iW > 0&&iH > 0) drawRepeatedSprite(x, y, w, h, iW, iH, sprite.getMinU(), sprite.getMaxU(), sprite.getMinV(), sprite.getMaxV()); } } public static void drawRepeatedSprite(float x, float y, float w, float h, int iconWidth, int iconHeight, float uMin, float uMax, float vMin, float vMax) { - int iterMaxW = (int) (w / iconWidth); - int iterMaxH = (int) (h / iconHeight); - float leftoverW = w % iconWidth; - float leftoverH = h % iconHeight; - float leftoverWf = leftoverW / (float) iconWidth; - float leftoverHf = leftoverH / (float) iconHeight; - float iconUDif = uMax - uMin; - float iconVDif = vMax - vMin; + int iterMaxW = (int)(w/iconWidth); + int iterMaxH = (int)(h/iconHeight); + float leftoverW = w%iconWidth; + float leftoverH = h%iconHeight; + float leftoverWf = leftoverW/(float)iconWidth; + float leftoverHf = leftoverH/(float)iconHeight; + float iconUDif = uMax-uMin; + float iconVDif = vMax-vMin; for(int ww = 0; ww < iterMaxW; ww++) { for(int hh = 0; hh < iterMaxH; hh++) - drawTexturedRect(x + ww * iconWidth, y + hh * iconHeight, iconWidth, iconHeight, uMin, uMax, vMin, vMax); - drawTexturedRect(x + ww * iconWidth, y + iterMaxH * iconHeight, iconWidth, leftoverH, uMin, uMax, vMin, (vMin + iconVDif * leftoverHf)); + drawTexturedRect(x+ww*iconWidth, y+hh*iconHeight, iconWidth, iconHeight, uMin, uMax, vMin, vMax); + drawTexturedRect(x+ww*iconWidth, y+iterMaxH*iconHeight, iconWidth, leftoverH, uMin, uMax, vMin, (vMin+iconVDif*leftoverHf)); } if(leftoverW > 0) { for(int hh = 0; hh < iterMaxH; hh++) - drawTexturedRect(x + iterMaxW * iconWidth, y + hh * iconHeight, leftoverW, iconHeight, uMin, (uMin + iconUDif * leftoverWf), vMin, vMax); - drawTexturedRect(x + iterMaxW * iconWidth, y + iterMaxH * iconHeight, leftoverW, leftoverH, uMin, (uMin + iconUDif * leftoverWf), vMin, (vMin + iconVDif * leftoverHf)); + drawTexturedRect(x+iterMaxW*iconWidth, y+hh*iconHeight, leftoverW, iconHeight, uMin, (uMin+iconUDif*leftoverWf), vMin, vMax); + drawTexturedRect(x+iterMaxW*iconWidth, y+iterMaxH*iconHeight, leftoverW, leftoverH, uMin, (uMin+iconUDif*leftoverWf), vMin, (vMin+iconVDif*leftoverHf)); } } public static void drawSlot(int x, int y, int w, int h) { - drawSlot(x,y, w,h, 0xff); + drawSlot(x, y, w, h, 0xff); } + public static void drawSlot(int x, int y, int w, int h, int alpha) { - drawColouredRect(x+8-w/2 , y+8-h/2-1, w,1, (alpha<<24)+0x373737); - drawColouredRect(x+8-w/2-1, y+8-h/2-1, 1,h+1, (alpha<<24)+0x373737); - drawColouredRect(x+8-w/2 , y+8-h/2 , w,h, (alpha<<24)+0x8b8b8b); - drawColouredRect(x+8-w/2 , y+8+h/2 , w+1,1, (alpha<<24)+0xffffff); - drawColouredRect(x+8+w/2 , y+8-h/2 , 1,h, (alpha<<24)+0xffffff); + drawColouredRect(x+8-w/2, y+8-h/2-1, w, 1, (alpha<<24)+0x373737); + drawColouredRect(x+8-w/2-1, y+8-h/2-1, 1, h+1, (alpha<<24)+0x373737); + drawColouredRect(x+8-w/2, y+8-h/2, w, h, (alpha<<24)+0x8b8b8b); + drawColouredRect(x+8-w/2, y+8+h/2, w+1, 1, (alpha<<24)+0xffffff); + drawColouredRect(x+8+w/2, y+8-h/2, 1, h, (alpha<<24)+0xffffff); } + public static void drawDarkSlot(int x, int y, int w, int h) { - drawColouredRect(x+8-w/2 , y+8-h/2-1, w,1, 0x77222222); - drawColouredRect(x+8-w/2-1, y+8-h/2-1, 1,h+1, 0x77222222); - drawColouredRect(x+8-w/2 , y+8-h/2 , w,h, 0x77111111); - drawColouredRect(x+8-w/2 , y+8+h/2 , w+1,1, 0x77999999); - drawColouredRect(x+8+w/2 , y+8-h/2 , 1,h, 0x77999999); + drawColouredRect(x+8-w/2, y+8-h/2-1, w, 1, 0x77222222); + drawColouredRect(x+8-w/2-1, y+8-h/2-1, 1, h+1, 0x77222222); + drawColouredRect(x+8-w/2, y+8-h/2, w, h, 0x77111111); + drawColouredRect(x+8-w/2, y+8+h/2, w+1, 1, 0x77999999); + drawColouredRect(x+8+w/2, y+8-h/2, 1, h, 0x77999999); } public static void renderToolTip(ItemStack stack, int x, int y) { - List list = stack.getTooltip(mc().player, mc().gameSettings.advancedItemTooltips?TooltipFlags.ADVANCED:TooltipFlags.NORMAL); + List list = stack.getTooltip(mc().player, mc().gameSettings.advancedItemTooltips?TooltipFlags.ADVANCED: TooltipFlags.NORMAL); for(int k = 0; k < list.size(); ++k) - if(k == 0) - list.set(k, stack.getRarity().rarityColor + (String) list.get(k)); + if(k==0) + list.set(k, stack.getRarity().rarityColor+(String)list.get(k)); else - list.set(k, TextFormatting.GRAY + (String) list.get(k)); + list.set(k, TextFormatting.GRAY+(String)list.get(k)); FontRenderer font = stack.getItem().getFontRenderer(stack); - drawHoveringText(list, x, y, (font == null ? font() : font)); + drawHoveringText(list, x, y, (font==null?font(): font)); } public static void drawHoveringText(List list, int x, int y, FontRenderer font) @@ -1246,31 +1250,31 @@ public static void drawHoveringText(List list, int x, int y, FontRendere k = l; } - int j2 = x + 12; - int k2 = y - 12; + int j2 = x+12; + int k2 = y-12; int i1 = 8; boolean shift = false; - if(xSize > 0 && j2 + k > xSize) + if(xSize > 0&&j2+k > xSize) { - j2 -= 28 + k; + j2 -= 28+k; shift = true; } - if(ySize > 0 && k2 + i1 + 6 > ySize) + if(ySize > 0&&k2+i1+6 > ySize) { - k2 = ySize - i1 - 6; + k2 = ySize-i1-6; shift = true; } - if(!shift && mc().currentScreen != null) + if(!shift&&mc().currentScreen!=null) { - if(j2 + k > mc().currentScreen.width) - j2 -= 28 + k; - if(k2 + i1 + 6 > mc().currentScreen.height) - k2 = mc().currentScreen.height - i1 - 6; + if(j2+k > mc().currentScreen.width) + j2 -= 28+k; + if(k2+i1+6 > mc().currentScreen.height) + k2 = mc().currentScreen.height-i1-6; } if(list.size() > 1) - i1 += 2 + (list.size() - 1) * 10; + i1 += 2+(list.size()-1)*10; // this.zLevel = 300.0F; // this.itemRender.zLevel = 300.0F; // int l = -267386864; @@ -1287,17 +1291,17 @@ public static void drawHoveringText(List list, int x, int y, FontRendere // this.drawGradientRect(l1 - 3, i2 + k + 2, l1 + i + 3, i2 + k + 3, j1, j1); GlStateManager.translate(0, 0, 300); int j1 = -267386864; - drawGradientRect(j2 - 3, k2 - 4, j2 + k + 3, k2 - 3, j1, j1); - drawGradientRect(j2 - 3, k2 + i1 + 3, j2 + k + 3, k2 + i1 + 4, j1, j1); - drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 + i1 + 3, j1, j1); - drawGradientRect(j2 - 4, k2 - 3, j2 - 3, k2 + i1 + 3, j1, j1); - drawGradientRect(j2 + k + 3, k2 - 3, j2 + k + 4, k2 + i1 + 3, j1, j1); + drawGradientRect(j2-3, k2-4, j2+k+3, k2-3, j1, j1); + drawGradientRect(j2-3, k2+i1+3, j2+k+3, k2+i1+4, j1, j1); + drawGradientRect(j2-3, k2-3, j2+k+3, k2+i1+3, j1, j1); + drawGradientRect(j2-4, k2-3, j2-3, k2+i1+3, j1, j1); + drawGradientRect(j2+k+3, k2-3, j2+k+4, k2+i1+3, j1, j1); int k1 = 1347420415; - int l1 = ((k1 & 16711422) >> 1 | k1 & -16777216); - drawGradientRect(j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + i1 + 3 - 1, k1, l1); - drawGradientRect(j2 + k + 2, k2 - 3 + 1, j2 + k + 3, k2 + i1 + 3 - 1, k1, l1); - drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 - 3 + 1, k1, k1); - drawGradientRect(j2 - 3, k2 + i1 + 2, j2 + k + 3, k2 + i1 + 3, l1, l1); + int l1 = ((k1&16711422) >> 1|k1&-16777216); + drawGradientRect(j2-3, k2-3+1, j2-3+1, k2+i1+3-1, k1, l1); + drawGradientRect(j2+k+2, k2-3+1, j2+k+3, k2+i1+3-1, k1, l1); + drawGradientRect(j2-3, k2-3, j2+k+3, k2-3+1, k1, k1); + drawGradientRect(j2-3, k2+i1+2, j2+k+3, k2+i1+3, l1, l1); GlStateManager.translate(0, 0, -300); for(int i2 = 0; i2 < list.size(); ++i2) @@ -1305,7 +1309,7 @@ public static void drawHoveringText(List list, int x, int y, FontRendere String s1 = list.get(i2); font.drawStringWithShadow(s1, j2, k2, -1); - if(i2 == 0) + if(i2==0) k2 += 2; k2 += 10; @@ -1322,38 +1326,41 @@ public static void drawHoveringText(List list, int x, int y, FontRendere public static void handleGuiTank(IFluidTank tank, int x, int y, int w, int h, int oX, int oY, int oW, int oH, int mX, int mY, String originalTexture, ArrayList tooltip) { - handleGuiTank(tank.getFluid(), tank.getCapacity(), x,y,w,h, oX,oY,oW,oH, mX,mY, originalTexture, tooltip); + handleGuiTank(tank.getFluid(), tank.getCapacity(), x, y, w, h, oX, oY, oW, oH, mX, mY, originalTexture, tooltip); } + public static void handleGuiTank(FluidStack fluid, int capacity, int x, int y, int w, int h, int oX, int oY, int oW, int oH, int mX, int mY, String originalTexture, ArrayList tooltip) { - if(tooltip == null) + if(tooltip==null) { - if(fluid!=null && fluid.getFluid()!=null) + if(fluid!=null&&fluid.getFluid()!=null) { - int fluidHeight = (int) (h * (fluid.amount / (float) capacity)); - drawRepeatedFluidSprite(fluid, x, y + h - fluidHeight, w, fluidHeight); + int fluidHeight = (int)(h*(fluid.amount/(float)capacity)); + drawRepeatedFluidSprite(fluid, x, y+h-fluidHeight, w, fluidHeight); bindTexture(originalTexture); - GlStateManager.color(1,1,1,1); + GlStateManager.color(1, 1, 1, 1); } - int xOff = (w - oW) / 2; - int yOff = (h - oH) / 2; - drawTexturedRect(x + xOff, y + yOff, oW, oH, 256f, oX, oX + oW, oY, oY + oH); - } else + int xOff = (w-oW)/2; + int yOff = (h-oH)/2; + drawTexturedRect(x+xOff, y+yOff, oW, oH, 256f, oX, oX+oW, oY, oY+oH); + } + else { - if(mX >= x && mX < x + w && mY >= y && mY < y + h) + if(mX >= x&&mX < x+w&&mY >= y&&mY < y+h) addFluidTooltip(fluid, tooltip, capacity); } } + public static void addFluidTooltip(FluidStack fluid, List tooltip, int tankCapacity) { - if(fluid!=null && fluid.getFluid()!=null) + if(fluid!=null&&fluid.getFluid()!=null) tooltip.add(fluid.getFluid().getRarity(fluid).rarityColor+fluid.getLocalizedName()); else tooltip.add(I18n.format("gui.immersiveengineering.empty")); - if(fluid!=null && fluid.getFluid() instanceof IEFluid) + if(fluid!=null&&fluid.getFluid() instanceof IEFluid) ((IEFluid)fluid.getFluid()).addTooltipInfo(fluid, null, tooltip); - if(mc().gameSettings.advancedItemTooltips && fluid!=null) + if(mc().gameSettings.advancedItemTooltips&&fluid!=null) if(!GuiScreen.isShiftKeyDown()) tooltip.add(I18n.format(Lib.DESC_INFO+"holdShiftForInfo")); else @@ -1365,10 +1372,10 @@ public static void addFluidTooltip(FluidStack fluid, List tooltip, int t tooltip.add(TextFormatting.DARK_GRAY+"NBT Data: "+fluid.tag); } - if(tankCapacity>0) - tooltip.add(TextFormatting.GRAY.toString()+(fluid!=null?fluid.amount:0)+"/"+tankCapacity+"mB"); + if(tankCapacity > 0) + tooltip.add(TextFormatting.GRAY.toString()+(fluid!=null?fluid.amount: 0)+"/"+tankCapacity+"mB"); else - tooltip.add(TextFormatting.GRAY.toString()+(fluid!=null?fluid.amount:0)+"mB"); + tooltip.add(TextFormatting.GRAY.toString()+(fluid!=null?fluid.amount: 0)+"mB"); } public static Quat4d degreeToQuaterion(double x, double y, double z) @@ -1376,9 +1383,9 @@ public static Quat4d degreeToQuaterion(double x, double y, double z) x = Math.toRadians(x); y = Math.toRadians(y); z = Math.toRadians(z); - Quat4d qYaw = new Quat4d(0, Math.sin(y / 2), 0, Math.cos(y / 2)); - Quat4d qPitch = new Quat4d(Math.sin(x / 2), 0, 0, Math.cos(x / 2)); - Quat4d qRoll = new Quat4d(0, 0, Math.sin(z / 2), Math.cos(z / 2)); + Quat4d qYaw = new Quat4d(0, Math.sin(y/2), 0, Math.cos(y/2)); + Quat4d qPitch = new Quat4d(Math.sin(x/2), 0, 0, Math.cos(x/2)); + Quat4d qRoll = new Quat4d(0, 0, Math.sin(z/2), Math.cos(z/2)); Quat4d quat = qYaw; quat.mul(qRoll); @@ -1389,13 +1396,14 @@ public static Quat4d degreeToQuaterion(double x, double y, double z) private static final Vector3f fadingOffset = new Vector3f(.0001F, .0001F, .0001F); private static float[] alphaFirst2Fading = {0, 0, 1, 1}; private static float[] alphaNoFading = {1, 1, 1, 1}; + public static List[] convertConnectionFromBlockstate(IExtendedBlockState s, TextureAtlasSprite t) { List[] ret = new List[2]; ret[0] = new ArrayList<>(); ret[1] = new ArrayList<>(); Set conns = s.getValue(IEProperties.CONNECTIONS); - if(conns == null) + if(conns==null) return ret; Vector3f dir = new Vector3f(); Vector3f cross = new Vector3f(); @@ -1404,66 +1412,68 @@ public static List[] convertConnectionFromBlockstate(IExtendedBlockSt BlockPos pos = null; for(Connection conn : conns) { - if (pos==null) + if(pos==null) pos = conn.start; Vec3d[] f = conn.catenaryVertices; if(f==null||f.length < 1) continue; int color = conn.cableType.getColour(conn); - float[] rgb = {(color >> 16 & 255) / 255f, (color >> 8 & 255) / 255f, (color & 255) / 255f, (color >> 24 & 255) / 255f}; - if (rgb[3]==0) + float[] rgb = {(color >> 16&255)/255f, (color >> 8&255)/255f, (color&255)/255f, (color >> 24&255)/255f}; + if(rgb[3]==0) rgb[3] = 1; - float radius = (float) (conn.cableType.getRenderDiameter() / 2); + float radius = (float)(conn.cableType.getRenderDiameter()/2); List crossings = new ArrayList<>(); - for (int i = 1;i0; - if (crossings.size()%2==0&&greater) + boolean greater = conn.start.compareTo(conn.end) > 0; + if(crossings.size()%2==0&&greater) index--; - int max = (crossings.size()>0? - (crossings.get(index)+(greater?1:2)): - (greater?f.length+1:0)); - for (int i = 1; i < max&&i 0? + (crossings.get(index)+(greater?1: 2)): + (greater?f.length+1: 0)); + for(int i = 1; i < max&&i < f.length; i++) { boolean fading = i==max-1; - List curr = ret[fading?1:0]; - int j = i - 1; - Vector3f here = new Vector3f((float) f[i].x, (float) f[i].y, (float) f[i].z); - Vector3f there = new Vector3f((float) f[j].x, (float) f[j].y, (float) f[j].z); - if (fading) + List curr = ret[fading?1: 0]; + int j = i-1; + Vector3f here = new Vector3f((float)f[i].x, (float)f[i].y, (float)f[i].z); + Vector3f there = new Vector3f((float)f[j].x, (float)f[j].y, (float)f[j].z); + if(fading) { Vector3f.add(here, fadingOffset, here); Vector3f.add(there, fadingOffset, there); } - boolean vertical = here.x == there.x && here.z == there.z; + boolean vertical = here.x==there.x&&here.z==there.z; if(!vertical) { Vector3f.sub(here, there, dir); Vector3f.cross(up, dir, cross); - cross.scale(radius / cross.length()); - } else + cross.scale(radius/cross.length()); + } + else cross.set(radius, 0, 0); Vector3f[] vertices = {Vector3f.add(here, cross, null), Vector3f.sub(here, cross, null), Vector3f.sub(there, cross, null), Vector3f.add(there, cross, null)}; - curr.add(createSmartLightingBakedQuad(DefaultVertexFormats.ITEM, vertices, EnumFacing.DOWN, t, rgb, false, fading?alphaFirst2Fading:alphaNoFading, pos)); - curr.add(createSmartLightingBakedQuad(DefaultVertexFormats.ITEM, vertices, EnumFacing.UP, t, rgb, true, fading?alphaFirst2Fading:alphaNoFading, pos)); + curr.add(createSmartLightingBakedQuad(DefaultVertexFormats.ITEM, vertices, EnumFacing.DOWN, t, rgb, false, fading?alphaFirst2Fading: alphaNoFading, pos)); + curr.add(createSmartLightingBakedQuad(DefaultVertexFormats.ITEM, vertices, EnumFacing.UP, t, rgb, true, fading?alphaFirst2Fading: alphaNoFading, pos)); if(!vertical) { Vector3f.cross(cross, dir, cross); - cross.scale(radius / cross.length()); - } else + cross.scale(radius/cross.length()); + } + else cross.set(0, 0, radius); vertices = new Vector3f[]{Vector3f.add(here, cross, null), Vector3f.sub(here, cross, null), Vector3f.sub(there, cross, null), Vector3f.add(there, cross, null)}; - curr.add(createSmartLightingBakedQuad(DefaultVertexFormats.ITEM, vertices, EnumFacing.WEST, t, rgb, false, fading?alphaFirst2Fading:alphaNoFading, pos)); - curr.add(createSmartLightingBakedQuad(DefaultVertexFormats.ITEM, vertices, EnumFacing.EAST, t, rgb, true, fading?alphaFirst2Fading:alphaNoFading, pos)); + curr.add(createSmartLightingBakedQuad(DefaultVertexFormats.ITEM, vertices, EnumFacing.WEST, t, rgb, false, fading?alphaFirst2Fading: alphaNoFading, pos)); + curr.add(createSmartLightingBakedQuad(DefaultVertexFormats.ITEM, vertices, EnumFacing.EAST, t, rgb, true, fading?alphaFirst2Fading: alphaNoFading, pos)); } } return ret; @@ -1472,19 +1482,19 @@ public static List[] convertConnectionFromBlockstate(IExtendedBlockSt private static void storeVertexData(int[] faceData, int storeIndex, Vector3f position, TextureAtlasSprite t, int u, int v, int color) { - int i = storeIndex * 7; + int i = storeIndex*7; faceData[i] = Float.floatToRawIntBits(position.x); - faceData[i + 1] = Float.floatToRawIntBits(position.y); - faceData[i + 2] = Float.floatToRawIntBits(position.z); - faceData[i + 3] = invertRgb(color); - faceData[i + 4] = Float.floatToRawIntBits(t.getInterpolatedU(u)); - faceData[i + 5] = Float.floatToRawIntBits(t.getInterpolatedV(v)); + faceData[i+1] = Float.floatToRawIntBits(position.y); + faceData[i+2] = Float.floatToRawIntBits(position.z); + faceData[i+3] = invertRgb(color); + faceData[i+4] = Float.floatToRawIntBits(t.getInterpolatedU(u)); + faceData[i+5] = Float.floatToRawIntBits(t.getInterpolatedV(v)); } public static Vector3f[] applyMatrixToVertices(Matrix4 matrix, Vector3f... vertices) { if(matrix==null) - return vertices; + return vertices; Vector3f[] ret = new Vector3f[vertices.length]; for(int i = 0; i < ret.length; i++) ret[i] = matrix.apply(vertices[i]); @@ -1495,49 +1505,51 @@ public static Set createBakedBox(Vector3f from, Vector3f to, Matrix4 { return createBakedBox(from, to, matrix, EnumFacing.NORTH, textureGetter, colour); } + public static Set createBakedBox(Vector3f from, Vector3f to, Matrix4 matrix, EnumFacing facing, Function textureGetter, float[] colour) { - return createBakedBox(from, to, matrix, facing, vertices->vertices, textureGetter, colour); + return createBakedBox(from, to, matrix, facing, vertices -> vertices, textureGetter, colour); } + @Nonnull - public static Set createBakedBox(Vector3f from, Vector3f to, Matrix4 matrix, EnumFacing facing, Function vertexTransformer, Function textureGetter, float[] colour) + public static Set createBakedBox(Vector3f from, Vector3f to, Matrix4 matrix, EnumFacing facing, Function vertexTransformer, Function textureGetter, float[] colour) { HashSet quads = new HashSet<>(); if(vertexTransformer==null) - vertexTransformer = v->v; + vertexTransformer = v -> v; - Vector3f[] vertices = {new Vector3f(from.x,from.y,from.z),new Vector3f(from.x,from.y,to.z),new Vector3f(to.x,from.y,to.z),new Vector3f(to.x,from.y,from.z)}; + Vector3f[] vertices = {new Vector3f(from.x, from.y, from.z), new Vector3f(from.x, from.y, to.z), new Vector3f(to.x, from.y, to.z), new Vector3f(to.x, from.y, from.z)}; TextureAtlasSprite sprite = textureGetter.apply(EnumFacing.DOWN); if(sprite!=null) - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertexTransformer.apply(vertices)), Utils.rotateFacingTowardsDir(EnumFacing.DOWN,facing), sprite, new double[]{from.x*16, 16-from.z*16, to.x*16, 16-to.z*16}, colour, true)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertexTransformer.apply(vertices)), Utils.rotateFacingTowardsDir(EnumFacing.DOWN, facing), sprite, new double[]{from.x*16, 16-from.z*16, to.x*16, 16-to.z*16}, colour, true)); for(Vector3f v : vertices) v.setY(to.y); sprite = textureGetter.apply(EnumFacing.UP); if(sprite!=null) - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertexTransformer.apply(vertices)), Utils.rotateFacingTowardsDir(EnumFacing.UP,facing), sprite, new double[]{from.x*16, from.z*16, to.x*16, to.z*16}, colour, false)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertexTransformer.apply(vertices)), Utils.rotateFacingTowardsDir(EnumFacing.UP, facing), sprite, new double[]{from.x*16, from.z*16, to.x*16, to.z*16}, colour, false)); - vertices = new Vector3f[]{new Vector3f(to.x,to.y,from.z),new Vector3f(to.x,from.y,from.z),new Vector3f(from.x,from.y,from.z),new Vector3f(from.x,to.y,from.z)}; + vertices = new Vector3f[]{new Vector3f(to.x, to.y, from.z), new Vector3f(to.x, from.y, from.z), new Vector3f(from.x, from.y, from.z), new Vector3f(from.x, to.y, from.z)}; sprite = textureGetter.apply(EnumFacing.NORTH); if(sprite!=null) - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertexTransformer.apply(vertices)), Utils.rotateFacingTowardsDir(EnumFacing.NORTH,facing), sprite, new double[]{from.x*16, 16-to.y*16, to.x*16, 16-from.y*16}, colour, false)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertexTransformer.apply(vertices)), Utils.rotateFacingTowardsDir(EnumFacing.NORTH, facing), sprite, new double[]{from.x*16, 16-to.y*16, to.x*16, 16-from.y*16}, colour, false)); for(Vector3f v : vertices) v.setZ(to.z); sprite = textureGetter.apply(EnumFacing.SOUTH); if(sprite!=null) - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertexTransformer.apply(vertices)), Utils.rotateFacingTowardsDir(EnumFacing.SOUTH,facing), sprite, new double[]{to.x*16, 16-to.y*16, from.x*16, 16-from.y*16}, colour, true)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertexTransformer.apply(vertices)), Utils.rotateFacingTowardsDir(EnumFacing.SOUTH, facing), sprite, new double[]{to.x*16, 16-to.y*16, from.x*16, 16-from.y*16}, colour, true)); - vertices = new Vector3f[]{new Vector3f(from.x,to.y,to.z),new Vector3f(from.x,from.y,to.z),new Vector3f(from.x,from.y,from.z),new Vector3f(from.x,to.y,from.z)}; + vertices = new Vector3f[]{new Vector3f(from.x, to.y, to.z), new Vector3f(from.x, from.y, to.z), new Vector3f(from.x, from.y, from.z), new Vector3f(from.x, to.y, from.z)}; sprite = textureGetter.apply(EnumFacing.WEST); if(sprite!=null) - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertexTransformer.apply(vertices)), Utils.rotateFacingTowardsDir(EnumFacing.WEST,facing), sprite, new double[]{to.z*16, 16-to.y*16, from.z*16, 16-from.y*16}, colour, true)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertexTransformer.apply(vertices)), Utils.rotateFacingTowardsDir(EnumFacing.WEST, facing), sprite, new double[]{to.z*16, 16-to.y*16, from.z*16, 16-from.y*16}, colour, true)); for(Vector3f v : vertices) v.setX(to.x); sprite = textureGetter.apply(EnumFacing.EAST); if(sprite!=null) - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertexTransformer.apply(vertices)), Utils.rotateFacingTowardsDir(EnumFacing.EAST,facing), sprite, new double[]{16-to.z*16, 16-to.y*16, 16-from.z*16, 16-from.y*16}, colour, false)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertexTransformer.apply(vertices)), Utils.rotateFacingTowardsDir(EnumFacing.EAST, facing), sprite, new double[]{16-to.z*16, 16-to.y*16, 16-from.z*16, 16-from.y*16}, colour, false)); return quads; } @@ -1568,20 +1580,20 @@ public static BakedQuad createBakedQuad(VertexFormat format, Vector3f[] vertices builder.setQuadOrientation(facing); builder.setTexture(sprite); Normal faceNormal = new Normal(facing.getDirectionVec().getX(), facing.getDirectionVec().getY(), facing.getDirectionVec().getZ()); - int vId = invert ? 3 : 0; - int u = vId>1?2:0; - putVertexData(format, builder, vertices[vId], faceNormal, uvs[u], uvs[1], sprite, colour, alpha[invert ? 3 : 0]); - vId = invert ? 2 : 1; - u = vId>1?2:0; - putVertexData(format, builder, vertices[invert ? 2 : 1], faceNormal, uvs[u], uvs[3], sprite, colour, alpha[invert ? 2 : 1]); - vId = invert ? 1 : 2; - u = vId>1?2:0; - putVertexData(format, builder, vertices[invert ? 1 : 2], faceNormal, uvs[u], uvs[3], sprite, colour, alpha[invert ? 1 : 2]); - vId = invert ? 1 : 3; - u = vId>1?2:0; - putVertexData(format, builder, vertices[invert ? 0 : 3], faceNormal, uvs[u], uvs[1], sprite, colour, alpha[invert ? 0 : 3]); + int vId = invert?3: 0; + int u = vId > 1?2: 0; + putVertexData(format, builder, vertices[vId], faceNormal, uvs[u], uvs[1], sprite, colour, alpha[invert?3: 0]); + vId = invert?2: 1; + u = vId > 1?2: 0; + putVertexData(format, builder, vertices[invert?2: 1], faceNormal, uvs[u], uvs[3], sprite, colour, alpha[invert?2: 1]); + vId = invert?1: 2; + u = vId > 1?2: 0; + putVertexData(format, builder, vertices[invert?1: 2], faceNormal, uvs[u], uvs[3], sprite, colour, alpha[invert?1: 2]); + vId = invert?1: 3; + u = vId > 1?2: 0; + putVertexData(format, builder, vertices[invert?0: 3], faceNormal, uvs[u], uvs[1], sprite, colour, alpha[invert?0: 3]); BakedQuad tmp = builder.build(); - return smartLighting?new SmartLightingQuad(tmp.getVertexData(), -1, facing, sprite, format, basePos):tmp; + return smartLighting?new SmartLightingQuad(tmp.getVertexData(), -1, facing, sprite, format, basePos): tmp; } protected static void putVertexData(VertexFormat format, UnpackedBakedQuad.Builder builder, Vector3f pos, Normal faceNormal, double u, double v, TextureAtlasSprite sprite, float[] colour, float alpha) @@ -1594,10 +1606,10 @@ protected static void putVertexData(VertexFormat format, UnpackedBakedQuad.Build break; case COLOR: float d = 1;//LightUtil.diffuseLight(faceNormal.x, faceNormal.y, faceNormal.z); - builder.put(e, d * colour[0], d * colour[1], d * colour[2], 1 * colour[3]*alpha); + builder.put(e, d*colour[0], d*colour[1], d*colour[2], 1*colour[3]*alpha); break; case UV: - if(sprite == null)//Double Safety. I have no idea how it even happens, but it somehow did .-. + if(sprite==null)//Double Safety. I have no idea how it even happens, but it somehow did .-. sprite = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite(); builder.put(e, sprite.getInterpolatedU(u), @@ -1611,17 +1623,19 @@ protected static void putVertexData(VertexFormat format, UnpackedBakedQuad.Build builder.put(e); } } + public static boolean crossesChunkBoundary(Vec3d start, Vec3d end, BlockPos offset) { - if (crossesChunkBorderSingleDim(start.x, end.x, offset.getX())) + if(crossesChunkBorderSingleDim(start.x, end.x, offset.getX())) return true; - if (crossesChunkBorderSingleDim(start.y, end.y, offset.getY())) + if(crossesChunkBorderSingleDim(start.y, end.y, offset.getY())) return true; return crossesChunkBorderSingleDim(start.z, end.z, offset.getZ()); } - private static boolean crossesChunkBorderSingleDim(double a, double b, int offset) { - return ((int)Math.floor(a+offset))>>4!=((int)Math.floor(b+offset))>>4; + private static boolean crossesChunkBorderSingleDim(double a, double b, int offset) + { + return ((int)Math.floor(a+offset)) >> 4!=((int)Math.floor(b+offset)) >> 4; } public static void renderQuads(Collection quads, float brightness, float red, float green, float blue) @@ -1633,7 +1647,7 @@ public static void renderQuads(Collection quads, float brightness, fl BufferBuilder.begin(7, DefaultVertexFormats.ITEM); BufferBuilder.addVertexData(bakedquad.getVertexData()); if(bakedquad.hasTintIndex()) - BufferBuilder.putColorRGB_F4(red * brightness, green * brightness, blue * brightness); + BufferBuilder.putColorRGB_F4(red*brightness, green*brightness, blue*brightness); else BufferBuilder.putColorRGB_F4(brightness, brightness, brightness); Vec3i vec3i = bakedquad.getFace().getDirectionVec(); @@ -1644,30 +1658,31 @@ public static void renderQuads(Collection quads, float brightness, fl public static ResourceLocation getSideTexture(@Nonnull ItemStack stack, EnumFacing side) { - IBakedModel model = mc().getRenderItem().getItemModelWithOverrides(stack, null,null); + IBakedModel model = mc().getRenderItem().getItemModelWithOverrides(stack, null, null); List quads = model.getQuads(null, side, 0); - if(quads==null || quads.isEmpty())//no quads for the specified side D: + if(quads==null||quads.isEmpty())//no quads for the specified side D: quads = model.getQuads(null, null, 0); - if(quads==null || quads.isEmpty())//no quads at all D: + if(quads==null||quads.isEmpty())//no quads at all D: return null; return new ResourceLocation(quads.get(0).getSprite().getIconName()); } + public static ResourceLocation getSideTexture(@Nonnull IBlockState state, EnumFacing side) { IBakedModel model = mc().getBlockRendererDispatcher().getModelForState(state); List quads = model.getQuads(state, side, 0); - if(quads==null || quads.isEmpty())//no quads for the specified side D: + if(quads==null||quads.isEmpty())//no quads for the specified side D: quads = model.getQuads(state, null, 0); - if(quads==null || quads.isEmpty())//no quads at all D: + if(quads==null||quads.isEmpty())//no quads at all D: return null; return new ResourceLocation(quads.get(0).getSprite().getIconName()); } private static int invertRgb(int in) { - int ret = in & (255 << 8); - ret += (in >> 16) & 255; - ret += (in & 255) << 16; + int ret = in&(255<<8); + ret += (in >> 16)&255; + ret += (in&255)<<16; return ret; } @@ -1679,6 +1694,7 @@ public static int pulseRGBAlpha(int rgb, int tickrate, float min, float max) return changeRGBAlpha(rgb, MathHelper.clamp(f_alpha, min, max)); } + public static int changeRGBAlpha(int rgb, float alpha) { return (rgb&0x00ffffff)|((int)(alpha*255)<<24); @@ -1721,10 +1737,11 @@ public static void renderTexturedBox(BufferBuilder wr, double x0, double y0, dou { float minU = tex.getInterpolatedU(x0*16); float maxU = tex.getInterpolatedU(x1*16); - float minV = tex.getInterpolatedV((yForV?y1:z0)*16); - float maxV = tex.getInterpolatedV((yForV?y0:z1)*16); + float minV = tex.getInterpolatedV((yForV?y1: z0)*16); + float maxV = tex.getInterpolatedV((yForV?y0: z1)*16); renderTexturedBox(wr, x0, y0, z0, x1, y1, z1, minU, minV, maxU, maxV); } + public static void renderTexturedBox(BufferBuilder wr, double x0, double y0, double z0, double x1, double y1, double z1, double u0, double v0, double u1, double v1) { wr.pos(x0, y0, z1).tex(u0, v0).endVertex(); @@ -1759,6 +1776,7 @@ public static void renderTexturedBox(BufferBuilder wr, double x0, double y0, dou wr.pos(x1, y0, z1).tex(u1, v1).endVertex(); wr.pos(x1, y0, z0).tex(u0, v1).endVertex(); } + public static int intFromRgb(float[] rgb) { int ret = (int)(255*rgb[0]); @@ -1785,129 +1803,135 @@ public static int intFromRgb(float[] rgb) /** * Renders the given quads. Uses the local and neighbour brightnesses to calculate lighting - * @param quads the quads to render - * @param renderer the BufferBuilder to render to - * @param world the world the model is in. Will be used to obtain lighting information - * @param pos the position that this model is in. Use the position the the quads are actually in, not the rendering block + * + * @param quads the quads to render + * @param renderer the BufferBuilder to render to + * @param world the world the model is in. Will be used to obtain lighting information + * @param pos the position that this model is in. Use the position the the quads are actually in, not the rendering block * @param useCached Whether to use cached information for world local data. Set to true if the previous call to this method was in the same tick and for the same world+pos */ public static void renderModelTESRFancy(List quads, BufferBuilder renderer, World world, BlockPos pos, boolean useCached) {//TODO include matrix transformations?, cache normals? - if (Config.IEConfig.disableFancyTESR) + if(Config.IEConfig.disableFancyTESR) renderModelTESRFast(quads, renderer, world, pos); else { - if (!useCached) + if(!useCached) { // Calculate surrounding brighness and split into block and sky light - for (EnumFacing f : EnumFacing.VALUES) + for(EnumFacing f : EnumFacing.VALUES) { int val = world.getCombinedLight(pos.offset(f), 0); - neighbourBrightness[0][f.getIndex()] = (val >> 16) & 255; - neighbourBrightness[1][f.getIndex()] = val & 255; + neighbourBrightness[0][f.getIndex()] = (val >> 16)&255; + neighbourBrightness[1][f.getIndex()] = val&255; } // calculate the different correction factors for all 8 possible light vectors - for (int type = 0; type < 2; type++) - for (int i = 0; i < 8; i++) + for(int type = 0; type < 2; type++) + for(int i = 0; i < 8; i++) { float sSquared = 0; - if ((i & 1) != 0) + if((i&1)!=0) sSquared += scaledSquared(neighbourBrightness[type][5], 255F); else sSquared += scaledSquared(neighbourBrightness[type][4], 255F); - if ((i & 2) != 0) + if((i&2)!=0) sSquared += scaledSquared(neighbourBrightness[type][1], 255F); else sSquared += scaledSquared(neighbourBrightness[type][0], 255F); - if ((i & 4) != 0) + if((i&4)!=0) sSquared += scaledSquared(neighbourBrightness[type][3], 255F); else sSquared += scaledSquared(neighbourBrightness[type][2], 255F); - normalizationFactors[type][i] = (float) Math.sqrt(sSquared); + normalizationFactors[type][i] = (float)Math.sqrt(sSquared); } } int localBrightness = world.getCombinedLight(pos, 0); - for (BakedQuad quad : quads) + for(BakedQuad quad : quads) { int[] vData = quad.getVertexData(); VertexFormat format = quad.getFormat(); int size = format.getIntegerSize(); - int uv = format.getUvOffsetById(0) / 4; + int uv = format.getUvOffsetById(0)/4; // extract position info from the quad - for (int i = 0; i < 4; i++) + for(int i = 0; i < 4; i++) { - quadCoords[i][0] = Float.intBitsToFloat(vData[size * i]); - quadCoords[i][1] = Float.intBitsToFloat(vData[size * i + 1]); - quadCoords[i][2] = Float.intBitsToFloat(vData[size * i + 2]); + quadCoords[i][0] = Float.intBitsToFloat(vData[size*i]); + quadCoords[i][1] = Float.intBitsToFloat(vData[size*i+1]); + quadCoords[i][2] = Float.intBitsToFloat(vData[size*i+2]); } //generate the normal vector - side1.x = quadCoords[1][0] - quadCoords[3][0]; - side1.y = quadCoords[1][1] - quadCoords[3][1]; - side1.z = quadCoords[1][2] - quadCoords[3][2]; - side2.x = quadCoords[2][0] - quadCoords[0][0]; - side2.y = quadCoords[2][1] - quadCoords[0][1]; - side2.z = quadCoords[2][2] - quadCoords[0][2]; + side1.x = quadCoords[1][0]-quadCoords[3][0]; + side1.y = quadCoords[1][1]-quadCoords[3][1]; + side1.z = quadCoords[1][2]-quadCoords[3][2]; + side2.x = quadCoords[2][0]-quadCoords[0][0]; + side2.y = quadCoords[2][1]-quadCoords[0][1]; + side2.z = quadCoords[2][2]-quadCoords[0][2]; Vector3f.cross(side1, side2, normal); normal.normalise(); // calculate the final light values and do the rendering - int l1 = getLightValue(neighbourBrightness[0], normalizationFactors[0], (localBrightness >> 16) & 255); - int l2 = getLightValue(neighbourBrightness[1], normalizationFactors[1], localBrightness & 255); - for (int i = 0; i < 4; ++i) + int l1 = getLightValue(neighbourBrightness[0], normalizationFactors[0], (localBrightness >> 16)&255); + int l2 = getLightValue(neighbourBrightness[1], normalizationFactors[1], localBrightness&255); + for(int i = 0; i < 4; ++i) { renderer .pos(quadCoords[i][0], quadCoords[i][1], quadCoords[i][2]) .color(255, 255, 255, 255) - .tex(Float.intBitsToFloat(vData[size * i + uv]), Float.intBitsToFloat(vData[size * i + uv + 1])) + .tex(Float.intBitsToFloat(vData[size*i+uv]), Float.intBitsToFloat(vData[size*i+uv+1])) .lightmap(l1, l2) .endVertex(); } } } } - private static int getLightValue(int[] neighbourBrightness, float[] normalizationFactors, int localBrightness) { + + private static int getLightValue(int[] neighbourBrightness, float[] normalizationFactors, int localBrightness) + { //calculate the dot product between the required light vector and the normal of the quad // quad brightness is proportional to this value, see https://github.com/ssloy/tinyrenderer/wiki/Lesson-2:-Triangle-rasterization-and-back-face-culling#flat-shading-render float sideBrightness; byte type = 0; - if (normal.x>0) + if(normal.x > 0) { - sideBrightness = normal.x* neighbourBrightness[5]; + sideBrightness = normal.x*neighbourBrightness[5]; type |= 1; } else - sideBrightness = -normal.x* neighbourBrightness[4]; - if (normal.y>0) + sideBrightness = -normal.x*neighbourBrightness[4]; + if(normal.y > 0) { - sideBrightness += normal.y* neighbourBrightness[1]; + sideBrightness += normal.y*neighbourBrightness[1]; type |= 2; } else - sideBrightness += -normal.y* neighbourBrightness[0]; - if (normal.z>0) + sideBrightness += -normal.y*neighbourBrightness[0]; + if(normal.z > 0) { - sideBrightness += normal.z* neighbourBrightness[3]; + sideBrightness += normal.z*neighbourBrightness[3]; type |= 4; } else - sideBrightness += -normal.z* neighbourBrightness[2]; + sideBrightness += -normal.z*neighbourBrightness[2]; // the final light value is the aritmethic mean of the local brighness and the normalized "dot-product-brightness" - return (int) ((localBrightness+sideBrightness/normalizationFactors[type])/2); + return (int)((localBrightness+sideBrightness/normalizationFactors[type])/2); } - private static float scaledSquared(int val, float scale) { + + private static float scaledSquared(int val, float scale) + { return (val/scale)*(val/scale); } + public static void renderModelTESRFast(List quads, BufferBuilder renderer, World world, BlockPos pos) { int brightness = world.getCombinedLight(pos, 0); - int l1 = (brightness >> 0x10) & 0xFFFF; - int l2 = brightness & 0xFFFF; - for (BakedQuad quad : quads) + int l1 = (brightness >> 0x10)&0xFFFF; + int l2 = brightness&0xFFFF; + for(BakedQuad quad : quads) { int[] vData = quad.getVertexData(); VertexFormat format = quad.getFormat(); int size = format.getIntegerSize(); int uv = format.getUvOffsetById(0)/4; - for (int i = 0; i < 4; ++i) + for(int i = 0; i < 4; ++i) { renderer .pos(Float.intBitsToFloat(vData[size*i]), @@ -1927,7 +1951,7 @@ public static void setLightmapDisabled(boolean disabled) { GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit); - if (disabled) + if(disabled) { GlStateManager.disableTexture2D(); } @@ -1940,20 +1964,21 @@ public static void setLightmapDisabled(boolean disabled) } private static Optional lightmapState; + public static void toggleLightmap(boolean pre, boolean disabled) { GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit); if(pre) { lightmapState = Optional.of(GL11.glIsEnabled(GL11.GL_TEXTURE_2D)); - if (disabled) + if(disabled) GlStateManager.disableTexture2D(); else GlStateManager.enableTexture2D(); } else if(lightmapState.isPresent()) { - if (lightmapState.get()) + if(lightmapState.get()) GlStateManager.enableTexture2D(); else GlStateManager.disableTexture2D(); diff --git a/src/main/java/blusunrize/immersiveengineering/client/IECustomStateMapper.java b/src/main/java/blusunrize/immersiveengineering/client/IECustomStateMapper.java index 036fb1aba7..a987b11e64 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/IECustomStateMapper.java +++ b/src/main/java/blusunrize/immersiveengineering/client/IECustomStateMapper.java @@ -20,6 +20,7 @@ public class IECustomStateMapper extends StateMapperBase { public static HashMap stateMappers = new HashMap<>(); + public static StateMapperBase getStateMapper(IIEMetaBlock metaBlock) { String key = metaBlock.getIEBlockName(); @@ -37,15 +38,16 @@ public static StateMapperBase getStateMapper(IIEMetaBlock metaBlock) @Override protected ModelResourceLocation getModelResourceLocation(IBlockState state) { - try{ + try + { ResourceLocation rl = Block.REGISTRY.getNameForObject(state.getBlock()); IIEMetaBlock metaBlock = (IIEMetaBlock)state.getBlock(); String custom = metaBlock.getCustomStateMapping(state.getBlock().getMetaFromState(state), false); if(custom!=null) rl = new ResourceLocation(rl.toString()+"_"+custom); - String prop = metaBlock.appendPropertiesToState()?this.getPropertyString(state.getProperties()):null; + String prop = metaBlock.appendPropertiesToState()?this.getPropertyString(state.getProperties()): null; return new ModelResourceLocation(rl, prop); - }catch(Exception e) + } catch(Exception e) { e.printStackTrace(); ResourceLocation rl = Block.REGISTRY.getNameForObject(state.getBlock()); diff --git a/src/main/java/blusunrize/immersiveengineering/client/IEDefaultColourHandlers.java b/src/main/java/blusunrize/immersiveengineering/client/IEDefaultColourHandlers.java index d12c3ff9a2..8618eaacf0 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/IEDefaultColourHandlers.java +++ b/src/main/java/blusunrize/immersiveengineering/client/IEDefaultColourHandlers.java @@ -33,6 +33,7 @@ public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @N return ((IColouredBlock)state.getBlock()).getRenderColour(state, worldIn, pos, tintIndex); return 0xffffff; } + @Override public int colorMultiplier(ItemStack stack, int tintIndex) { diff --git a/src/main/java/blusunrize/immersiveengineering/client/IEItemFontRender.java b/src/main/java/blusunrize/immersiveengineering/client/IEItemFontRender.java index a2ae61be9e..bec6fddebc 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/IEItemFontRender.java +++ b/src/main/java/blusunrize/immersiveengineering/client/IEItemFontRender.java @@ -26,7 +26,7 @@ public class IEItemFontRender extends FontRenderer static { - unicodeReplacements.put((char) Integer.parseInt("260E", 16), new CharReplacement("immersiveengineering:textures/gui/hud_elements.png", .5f, .75f, .5625f, .8125f)); + unicodeReplacements.put((char)Integer.parseInt("260E", 16), new CharReplacement("immersiveengineering:textures/gui/hud_elements.png", .5f, .75f, .5625f, .8125f)); } int[] backupColours; @@ -38,7 +38,7 @@ public class IEItemFontRender extends FontRenderer public IEItemFontRender() { super(ClientUtils.mc().gameSettings, new ResourceLocation("textures/font/ascii.png"), ClientUtils.mc().renderEngine, false); - if (Minecraft.getMinecraft().gameSettings.language != null) + if(Minecraft.getMinecraft().gameSettings.language!=null) { this.setUnicodeFlag(ClientUtils.mc().getLanguageManager().isCurrentLocaleUnicode()); this.setBidiFlag(ClientUtils.mc().getLanguageManager().isCurrentLanguageBidirectional()); @@ -47,7 +47,9 @@ public IEItemFontRender() createColourBackup(); } - /** This should be called again if the colour array was modified after instantiation*/ + /** + * This should be called again if the colour array was modified after instantiation + */ public void createColourBackup() { this.backupColours = Arrays.copyOf(this.colorCode, 32); @@ -59,34 +61,37 @@ public void renderStringAtPos(String text, boolean shadow) int idx = -1; int loop = 0; HashMap formattingReplacements = new HashMap(); - while((idx=text.indexOf("=0 && loop++<20) + while((idx = text.indexOf("= 0&&loop++ < 20) { - int end = text.indexOf(">",idx); - if(end>=0) + int end = text.indexOf(">", idx); + if(end >= 0) { String rep = "ERROR"; String s = text.substring(idx, end+1); int formatEnd = s.indexOf(":"); - if(formatEnd>=0) + if(formatEnd >= 0) { rep = s.substring(formatEnd+1, s.length()-1); String hex = s.substring("0) + if(flag&&k > 0) ++i; } return (int)i; } } + @Override public int sizeStringToWidth(String str, int wrapWidth) { @@ -179,7 +188,7 @@ public int sizeStringToWidth(String str, int wrapWidth) int k = 0; int l = -1; - for(boolean flag = false; k= 48 && c1 <= 57 || c1 >= 97 && c1 <= 102 || c1 >= 65 && c1 <= 70)) + if(c1==114||c1==82||(c1 >= 48&&c1 <= 57||c1 >= 97&&c1 <= 102||c1 >= 65&&c1 <= 70)) flag = false; - } else + } + else flag = true; } } - if(c0 == 10) + if(c0==10) { ++k; l = k; break; } - if(j>wrapWidth) + if(j > wrapWidth) break; } - return k!=i && l!=-1 && l?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(ic); - if(ic>0 && i!=-1 && !this.getUnicodeFlag()) + if(ic > 0&&i!=-1&&!this.getUnicodeFlag()) return 10; - else if (this.glyphWidth[ic] != 0) + else if(this.glyphWidth[ic]!=0) return 6; else return 0; @@ -78,10 +78,10 @@ else if (this.glyphWidth[ic] != 0) @Override protected void setColor(float r, float g, float b, float a) { - this.c_red=r; - this.c_green=g; - this.c_blue=b; - this.c_alpha=a; + this.c_red = r; + this.c_green = g; + this.c_blue = b; + this.c_alpha = a; GlStateManager.color(r, g, b, a); } @@ -92,7 +92,7 @@ protected float renderDefaultChar(int ic, boolean italic) GlStateManager.tryBlendFuncSeparate(SRC_ALPHA, ONE_MINUS_SRC_ALPHA, ZERO, ONE); bindTexture(this.locationFontTexture); - float italicOffset = italic ? 1.0F : 0.0F; + float italicOffset = italic?1.0F: 0.0F; Tessellator tes = Tessellator.getInstance(); BufferBuilder bb = tes.getBuffer(); @@ -110,7 +110,7 @@ protected float renderDefaultChar(int ic, boolean italic) this.posX -= .5f; this.posY -= .5f; - if (this.drawTube) + if(this.drawTube) drawTube(bb, tes, italicOffset); GlStateManager.color(c_red, c_green, c_blue, c_alpha); @@ -154,7 +154,7 @@ protected float renderUnicodeChar(char ic, boolean italic) OpenGlHelper.glBlendFunc(770, 771, 0, 1); bindTexture(this.locationFontTexture); - float italicOffset = italic ? 1.0F : 0.0F; + float italicOffset = italic?1.0F: 0.0F; Tessellator tes = Tessellator.getInstance(); BufferBuilder bb = tes.getBuffer(); @@ -162,19 +162,19 @@ protected float renderUnicodeChar(char ic, boolean italic) super.renderUnicodeChar(ic, italic); - GlStateManager.color(c_red*.875f,c_green*.875f,c_blue*.875f,c_alpha*.375f); - this.posX-=.5f; - this.posY-=.5f; + GlStateManager.color(c_red*.875f, c_green*.875f, c_blue*.875f, c_alpha*.375f); + this.posX -= .5f; + this.posY -= .5f; super.renderUnicodeChar(ic, italic); - this.posX+=1; - this.posY+=1; + this.posX += 1; + this.posY += 1; super.renderUnicodeChar(ic, italic); - this.posX-=.5f; - this.posY-=.5f; + this.posX -= .5f; + this.posY -= .5f; if(this.drawTube) drawTube(bb, tes, italicOffset); - GlStateManager.color(c_red,c_green,c_blue,c_alpha); + GlStateManager.color(c_red, c_green, c_blue, c_alpha); return 6; } diff --git a/src/main/java/blusunrize/immersiveengineering/client/ImmersiveModelRegistry.java b/src/main/java/blusunrize/immersiveengineering/client/ImmersiveModelRegistry.java index b21f43ffb7..590fd16eed 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/ImmersiveModelRegistry.java +++ b/src/main/java/blusunrize/immersiveengineering/client/ImmersiveModelRegistry.java @@ -55,7 +55,7 @@ public void onModelBakeEvent(ModelBakeEvent event) for(Map.Entry entry : itemModelReplacements.entrySet()) { IBakedModel object = event.getModelRegistry().getObject(entry.getKey()); - if(object != null) + if(object!=null) { try { @@ -84,10 +84,10 @@ public void registerCustomItemModel(ItemStack stack, ItemModelReplacement replac if(stack.getItem() instanceof ItemIEBase) { ResourceLocation loc; - if(((ItemIEBase) stack.getItem()).getSubNames() != null && ((ItemIEBase) stack.getItem()).getSubNames().length > 0) - loc = new ResourceLocation("immersiveengineering", ((ItemIEBase) stack.getItem()).itemName + "/" + ((ItemIEBase) stack.getItem()).getSubNames()[stack.getMetadata()]); + if(((ItemIEBase)stack.getItem()).getSubNames()!=null&&((ItemIEBase)stack.getItem()).getSubNames().length > 0) + loc = new ResourceLocation("immersiveengineering", ((ItemIEBase)stack.getItem()).itemName+"/"+((ItemIEBase)stack.getItem()).getSubNames()[stack.getMetadata()]); else - loc = new ResourceLocation("immersiveengineering", ((ItemIEBase) stack.getItem()).itemName); + loc = new ResourceLocation("immersiveengineering", ((ItemIEBase)stack.getItem()).itemName); itemModelReplacements.put(new ModelResourceLocation(loc, "inventory"), replacement); } } @@ -132,8 +132,8 @@ public TextureAtlasSprite apply(ResourceLocation location) } }; ResourceLocation modelLocation = new ResourceLocation(objPath); - OBJModel objModel = (OBJModel) OBJLoader.INSTANCE.loadModel(modelLocation); - objModel = (OBJModel) objModel.process(flipData); + OBJModel objModel = (OBJModel)OBJLoader.INSTANCE.loadModel(modelLocation); + objModel = (OBJModel)objModel.process(flipData); ImmutableMap.Builder builder = ImmutableMap.builder(); builder.put(ModelLoader.White.LOCATION.toString(), ModelLoader.White.INSTANCE); TextureAtlasSprite missing = textureGetter.apply(new ResourceLocation("missingno")); @@ -143,7 +143,8 @@ public TextureAtlasSprite apply(ResourceLocation location) IELogger.error("OBJLoader: Unresolved texture '{}' for obj model '{}'", objModel.getMatLib().getMaterial(s).getTexture().getTextureLocation().getResourcePath(), modelLocation); builder.put(s, missing); - } else + } + else builder.put(s, textureGetter.apply(objModel.getMatLib().getMaterial(s).getTexture().getTextureLocation())); return new IESmartObjModel(existingModel, objModel, new OBJModel.OBJState(Lists.newArrayList(OBJModel.Group.ALL), true), diff --git a/src/main/java/blusunrize/immersiveengineering/client/ShaderHelper.java b/src/main/java/blusunrize/immersiveengineering/client/ShaderHelper.java index cc7ae445a4..3c2dee51a7 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/ShaderHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/client/ShaderHelper.java @@ -21,35 +21,41 @@ public class ShaderHelper private static final int FRAG = ARBFragmentShader.GL_FRAGMENT_SHADER_ARB; private static final String PREFIX = "/assets/immersiveengineering/shader/"; - public static void initShaders() { + public static void initShaders() + { if(!useShaders()) return; } - public static void useShader(int shader, IntConsumer callback) { + public static void useShader(int shader, IntConsumer callback) + { if(!useShaders()) return; ARBShaderObjects.glUseProgramObjectARB(shader); - if(shader != 0) { + if(shader!=0) + { int time = ARBShaderObjects.glGetUniformLocationARB(shader, "time"); ARBShaderObjects.glUniform1iARB(time, ClientUtils.mc().player.ticksExisted); - if(callback != null) + if(callback!=null) callback.accept(shader); } } - public static void useShader(int shader) { + public static void useShader(int shader) + { useShader(shader, null); } - public static void releaseShader() { + public static void releaseShader() + { useShader(0); } - public static boolean useShaders() { + public static boolean useShaders() + { // TEMA: here's where you'd stick in any config option for enabling/disabling the shaders... don't know how it would interact with the shader mod, etc. //return ConfigHandler.useShaders && OpenGlHelper.shadersSupported; @@ -59,30 +65,33 @@ public static boolean useShaders() { // Most of the code taken from the LWJGL wiki // http://lwjgl.org/wiki/index.php?title=GLSL_Shaders_with_LWJGL - private static int createProgram(String vert, String frag) { + private static int createProgram(String vert, String frag) + { int vertId = 0, fragId = 0, program = 0; - if(vert != null) - vertId = createShader(PREFIX + vert, VERT); - if(frag != null) - fragId = createShader(PREFIX + frag, FRAG); + if(vert!=null) + vertId = createShader(PREFIX+vert, VERT); + if(frag!=null) + fragId = createShader(PREFIX+frag, FRAG); program = ARBShaderObjects.glCreateProgramObjectARB(); - if(program == 0) + if(program==0) return 0; - if(vert != null) + if(vert!=null) ARBShaderObjects.glAttachObjectARB(program, vertId); - if(frag != null) + if(frag!=null) ARBShaderObjects.glAttachObjectARB(program, fragId); ARBShaderObjects.glLinkProgramARB(program); - if(ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE) { + if(ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB)==GL11.GL_FALSE) + { IELogger.error(getLogInfo(program)); return 0; } ARBShaderObjects.glValidateProgramARB(program); - if (ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB) == GL11.GL_FALSE) { + if(ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB)==GL11.GL_FALSE) + { IELogger.error(getLogInfo(program)); return 0; } @@ -90,76 +99,90 @@ private static int createProgram(String vert, String frag) { return program; } - private static int createShader(String filename, int shaderType){ + private static int createShader(String filename, int shaderType) + { int shader = 0; - try { + try + { shader = ARBShaderObjects.glCreateShaderObjectARB(shaderType); - if(shader == 0) + if(shader==0) return 0; ARBShaderObjects.glShaderSourceARB(shader, readFileAsString(filename)); ARBShaderObjects.glCompileShaderARB(shader); - if (ARBShaderObjects.glGetObjectParameteriARB(shader, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE) - throw new RuntimeException("Error creating shader: " + getLogInfo(shader)); + if(ARBShaderObjects.glGetObjectParameteriARB(shader, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB)==GL11.GL_FALSE) + throw new RuntimeException("Error creating shader: "+getLogInfo(shader)); return shader; - } - catch(Exception e) { + } catch(Exception e) + { ARBShaderObjects.glDeleteObjectARB(shader); e.printStackTrace(); return -1; } } - private static String getLogInfo(int obj) { + private static String getLogInfo(int obj) + { return ARBShaderObjects.glGetInfoLogARB(obj, ARBShaderObjects.glGetObjectParameteriARB(obj, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB)); } - private static String readFileAsString(String filename) throws Exception { + private static String readFileAsString(String filename) throws Exception + { StringBuilder source = new StringBuilder(); InputStream in = ShaderHelper.class.getResourceAsStream(filename); Exception exception = null; BufferedReader reader; - if(in == null) + if(in==null) return ""; - try { + try + { reader = new BufferedReader(new InputStreamReader(in, "UTF-8")); - Exception innerExc= null; - try { + Exception innerExc = null; + try + { String line; - while((line = reader.readLine()) != null) + while((line = reader.readLine())!=null) source.append(line).append('\n'); - } catch(Exception exc) { + } catch(Exception exc) + { exception = exc; - } finally { - try { + } finally + { + try + { reader.close(); - } catch(Exception exc) { - if(innerExc == null) + } catch(Exception exc) + { + if(innerExc==null) innerExc = exc; else exc.printStackTrace(); } } - if(innerExc != null) + if(innerExc!=null) throw innerExc; - } catch(Exception exc) { + } catch(Exception exc) + { exception = exc; - } finally { - try { + } finally + { + try + { in.close(); - } catch(Exception exc) { - if(exception == null) + } catch(Exception exc) + { + if(exception==null) exception = exc; else exc.printStackTrace(); } - if(exception != null) + if(exception!=null) throw exception; } diff --git a/src/main/java/blusunrize/immersiveengineering/client/fx/ParticleFluidSplash.java b/src/main/java/blusunrize/immersiveengineering/client/fx/ParticleFluidSplash.java index 62ae9fcfa4..5b89e0cd69 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/fx/ParticleFluidSplash.java +++ b/src/main/java/blusunrize/immersiveengineering/client/fx/ParticleFluidSplash.java @@ -33,14 +33,14 @@ public ParticleFluidSplash(World worldIn, double xCoordIn, double yCoordIn, doub super(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn); this.motionX *= 0.30000001192092896D; - this.motionY = Math.random() * 0.20000000298023224D + 0.10000000149011612D; + this.motionY = Math.random()*0.20000000298023224D+0.10000000149011612D; this.motionZ *= 0.30000001192092896D; this.particleRed = 1.0F; this.particleGreen = 1.0F; this.particleBlue = 1.0F; this.setSize(0.01F, 0.01F); this.particleGravity = 0.06F; - this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); + this.particleMaxAge = (int)(8.0D/(Math.random()*0.8D+0.2D)); this.particleScale = .375f; this.setParticleTexture(ClientUtils.getSprite(FluidRegistry.WATER.getStill())); } @@ -60,7 +60,7 @@ public void onUpdate() if(this.particleMaxAge-- <= 0) this.setExpired(); - if (this.onGround) + if(this.onGround) { if(Math.random() < 0.5D) this.setExpired(); @@ -72,14 +72,14 @@ public void onUpdate() IBlockState iblockstate = this.world.getBlockState(blockpos); Material material = iblockstate.getMaterial(); - if(material.isLiquid() || material.isSolid()) + if(material.isLiquid()||material.isSolid()) { double d0; if(iblockstate.getBlock() instanceof BlockLiquid) - d0 = (double)(1.0F - BlockLiquid.getLiquidHeightPercent(iblockstate.getValue(BlockLiquid.LEVEL).intValue())); + d0 = (double)(1.0F-BlockLiquid.getLiquidHeightPercent(iblockstate.getValue(BlockLiquid.LEVEL).intValue())); else d0 = iblockstate.getBoundingBox(this.world, blockpos).maxY; - double d1 = (double)MathHelper.floor(this.posY) + d0; + double d1 = (double)MathHelper.floor(this.posY)+d0; if(this.posY < d1) this.setExpired(); } @@ -89,9 +89,9 @@ public void setFluidTexture(FluidStack fluid) { this.setParticleTexture(ClientUtils.getSprite(fluid.getFluid().getStill(fluid))); int argb = fluid.getFluid().getColor(fluid); - this.particleAlpha = ((argb>>24)&255)/255f; - this.particleRed = ((argb>>16)&255)/255f; - this.particleRed = ((argb>>8&255))/255f; + this.particleAlpha = ((argb >> 24)&255)/255f; + this.particleRed = ((argb >> 16)&255)/255f; + this.particleRed = ((argb >> 8&255))/255f; this.particleRed = (argb&255)/255f; } diff --git a/src/main/java/blusunrize/immersiveengineering/client/fx/ParticleFractal.java b/src/main/java/blusunrize/immersiveengineering/client/fx/ParticleFractal.java index 2e870a0514..987a0f4a68 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/fx/ParticleFractal.java +++ b/src/main/java/blusunrize/immersiveengineering/client/fx/ParticleFractal.java @@ -25,8 +25,8 @@ public class ParticleFractal extends Particle public static final Deque PARTICLE_FRACTAL_DEQUE = new ArrayDeque<>(); public static final float[][] COLOUR_RED = {{.79f, .31f, .31f, .5f}, {1, .97f, .87f, .75f}}; - public static final float[][] COLOUR_ORANGE = {{Lib.COLOUR_F_ImmersiveOrange[0],Lib.COLOUR_F_ImmersiveOrange[1],Lib.COLOUR_F_ImmersiveOrange[2], .5f}, {1, .97f, .87f, .75f}}; - public static final float[][] COLOUR_LIGHTNING = {{77/255f,74/255f,152/255f, .75f}, {1, 1, 1, 1}}; + public static final float[][] COLOUR_ORANGE = {{Lib.COLOUR_F_ImmersiveOrange[0], Lib.COLOUR_F_ImmersiveOrange[1], Lib.COLOUR_F_ImmersiveOrange[2], .5f}, {1, .97f, .87f, .75f}}; + public static final float[][] COLOUR_LIGHTNING = {{77/255f, 74/255f, 152/255f, .75f}, {1, 1, 1, 1}}; private Vec3d[] pointsList; private float[] colourOut; diff --git a/src/main/java/blusunrize/immersiveengineering/client/fx/ParticleSparks.java b/src/main/java/blusunrize/immersiveengineering/client/fx/ParticleSparks.java index 41babf0dcd..ebfb08cfe4 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/fx/ParticleSparks.java +++ b/src/main/java/blusunrize/immersiveengineering/client/fx/ParticleSparks.java @@ -11,9 +11,6 @@ import blusunrize.immersiveengineering.common.util.Utils; import net.minecraft.client.particle.Particle; import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.Entity; import net.minecraft.world.World; @@ -21,7 +18,7 @@ public class ParticleSparks extends Particle { public ParticleSparks(World world, double x, double y, double z, double mx, double my, double mz) { - super(world, x,y,z, mx,my,mz); + super(world, x, y, z, mx, my, mz); this.particleMaxAge = 16; this.posX = x; this.posY = y; @@ -39,11 +36,10 @@ public int getBrightnessForRender(float p_70070_1_) } - @Override public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) { - this.setRBGColorF(1, .2f+(16-particleAge)/16f, this.particleAge>4?0: (4-particleAge)/4f); + this.setRBGColorF(1, .2f+(16-particleAge)/16f, this.particleAge > 4?0: (4-particleAge)/4f); super.renderParticle(buffer, entityIn, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiAlloySmelter.java b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiAlloySmelter.java index e308648a9b..fcc9725a96 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiAlloySmelter.java +++ b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiAlloySmelter.java @@ -17,29 +17,30 @@ public class GuiAlloySmelter extends GuiIEContainerBase { TileEntityAlloySmelter tile; + public GuiAlloySmelter(InventoryPlayer inventoryPlayer, TileEntityAlloySmelter tile) { super(new ContainerAlloySmelter(inventoryPlayer, tile)); - this.tile=tile; + this.tile = tile; } - + @Override protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); ClientUtils.bindTexture("immersiveengineering:textures/gui/alloy_smelter.png"); - this.drawTexturedModalRect(guiLeft,guiTop, 0, 0, xSize, ySize); + this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - if(tile.lastBurnTime>0) + if(tile.lastBurnTime > 0) { int h = (int)(12*(tile.burnTime/(float)tile.lastBurnTime)); - this.drawTexturedModalRect(guiLeft+56,guiTop+37+12-h, 179, 1+12-h, 9, h); + this.drawTexturedModalRect(guiLeft+56, guiTop+37+12-h, 179, 1+12-h, 9, h); } - if(tile.processMax>0) + if(tile.processMax > 0) { - int w = (int)(22*( (tile.processMax-tile.process)/(float)tile.processMax)); - this.drawTexturedModalRect(guiLeft+84,guiTop+35, 177, 14, w, 16); + int w = (int)(22*((tile.processMax-tile.process)/(float)tile.processMax)); + this.drawTexturedModalRect(guiLeft+84, guiTop+35, 177, 14, w, 16); } } } diff --git a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiArcFurnace.java b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiArcFurnace.java index 42fc7d1475..15cc8ea8ca 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiArcFurnace.java +++ b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiArcFurnace.java @@ -22,23 +22,25 @@ public class GuiArcFurnace extends GuiIEContainerBase { TileEntityArcFurnace tile; + public GuiArcFurnace(InventoryPlayer inventoryPlayer, TileEntityArcFurnace tile) { super(new ContainerArcFurnace(inventoryPlayer, tile)); - this.ySize=207; - this.tile=tile; + this.ySize = 207; + this.tile = tile; } + @Override public void drawScreen(int mx, int my, float partial) { super.drawScreen(mx, my, partial); ArrayList tooltip = new ArrayList(); - if(mx>guiLeft+157&&mxguiTop+22&&my guiLeft+157&&mx < guiLeft+164&&my > guiTop+22&&my < guiTop+68) tooltip.add(tile.getEnergyStored(null)+"/"+tile.getMaxEnergyStored(null)+" RF"); if(!tooltip.isEmpty()) { - ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer, guiLeft+xSize,-1); + ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer, guiLeft+xSize, -1); RenderHelper.enableGUIStandardItemLighting(); } } @@ -47,18 +49,18 @@ public void drawScreen(int mx, int my, float partial) @Override protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) { - GlStateManager.color(1,1,1,1); + GlStateManager.color(1, 1, 1, 1); ClientUtils.bindTexture("immersiveengineering:textures/gui/arc_furnace.png"); - this.drawTexturedModalRect(guiLeft,guiTop, 0, 0, xSize, ySize); + this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); for(MultiblockProcess process : tile.processQueue) if(process instanceof MultiblockProcessInMachine) - { - float mod = process.processTick/(float)process.maxTicks; - int slot = ((MultiblockProcessInMachine)process).getInputSlots()[0]; - int h = (int)Math.max(1, mod*16); - this.drawTexturedModalRect(guiLeft+27+slot%3*21,guiTop+34+slot/3*18+(16-h), 176,16-h, 2,h); - } + { + float mod = process.processTick/(float)process.maxTicks; + int slot = ((MultiblockProcessInMachine)process).getInputSlots()[0]; + int h = (int)Math.max(1, mod*16); + this.drawTexturedModalRect(guiLeft+27+slot%3*21, guiTop+34+slot/3*18+(16-h), 176, 16-h, 2, h); + } // for(int i=0; i<12; i++) // if(tile.process[i]>0 && tile.processMax[i]>0) // { @@ -68,6 +70,6 @@ protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) // } int stored = (int)(46*(tile.getEnergyStored(null)/(float)tile.getMaxEnergyStored(null))); - ClientUtils.drawGradientRect(guiLeft+157,guiTop+22+(46-stored), guiLeft+164,guiTop+68, 0xffb51500, 0xff600b00); + ClientUtils.drawGradientRect(guiLeft+157, guiTop+22+(46-stored), guiLeft+164, guiTop+68, 0xffb51500, 0xff600b00); } } diff --git a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiAssembler.java b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiAssembler.java index 08390dbcad..afdcc0fd1b 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiAssembler.java +++ b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiAssembler.java @@ -33,10 +33,11 @@ public class GuiAssembler extends GuiIEContainerBase { static final String texture = "immersiveengineering:textures/gui/assembler.png"; public TileEntityAssembler tile; + public GuiAssembler(InventoryPlayer inventoryPlayer, TileEntityAssembler tile) { super(new ContainerAssembler(inventoryPlayer, tile)); - this.tile=tile; + this.tile = tile; this.xSize = 230; this.ySize = 218; } @@ -49,11 +50,12 @@ public void initGui() // "\u2716" super.initGui(); this.buttonList.clear(); - this.buttonList.add(new GuiButtonIE(0, guiLeft+ 11,guiTop+67, 10,10, null, texture,230,50).setHoverOffset(0,10)); - this.buttonList.add(new GuiButtonIE(1, guiLeft+ 69,guiTop+67, 10,10, null, texture,230,50).setHoverOffset(0,10)); - this.buttonList.add(new GuiButtonIE(2, guiLeft+127,guiTop+67, 10,10, null, texture,230,50).setHoverOffset(0,10)); - this.buttonList.add(new GuiButtonState(3, guiLeft+162,guiTop+69, 16,16, null, tile.recursiveIngredients, texture,240,66,3)); + this.buttonList.add(new GuiButtonIE(0, guiLeft+11, guiTop+67, 10, 10, null, texture, 230, 50).setHoverOffset(0, 10)); + this.buttonList.add(new GuiButtonIE(1, guiLeft+69, guiTop+67, 10, 10, null, texture, 230, 50).setHoverOffset(0, 10)); + this.buttonList.add(new GuiButtonIE(2, guiLeft+127, guiTop+67, 10, 10, null, texture, 230, 50).setHoverOffset(0, 10)); + this.buttonList.add(new GuiButtonState(3, guiLeft+162, guiTop+69, 16, 16, null, tile.recursiveIngredients, texture, 240, 66, 3)); } + @Override protected void actionPerformed(GuiButton button) { @@ -72,31 +74,31 @@ public void drawScreen(int mx, int my, float partial) { super.drawScreen(mx, my, partial); ArrayList tooltip = new ArrayList(); - if(mx>=guiLeft+187&&mx=guiTop+12&&my= guiLeft+187&&mx < guiLeft+194&&my >= guiTop+12&&my < guiTop+59) tooltip.add(tile.getEnergyStored(null)+"/"+tile.getMaxEnergyStored(null)+" RF"); - ClientUtils.handleGuiTank(tile.tanks[0], guiLeft+204,guiTop+13,16,46, 250,0,20,50, mx,my, texture,tooltip); - ClientUtils.handleGuiTank(tile.tanks[1], guiLeft+182,guiTop+70,16,46, 250,0,20,50, mx,my, texture,tooltip); - ClientUtils.handleGuiTank(tile.tanks[2], guiLeft+204,guiTop+70,16,46, 250,0,20,50, mx,my, texture,tooltip); + ClientUtils.handleGuiTank(tile.tanks[0], guiLeft+204, guiTop+13, 16, 46, 250, 0, 20, 50, mx, my, texture, tooltip); + ClientUtils.handleGuiTank(tile.tanks[1], guiLeft+182, guiTop+70, 16, 46, 250, 0, 20, 50, mx, my, texture, tooltip); + ClientUtils.handleGuiTank(tile.tanks[2], guiLeft+204, guiTop+70, 16, 46, 250, 0, 20, 50, mx, my, texture, tooltip); - for(int i=0; i=guiLeft+27+i*58&&mx=guiTop+64&&my= guiLeft+27+i*58&&mx < guiLeft+43+i*58&&my >= guiTop+64&&my < guiTop+80) { tooltip.add(tile.patterns[i].inv.get(9).getDisplayName()); tile.patterns[i].inv.get(9).getItem().addInformation(tile.patterns[i].inv.get(9), ClientUtils.mc().world, tooltip, TooltipFlags.NORMAL); - for(int j=0; j=guiLeft+11&&mx=guiLeft+69&&mx=guiLeft+127&&mxguiTop+67&&my= guiLeft+11&&mx < guiLeft+21)||(mx >= guiLeft+69&&mx < guiLeft+79)||(mx >= guiLeft+127&&mx < guiLeft+137))&&my > guiTop+67&&my < guiTop+77) tooltip.add(I18n.format(Lib.GUI_CONFIG+"assembler.clearRecipe")); - if(mx>=guiLeft+162&&mxguiTop+69&&my= guiLeft+162&&mx < guiLeft+178&&my > guiTop+69&&my < guiTop+85) + tooltip.add(I18n.format(Lib.GUI_CONFIG+"assembler."+(tile.recursiveIngredients?"recursiveIngredients": "nonRecursiveIngredients"))); if(!tooltip.isEmpty()) { - ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer, xSize,-1); + ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer, xSize, -1); RenderHelper.enableGUIStandardItemLighting(); } @@ -107,17 +109,17 @@ protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); ClientUtils.bindTexture(texture); - this.drawTexturedModalRect(guiLeft,guiTop, 0, 0, xSize, ySize); + this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); int stored = (int)(46*(tile.getEnergyStored(null)/(float)tile.getMaxEnergyStored(null))); - ClientUtils.drawGradientRect(guiLeft+187,guiTop+13+(46-stored), guiLeft+194,guiTop+59, 0xffb51500, 0xff600b00); + ClientUtils.drawGradientRect(guiLeft+187, guiTop+13+(46-stored), guiLeft+194, guiTop+59, 0xffb51500, 0xff600b00); - ClientUtils.handleGuiTank(tile.tanks[0], guiLeft+204,guiTop+13,16,46, 230,0,20,50, mx,my, texture,null); - ClientUtils.handleGuiTank(tile.tanks[1], guiLeft+182,guiTop+70,16,46, 230,0,20,50, mx,my, texture,null); - ClientUtils.handleGuiTank(tile.tanks[2], guiLeft+204,guiTop+70,16,46, 230,0,20,50, mx,my, texture,null); + ClientUtils.handleGuiTank(tile.tanks[0], guiLeft+204, guiTop+13, 16, 46, 230, 0, 20, 50, mx, my, texture, null); + ClientUtils.handleGuiTank(tile.tanks[1], guiLeft+182, guiTop+70, 16, 46, 230, 0, 20, 50, mx, my, texture, null); + ClientUtils.handleGuiTank(tile.tanks[2], guiLeft+204, guiTop+70, 16, 46, 230, 0, 20, 50, mx, my, texture, null); - for(int i=0; i0) + BlueprintCraftingRecipe[] recipes = BlueprintCraftingRecipe.findRecipes(ItemNBTHelper.getString(s.getStack(), "blueprint")); + if(recipes!=null&&recipes.length > 0) { int l = recipes.length; int xx = guiLeft+121; - int yy = guiTop+(l>6?59-(l-3)/3*18: l>3?59: 68); - for(int i=0; i 6?59-(l-3)/3*18: l > 3?59: 68); + for(int i = 0; i < l; i++) + if(recipes[i]!=null&&!recipes[i].output.isEmpty()) { - this.buttonList.add(new GuiButtonItem(i, xx+(i%3)*18,yy+(i/3)*18, recipes[i].output.copy(), i==tile.selectedRecipe)); + this.buttonList.add(new GuiButtonItem(i, xx+(i%3)*18, yy+(i/3)*18, recipes[i].output.copy(), i==tile.selectedRecipe)); } } // ItemStack stack = s.getStack(); @@ -80,13 +81,14 @@ protected void actionPerformed(GuiButton button) else tile.selectedRecipe = button.id; NBTTagCompound message = new NBTTagCompound(); - message.setInteger("recipe",tile.selectedRecipe); + message.setInteger("recipe", tile.selectedRecipe); ImmersiveEngineering.packetHandler.sendToServer(new MessageTileSync(this.tile, message)); initGui(); } } NBTTagCompound lastMessage; + @Override protected void mouseReleased(int mouseX, int mouseY, int state) { @@ -120,12 +122,12 @@ public void drawScreen(int mx, int my, float partial) super.drawScreen(mx, my, partial); ArrayList tooltip = new ArrayList(); - if(mx>guiLeft+80&&mxguiTop+36&&my guiLeft+80&&mx < guiLeft+87&&my > guiTop+36&&my < guiTop+82) tooltip.add(tile.getEnergyStored(null)+"/"+tile.getMaxEnergyStored(null)+" RF"); if(!tooltip.isEmpty()) { - ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer, guiLeft+xSize,-1); + ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer, guiLeft+xSize, -1); RenderHelper.enableGUIStandardItemLighting(); } } @@ -136,10 +138,10 @@ protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); ClientUtils.bindTexture("immersiveengineering:textures/gui/auto_workbench.png"); - this.drawTexturedModalRect(guiLeft,guiTop, 0, 0, xSize, ySize); + this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); int stored = (int)(46*(tile.getEnergyStored(null)/(float)tile.getMaxEnergyStored(null))); - ClientUtils.drawGradientRect(guiLeft+80,guiTop+36+(46-stored), guiLeft+87,guiTop+82, 0xffb51500, 0xff600b00); + ClientUtils.drawGradientRect(guiLeft+80, guiTop+36+(46-stored), guiLeft+87, guiTop+82, 0xffb51500, 0xff600b00); // for(int i=0; i<((ContainerAutoWorkbench)inventorySlots).slotCount; i++) // { diff --git a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiBelljar.java b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiBelljar.java index 42bed7189f..375156bced 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiBelljar.java +++ b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiBelljar.java @@ -24,28 +24,30 @@ public class GuiBelljar extends GuiIEContainerBase { TileEntityBelljar tile; - public GuiBelljar(InventoryPlayer inventoryPlayer, TileEntityBelljar tile ) + + public GuiBelljar(InventoryPlayer inventoryPlayer, TileEntityBelljar tile) { super(new ContainerBelljar(inventoryPlayer, tile)); this.tile = tile; } + @Override public void drawScreen(int mx, int my, float partial) { super.drawScreen(mx, my, partial); ArrayList tooltip = new ArrayList(); - ClientUtils.handleGuiTank(tile.tank, guiLeft+8,guiTop+8, 16,47, 176,30,20,51, mx,my, "immersiveengineering:textures/gui/belljar.png", tooltip); - if(mx>guiLeft+30&&mxguiTop+22&&my guiLeft+30&&mx < guiLeft+37&&my > guiTop+22&&my < guiTop+68) { tooltip.add(I18n.format(Lib.DESC_INFO+"fertFill", Utils.formatDouble(tile.fertilizerAmount/(float)IEConfig.Machines.belljar_fertilizer, "0.00"))); tooltip.add(I18n.format(Lib.DESC_INFO+"fertMod", Utils.formatDouble(tile.fertilizerMod, "0.00"))); } - if(mx>guiLeft+158&&mxguiTop+22&&my guiLeft+158&&mx < guiLeft+165&&my > guiTop+22&&my < guiTop+68) tooltip.add(tile.getEnergyStored(null)+"/"+tile.getMaxEnergyStored(null)+" RF"); if(!tooltip.isEmpty()) { - ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer, guiLeft+xSize,-1); + ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer, guiLeft+xSize, -1); RenderHelper.enableGUIStandardItemLighting(); } } @@ -57,14 +59,14 @@ protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.enableBlend(); ClientUtils.bindTexture("immersiveengineering:textures/gui/belljar.png"); - this.drawTexturedModalRect(guiLeft,guiTop, 0, 0, xSize, ySize); + this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); GlStateManager.disableBlend(); - ClientUtils.handleGuiTank(tile.tank, guiLeft+8,guiTop+8, 16,47, 176,30,20,51, mx,my, "immersiveengineering:textures/gui/belljar.png", null); + ClientUtils.handleGuiTank(tile.tank, guiLeft+8, guiTop+8, 16, 47, 176, 30, 20, 51, mx, my, "immersiveengineering:textures/gui/belljar.png", null); int stored = (int)(46*(tile.fertilizerAmount/(float)IEConfig.Machines.belljar_fertilizer)); - ClientUtils.drawGradientRect(guiLeft+30,guiTop+22+(46-stored), guiLeft+37,guiTop+68, 0xff95ed00, 0xff8a5a00); + ClientUtils.drawGradientRect(guiLeft+30, guiTop+22+(46-stored), guiLeft+37, guiTop+68, 0xff95ed00, 0xff8a5a00); stored = (int)(46*(tile.getEnergyStored(null)/(float)tile.getMaxEnergyStored(null))); - ClientUtils.drawGradientRect(guiLeft+158,guiTop+22+(46-stored), guiLeft+165,guiTop+68, 0xffb51500, 0xff600b00); + ClientUtils.drawGradientRect(guiLeft+158, guiTop+22+(46-stored), guiLeft+165, guiTop+68, 0xffb51500, 0xff600b00); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiBlastFurnace.java b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiBlastFurnace.java index 6df15ad75a..8f644e8085 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiBlastFurnace.java +++ b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiBlastFurnace.java @@ -17,29 +17,30 @@ public class GuiBlastFurnace extends GuiIEContainerBase { TileEntityBlastFurnace tile; + public GuiBlastFurnace(InventoryPlayer inventoryPlayer, TileEntityBlastFurnace tile) { super(new ContainerBlastFurnace(inventoryPlayer, tile)); - this.tile=tile; + this.tile = tile; } - + @Override protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); ClientUtils.bindTexture("immersiveengineering:textures/gui/blast_furnace.png"); - this.drawTexturedModalRect(guiLeft,guiTop, 0, 0, xSize, ySize); + this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - if(tile.lastBurnTime>0) + if(tile.lastBurnTime > 0) { int h = (int)(12*(tile.burnTime/(float)tile.lastBurnTime)); - this.drawTexturedModalRect(guiLeft+56,guiTop+37+12-h, 179, 1+12-h, 9, h); + this.drawTexturedModalRect(guiLeft+56, guiTop+37+12-h, 179, 1+12-h, 9, h); } - if(tile.processMax>0) + if(tile.processMax > 0) { - int w = (int)(22*( (tile.processMax-tile.process)/(float)tile.processMax)); - this.drawTexturedModalRect(guiLeft+76,guiTop+35, 177, 14, w, 16); + int w = (int)(22*((tile.processMax-tile.process)/(float)tile.processMax)); + this.drawTexturedModalRect(guiLeft+76, guiTop+35, 177, 14, w, 16); } } } diff --git a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiCokeOven.java b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiCokeOven.java index b6f9d105cd..172a64b857 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiCokeOven.java +++ b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiCokeOven.java @@ -20,10 +20,11 @@ public class GuiCokeOven extends GuiIEContainerBase { TileEntityCokeOven tile; + public GuiCokeOven(InventoryPlayer inventoryPlayer, TileEntityCokeOven tile) { super(new ContainerCokeOven(inventoryPlayer, tile)); - this.tile=tile; + this.tile = tile; } @Override @@ -31,10 +32,10 @@ public void drawScreen(int mx, int my, float partial) { super.drawScreen(mx, my, partial); ArrayList tooltip = new ArrayList(); - ClientUtils.handleGuiTank(tile.tank, guiLeft+129,guiTop+20, 16,47, 176,31,20,51, mx,my, "immersiveengineering:textures/gui/coke_oven.png", tooltip); + ClientUtils.handleGuiTank(tile.tank, guiLeft+129, guiTop+20, 16, 47, 176, 31, 20, 51, mx, my, "immersiveengineering:textures/gui/coke_oven.png", tooltip); if(!tooltip.isEmpty()) { - ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer, guiLeft+xSize,-1); + ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer, guiLeft+xSize, -1); RenderHelper.enableGUIStandardItemLighting(); } } @@ -45,12 +46,12 @@ protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); ClientUtils.bindTexture("immersiveengineering:textures/gui/coke_oven.png"); - this.drawTexturedModalRect(guiLeft,guiTop, 0, 0, xSize, ySize); + this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - if(tile.processMax>0&&tile.process>0) + if(tile.processMax > 0&&tile.process > 0) { int h = (int)(12*(tile.process/(float)tile.processMax)); - this.drawTexturedModalRect(guiLeft+59,guiTop+37+12-h, 179, 1+12-h, 9, h); + this.drawTexturedModalRect(guiLeft+59, guiTop+37+12-h, 179, 1+12-h, 9, h); } // if(tile.tank.getFluid()!=null && tile.tank.getFluid().getFluid()!=null) @@ -60,7 +61,7 @@ protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) // ClientUtils.bindTexture("immersiveengineering:textures/gui/cokeOven.png"); // } // this.drawTexturedModalRect(guiLeft+127,guiTop+18, 176,31, 20,51); - ClientUtils.handleGuiTank(tile.tank, guiLeft+129,guiTop+20, 16,47, 176,31,20,51, mx,my, "immersiveengineering:textures/gui/coke_oven.png", null); - + ClientUtils.handleGuiTank(tile.tank, guiLeft+129, guiTop+20, 16, 47, 176, 31, 20, 51, mx, my, "immersiveengineering:textures/gui/coke_oven.png", null); + } } diff --git a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiCrate.java b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiCrate.java index 08522d7ab4..d82a78cec7 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiCrate.java +++ b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiCrate.java @@ -16,10 +16,10 @@ public class GuiCrate extends GuiIEContainerBase { - public GuiCrate(InventoryPlayer inventoryPlayer, TileEntityWoodenCrate tile ) + public GuiCrate(InventoryPlayer inventoryPlayer, TileEntityWoodenCrate tile) { super(new ContainerCrate(inventoryPlayer, tile)); - this.ySize=168; + this.ySize = 168; } @Override @@ -33,6 +33,6 @@ protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); ClientUtils.bindTexture("immersiveengineering:textures/gui/crate.png"); - this.drawTexturedModalRect(guiLeft,guiTop, 0, 0, xSize, ySize); + this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiFermenter.java b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiFermenter.java index 036d434786..2dc066af72 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiFermenter.java +++ b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiFermenter.java @@ -20,10 +20,11 @@ public class GuiFermenter extends GuiIEContainerBase { TileEntityFermenter tile; + public GuiFermenter(InventoryPlayer inventoryPlayer, TileEntityFermenter tile) { super(new ContainerFermenter(inventoryPlayer, tile)); - this.tile=tile; + this.tile = tile; } @Override @@ -31,12 +32,12 @@ public void drawScreen(int mx, int my, float partial) { super.drawScreen(mx, my, partial); ArrayList tooltip = new ArrayList(); - ClientUtils.handleGuiTank(tile.tanks[0], guiLeft+112,guiTop+21, 16,47, 177,31,20,51, mx,my, "immersiveengineering:textures/gui/cokeOven.png", tooltip); - if(mx>guiLeft+158&&mxguiTop+22&&my guiLeft+158&&mx < guiLeft+165&&my > guiTop+22&&my < guiTop+68) tooltip.add(tile.getEnergyStored(null)+"/"+tile.getMaxEnergyStored(null)+" RF"); if(!tooltip.isEmpty()) { - ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer, guiLeft+xSize,-1); + ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer, guiLeft+xSize, -1); RenderHelper.enableGUIStandardItemLighting(); } } @@ -47,10 +48,10 @@ protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); ClientUtils.bindTexture("immersiveengineering:textures/gui/fermenter.png"); - this.drawTexturedModalRect(guiLeft,guiTop, 0, 0, xSize, ySize); + this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); int stored = (int)(46*(tile.getEnergyStored(null)/(float)tile.getMaxEnergyStored(null))); - ClientUtils.drawGradientRect(guiLeft+158,guiTop+22+(46-stored), guiLeft+165,guiTop+68, 0xffb51500, 0xff600b00); + ClientUtils.drawGradientRect(guiLeft+158, guiTop+22+(46-stored), guiLeft+165, guiTop+68, 0xffb51500, 0xff600b00); // if(tile.processMax>0&&tile.process>0) // { @@ -65,7 +66,7 @@ protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) // ClientUtils.bindTexture("immersiveengineering:textures/gui/cokeOven.png"); // } // this.drawTexturedModalRect(guiLeft+127,guiTop+18, 176,31, 20,51); - ClientUtils.handleGuiTank(tile.tanks[0], guiLeft+112,guiTop+21, 16,47, 177,31,20,51, mx,my, "immersiveengineering:textures/gui/squeezer.png", null); + ClientUtils.handleGuiTank(tile.tanks[0], guiLeft+112, guiTop+21, 16, 47, 177, 31, 20, 51, mx, my, "immersiveengineering:textures/gui/squeezer.png", null); } } diff --git a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiFluidSorter.java b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiFluidSorter.java index 045d1dd53e..2a77242a9a 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiFluidSorter.java +++ b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiFluidSorter.java @@ -36,6 +36,7 @@ public class GuiFluidSorter extends GuiIEContainerBase { TileEntityFluidSorter tile; InventoryPlayer playerInventory; + public GuiFluidSorter(InventoryPlayer inventoryPlayer, TileEntityFluidSorter tile) { super(new ContainerFluidSorter(inventoryPlayer, tile)); @@ -52,7 +53,7 @@ public void drawScreen(int mx, int my, float partial) for(GuiButton button : this.buttonList) { if(button instanceof ButtonSorter) - if(mx>button.x&&mxbutton.y&&my button.x&&mx < button.x+18&&my > button.y&&my < button.y+18) { int type = ((ButtonSorter)button).type; String[] split = I18n.format(Lib.DESC_INFO+"filter.nbt").split("
"); @@ -64,9 +65,9 @@ public void drawScreen(int mx, int my, float partial) for(int i = 0; i < 8; i++) if(tile.filters[side][i]!=null) { - int x = guiLeft+4+(side/2)*58 +(i<3?i*18: i>4?(i-5)*18: i==3?0: 36); - int y = guiTop+22+(side%2)*76 +(i<3?0: i>4?36: 18); - if(mx>x&&mxy&&my 4?(i-5)*18: i==3?0: 36); + int y = guiTop+22+(side%2)*76+(i < 3?0: i > 4?36: 18); + if(mx > x&&mx < x+16&&my > y&&my < y+16) ClientUtils.addFluidTooltip(tile.filters[side][i], tooltip, 0); } if(!tooltip.isEmpty()) @@ -83,9 +84,9 @@ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOEx for(int side = 0; side < 6; side++) for(int i = 0; i < 8; i++) { - int x = guiLeft+4+(side/2)*58 +(i<3?i*18: i>4?(i-5)*18: i==3?0: 36); - int y = guiTop+22+(side%2)*76 +(i<3?0: i>4?36: 18); - if(mouseX>x&&mouseXy&&mouseY 4?(i-5)*18: i==3?0: 36); + int y = guiTop+22+(side%2)*76+(i < 3?0: i > 4?36: 18); + if(mouseX > x&&mouseX < x+16&&mouseY > y&&mouseY < y+16) { FluidStack fs = FluidUtil.getFluidContained(playerInventory.getItemStack()); tile.filters[side][i] = fs; @@ -104,21 +105,21 @@ protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); ClientUtils.bindTexture("immersiveengineering:textures/gui/sorter.png"); - this.drawTexturedModalRect(guiLeft,guiTop, 0, 0, xSize, ySize); - for(int side=0; side<6; side++) + this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + for(int side = 0; side < 6; side++) { ClientUtils.bindAtlas(); - for(int i=0; i<8; i++) + for(int i = 0; i < 8; i++) if(tile.filters[side][i]!=null) { TextureAtlasSprite sprite = ClientUtils.getSprite(tile.filters[side][i].getFluid().getStill(tile.filters[side][i])); if(sprite!=null) { - int x = guiLeft+4+(side/2)*58 +(i<3?i*18: i>4?(i-5)*18: i==3?0: 36); - int y = guiTop+22+(side%2)*76 +(i<3?0: i>4?36: 18); + int x = guiLeft+4+(side/2)*58+(i < 3?i*18: i > 4?(i-5)*18: i==3?0: 36); + int y = guiTop+22+(side%2)*76+(i < 3?0: i > 4?36: 18); int col = tile.filters[side][i].getFluid().getColor(tile.filters[side][i]); - GlStateManager.color((col>>16&255)/255.0f, (col>>8&255)/255.0f, (col&255)/255.0f, 1); - ClientUtils.drawTexturedRect(x,y, 16,16, sprite.getMinU(),sprite.getMaxU(),sprite.getMinV(),sprite.getMaxV()); + GlStateManager.color((col >> 16&255)/255.0f, (col >> 8&255)/255.0f, (col&255)/255.0f, 1); + ClientUtils.drawTexturedRect(x, y, 16, 16, sprite.getMinU(), sprite.getMaxU(), sprite.getMinV(), sprite.getMaxV()); } } int x = guiLeft+30+(side/2)*58; @@ -135,23 +136,23 @@ public void initGui() { super.initGui(); this.buttonList.clear(); - for(int side=0; side<6; side++) - { - int x = guiLeft+21+ (side/2)*58; - int y = guiTop+3+ (side%2)*76; - ButtonSorter b = new ButtonSorter(side, x,y, 1); - b.active = this.tile.doNBT(side); - this.buttonList.add(b); - } + for(int side = 0; side < 6; side++) + { + int x = guiLeft+21+(side/2)*58; + int y = guiTop+3+(side%2)*76; + ButtonSorter b = new ButtonSorter(side, x, y, 1); + b.active = this.tile.doNBT(side); + this.buttonList.add(b); + } } @Override protected void actionPerformed(GuiButton button) { - if(button instanceof ButtonSorter && FMLCommonHandler.instance().getEffectiveSide()==Side.CLIENT) + if(button instanceof ButtonSorter&&FMLCommonHandler.instance().getEffectiveSide()==Side.CLIENT) { int side = button.id; - this.tile.sortWithNBT[side] = (byte)(this.tile.sortWithNBT[side]==1?0:1); + this.tile.sortWithNBT[side] = (byte)(this.tile.sortWithNBT[side]==1?0: 1); NBTTagCompound tag = new NBTTagCompound(); tag.setByteArray("sideConfig", this.tile.sortWithNBT); diff --git a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiMixer.java b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiMixer.java index b96b04c484..766877d617 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiMixer.java +++ b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiMixer.java @@ -30,10 +30,11 @@ public class GuiMixer extends GuiIEContainerBase { TileEntityMixer tile; + public GuiMixer(InventoryPlayer inventoryPlayer, TileEntityMixer tile) { super(new ContainerMixer(inventoryPlayer, tile)); - this.tile=tile; + this.tile = tile; this.ySize = 167; } @@ -42,8 +43,9 @@ public void initGui() { super.initGui(); this.buttonList.clear(); - this.buttonList.add(new GuiButtonState(0, guiLeft+106,guiTop+61, 30,16, null, tile.outputAll, "immersiveengineering:textures/gui/mixer.png",176,82, 1)); + this.buttonList.add(new GuiButtonState(0, guiLeft+106, guiTop+61, 30, 16, null, tile.outputAll, "immersiveengineering:textures/gui/mixer.png", 176, 82, 1)); } + @Override protected void actionPerformed(GuiButton button) { @@ -85,7 +87,7 @@ public void drawScreen(int mx, int my, float partial) if(mx >= guiLeft+158&&mx < guiLeft+165&&my > guiTop+22&&my < guiTop+68) tooltip.add(tile.getEnergyStored(null)+"/"+tile.getMaxEnergyStored(null)+" RF"); if(mx >= guiLeft+106&&mx <= guiLeft+136&&my >= guiTop+61&&my <= guiTop+77) - tooltip.add(I18n.format(Lib.GUI_CONFIG+"mixer.output"+(tile.outputAll?"All":"Single"))); + tooltip.add(I18n.format(Lib.GUI_CONFIG+"mixer.output"+(tile.outputAll?"All": "Single"))); if(!tooltip.isEmpty()) { ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer, guiLeft+xSize, -1); @@ -98,7 +100,7 @@ protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); ClientUtils.bindTexture("immersiveengineering:textures/gui/mixer.png"); - this.drawTexturedModalRect(guiLeft,guiTop, 0, 0, xSize, ySize); + this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); for(MultiblockProcess process : tile.processQueue) if(process instanceof MultiblockProcessInMachine) @@ -112,18 +114,18 @@ protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) } int stored = (int)(46*(tile.getEnergyStored(null)/(float)tile.getMaxEnergyStored(null))); - ClientUtils.drawGradientRect(guiLeft+158,guiTop+22+(46-stored), guiLeft+165,guiTop+68, 0xffb51500, 0xff600b00); + ClientUtils.drawGradientRect(guiLeft+158, guiTop+22+(46-stored), guiLeft+165, guiTop+68, 0xffb51500, 0xff600b00); float capacity = tile.tank.getCapacity(); int yy = guiTop+58; - for(int i=tile.tank.getFluidTypes()-1; i>=0; i--) + for(int i = tile.tank.getFluidTypes()-1; i >= 0; i--) { FluidStack fs = tile.tank.fluids.get(i); - if(fs!=null && fs.getFluid()!=null) + if(fs!=null&&fs.getFluid()!=null) { int fluidHeight = (int)(47*(fs.amount/capacity)); yy -= fluidHeight; - ClientUtils.drawRepeatedFluidSprite(fs, guiLeft+76,yy, 58,fluidHeight); + ClientUtils.drawRepeatedFluidSprite(fs, guiLeft+76, yy, 58, fluidHeight); } } } diff --git a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiModWorkbench.java b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiModWorkbench.java index ea92670e64..5be0a141b1 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiModWorkbench.java +++ b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiModWorkbench.java @@ -38,11 +38,12 @@ public class GuiModWorkbench extends GuiIEContainerBase { TileEntityModWorkbench workbench; - public GuiModWorkbench(InventoryPlayer inventoryPlayer, TileEntityModWorkbench tile ) + + public GuiModWorkbench(InventoryPlayer inventoryPlayer, TileEntityModWorkbench tile) { super(new ContainerModWorkbench(inventoryPlayer, tile)); workbench = tile; - this.ySize=168; + this.ySize = 168; } @Override @@ -51,7 +52,7 @@ public void initGui() this.buttonList.clear(); super.initGui(); Slot s = inventorySlots.getSlot(0); - if(s!=null && s.getHasStack() && s.getStack().getItem() instanceof IConfigurableTool) + if(s!=null&&s.getHasStack()&&s.getStack().getItem() instanceof IConfigurableTool) { ItemStack stack = s.getStack(); IConfigurableTool tool = ((IConfigurableTool)stack.getItem()); @@ -59,21 +60,22 @@ public void initGui() ToolConfigBoolean[] boolArray = tool.getBooleanOptions(stack); if(boolArray!=null) for(ToolConfigBoolean b : boolArray) - this.buttonList.add(new GuiButtonCheckbox(buttonid++, guiLeft+b.x,guiTop+b.y, tool.fomatConfigName(stack,b), b.value)); + this.buttonList.add(new GuiButtonCheckbox(buttonid++, guiLeft+b.x, guiTop+b.y, tool.fomatConfigName(stack, b), b.value)); ToolConfigFloat[] floatArray = tool.getFloatOptions(stack); if(floatArray!=null) for(ToolConfigFloat f : floatArray) - this.buttonList.add(new GuiSliderIE(buttonid++, guiLeft+f.x,guiTop+f.y, 80, tool.fomatConfigName(stack,f), f.value)); + this.buttonList.add(new GuiSliderIE(buttonid++, guiLeft+f.x, guiTop+f.y, 80, tool.fomatConfigName(stack, f), f.value)); } } NBTTagCompound lastMessage; + @Override protected void mouseReleased(int mouseX, int mouseY, int state) { super.mouseReleased(mouseX, mouseY, state); Slot s = inventorySlots.getSlot(0); - if(s!=null && s.getHasStack() && s.getStack().getItem() instanceof IConfigurableTool) + if(s!=null&&s.getHasStack()&&s.getStack().getItem() instanceof IConfigurableTool) { ItemStack stack = s.getStack(); IConfigurableTool tool = ((IConfigurableTool)stack.getItem()); @@ -84,10 +86,10 @@ protected void mouseReleased(int mouseX, int mouseY, int state) int iFloat = 0; for(GuiButton button : this.buttonList) { - if(button instanceof GuiButtonCheckbox && boolArray!=null) - message.setBoolean("b_"+boolArray[iBool++].name,((GuiButtonCheckbox)button).state); - if(button instanceof GuiSliderIE && floatArray!=null) - message.setFloat("f_"+floatArray[iFloat++].name,(float)((GuiSliderIE)button).sliderValue); + if(button instanceof GuiButtonCheckbox&&boolArray!=null) + message.setBoolean("b_"+boolArray[iBool++].name, ((GuiButtonCheckbox)button).state); + if(button instanceof GuiSliderIE&&floatArray!=null) + message.setFloat("f_"+floatArray[iFloat++].name, (float)((GuiSliderIE)button).sliderValue); } if(!message.equals(lastMessage))//Only send packets when values have changed ImmersiveEngineering.packetHandler.sendToServer(new MessageTileSync(this.workbench, message)); @@ -99,14 +101,14 @@ protected void mouseReleased(int mouseX, int mouseY, int state) public void drawScreen(int mx, int my, float partial) { super.drawScreen(mx, my, partial); - for(int i=0; i<((ContainerModWorkbench)inventorySlots).slotCount; i++) + for(int i = 0; i < ((ContainerModWorkbench)inventorySlots).slotCount; i++) { Slot s = inventorySlots.getSlot(i); - if(s instanceof IESlot.BlueprintOutput && !s.getHasStack()) + if(s instanceof IESlot.BlueprintOutput&&!s.getHasStack()) { BlueprintCraftingRecipe recipe = ((IESlot.BlueprintOutput)s).recipe; - if(recipe!=null && !recipe.output.isEmpty()) - if(isPointInRegion(s.xPos,s.yPos, 16,16, mx,my)) + if(recipe!=null&&!recipe.output.isEmpty()) + if(isPointInRegion(s.xPos, s.yPos, 16, 16, mx, my)) { ArrayList tooltip = new ArrayList(); tooltip.add(recipe.output.getRarity().rarityColor+recipe.output.getDisplayName()); @@ -128,7 +130,7 @@ public void drawScreen(int mx, int my, float partial) inputs.add(toAdd.copy()); } for(ItemStack ss : inputs) - tooltip.add(TextFormatting.GRAY.toString() + ss.getCount() + "x " + ss.getDisplayName()); + tooltip.add(TextFormatting.GRAY.toString()+ss.getCount()+"x "+ss.getDisplayName()); ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer); RenderHelper.enableGUIStandardItemLighting(); @@ -143,25 +145,25 @@ protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); ClientUtils.bindTexture("immersiveengineering:textures/gui/workbench.png"); - this.drawTexturedModalRect(guiLeft,guiTop, 0, 0, xSize, ySize); + this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - for(int i=0; i<((ContainerModWorkbench)inventorySlots).slotCount; i++) + for(int i = 0; i < ((ContainerModWorkbench)inventorySlots).slotCount; i++) { Slot s = inventorySlots.getSlot(i); - ClientUtils.drawColouredRect(guiLeft+ s.xPos-1, guiTop+ s.yPos-1, 17,1, 0x77222222); - ClientUtils.drawColouredRect(guiLeft+ s.xPos-1, guiTop+ s.yPos+0, 1,16, 0x77222222); - ClientUtils.drawColouredRect(guiLeft+ s.xPos+16, guiTop+ s.yPos+0, 1,17, 0x77999999); - ClientUtils.drawColouredRect(guiLeft+ s.xPos+0, guiTop+ s.yPos+16, 16,1, 0x77999999); - if( !(s instanceof IESlot.BlueprintOutput) || s.getHasStack() || ((IESlot.BlueprintOutput)s).recipe.output.isEmpty()) - ClientUtils.drawColouredRect(guiLeft+ s.xPos+0, guiTop+ s.yPos+0, 16,16, 0x77444444); + ClientUtils.drawColouredRect(guiLeft+s.xPos-1, guiTop+s.yPos-1, 17, 1, 0x77222222); + ClientUtils.drawColouredRect(guiLeft+s.xPos-1, guiTop+s.yPos+0, 1, 16, 0x77222222); + ClientUtils.drawColouredRect(guiLeft+s.xPos+16, guiTop+s.yPos+0, 1, 17, 0x77999999); + ClientUtils.drawColouredRect(guiLeft+s.xPos+0, guiTop+s.yPos+16, 16, 1, 0x77999999); + if(!(s instanceof IESlot.BlueprintOutput)||s.getHasStack()||((IESlot.BlueprintOutput)s).recipe.output.isEmpty()) + ClientUtils.drawColouredRect(guiLeft+s.xPos+0, guiTop+s.yPos+0, 16, 16, 0x77444444); } - for(int i=0; i<((ContainerModWorkbench)inventorySlots).slotCount; i++) + for(int i = 0; i < ((ContainerModWorkbench)inventorySlots).slotCount; i++) { Slot s = inventorySlots.getSlot(i); - if(s instanceof IESlot.BlueprintOutput && !s.getHasStack()) + if(s instanceof IESlot.BlueprintOutput&&!s.getHasStack()) { ItemStack ghostStack = ((IESlot.BlueprintOutput)s).recipe.output; if(!ghostStack.isEmpty()) @@ -177,7 +179,7 @@ protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) GlStateManager.disableLighting(); GlStateManager.disableDepth(); - ClientUtils.drawColouredRect(guiLeft+ s.xPos+0, guiTop+ s.yPos+0, 16,16, 0x77444444); + ClientUtils.drawColouredRect(guiLeft+s.xPos+0, guiTop+s.yPos+0, 16, 16, 0x77444444); GlStateManager.enableLighting(); GlStateManager.enableDepth(); } diff --git a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiRefinery.java b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiRefinery.java index a0ed2b654b..d977c8c838 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiRefinery.java +++ b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiRefinery.java @@ -20,10 +20,11 @@ public class GuiRefinery extends GuiIEContainerBase { TileEntityRefinery tile; + public GuiRefinery(InventoryPlayer inventoryPlayer, TileEntityRefinery tile) { super(new ContainerRefinery(inventoryPlayer, tile)); - this.tile=tile; + this.tile = tile; } @Override @@ -31,15 +32,15 @@ public void drawScreen(int mx, int my, float partial) { super.drawScreen(mx, my, partial); ArrayList tooltip = new ArrayList(); - ClientUtils.handleGuiTank(tile.tanks[0], guiLeft+ 13,guiTop+20, 16,47, 177,31,20,51, mx,my, "immersiveengineering:textures/gui/refinery.png", tooltip); - ClientUtils.handleGuiTank(tile.tanks[1], guiLeft+ 61,guiTop+20, 16,47, 177,31,20,51, mx,my, "immersiveengineering:textures/gui/refinery.png", tooltip); - ClientUtils.handleGuiTank(tile.tanks[2], guiLeft+109,guiTop+20, 16,47, 177,31,20,51, mx,my, "immersiveengineering:textures/gui/refinery.png", tooltip); - if(mx>guiLeft+157&&mxguiTop+21&&my guiLeft+157&&mx < guiLeft+164&&my > guiTop+21&&my < guiTop+67) tooltip.add(tile.getEnergyStored(null)+"/"+tile.getMaxEnergyStored(null)+" RF"); if(!tooltip.isEmpty()) { - ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer, guiLeft+xSize,-1); + ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer, guiLeft+xSize, -1); RenderHelper.enableGUIStandardItemLighting(); } } @@ -49,7 +50,7 @@ protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); ClientUtils.bindTexture("immersiveengineering:textures/gui/refinery.png"); - this.drawTexturedModalRect(guiLeft,guiTop, 0, 0, xSize, ySize); + this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); // if(tile.tick>0) // { @@ -58,13 +59,13 @@ protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) // } int stored = (int)(46*(tile.getEnergyStored(null)/(float)tile.getMaxEnergyStored(null))); - ClientUtils.drawGradientRect(guiLeft+157,guiTop+21+(46-stored), guiLeft+164,guiTop+67, 0xffb51500, 0xff600b00); + ClientUtils.drawGradientRect(guiLeft+157, guiTop+21+(46-stored), guiLeft+164, guiTop+67, 0xffb51500, 0xff600b00); + + ClientUtils.handleGuiTank(tile.tanks[0], guiLeft+13, guiTop+20, 16, 47, 177, 31, 20, 51, mx, my, "immersiveengineering:textures/gui/refinery.png", null); + ClientUtils.handleGuiTank(tile.tanks[1], guiLeft+61, guiTop+20, 16, 47, 177, 31, 20, 51, mx, my, "immersiveengineering:textures/gui/refinery.png", null); + ClientUtils.handleGuiTank(tile.tanks[2], guiLeft+109, guiTop+20, 16, 47, 177, 31, 20, 51, mx, my, "immersiveengineering:textures/gui/refinery.png", null); + - ClientUtils.handleGuiTank(tile.tanks[0], guiLeft+ 13,guiTop+20, 16,47, 177,31,20,51, mx,my, "immersiveengineering:textures/gui/refinery.png", null); - ClientUtils.handleGuiTank(tile.tanks[1], guiLeft+ 61,guiTop+20, 16,47, 177,31,20,51, mx,my, "immersiveengineering:textures/gui/refinery.png", null); - ClientUtils.handleGuiTank(tile.tanks[2], guiLeft+109,guiTop+20, 16,47, 177,31,20,51, mx,my, "immersiveengineering:textures/gui/refinery.png", null); - - // if(tile.tank.getFluid()!=null && tile.tank.getFluid().getFluid()!=null) // { // int h = (int)(47*(tile.tank.getFluid().amount/(float)tile.tank.getCapacity())); diff --git a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiRevolver.java b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiRevolver.java index 46c24edb2c..93bc88896e 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiRevolver.java +++ b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiRevolver.java @@ -28,18 +28,18 @@ public class GuiRevolver extends GuiIEContainerBase public GuiRevolver(InventoryPlayer inventoryPlayer, World world, EntityEquipmentSlot slot, ItemStack revolver) { super(new ContainerRevolver(inventoryPlayer, world, slot, revolver)); - if(!revolver.isEmpty() && revolver.getItem() instanceof IBulletContainer) + if(!revolver.isEmpty()&&revolver.getItem() instanceof IBulletContainer) this.bullets[0] = ((IBulletContainer)revolver.getItem()).getBulletCount(revolver); this.otherRevolver = !((ContainerRevolver)this.inventorySlots).secondRevolver.isEmpty(); if(this.otherRevolver) { this.bullets[1] = ((IBulletContainer)((ContainerRevolver)this.inventorySlots).secondRevolver.getItem()).getBulletCount(((ContainerRevolver)this.inventorySlots).secondRevolver); - this.offset = ((bullets[0]>=18?150:bullets[0]>8?136:74)+(bullets[1]>=18?150:bullets[1]>8?136:74)+4-176)/2; - if(this.offset>0) + this.offset = ((bullets[0] >= 18?150: bullets[0] > 8?136: 74)+(bullets[1] >= 18?150: bullets[1] > 8?136: 74)+4-176)/2; + if(this.offset > 0) this.xSize += this.offset*2; } else - this.offset = ((bullets[0]>=18?150:bullets[0]>8?136:74)-176)/2; + this.offset = ((bullets[0] >= 18?150: bullets[0] > 8?136: 74)-176)/2; } @Override @@ -47,12 +47,12 @@ protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); ClientUtils.bindTexture("immersiveengineering:textures/gui/revolver.png"); - this.drawTexturedModalRect(guiLeft+(offset>0?offset:0),guiTop+77, 0,125, 176,89); + this.drawTexturedModalRect(guiLeft+(offset > 0?offset: 0), guiTop+77, 0, 125, 176, 89); - int off = (offset<0?-offset:0); - for(int hand=0; hand<(otherRevolver?2:1); hand++) + int off = (offset < 0?-offset: 0); + for(int hand = 0; hand < (otherRevolver?2: 1); hand++) { - int side = !otherRevolver?0: (hand==0)==(ImmersiveEngineering.proxy.getClientPlayer().getPrimaryHand()==EnumHandSide.RIGHT)?1:0; + int side = !otherRevolver?0: (hand==0)==(ImmersiveEngineering.proxy.getClientPlayer().getPrimaryHand()==EnumHandSide.RIGHT)?1: 0; this.drawTexturedModalRect(guiLeft+off+00, guiTop+1, 00, 51, 74, 74); if(bullets[side] >= 18) this.drawTexturedModalRect(guiLeft+off+47, guiTop+1, 74, 51, 103, 74); diff --git a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiSorter.java b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiSorter.java index 4022dcde69..62518b7480 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiSorter.java +++ b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiSorter.java @@ -35,10 +35,11 @@ public class GuiSorter extends GuiIEContainerBase { TileEntitySorter tile; + public GuiSorter(InventoryPlayer inventoryPlayer, TileEntitySorter tile) { super(new ContainerSorter(inventoryPlayer, tile)); - this.tile=tile; + this.tile = tile; this.ySize = 244; } @@ -49,14 +50,14 @@ public void drawScreen(int mx, int my, float partial) for(GuiButton button : this.buttonList) { if(button instanceof ButtonSorter) - if(mx>button.x&&mxbutton.y&&my button.x&&mx < button.x+18&&my > button.y&&my < button.y+18) { ArrayList tooltip = new ArrayList(); int type = ((ButtonSorter)button).type; - String[] split = I18n.format(Lib.DESC_INFO + "filter." + (type == 0 ? "oreDict" : type == 1 ? "nbt" : "fuzzy")).split("
"); - for(int i=0; i"); + for(int i = 0; i < split.length; i++) + tooltip.add((i==0?TextFormatting.WHITE: TextFormatting.GRAY)+split[i]); + ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer, guiLeft+xSize, -1); RenderHelper.enableGUIStandardItemLighting(); } } @@ -68,11 +69,11 @@ protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); ClientUtils.bindTexture("immersiveengineering:textures/gui/sorter.png"); - this.drawTexturedModalRect(guiLeft,guiTop, 0, 0, xSize, ySize); - for(int side=0; side<6; side++) + this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + for(int side = 0; side < 6; side++) { - int x = guiLeft+ 30+ (side/2)*58; - int y = guiTop+ 44+ (side%2)*76; + int x = guiLeft+30+(side/2)*58; + int y = guiTop+44+(side%2)*76; String s = I18n.format("desc.immersiveengineering.info.blockSide."+EnumFacing.getFront(side).toString()).substring(0, 1); GlStateManager.enableBlend(); ClientUtils.font().drawString(s, x-(ClientUtils.font().getStringWidth(s)/2), y, 0xaacccccc, true); @@ -85,12 +86,12 @@ public void initGui() { super.initGui(); this.buttonList.clear(); - for(int side=0; side<6; side++) - for(int i=0; i<3; i++) + for(int side = 0; side < 6; side++) + for(int i = 0; i < 3; i++) { - int x = guiLeft+3+ (side/2)*58 +i*18; - int y = guiTop+3+ (side%2)*76; - ButtonSorter b = new ButtonSorter(side*3+i, x,y, i); + int x = guiLeft+3+(side/2)*58+i*18; + int y = guiTop+3+(side%2)*76; + ButtonSorter b = new ButtonSorter(side*3+i, x, y, i); b.active = i==0?this.tile.doOredict(side): i==1?this.tile.doNBT(side): this.tile.doFuzzy(side); this.buttonList.add(b); } @@ -99,7 +100,7 @@ public void initGui() @Override protected void actionPerformed(GuiButton button) { - if(button instanceof ButtonSorter && FMLCommonHandler.instance().getEffectiveSide()==Side.CLIENT) + if(button instanceof ButtonSorter&&FMLCommonHandler.instance().getEffectiveSide()==Side.CLIENT) { int side = button.id/3; int bit = button.id%3; @@ -115,24 +116,25 @@ protected void actionPerformed(GuiButton button) public static class ButtonSorter extends GuiButton { - int type; + int type; boolean active = false; + public ButtonSorter(int id, int x, int y, int type) { - super(id, x, y, 18,18, ""); + super(id, x, y, 18, 18, ""); this.type = type; } @Override public void drawButton(Minecraft mc, int mx, int my, float partialTicks) { - if (this.visible) + if(this.visible) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - this.hovered = mx >= this.x && my >= this.y && mx < this.x + this.width && my < this.y + this.height; + this.hovered = mx >= this.x&&my >= this.y&&mx < this.x+this.width&&my < this.y+this.height; GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, ONE, ZERO); - this.drawTexturedModalRect(this.x, this.y, 176+type*18,(active?3:21), this.width, this.height); + this.drawTexturedModalRect(this.x, this.y, 176+type*18, (active?3: 21), this.width, this.height); this.mouseDragged(mc, mx, my); } } diff --git a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiSqueezer.java b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiSqueezer.java index af47a1e25e..89becb965a 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiSqueezer.java +++ b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiSqueezer.java @@ -20,10 +20,11 @@ public class GuiSqueezer extends GuiIEContainerBase { TileEntitySqueezer tile; + public GuiSqueezer(InventoryPlayer inventoryPlayer, TileEntitySqueezer tile) { super(new ContainerSqueezer(inventoryPlayer, tile)); - this.tile=tile; + this.tile = tile; } @Override @@ -31,12 +32,12 @@ public void drawScreen(int mx, int my, float partial) { super.drawScreen(mx, my, partial); ArrayList tooltip = new ArrayList(); - ClientUtils.handleGuiTank(tile.tanks[0], guiLeft+112,guiTop+21, 16,47, 177,31,20,51, mx,my, "immersiveengineering:textures/gui/cokeOven.png", tooltip); - if(mx>guiLeft+158&&mxguiTop+22&&my guiLeft+158&&mx < guiLeft+165&&my > guiTop+22&&my < guiTop+68) tooltip.add(tile.getEnergyStored(null)+"/"+tile.getMaxEnergyStored(null)+" RF"); if(!tooltip.isEmpty()) { - ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer, guiLeft+xSize,-1); + ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer, guiLeft+xSize, -1); RenderHelper.enableGUIStandardItemLighting(); } } @@ -47,10 +48,10 @@ protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); ClientUtils.bindTexture("immersiveengineering:textures/gui/squeezer.png"); - this.drawTexturedModalRect(guiLeft,guiTop, 0, 0, xSize, ySize); + this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); int stored = (int)(46*(tile.getEnergyStored(null)/(float)tile.getMaxEnergyStored(null))); - ClientUtils.drawGradientRect(guiLeft+158,guiTop+22+(46-stored), guiLeft+165,guiTop+68, 0xffb51500, 0xff600b00); + ClientUtils.drawGradientRect(guiLeft+158, guiTop+22+(46-stored), guiLeft+165, guiTop+68, 0xffb51500, 0xff600b00); // if(tile.processMax>0&&tile.process>0) // { @@ -65,7 +66,7 @@ protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) // ClientUtils.bindTexture("immersiveengineering:textures/gui/cokeOven.png"); // } // this.drawTexturedModalRect(guiLeft+127,guiTop+18, 176,31, 20,51); - ClientUtils.handleGuiTank(tile.tanks[0], guiLeft+112,guiTop+21, 16,47, 177,31,20,51, mx,my, "immersiveengineering:textures/gui/squeezer.png", null); + ClientUtils.handleGuiTank(tile.tanks[0], guiLeft+112, guiTop+21, 16, 47, 177, 31, 20, 51, mx, my, "immersiveengineering:textures/gui/squeezer.png", null); } } diff --git a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiToolbox.java b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiToolbox.java index cc5565092f..54402d8f39 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiToolbox.java +++ b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiToolbox.java @@ -28,7 +28,7 @@ public class GuiToolbox extends GuiIEContainerBase public GuiToolbox(InventoryPlayer inventoryPlayer, World world, EntityEquipmentSlot slot, ItemStack toolbox) { super(new ContainerToolbox(inventoryPlayer, world, slot, toolbox)); - this.ySize=238; + this.ySize = 238; } @Override @@ -37,20 +37,20 @@ public void drawScreen(int mx, int my, float partial) super.drawScreen(mx, my, partial); ArrayList tooltip = new ArrayList(); int slot = -1; - for(int i=0; i<((ContainerToolbox)this.inventorySlots).internalSlots; i++) + for(int i = 0; i < ((ContainerToolbox)this.inventorySlots).internalSlots; i++) { Slot s = this.inventorySlots.inventorySlots.get(i); - if(!s.getHasStack() && mx>guiLeft+s.xPos&&mxguiTop+s.yPos&&my guiLeft+s.xPos&&mx < guiLeft+s.xPos+16&&my > guiTop+s.yPos&&my < guiTop+s.yPos+16) slot = i; } String ss = null; - if(slot>=0) - ss = slot<3?"food": slot<10?"tool": slot<16?"wire": "any"; + if(slot >= 0) + ss = slot < 3?"food": slot < 10?"tool": slot < 16?"wire": "any"; if(ss!=null) - tooltip.add(TextFormatting.GRAY+ I18n.format(Lib.DESC_INFO+"toolbox."+ss)); + tooltip.add(TextFormatting.GRAY+I18n.format(Lib.DESC_INFO+"toolbox."+ss)); if(!tooltip.isEmpty()) { - ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer, guiLeft+xSize,-1); + ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer, guiLeft+xSize, -1); RenderHelper.enableGUIStandardItemLighting(); } } @@ -60,7 +60,7 @@ protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); ClientUtils.bindTexture("immersiveengineering:textures/gui/toolbox.png"); - this.drawTexturedModalRect(guiLeft,guiTop-17, 0,0, 176,ySize+17); + this.drawTexturedModalRect(guiLeft, guiTop-17, 0, 0, 176, ySize+17); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiToolboxBlock.java b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiToolboxBlock.java index 09a4f7c218..c4e866ab4b 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiToolboxBlock.java +++ b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiToolboxBlock.java @@ -26,7 +26,7 @@ public class GuiToolboxBlock extends GuiIEContainerBase public GuiToolboxBlock(InventoryPlayer inventoryPlayer, TileEntityToolbox toolbox) { super(new ContainerToolboxBlock(inventoryPlayer, toolbox)); - this.ySize=238; + this.ySize = 238; } @Override @@ -35,20 +35,20 @@ public void drawScreen(int mx, int my, float partial) super.drawScreen(mx, my, partial); ArrayList tooltip = new ArrayList(); int slot = -1; - for(int i=0; i<((ContainerToolboxBlock)this.inventorySlots).slotCount; i++) + for(int i = 0; i < ((ContainerToolboxBlock)this.inventorySlots).slotCount; i++) { Slot s = this.inventorySlots.inventorySlots.get(i); - if(!s.getHasStack() && mx>guiLeft+s.xPos&&mxguiTop+s.yPos&&my guiLeft+s.xPos&&mx < guiLeft+s.xPos+16&&my > guiTop+s.yPos&&my < guiTop+s.yPos+16) slot = i; } String ss = null; - if(slot>=0) - ss = slot<3?"food": slot<10?"tool": slot<16?"wire": "any"; + if(slot >= 0) + ss = slot < 3?"food": slot < 10?"tool": slot < 16?"wire": "any"; if(ss!=null) - tooltip.add(TextFormatting.GRAY+ I18n.format(Lib.DESC_INFO+"toolbox."+ss)); + tooltip.add(TextFormatting.GRAY+I18n.format(Lib.DESC_INFO+"toolbox."+ss)); if(!tooltip.isEmpty()) { - ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer, guiLeft+xSize,-1); + ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer, guiLeft+xSize, -1); RenderHelper.enableGUIStandardItemLighting(); } } @@ -58,7 +58,7 @@ protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); ClientUtils.bindTexture("immersiveengineering:textures/gui/toolbox.png"); - this.drawTexturedModalRect(guiLeft,guiTop-17, 0,0, 176,ySize+17); + this.drawTexturedModalRect(guiLeft, guiTop-17, 0, 0, 176, ySize+17); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiTurret.java b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiTurret.java index 03a3d558ee..e0db48f684 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/gui/GuiTurret.java +++ b/src/main/java/blusunrize/immersiveengineering/client/gui/GuiTurret.java @@ -40,7 +40,7 @@ public class GuiTurret extends GuiIEContainerBase public GuiTurret(InventoryPlayer inventoryPlayer, TileEntityTurret tile) { super(new ContainerTurret(inventoryPlayer, tile)); - this.tile=tile; + this.tile = tile; this.ySize = 190; } @@ -49,26 +49,27 @@ public void initGui() { super.initGui(); Keyboard.enableRepeatEvents(true); - this.nameField = new GuiTextField(0, this.fontRenderer, guiLeft+11,guiTop+88,58,12); + this.nameField = new GuiTextField(0, this.fontRenderer, guiLeft+11, guiTop+88, 58, 12); this.nameField.setTextColor(-1); this.nameField.setDisabledTextColour(-1); this.nameField.setEnableBackgroundDrawing(false); this.nameField.setMaxStringLength(30); this.buttonList.clear(); - this.buttonList.add(new GuiReactiveList(this, 0, guiLeft+10,guiTop+10, 60,72, tile.targetList.toArray(new String[tile.targetList.size()])).setPadding(0,0,2,2).setFormatting(1,false)); - this.buttonList.add(new GuiButtonIE(1, guiLeft+74,guiTop+84, 24,16, I18n.format(Lib.GUI_CONFIG+"turret.add"), "immersiveengineering:textures/gui/turret.png", 176,65)); - this.buttonList.add(new GuiButtonCheckbox(2, guiLeft+74,guiTop+10, I18n.format(Lib.GUI_CONFIG+"turret.blacklist"), !tile.whitelist)); - this.buttonList.add(new GuiButtonCheckbox(3, guiLeft+74,guiTop+26, I18n.format(Lib.GUI_CONFIG+"turret.animals"), tile.attackAnimals)); - this.buttonList.add(new GuiButtonCheckbox(4, guiLeft+74,guiTop+42, I18n.format(Lib.GUI_CONFIG+"turret.players"), tile.attackPlayers)); - this.buttonList.add(new GuiButtonCheckbox(5, guiLeft+74,guiTop+58, I18n.format(Lib.GUI_CONFIG+"turret.neutrals"), tile.attackNeutrals)); + this.buttonList.add(new GuiReactiveList(this, 0, guiLeft+10, guiTop+10, 60, 72, tile.targetList.toArray(new String[tile.targetList.size()])).setPadding(0, 0, 2, 2).setFormatting(1, false)); + this.buttonList.add(new GuiButtonIE(1, guiLeft+74, guiTop+84, 24, 16, I18n.format(Lib.GUI_CONFIG+"turret.add"), "immersiveengineering:textures/gui/turret.png", 176, 65)); + this.buttonList.add(new GuiButtonCheckbox(2, guiLeft+74, guiTop+10, I18n.format(Lib.GUI_CONFIG+"turret.blacklist"), !tile.whitelist)); + this.buttonList.add(new GuiButtonCheckbox(3, guiLeft+74, guiTop+26, I18n.format(Lib.GUI_CONFIG+"turret.animals"), tile.attackAnimals)); + this.buttonList.add(new GuiButtonCheckbox(4, guiLeft+74, guiTop+42, I18n.format(Lib.GUI_CONFIG+"turret.players"), tile.attackPlayers)); + this.buttonList.add(new GuiButtonCheckbox(5, guiLeft+74, guiTop+58, I18n.format(Lib.GUI_CONFIG+"turret.neutrals"), tile.attackNeutrals)); if(tile instanceof TileEntityTurretChem) - this.buttonList.add(new GuiButtonState(6, guiLeft+135,guiTop+68, 14,14, null, ((TileEntityTurretChem)tile).ignite, "immersiveengineering:textures/gui/turret.png",176,51, 0)); + this.buttonList.add(new GuiButtonState(6, guiLeft+135, guiTop+68, 14, 14, null, ((TileEntityTurretChem)tile).ignite, "immersiveengineering:textures/gui/turret.png", 176, 51, 0)); else if(tile instanceof TileEntityTurretGun) - this.buttonList.add(new GuiButtonState(6, guiLeft+134,guiTop+31, 16,16, null, ((TileEntityTurretGun)tile).expelCasings, "immersiveengineering:textures/gui/turret.png",176,81, 0)); + this.buttonList.add(new GuiButtonState(6, guiLeft+134, guiTop+31, 16, 16, null, ((TileEntityTurretGun)tile).expelCasings, "immersiveengineering:textures/gui/turret.png", 176, 81, 0)); } + @Override protected void actionPerformed(GuiButton button) { @@ -81,7 +82,7 @@ protected void actionPerformed(GuiButton button) tag.setInteger("remove", rem); listOffset = ((GuiReactiveList)button).getOffset()-1; } - else if(button.id==1 && !this.nameField.getText().isEmpty()) + else if(button.id==1&&!this.nameField.getText().isEmpty()) { String name = this.nameField.getText(); if(!tile.targetList.contains(name)) @@ -112,12 +113,12 @@ else if(button.id==5) tile.attackNeutrals = ((GuiButtonState)button).state; tag.setBoolean("attackNeutrals", tile.attackNeutrals); } - else if(button.id==6 && tile instanceof TileEntityTurretChem) + else if(button.id==6&&tile instanceof TileEntityTurretChem) { ((TileEntityTurretChem)tile).ignite = ((GuiButtonState)button).state; tag.setBoolean("ignite", ((TileEntityTurretChem)tile).ignite); } - else if(button.id==6 && tile instanceof TileEntityTurretGun) + else if(button.id==6&&tile instanceof TileEntityTurretGun) { ((TileEntityTurretGun)tile).expelCasings = ((GuiButtonState)button).state; tag.setBoolean("expelCasings", ((TileEntityTurretGun)tile).expelCasings); @@ -126,7 +127,7 @@ else if(button.id==6 && tile instanceof TileEntityTurretGun) { ImmersiveEngineering.packetHandler.sendToServer(new MessageTileSync(tile, tag)); this.initGui(); - if(listOffset>=0) + if(listOffset >= 0) ((GuiReactiveList)this.buttonList.get(0)).setOffset(listOffset); } } @@ -138,23 +139,23 @@ public void drawScreen(int mx, int my, float partial) this.nameField.drawTextBox(); ArrayList tooltip = new ArrayList(); - if(mx>=guiLeft+158&&mx=guiTop+16&&my= guiLeft+158&&mx < guiLeft+165&&my >= guiTop+16&&my < guiTop+62) tooltip.add(tile.getEnergyStored(null)+"/"+tile.getMaxEnergyStored(null)+" RF"); if(tile instanceof TileEntityTurretChem) { - ClientUtils.handleGuiTank(((TileEntityTurretChem)tile).tank, guiLeft+134,guiTop+16,16,47, 196,0,20,51, mx,my, "immersiveengineering:textures/gui/turret.png", tooltip); - if(mx>=guiLeft+135&&mx=guiTop+68&&my= guiLeft+135&&mx < guiLeft+149&&my >= guiTop+68&&my < guiTop+82) tooltip.add(I18n.format(Lib.GUI_CONFIG+"turret.ignite_fluid")); } else if(tile instanceof TileEntityTurretGun) { - if(mx>=guiLeft+134&&mx=guiTop+31&&my= guiLeft+134&&mx < guiLeft+150&&my >= guiTop+31&&my < guiTop+47) + tooltip.add(I18n.format(Lib.GUI_CONFIG+"turret.expel_casings_"+(((TileEntityTurretGun)tile).expelCasings?"on": "off"))); } if(!tooltip.isEmpty()) { - ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer, -1,-1); + ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer, -1, -1); RenderHelper.enableGUIStandardItemLighting(); } @@ -165,20 +166,20 @@ protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); ClientUtils.bindTexture("immersiveengineering:textures/gui/turret.png"); - this.drawTexturedModalRect(guiLeft,guiTop, 0, 0, xSize, ySize); + this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); int stored = (int)(46*(tile.getEnergyStored(null)/(float)tile.getMaxEnergyStored(null))); - ClientUtils.drawGradientRect(guiLeft+158,guiTop+16+(46-stored), guiLeft+165,guiTop+62, 0xffb51500, 0xff600b00); + ClientUtils.drawGradientRect(guiLeft+158, guiTop+16+(46-stored), guiLeft+165, guiTop+62, 0xffb51500, 0xff600b00); if(tile instanceof TileEntityTurretChem) { - this.drawTexturedModalRect(guiLeft+132,guiTop+14, 176,0, 20,51); - ClientUtils.handleGuiTank(((TileEntityTurretChem)tile).tank, guiLeft+134,guiTop+16,16,47, 196,0,20,51, mx,my, "immersiveengineering:textures/gui/turret.png",null); + this.drawTexturedModalRect(guiLeft+132, guiTop+14, 176, 0, 20, 51); + ClientUtils.handleGuiTank(((TileEntityTurretChem)tile).tank, guiLeft+134, guiTop+16, 16, 47, 196, 0, 20, 51, mx, my, "immersiveengineering:textures/gui/turret.png", null); } else if(tile instanceof TileEntityTurretGun) { - ClientUtils.drawDarkSlot(guiLeft+134,guiTop+13, 16,16); - ClientUtils.drawDarkSlot(guiLeft+134,guiTop+49, 16,16); + ClientUtils.drawDarkSlot(guiLeft+134, guiTop+13, 16, 16); + ClientUtils.drawDarkSlot(guiLeft+134, guiTop+49, 16, 16); } } @@ -192,7 +193,7 @@ public void onGuiClosed() @Override protected void keyTyped(char typedChar, int keyCode) throws IOException { - if(this.nameField.isFocused() && keyCode==28) + if(this.nameField.isFocused()&&keyCode==28) { String name = this.nameField.getText(); if(!tile.targetList.contains(name)) @@ -210,6 +211,7 @@ else if(!this.nameField.textboxKeyTyped(typedChar, keyCode)) super.keyTyped(typedChar, keyCode); } + @Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { diff --git a/src/main/java/blusunrize/immersiveengineering/client/gui/elements/GuiButtonCheckbox.java b/src/main/java/blusunrize/immersiveengineering/client/gui/elements/GuiButtonCheckbox.java index 7671906965..2ef182c544 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/gui/elements/GuiButtonCheckbox.java +++ b/src/main/java/blusunrize/immersiveengineering/client/gui/elements/GuiButtonCheckbox.java @@ -15,14 +15,14 @@ public class GuiButtonCheckbox extends GuiButtonState { public GuiButtonCheckbox(int buttonId, int x, int y, String name, boolean state) { - super(buttonId, x,y, 8,8, name, state, "immersiveengineering:textures/gui/hud_elements.png",0,128, -1); + super(buttonId, x, y, 8, 8, name, state, "immersiveengineering:textures/gui/hud_elements.png", 0, 128, -1); } @Override public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) { super.drawButton(mc, mouseX, mouseY, partialTicks); - if(this.visible && state) - this.drawCenteredString( mc.fontRenderer, "\u2714", x+width/2, y-2, !this.enabled?0xA0A0A0: this.hovered?Lib.COLOUR_I_ImmersiveOrange: 0xE0E0E0); + if(this.visible&&state) + this.drawCenteredString(mc.fontRenderer, "\u2714", x+width/2, y-2, !this.enabled?0xA0A0A0: this.hovered?Lib.COLOUR_I_ImmersiveOrange: 0xE0E0E0); } } diff --git a/src/main/java/blusunrize/immersiveengineering/client/gui/elements/GuiButtonIE.java b/src/main/java/blusunrize/immersiveengineering/client/gui/elements/GuiButtonIE.java index 86295f146b..6c10908744 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/gui/elements/GuiButtonIE.java +++ b/src/main/java/blusunrize/immersiveengineering/client/gui/elements/GuiButtonIE.java @@ -20,18 +20,20 @@ public class GuiButtonIE extends GuiButton protected final String texture; protected final int texU; protected final int texV; + public GuiButtonIE(int buttonId, int x, int y, int w, int h, String name, String texture, int u, int v) { - super(buttonId, x, y, w,h, name); + super(buttonId, x, y, w, h, name); this.texture = texture; this.texU = u; this.texV = v; } int[] hoverOffset; + public GuiButtonIE setHoverOffset(int x, int y) { - this.hoverOffset = new int[]{x,y}; + this.hoverOffset = new int[]{x, y}; return this; } @@ -43,23 +45,23 @@ public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) ClientUtils.bindTexture(texture); FontRenderer fontrenderer = mc.fontRenderer; GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height; + this.hovered = mouseX >= this.x&&mouseY >= this.y&&mouseX < this.x+this.width&&mouseY < this.y+this.height; GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.blendFunc(770, 771); - if(hoverOffset!=null && this.hovered) - this.drawTexturedModalRect(x,y, texU+hoverOffset[0],texV+hoverOffset[1], width,height); + if(hoverOffset!=null&&this.hovered) + this.drawTexturedModalRect(x, y, texU+hoverOffset[0], texV+hoverOffset[1], width, height); else - this.drawTexturedModalRect(x,y, texU,texV, width,height); + this.drawTexturedModalRect(x, y, texU, texV, width, height); this.mouseDragged(mc, mouseX, mouseY); - if(displayString!=null && !displayString.isEmpty()) + if(displayString!=null&&!displayString.isEmpty()) { int txtCol = 0xE0E0E0; if(!this.enabled) txtCol = 0xA0A0A0; else if(this.hovered) txtCol = Lib.COLOUR_I_ImmersiveOrange; - this.drawCenteredString(fontrenderer, this.displayString, this.x+this.width/2, this.y+(this.height-8)/ 2, txtCol); + this.drawCenteredString(fontrenderer, this.displayString, this.x+this.width/2, this.y+(this.height-8)/2, txtCol); } } } diff --git a/src/main/java/blusunrize/immersiveengineering/client/gui/elements/GuiButtonItem.java b/src/main/java/blusunrize/immersiveengineering/client/gui/elements/GuiButtonItem.java index dfb14c8847..bd345b2df0 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/gui/elements/GuiButtonItem.java +++ b/src/main/java/blusunrize/immersiveengineering/client/gui/elements/GuiButtonItem.java @@ -21,9 +21,10 @@ public class GuiButtonItem extends GuiButton { public boolean state; ItemStack item; + public GuiButtonItem(int buttonId, int x, int y, ItemStack stack, boolean state) { - super(buttonId, x, y, 18,18, ""); + super(buttonId, x, y, 18, 18, ""); this.state = state; this.item = stack; } @@ -35,11 +36,11 @@ public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) { ClientUtils.bindTexture("immersiveengineering:textures/gui/hud_elements.png"); GlStateManager.color(1.0F, 1.0F, 1.0F, 0.5F); - this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height; + this.hovered = mouseX >= this.x&&mouseY >= this.y&&mouseX < this.x+this.width&&mouseY < this.y+this.height; GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.blendFunc(770, 771); - this.drawTexturedModalRect(x,y, 24+(state?18:0),128, width,height); + this.drawTexturedModalRect(x, y, 24+(state?18: 0), 128, width, height); this.mouseDragged(mc, mouseX, mouseY); if(!item.isEmpty()) @@ -69,11 +70,11 @@ public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) } @Override - public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) - { + public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) + { boolean b = super.mousePressed(mc, mouseX, mouseY); if(b) this.state = !state; return b; - } + } } diff --git a/src/main/java/blusunrize/immersiveengineering/client/gui/elements/GuiButtonState.java b/src/main/java/blusunrize/immersiveengineering/client/gui/elements/GuiButtonState.java index a690e5b954..00aabe6fff 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/gui/elements/GuiButtonState.java +++ b/src/main/java/blusunrize/immersiveengineering/client/gui/elements/GuiButtonState.java @@ -18,13 +18,14 @@ public class GuiButtonState extends GuiButtonIE { public boolean state; protected final int offsetDir; - public int[] textOffset = {0,0}; + public int[] textOffset = {0, 0}; + public GuiButtonState(int buttonId, int x, int y, int w, int h, String name, boolean state, String texture, int u, int v, int offsetDir) { - super(buttonId, x, y, w,h, name, texture, u,v); + super(buttonId, x, y, w, h, name, texture, u, v); this.state = state; this.offsetDir = offsetDir; - textOffset = new int[]{width+1,height/2-3}; + textOffset = new int[]{width+1, height/2-3}; } @Override @@ -35,15 +36,15 @@ public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) ClientUtils.bindTexture(texture); FontRenderer fontrenderer = mc.fontRenderer; GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height; + this.hovered = mouseX >= this.x&&mouseY >= this.y&&mouseX < this.x+this.width&&mouseY < this.y+this.height; GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.blendFunc(770, 771); - int u = texU + (!state?0: offsetDir==0?width: offsetDir==2?-width: 0); - int v = texV + (!state?0: offsetDir==1?height: offsetDir==3?-height: 0); - this.drawTexturedModalRect(x,y, u,v, width,height); + int u = texU+(!state?0: offsetDir==0?width: offsetDir==2?-width: 0); + int v = texV+(!state?0: offsetDir==1?height: offsetDir==3?-height: 0); + this.drawTexturedModalRect(x, y, u, v, width, height); this.mouseDragged(mc, mouseX, mouseY); - if(displayString!=null && !displayString.isEmpty()) + if(displayString!=null&&!displayString.isEmpty()) { int txtCol = 0xE0E0E0; if(!this.enabled) diff --git a/src/main/java/blusunrize/immersiveengineering/client/gui/elements/GuiReactiveList.java b/src/main/java/blusunrize/immersiveengineering/client/gui/elements/GuiReactiveList.java index a9ba31597b..6a5943ef45 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/gui/elements/GuiReactiveList.java +++ b/src/main/java/blusunrize/immersiveengineering/client/gui/elements/GuiReactiveList.java @@ -23,7 +23,7 @@ public class GuiReactiveList extends GuiButton { private final GuiScreen gui; private String[] entries; - private int[] padding = {0,0,0,0}; + private int[] padding = {0, 0, 0, 0}; private boolean needsSlider = false; private int perPage; private Function translationFunction; @@ -45,10 +45,11 @@ public GuiReactiveList(GuiScreen gui, int id, int x, int y, int w, int h, String this.entries = entries; recalculateEntries(); } + private void recalculateEntries() { perPage = (int)((this.height-padding[0]-padding[1])/(ClientUtils.mc().fontRenderer.FONT_HEIGHT*textScale)); - if(perPage func) + + public GuiReactiveList setTranslationFunc(Function func) { this.translationFunction = func; return this; } - /** @param mode 0: No scrolling
1: Scroll when hovered
2: Scroll all */ + + /** + * @param mode 0: No scrolling
1: Scroll when hovered
2: Scroll all + */ public GuiReactiveList setScrollMode(int mode) { this.scrollMode = mode; return this; } + public GuiReactiveList setFormatting(float textScale, boolean unicode) { this.textScale = textScale; @@ -88,10 +95,12 @@ public int getOffset() { return this.offset; } + public void setOffset(int offset) { this.offset = offset; } + public int getMaxOffset() { return this.maxOffset; @@ -105,33 +114,33 @@ public void drawButton(Minecraft mc, int mx, int my, float partialTicks) fr.setUnicodeFlag(unicode); int mmY = my-this.y; - int strWidth = width-padding[2]-padding[3]-(needsSlider?6:0); + int strWidth = width-padding[2]-padding[3]-(needsSlider?6: 0); GlStateManager.color(1, 1, 1); if(needsSlider) { ClientUtils.bindTexture("immersiveengineering:textures/gui/hud_elements.png"); - this.drawTexturedModalRect(x+width-6,y, 16,136, 6,4); - this.drawTexturedModalRect(x+width-6,y+height-4, 16,144, 6,4); - for(int i=0;i=x&&mx=y&&my= x&&mx < x+width&&my >= y&&my < y+height; boolean hasTarget = false; - for(int i=0; i=i*fr.FONT_HEIGHT && mmY<(i+1)*fr.FONT_HEIGHT; + boolean selectionHover = hovered&&mmY >= i*fr.FONT_HEIGHT&&mmY < (i+1)*fr.FONT_HEIGHT; if(selectionHover) { hasTarget = true; @@ -144,26 +153,26 @@ public void drawButton(Minecraft mc, int mx, int my, float partialTicks) hoverTimer++; col = Lib.COLOUR_I_ImmersiveOrange; } - if(j>entries.length-1) - j=entries.length-1; - String s = translationFunction!=null?translationFunction.apply(entries[j]):entries[j]; + if(j > entries.length-1) + j = entries.length-1; + String s = translationFunction!=null?translationFunction.apply(entries[j]): entries[j]; int overLength = s.length()-fr.sizeStringToWidth(s, strWidth); - if(overLength>0)//String is too long + if(overLength > 0)//String is too long { - if(selectionHover && hoverTimer>20) + if(selectionHover&&hoverTimer > 20) { int textOffset = (hoverTimer/10)%(s.length()); - s = s.substring(textOffset)+" "+s.substring(0,textOffset); + s = s.substring(textOffset)+" "+s.substring(0, textOffset); } s = fr.trimStringToWidth(s, strWidth); } float tx = ((x+padding[2])/textScale); float ty = ((y+padding[0]+(fr.FONT_HEIGHT*i))/textScale); GlStateManager.translate(tx, ty, 0); - fr.drawString(s, 0,0, col, false); + fr.drawString(s, 0, 0, col, false); GlStateManager.translate(-tx, -ty, 0); } - GlStateManager.scale(1/textScale,1/textScale,1); + GlStateManager.scale(1/textScale, 1/textScale, 1); if(!hasTarget) { targetEntry = -1; @@ -174,29 +183,30 @@ public void drawButton(Minecraft mc, int mx, int my, float partialTicks) //Handle DWheel int mouseWheel = Mouse.getEventDWheel(); - if(mouseWheel!=0 && maxOffset>0 && Mouse.getEventNanoseconds()!=prevWheelNano) + if(mouseWheel!=0&&maxOffset > 0&&Mouse.getEventNanoseconds()!=prevWheelNano) { prevWheelNano = Mouse.getEventNanoseconds(); - if(mouseWheel<0 && offset0 && offset>0) + if(mouseWheel > 0&&offset > 0) offset--; } } - public int selectedOption=-1; + public int selectedOption = -1; + @Override public boolean mousePressed(Minecraft mc, int mx, int my) { boolean b = super.mousePressed(mc, mx, my); FontRenderer fr = ClientUtils.mc().fontRenderer; - selectedOption=-1; + selectedOption = -1; if(b) { int mmY = my-this.y; - for(int i=0; i=i*fr.FONT_HEIGHT && mmY<(i+1)*fr.FONT_HEIGHT) - selectedOption=offset+i; + for(int i = 0; i < Math.min(perPage, entries.length); i++) + if(mmY >= i*fr.FONT_HEIGHT&&mmY < (i+1)*fr.FONT_HEIGHT) + selectedOption = offset+i; } return selectedOption!=-1; } diff --git a/src/main/java/blusunrize/immersiveengineering/client/gui/elements/GuiSliderIE.java b/src/main/java/blusunrize/immersiveengineering/client/gui/elements/GuiSliderIE.java index 44a2b1b52b..ac7e16e152 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/gui/elements/GuiSliderIE.java +++ b/src/main/java/blusunrize/immersiveengineering/client/gui/elements/GuiSliderIE.java @@ -18,7 +18,7 @@ public class GuiSliderIE extends GuiSlider { public GuiSliderIE(int buttonId, int x, int y, int width, String name, float value) { - super(buttonId, x, y, width,8, name+" ","%", 0,100, 100*value, false,true); + super(buttonId, x, y, width, 8, name+" ", "%", 0, 100, 100*value, false, true); } @Override @@ -29,14 +29,14 @@ public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) ClientUtils.bindTexture("immersiveengineering:textures/gui/hud_elements.png"); FontRenderer fontrenderer = mc.fontRenderer; GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height; + this.hovered = mouseX >= this.x&&mouseY >= this.y&&mouseX < this.x+this.width&&mouseY < this.y+this.height; GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.blendFunc(770, 771); - this.drawTexturedModalRect(x,y, 8,128, 4,height); - this.drawTexturedModalRect(x+width-4,y, 16,128, 4,height); - for(int i=0;i", "\n"); int start; - int overflow=0; - while( (start=s.indexOf("=0 && overflow<50) + int overflow = 0; + while((start = s.indexOf("= 0&&overflow < 50) { overflow++; int end = s.indexOf(">", start); String rep = s.substring(start, end+1); - String[] segment = rep.substring(0,rep.length()-1).split(splitKey); - if(segment.length<3) + String[] segment = rep.substring(0, rep.length()-1).split(splitKey); + if(segment.length < 3) break; String result = ""; if(segment[1].equalsIgnoreCase("b")) { - if(segment.length>3) - result = (Config.manual_bool.get(segment[2])?segment[3]: segment.length>4?segment[4]:""); + if(segment.length > 3) + result = (Config.manual_bool.get(segment[2])?segment[3]: segment.length > 4?segment[4]: ""); else - result = ""+ Config.manual_bool.get(segment[2]); + result = ""+Config.manual_bool.get(segment[2]); } else if(segment[1].equalsIgnoreCase("i")) - result = ""+ Config.manual_int.get(segment[2]); + result = ""+Config.manual_int.get(segment[2]); else if(segment[1].equalsIgnoreCase("iA")) { int[] iA = Config.manual_intA.get(segment[2]); - if(segment.length>3) - try{ + if(segment.length > 3) + try + { if(segment[3].startsWith("l")) { int limiter = Integer.parseInt(segment[3].substring(1)); - for(int i=0; i0?", ":"")+iA[i]; + for(int i = 0; i < limiter; i++) + result += (i > 0?", ": "")+iA[i]; } else { int idx = Integer.parseInt(segment[3]); result = ""+iA[idx]; } - }catch(Exception ex){ + } catch(Exception ex) + { break; } else - for(int i=0; i0?", ":"")+iA[i]; + for(int i = 0; i < iA.length; i++) + result += (i > 0?", ": "")+iA[i]; } else if(segment[1].equalsIgnoreCase("d")) - result = ""+ Config.manual_double.get(segment[2]); + result = ""+Config.manual_double.get(segment[2]); else if(segment[1].equalsIgnoreCase("dA")) { double[] iD = Config.manual_doubleA.get(segment[2]); - if(segment.length>3) - try{ + if(segment.length > 3) + try + { int idx = Integer.parseInt(segment[3]); result = ""+Utils.formatDouble(iD[idx], "##0.0##"); - }catch(Exception ex){ + } catch(Exception ex) + { break; } else - for(int i=0; i0?", ":"")+Utils.formatDouble(iD[i], "##0.0##"); + for(int i = 0; i < iD.length; i++) + result += (i > 0?", ": "")+Utils.formatDouble(iD[i], "##0.0##"); } s = s.replaceFirst(rep, result); } - overflow=0; - while( (start=s.indexOf("=0 && overflow<50) + overflow = 0; + while((start = s.indexOf("= 0&&overflow < 50) { overflow++; int end = s.indexOf(">", start); String rep = s.substring(start, end+1); - String[] segment = rep.substring(0,rep.length()-1).split(splitKey); - if(segment.length<2) + String[] segment = rep.substring(0, rep.length()-1).split(splitKey); + if(segment.length < 2) break; String result = ""; - try{ + try + { int dim = Integer.parseInt(segment[1]); World world = DimensionManager.getWorld(dim); - if(world!=null && world.provider!=null) + if(world!=null&&world.provider!=null) { String name = world.provider.getDimensionType().getName(); - if(name.toLowerCase(Locale.ENGLISH).startsWith("the ") || name.toLowerCase(Locale.ENGLISH).startsWith("the_")) - name = name.substring(4,5).toUpperCase()+name.substring(5); + if(name.toLowerCase(Locale.ENGLISH).startsWith("the ")||name.toLowerCase(Locale.ENGLISH).startsWith("the_")) + name = name.substring(4, 5).toUpperCase()+name.substring(5); result = name; } else result = "Dimension "+dim; - }catch(Exception ex){ + } catch(Exception ex) + { ex.printStackTrace(); } s = s.replaceFirst(rep, result); } - overflow=0; - while( (start=s.indexOf("=0 && overflow<50) + overflow = 0; + while((start = s.indexOf("= 0&&overflow < 50) { overflow++; int end = s.indexOf(">", start); String rep = s.substring(start, end+1); - String[] segment = rep.substring(0,rep.length()-1).split(splitKey); - if(segment.length<2) + String[] segment = rep.substring(0, rep.length()-1).split(splitKey); + if(segment.length < 2) break; String result = ""; for(KeyBinding kb : ClientUtils.mc().gameSettings.keyBindings) @@ -174,15 +180,15 @@ else if(segment[1].equalsIgnoreCase("dA")) if(improveReadability()) { - overflow=0; + overflow = 0; int end = 0; - while( (start=s.indexOf(TextFormatting.RESET.toString(),end))>=0 && overflow<50) + while((start = s.indexOf(TextFormatting.RESET.toString(), end)) >= 0&&overflow < 50) { overflow++; - end = start+ TextFormatting.RESET.toString().length(); - s = s.substring(0,end)+ TextFormatting.BOLD.toString()+s.substring(end); + end = start+TextFormatting.RESET.toString().length(); + s = s.substring(0, end)+TextFormatting.BOLD.toString()+s.substring(end); } - s = TextFormatting.BOLD + s; + s = TextFormatting.BOLD+s; } return s; } @@ -192,58 +198,64 @@ public void openManual() { if(improveReadability()) { - ((IEItemFontRender)this.fontRenderer).spacingModifier=-.5f; - ((IEItemFontRender)this.fontRenderer).customSpaceWidth=1f; + ((IEItemFontRender)this.fontRenderer).spacingModifier = -.5f; + ((IEItemFontRender)this.fontRenderer).customSpaceWidth = 1f; } } + @Override public void titleRenderPre() { if(improveReadability()) { - ((IEItemFontRender)this.fontRenderer).spacingModifier=.5f; - ((IEItemFontRender)this.fontRenderer).customSpaceWidth=4f; + ((IEItemFontRender)this.fontRenderer).spacingModifier = .5f; + ((IEItemFontRender)this.fontRenderer).customSpaceWidth = 4f; } } + @Override public void titleRenderPost() { if(improveReadability()) { - ((IEItemFontRender)this.fontRenderer).spacingModifier=-.5f; - ((IEItemFontRender)this.fontRenderer).customSpaceWidth=1f; + ((IEItemFontRender)this.fontRenderer).spacingModifier = -.5f; + ((IEItemFontRender)this.fontRenderer).customSpaceWidth = 1f; } } + @Override public void entryRenderPre() { if(improveReadability()) - ((IEItemFontRender)this.fontRenderer).verticalBoldness=true; + ((IEItemFontRender)this.fontRenderer).verticalBoldness = true; } + @Override public void entryRenderPost() { if(improveReadability()) - ((IEItemFontRender)this.fontRenderer).verticalBoldness=false; + ((IEItemFontRender)this.fontRenderer).verticalBoldness = false; } + @Override public void tooltipRenderPre() { if(improveReadability()) { - ((IEItemFontRender)this.fontRenderer).spacingModifier=0f; - ((IEItemFontRender)this.fontRenderer).customSpaceWidth=4f; - ((IEItemFontRender)this.fontRenderer).verticalBoldness=false; + ((IEItemFontRender)this.fontRenderer).spacingModifier = 0f; + ((IEItemFontRender)this.fontRenderer).customSpaceWidth = 4f; + ((IEItemFontRender)this.fontRenderer).verticalBoldness = false; } } + @Override public void tooltipRenderPost() { if(improveReadability()) { - ((IEItemFontRender)this.fontRenderer).spacingModifier=-.5f; - ((IEItemFontRender)this.fontRenderer).customSpaceWidth=1f; - ((IEItemFontRender)this.fontRenderer).verticalBoldness=true; + ((IEItemFontRender)this.fontRenderer).spacingModifier = -.5f; + ((IEItemFontRender)this.fontRenderer).customSpaceWidth = 1f; + ((IEItemFontRender)this.fontRenderer).verticalBoldness = true; } } @@ -253,46 +265,53 @@ public String getManualName() { return I18n.format("item.immersiveengineering.tool.manual.name"); } + @Override public void addEntry(String name, String category, IManualPage... pages) { super.addEntry(name, category, pages); - if(!categorySet.contains(category)) - categorySet.add(category); + categorySet.add(category); } + LinkedHashSet categorySet = new LinkedHashSet(); + @Override public String[] getSortedCategoryList() { return categorySet.toArray(new String[categorySet.size()]); } + @Override public String formatCategoryName(String s) { - return (improveReadability()? TextFormatting.BOLD:"")+ I18n.format("ie.manual.category."+s+".name"); + return (improveReadability()?TextFormatting.BOLD: "")+I18n.format("ie.manual.category."+s+".name"); } + @Override public String formatEntryName(String s) { - String unformatted = "ie.manual.entry." + s + ".name"; + String unformatted = "ie.manual.entry."+s+".name"; String formatted = I18n.format(unformatted); // return "\uD83D\uDCBB"; - return (improveReadability() ? TextFormatting.BOLD : "") + (unformatted.equals(formatted) ? s : formatted); + return (improveReadability()?TextFormatting.BOLD: "")+(unformatted.equals(formatted)?s: formatted); } + @Override public String formatEntrySubtext(String s) { - String unformatted = "ie.manual.entry." + s + ".subtext"; + String unformatted = "ie.manual.entry."+s+".subtext"; String formatted = I18n.format(unformatted); - return unformatted.equals(formatted) ? "" : formatted; + return unformatted.equals(formatted)?"": formatted; } + @Override public boolean showEntryInList(ManualEntry entry) { - if(entry!=null && ManualHelper.CAT_UPDATE.equalsIgnoreCase(entry.getCategory())) + if(entry!=null&&ManualHelper.CAT_UPDATE.equalsIgnoreCase(entry.getCategory())) return IEConfig.showUpdateNews; - return !(entry != null && "shaderList".equalsIgnoreCase(entry.getName())); + return !(entry!=null&&"shaderList".equalsIgnoreCase(entry.getName())); } + @Override public boolean showCategoryInList(String category) { @@ -317,21 +336,25 @@ public int getTitleColour() { return 0xf78034; } + @Override public int getSubTitleColour() { return 0xf78034; } + @Override public int getTextColour() { - return improveReadability()?0:0x555555; + return improveReadability()?0: 0x555555; } + @Override public int getHighlightColour() { return 0xd4804a; } + @Override public int getPagenumberColour() { @@ -343,6 +366,7 @@ public boolean allowGuiRescale() { return IEConfig.adjustManualScale; } + @Override public boolean improveReadability() { diff --git a/src/main/java/blusunrize/immersiveengineering/client/manual/ManualPageShader.java b/src/main/java/blusunrize/immersiveengineering/client/manual/ManualPageShader.java index e2bc9e7ee1..e52dbfdedd 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/manual/ManualPageShader.java +++ b/src/main/java/blusunrize/immersiveengineering/client/manual/ManualPageShader.java @@ -70,10 +70,10 @@ public void initPage(GuiManual gui, int x, int y, List pageButtons) { ArrayList list = new ArrayList(); for(ItemStack is : ShaderRegistry.itemExamples) - if(!is.isEmpty() && is.hasCapability(CapabilityShader.SHADER_CAPABILITY,null)) + if(!is.isEmpty()&&is.hasCapability(CapabilityShader.SHADER_CAPABILITY, null)) { ItemStack s = is.copy(); - ShaderWrapper wrapper = s.getCapability(CapabilityShader.SHADER_CAPABILITY,null); + ShaderWrapper wrapper = s.getCapability(CapabilityShader.SHADER_CAPABILITY, null); if(wrapper!=null) { wrapper.setShaderItem(shaderItem); @@ -82,10 +82,10 @@ public void initPage(GuiManual gui, int x, int y, List pageButtons) } exampleItems = list.toArray(new ItemStack[list.size()]); example = 0; - if(exampleItems.length>1) + if(exampleItems.length > 1) { - pageButtons.add(new GuiButtonManualNavigation(gui, 100, x+50, y, 10,16, 0)); - pageButtons.add(new GuiButtonManualNavigation(gui, 101, x+100, y, 10,16, 1)); + pageButtons.add(new GuiButtonManualNavigation(gui, 100, x+50, y, 10, 16, 0)); + pageButtons.add(new GuiButtonManualNavigation(gui, 101, x+100, y, 10, 16, 1)); } } else @@ -98,23 +98,23 @@ public void initPage(GuiManual gui, int x, int y, List pageButtons) String reference = shader.info_reference==null||shader.info_reference.isEmpty()?null: ManualUtils.attemptStringTranslation(Lib.DESC_INFO+"shader.reference.%s", shader.info_reference); String details = shader.info_details==null||shader.info_details.isEmpty()?null: ManualUtils.attemptStringTranslation(Lib.DESC_INFO+"shader.details.%s", shader.info_details); - if(set != null) - this.text += "

" + I18n.format("desc.immersiveengineering.info.shader.set") + " " + set; - if(reference != null) - this.text += "

" + I18n.format("desc.immersiveengineering.info.shader.reference") + "
" + reference; - if(details != null) - this.text += "

" + I18n.format("desc.immersiveengineering.info.shader.details") + "
" + details; + if(set!=null) + this.text += "

"+I18n.format("desc.immersiveengineering.info.shader.set")+" "+set; + if(reference!=null) + this.text += "

"+I18n.format("desc.immersiveengineering.info.shader.reference")+"
"+reference; + if(details!=null) + this.text += "

"+I18n.format("desc.immersiveengineering.info.shader.details")+"
"+details; String cost = Integer.toString(replicationCost.inputSize); - if(!ApiUtils.hasPlayerIngredient(gui.mc.player,replicationCost) && !gui.mc.player.capabilities.isCreativeMode) + if(!ApiUtils.hasPlayerIngredient(gui.mc.player, replicationCost)&&!gui.mc.player.capabilities.isCreativeMode) cost = TextFormatting.RED+cost; - pageButtons.add(new GuiButtonManual(gui, 102, x+50, y+138, 70,12, TextFormatting.BOLD+I18n.format("ie.manual.entry.shaderList.order")+" "+cost+"x ").setTextColour(gui.getManual().getTextColour(),gui.getManual().getHighlightColour())); + pageButtons.add(new GuiButtonManual(gui, 102, x+50, y+138, 70, 12, TextFormatting.BOLD+I18n.format("ie.manual.entry.shaderList.order")+" "+cost+"x ").setTextColour(gui.getManual().getTextColour(), gui.getManual().getHighlightColour())); } else { - this.text += "

" + I18n.format("ie.manual.entry.shaderList.noInfo"); + this.text += "

"+I18n.format("ie.manual.entry.shaderList.noInfo"); if(player.capabilities.isCreativeMode) - pageButtons.add(new GuiButtonManual(gui, 103, x+10, y+80, 100,16, I18n.format("ie.manual.entry.shaderList.unlock")).setTextColour(gui.getManual().getTextColour(),gui.getManual().getHighlightColour())); + pageButtons.add(new GuiButtonManual(gui, 103, x+10, y+80, 100, 16, I18n.format("ie.manual.entry.shaderList.unlock")).setTextColour(gui.getManual().getTextColour(), gui.getManual().getHighlightColour())); } super.initPage(gui, x, y, pageButtons); } @@ -125,17 +125,17 @@ public void renderPage(GuiManual gui, int x, int y, int mx, int my) GlStateManager.enableRescaleNormal(); RenderHelper.enableGUIStandardItemLighting(); float scale = 2; - GlStateManager.scale(scale,scale,scale); - boolean examples = exampleItems!=null && exampleItems.length>0; + GlStateManager.scale(scale, scale, scale); + boolean examples = exampleItems!=null&&exampleItems.length > 0; - ManualUtils.renderItem().renderItemAndEffectIntoGUI(shaderItem, (int)((x+10+(examples?0:34))/scale),(int)((y-8)/scale)); - if(examples && example>=0&&example= 0&&example < exampleItems.length) + ManualUtils.renderItem().renderItemAndEffectIntoGUI(exampleItems[example], (int)((x+63)/scale), (int)((y-8)/scale)); - GlStateManager.scale(1/scale,1/scale,1/scale); + GlStateManager.scale(1/scale, 1/scale, 1/scale); if(unlocked) - ManualUtils.renderItem().renderItemAndEffectIntoGUI(replicationCost.getRandomizedExampleStack(gui.mc.player.ticksExisted), x+102, y + 136); + ManualUtils.renderItem().renderItemAndEffectIntoGUI(replicationCost.getRandomizedExampleStack(gui.mc.player.ticksExisted), x+102, y+136); RenderHelper.disableStandardItemLighting(); GlStateManager.disableRescaleNormal(); @@ -143,8 +143,8 @@ public void renderPage(GuiManual gui, int x, int y, int mx, int my) manual.fontRenderer.setUnicodeFlag(true); String name = "§l"+shader.getName(); int w = manual.fontRenderer.getStringWidth(name); - manual.fontRenderer.drawString(name,x+60-w/2,y+24,manual.getTextColour(),false); - if(localizedText != null && !localizedText.isEmpty()) + manual.fontRenderer.drawString(name, x+60-w/2, y+24, manual.getTextColour(), false); + if(localizedText!=null&&!localizedText.isEmpty()) manual.fontRenderer.drawSplitString(localizedText, x, y+38, 120, manual.getTextColour()); } @@ -160,22 +160,22 @@ public void buttonPressed(GuiManual gui, GuiButton button) if(button.id==100) { example--; - if(example<0) - example=this.exampleItems.length-1; + if(example < 0) + example = this.exampleItems.length-1; } else if(button.id==101) example = (example+1)%exampleItems.length; else if(button.id==102) { - if(ApiUtils.hasPlayerIngredient(gui.mc.player,replicationCost) || gui.mc.player.capabilities.isCreativeMode) - ImmersiveEngineering.packetHandler.sendToServer(new MessageShaderManual(MessageType.SPAWN,shader.getName())); + if(ApiUtils.hasPlayerIngredient(gui.mc.player, replicationCost)||gui.mc.player.capabilities.isCreativeMode) + ImmersiveEngineering.packetHandler.sendToServer(new MessageShaderManual(MessageType.SPAWN, shader.getName())); gui.initGui(); } else if(button.id==103) { String player = ManualUtils.mc().player.getName(); - ImmersiveEngineering.packetHandler.sendToServer(new MessageShaderManual(MessageType.UNLOCK,shader.getName())); - ShaderRegistry.receivedShaders.put(player,shader.getName()); + ImmersiveEngineering.packetHandler.sendToServer(new MessageShaderManual(MessageType.UNLOCK, shader.getName())); + ShaderRegistry.receivedShaders.put(player, shader.getName()); gui.initGui(); } super.buttonPressed(gui, button); diff --git a/src/main/java/blusunrize/immersiveengineering/client/models/IESmartObjModel.java b/src/main/java/blusunrize/immersiveengineering/client/models/IESmartObjModel.java index 41ed717b77..801eb9bce3 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/models/IESmartObjModel.java +++ b/src/main/java/blusunrize/immersiveengineering/client/models/IESmartObjModel.java @@ -88,11 +88,11 @@ public IESmartObjModel(IBakedModel baseModel, OBJModel model, IModelState state, public Pair handlePerspective(TransformType cameraTransformType) { this.lastCameraTransform = cameraTransformType; - if(transformationMap==null || transformationMap.isEmpty()) + if(transformationMap==null||transformationMap.isEmpty()) return super.handlePerspective(cameraTransformType); - Matrix4 matrix = transformationMap.containsKey(cameraTransformType)?transformationMap.get(cameraTransformType).copy():new Matrix4(); + Matrix4 matrix = transformationMap.containsKey(cameraTransformType)?transformationMap.get(cameraTransformType).copy(): new Matrix4(); - if(!this.tempStack.isEmpty() && this.tempStack.getItem() instanceof IOBJModelCallback) + if(!this.tempStack.isEmpty()&&this.tempStack.getItem() instanceof IOBJModelCallback) matrix = ((IOBJModelCallback)this.tempStack.getItem()).handlePerspective(this.tempStack, cameraTransformType, matrix, tempEntity); //matrix = new Matrix4(); //Assign Matrixes here manually in debug mode, then move them to the actual registration method @@ -131,6 +131,7 @@ public ItemOverrideList getOverrides() { return overrideList; } + ItemOverrideList overrideList = new ItemOverrideList(new ArrayList<>()) { @Override @@ -138,41 +139,41 @@ public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, W { tempEntityStatic = entity; ComparableItemStack comp = ApiUtils.createComparableItemStack(stack, false, true); - if (comp == null) + if(comp==null) return originalModel; IBakedModel model = cachedBakedItemModels.getIfPresent(comp); - if (model == null) + if(model==null) { - if (originalModel instanceof IESmartObjModel) + if(originalModel instanceof IESmartObjModel) { - IESmartObjModel newModel = (IESmartObjModel) originalModel; + IESmartObjModel newModel = (IESmartObjModel)originalModel; ImmutableMap.Builder builder = ImmutableMap.builder(); builder.put(ModelLoader.White.LOCATION.toString(), ModelLoader.White.INSTANCE); TextureAtlasSprite missing = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(new ResourceLocation("missingno").toString()); - for (String s : newModel.getModel().getMatLib().getMaterialNames()) + for(String s : newModel.getModel().getMatLib().getMaterialNames()) { TextureAtlasSprite sprite = null; - if (stack.hasCapability(CapabilityShader.SHADER_CAPABILITY, null)) + if(stack.hasCapability(CapabilityShader.SHADER_CAPABILITY, null)) { ShaderWrapper wrapper = stack.getCapability(CapabilityShader.SHADER_CAPABILITY, null); ItemStack shader = wrapper.getShaderItem(); - if (!shader.isEmpty() && shader.getItem() instanceof IShaderItem) + if(!shader.isEmpty()&&shader.getItem() instanceof IShaderItem) { - ShaderCase sCase = ((IShaderItem) shader.getItem()).getShaderCase(shader, stack, wrapper.getShaderType()); - if (sCase != null) + ShaderCase sCase = ((IShaderItem)shader.getItem()).getShaderCase(shader, stack, wrapper.getShaderType()); + if(sCase!=null) { ResourceLocation rl = sCase.getReplacementSprite(shader, stack, s, 0); sprite = ClientUtils.getSprite(rl); } } } - if (sprite == null && stack.getItem() instanceof IOBJModelCallback) - sprite = ((IOBJModelCallback) stack.getItem()).getTextureReplacement(stack, s); - if (sprite == null) + if(sprite==null&&stack.getItem() instanceof IOBJModelCallback) + sprite = ((IOBJModelCallback)stack.getItem()).getTextureReplacement(stack, s); + if(sprite==null) sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(newModel.getModel().getMatLib().getMaterial(s).getTexture().getTextureLocation().toString()); - if (sprite == null) + if(sprite==null) sprite = missing; builder.put(s, sprite); } @@ -182,15 +183,16 @@ public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, W bakedModel.tempStack = stack; bakedModel.tempEntity = entity; model = bakedModel; - } else + } + else model = originalModel; comp.copy(); cachedBakedItemModels.put(comp, model); } - if (model instanceof IESmartObjModel) + if(model instanceof IESmartObjModel) { - ((IESmartObjModel) model).tempStack = stack; - ((IESmartObjModel) model).tempEntity = entity; + ((IESmartObjModel)model).tempStack = stack; + ((IESmartObjModel)model).tempEntity = entity; } return model; } @@ -201,20 +203,21 @@ public List getQuads(IBlockState blockState, EnumFacing side, long ra { OBJState objState = null; Map tex = null; - if (blockState instanceof IExtendedBlockState) + if(blockState instanceof IExtendedBlockState) { - IExtendedBlockState ext = (IExtendedBlockState) blockState; - if (ext.getUnlistedNames().contains(Properties.AnimationProperty)) + IExtendedBlockState ext = (IExtendedBlockState)blockState; + if(ext.getUnlistedNames().contains(Properties.AnimationProperty)) { IModelState modState = ext.getValue(Properties.AnimationProperty); - if (modState instanceof OBJState) - objState = (OBJState) modState; + if(modState instanceof OBJState) + objState = (OBJState)modState; } - if (ext.getUnlistedNames().contains(IEProperties.OBJ_TEXTURE_REMAP)) + if(ext.getUnlistedNames().contains(IEProperties.OBJ_TEXTURE_REMAP)) tex = ext.getValue(IEProperties.OBJ_TEXTURE_REMAP); } return getQuads(blockState, side, rand, objState, tex, false); } + public List getQuads(IBlockState blockState, EnumFacing side, long rand, OBJState objstate, Map tex, boolean addAnimationAndTex) { @@ -222,16 +225,16 @@ public List getQuads(IBlockState blockState, EnumFacing side, long ra this.tempState = blockState; if(blockState instanceof IExtendedBlockState) { - IExtendedBlockState exState = (IExtendedBlockState) blockState; + IExtendedBlockState exState = (IExtendedBlockState)blockState; ExtBlockstateAdapter adapter; - if (objstate!=null) + if(objstate!=null) { - if(objstate.parent==null || objstate.parent==TRSRTransformation.identity()) + if(objstate.parent==null||objstate.parent==TRSRTransformation.identity()) objstate.parent = this.getState(); - if(objstate.getVisibilityMap().containsKey(Group.ALL) || objstate.getVisibilityMap().containsKey(Group.ALL_EXCEPT)) + if(objstate.getVisibilityMap().containsKey(Group.ALL)||objstate.getVisibilityMap().containsKey(Group.ALL_EXCEPT)) this.updateStateVisibilityMap(objstate); } - if (addAnimationAndTex) + if(addAnimationAndTex) adapter = new ExtBlockstateAdapter(exState, MinecraftForgeClient.getRenderLayer(), ExtBlockstateAdapter.CONNS_OBJ_CALLBACK, new Object[]{objstate, tex}); else @@ -267,7 +270,7 @@ private ImmutableList buildQuads() ShaderCase sCase = null; IOBJModelCallback callback = null; Object callbackObject = null; - if(!this.tempStack.isEmpty() && tempStack.hasCapability(CapabilityShader.SHADER_CAPABILITY, null)) + if(!this.tempStack.isEmpty()&&tempStack.hasCapability(CapabilityShader.SHADER_CAPABILITY, null)) { ShaderWrapper wrapper = tempStack.getCapability(CapabilityShader.SHADER_CAPABILITY, null); if(wrapper!=null) @@ -276,7 +279,8 @@ private ImmutableList buildQuads() if(!shader.isEmpty()&&shader.getItem() instanceof IShaderItem) sCase = ((IShaderItem)shader.getItem()).getShaderCase(shader, tempStack, wrapper.getShaderType()); } - } else if(this.tempState != null && this.tempState instanceof IExtendedBlockState && ((IExtendedBlockState)this.tempState).getUnlistedNames().contains(CapabilityShader.BLOCKSTATE_PROPERTY)) + } + else if(this.tempState!=null&&this.tempState instanceof IExtendedBlockState&&((IExtendedBlockState)this.tempState).getUnlistedNames().contains(CapabilityShader.BLOCKSTATE_PROPERTY)) { ShaderWrapper wrapper = ((IExtendedBlockState)this.tempState).getValue(CapabilityShader.BLOCKSTATE_PROPERTY); if(wrapper!=null) @@ -287,11 +291,12 @@ private ImmutableList buildQuads() } } - if(!this.tempStack.isEmpty() && tempStack.getItem() instanceof IOBJModelCallback) + if(!this.tempStack.isEmpty()&&tempStack.getItem() instanceof IOBJModelCallback) { callback = (IOBJModelCallback)tempStack.getItem(); callbackObject = this.tempStack; - } else if(this.tempState != null && this.tempState instanceof IExtendedBlockState && ((IExtendedBlockState)this.tempState).getUnlistedNames().contains(IOBJModelCallback.PROPERTY)) + } + else if(this.tempState!=null&&this.tempState instanceof IExtendedBlockState&&((IExtendedBlockState)this.tempState).getUnlistedNames().contains(IOBJModelCallback.PROPERTY)) { callback = ((IExtendedBlockState)this.tempState).getValue(IOBJModelCallback.PROPERTY); callbackObject = this.tempState; @@ -303,7 +308,7 @@ private ImmutableList buildQuads() } quads.addAll(shaderedQuadMap.keySet()); - if(callback != null) + if(callback!=null) quads = callback.modifyQuads(callbackObject, quads); return ImmutableList.copyOf(quads); } @@ -315,78 +320,78 @@ public void addQuadsForGroup(IOBJModelCallback callback, T callbackObject int maxPasses = 1; if(sCase!=null) maxPasses = sCase.getLayers().length; - for(int pass=0; pass faces = Collections.synchronizedSet(new LinkedHashSet<>()); Optional transform = Optional.empty(); - if (this.getState() instanceof OBJState) + if(this.getState() instanceof OBJState) { - OBJState state = (OBJState) this.getState(); - if (state.parent != null) + OBJState state = (OBJState)this.getState(); + if(state.parent!=null) transform = state.parent.apply(Optional.empty()); - if (callback != null) + if(callback!=null) transform = callback.applyTransformations(callbackObject, groupName, transform); - if (state.getGroupsWithVisibility(true).contains(groupName)) + if(state.getGroupsWithVisibility(true).contains(groupName)) faces.addAll(g.applyTransform(transform)); } else { transform = getState().apply(Optional.empty()); - if (callback != null) + if(callback!=null) transform = callback.applyTransformations(callbackObject, groupName, transform); faces.addAll(g.applyTransform(transform)); } int argb = 0xffffffff; - if (sCase != null) + if(sCase!=null) argb = sCase.getARGBColourModifier(shader, tempStack, groupName, pass); - else if (callback != null) + else if(callback!=null) argb = callback.getRenderColour(callbackObject, groupName); boolean dynQuad = false; - float[] colour = {(argb >> 16 & 255) / 255f, (argb >> 8 & 255) / 255f, (argb & 255) / 255f, (argb >> 24 & 255) / 255f}; + float[] colour = {(argb >> 16&255)/255f, (argb >> 8&255)/255f, (argb&255)/255f, (argb >> 24&255)/255f}; - for (Face f : faces) + for(Face f : faces) { TextureAtlasSprite tempSprite = null; - if (this.getModel().getMatLib().getMaterial(f.getMaterialName()).isWhite() && !"null".equals(f.getMaterialName())) + if(this.getModel().getMatLib().getMaterial(f.getMaterialName()).isWhite()&&!"null".equals(f.getMaterialName())) { - for (Vertex v : f.getVertices()) - if (!v.getMaterial().equals(this.getModel().getMatLib().getMaterial(v.getMaterial().getName()))) + for(Vertex v : f.getVertices()) + if(!v.getMaterial().equals(this.getModel().getMatLib().getMaterial(v.getMaterial().getName()))) v.setMaterial(this.getModel().getMatLib().getMaterial(v.getMaterial().getName())); tempSprite = ModelLoader.White.INSTANCE; } else { - if (sCase != null) + if(sCase!=null) { ResourceLocation rl = sCase.getReplacementSprite(shader, tempStack, groupName, pass); - if (rl != null) + if(rl!=null) tempSprite = ClientUtils.getSprite(rl); } - if (tempSprite == null && callback != null) + if(tempSprite==null&&callback!=null) tempSprite = callback.getTextureReplacement(callbackObject, f.getMaterialName()); - if (tempSprite == null && tempState != null && texReplace != null) + if(tempSprite==null&&tempState!=null&&texReplace!=null) { String s = texReplace.get(groupName); - if (s != null) + if(s!=null) tempSprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(s); } - if (tempSprite == null && !"null".equals(f.getMaterialName())) + if(tempSprite==null&&!"null".equals(f.getMaterialName())) tempSprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(this.getModel().getMatLib().getMaterial(f.getMaterialName()).getTexture().getTextureLocation().toString()); } - if (tempSprite == null) + if(tempSprite==null) tempSprite = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite(); - if (tempSprite != null) + if(tempSprite!=null) { IVertexConsumer builder = new UnpackedBakedQuad.Builder(getFormat()); builder.setQuadOrientation(EnumFacing.getFacingFromVector(f.getNormal().x, f.getNormal().y, f.getNormal().z)); @@ -395,47 +400,47 @@ else if (callback != null) Normal faceNormal = f.getNormal(); TextureCoordinate[] uvs = new TextureCoordinate[4]; boolean renderFace = true; - for (int i = 0; i < 4; i++) + for(int i = 0; i < 4; i++) { Vertex vertex = f.getVertices()[i]; //V-Flip is processed here already, rather than in the later method, since it's needed for easy UV comparissons on the Shader Layers - uvs[i] = vertex.hasTextureCoordinate() ? new TextureCoordinate(vertex.getTextureCoordinate().u, 1 - vertex.getTextureCoordinate().v, vertex.getTextureCoordinate().w) : TextureCoordinate.getDefaultUVs()[i]; + uvs[i] = vertex.hasTextureCoordinate()?new TextureCoordinate(vertex.getTextureCoordinate().u, 1-vertex.getTextureCoordinate().v, vertex.getTextureCoordinate().w): TextureCoordinate.getDefaultUVs()[i]; - if (shaderLayer != null) + if(shaderLayer!=null) { double[] texBounds = shaderLayer.getTextureBounds(); - if (texBounds != null) + if(texBounds!=null) { - if (texBounds[0] > uvs[i].u || uvs[i].u > texBounds[2] || texBounds[1] > uvs[i].v || uvs[i].v > texBounds[3])//if any uvs are outside the layers bounds + if(texBounds[0] > uvs[i].u||uvs[i].u > texBounds[2]||texBounds[1] > uvs[i].v||uvs[i].v > texBounds[3])//if any uvs are outside the layers bounds { renderFace = false; break; } - double dU = texBounds[2] - texBounds[0]; - double dV = texBounds[3] - texBounds[1]; + double dU = texBounds[2]-texBounds[0]; + double dV = texBounds[3]-texBounds[1]; //Rescaling to the partial bounds that the texture represents - uvs[i].u = (float) ((uvs[i].u - texBounds[0]) / dU); - uvs[i].v = (float) ((uvs[i].v - texBounds[1]) / dV); + uvs[i].u = (float)((uvs[i].u-texBounds[0])/dU); + uvs[i].v = (float)((uvs[i].v-texBounds[1])/dV); } //Rescaling to the selective area of the texture that is used double[] cutBounds = shaderLayer.getCutoutBounds(); - if (cutBounds != null) + if(cutBounds!=null) { - double dU = cutBounds[2] - cutBounds[0]; - double dV = cutBounds[3] - cutBounds[1]; - uvs[i].u = (float) (cutBounds[0] + dU * uvs[i].u); - uvs[i].v = (float) (cutBounds[1] + dV * uvs[i].v); + double dU = cutBounds[2]-cutBounds[0]; + double dV = cutBounds[3]-cutBounds[1]; + uvs[i].u = (float)(cutBounds[0]+dU*uvs[i].u); + uvs[i].v = (float)(cutBounds[1]+dV*uvs[i].v); } } } - if (renderFace) + if(renderFace) { - for (int i = 0; i < 4; i++) + for(int i = 0; i < 4; i++) putVertexData(builder, f.getVertices()[i], faceNormal, uvs[i], tempSprite, colour); - if (builder instanceof UnpackedBakedQuad.Builder) + if(builder instanceof UnpackedBakedQuad.Builder) { //It's ugly, but it should do the trick - quads.put(((UnpackedBakedQuad.Builder) builder).build(), shaderLayer!=null && shaderLayer.isDynamicLayer()?shaderLayer:null); + quads.put(((UnpackedBakedQuad.Builder)builder).build(), shaderLayer!=null&&shaderLayer.isDynamicLayer()?shaderLayer: null); // if(shaderLayer==null || !shaderLayer.isDynamicLayer()) // quads.put(((UnpackedBakedQuad.Builder) builder).build(), null); } @@ -449,7 +454,7 @@ protected final void putVertexData(IVertexConsumer builder, Vertex v, Normal fac { for(int e = 0; e < getFormat().getElementCount(); e++) { - switch (getFormat().getElement(e).getUsage()) + switch(getFormat().getElement(e).getUsage()) { case POSITION: builder.put(e, v.getPos().x, v.getPos().y, v.getPos().z, v.getPos().w); @@ -460,11 +465,11 @@ protected final void putVertexData(IVertexConsumer builder, Vertex v, Normal fac d = LightUtil.diffuseLight(v.getNormal().x, v.getNormal().y, v.getNormal().z); else d = LightUtil.diffuseLight(faceNormal.x, faceNormal.y, faceNormal.z); - if(v.getMaterial() != null) + if(v.getMaterial()!=null) builder.put(e, - d * v.getMaterial().getColor().x*colour[0], - d * v.getMaterial().getColor().y*colour[1], - d * v.getMaterial().getColor().z*colour[2], + d*v.getMaterial().getColor().x*colour[0], + d*v.getMaterial().getColor().y*colour[1], + d*v.getMaterial().getColor().z*colour[2], v.getMaterial().getColor().w*colour[3]); else builder.put(e, d*colour[0], d*colour[1], d*colour[2], 1*colour[3]); @@ -473,8 +478,8 @@ protected final void putVertexData(IVertexConsumer builder, Vertex v, Normal fac if(sprite==null)//Double Safety. I have no idea how it even happens, but it somehow did .-. sprite = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite(); builder.put(e, - sprite.getInterpolatedU(texCoord.u * 16), - sprite.getInterpolatedV((texCoord.v) * 16),//v-flip used to be processed here but was moved because of shader layers + sprite.getInterpolatedU(texCoord.u*16), + sprite.getInterpolatedV((texCoord.v)*16),//v-flip used to be processed here but was moved because of shader layers 0, 1); break; case NORMAL: @@ -491,7 +496,7 @@ protected final void putVertexData(IVertexConsumer builder, Vertex v, Normal fac static int getExtendedStateHash(IExtendedBlockState state) { - return state.hashCode()*31 + state.getUnlistedProperties().hashCode(); + return state.hashCode()*31+state.getUnlistedProperties().hashCode(); } // private final LoadingCache ieobjcache = CacheBuilder.newBuilder().maximumSize(20).build(new CacheLoader() @@ -504,22 +509,22 @@ static int getExtendedStateHash(IExtendedBlockState state) protected void updateStateVisibilityMap(OBJState state) { - if (state.getVisibilityMap().containsKey(Group.ALL)) + if(state.getVisibilityMap().containsKey(Group.ALL)) { boolean operation = state.getVisibilityMap().get(Group.ALL); state.getVisibilityMap().clear(); - for (String s : this.getModel().getMatLib().getGroups().keySet()) + for(String s : this.getModel().getMatLib().getGroups().keySet()) { - state.getVisibilityMap().put(s, OBJState.Operation.SET_TRUE.performOperation(operation)); + state.getVisibilityMap().put(s, OBJState.Operation.SET_TRUE.performOperation(operation)); } } - else if (state.getVisibilityMap().containsKey(Group.ALL_EXCEPT)) + else if(state.getVisibilityMap().containsKey(Group.ALL_EXCEPT)) { List exceptList = state.getGroupNamesFromMap().subList(1, state.getGroupNamesFromMap().size()); state.getVisibilityMap().remove(Group.ALL_EXCEPT); - for (String s : this.getModel().getMatLib().getGroups().keySet()) + for(String s : this.getModel().getMatLib().getGroups().keySet()) { - if (!exceptList.contains(s)) + if(!exceptList.contains(s)) { state.getVisibilityMap().put(s, OBJState.Operation.SET_TRUE.performOperation(state.getVisibilityMap().get(s))); } @@ -527,7 +532,7 @@ else if (state.getVisibilityMap().containsKey(Group.ALL_EXCEPT)) } else { - for (String s : state.getVisibilityMap().keySet()) + for(String s : state.getVisibilityMap().keySet()) { state.getVisibilityMap().put(s, OBJState.Operation.SET_TRUE.performOperation(state.getVisibilityMap().get(s))); } @@ -535,30 +540,36 @@ else if (state.getVisibilityMap().containsKey(Group.ALL_EXCEPT)) } static Field f_textures; + public static ImmutableMap getTexturesForOBJModel(IBakedModel model) { - try{ + try + { if(f_textures==null) { f_textures = OBJBakedModel.class.getDeclaredField("textures"); f_textures.setAccessible(true); } return (ImmutableMap)f_textures.get(model); - }catch(Exception e){ + } catch(Exception e) + { e.printStackTrace(); } return null; } + public ImmutableMap getTextures() { - try{ + try + { if(f_textures==null) { f_textures = OBJBakedModel.class.getDeclaredField("textures"); f_textures.setAccessible(true); } return (ImmutableMap)f_textures.get(this); - }catch(Exception e){ + } catch(Exception e) + { e.printStackTrace(); } return null; diff --git a/src/main/java/blusunrize/immersiveengineering/client/models/IOBJModelCallback.java b/src/main/java/blusunrize/immersiveengineering/client/models/IOBJModelCallback.java index 744acf206e..a01533a7d7 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/models/IOBJModelCallback.java +++ b/src/main/java/blusunrize/immersiveengineering/client/models/IOBJModelCallback.java @@ -56,13 +56,28 @@ public String valueToString(IOBJModelCallback value) }; @SideOnly(Side.CLIENT) - default TextureAtlasSprite getTextureReplacement(T object, String material){ return null; } + default TextureAtlasSprite getTextureReplacement(T object, String material) + { + return null; + } + @SideOnly(Side.CLIENT) - default boolean shouldRenderGroup(T object, String group){ return true; } + default boolean shouldRenderGroup(T object, String group) + { + return true; + } + @SideOnly(Side.CLIENT) - default Optional applyTransformations(T object, String group, Optional transform) { return transform; } + default Optional applyTransformations(T object, String group, Optional transform) + { + return transform; + } + @SideOnly(Side.CLIENT) - default Matrix4 handlePerspective(T Object, TransformType cameraTransformType, Matrix4 perspective, @Nullable EntityLivingBase entity) { return perspective; } + default Matrix4 handlePerspective(T Object, TransformType cameraTransformType, Matrix4 perspective, @Nullable EntityLivingBase entity) + { + return perspective; + } @SideOnly(Side.CLIENT) default int getRenderColour(T object, String group) diff --git a/src/main/java/blusunrize/immersiveengineering/client/models/ModelConfigurableSides.java b/src/main/java/blusunrize/immersiveengineering/client/models/ModelConfigurableSides.java index ca46535c6f..bcc06c446c 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/models/ModelConfigurableSides.java +++ b/src/main/java/blusunrize/immersiveengineering/client/models/ModelConfigurableSides.java @@ -45,51 +45,62 @@ public class ModelConfigurableSides implements IBakedModel private static final String RESOURCE_LOCATION = "models/block/smartmodel/"+MODEL_PREFIX; //Holy shit, this type-chaining is messy. But I wanted to use lambdas! private static HashMap TYPES = new HashMap(); - static{ - TYPES.put("all6_", new ITextureNamer(){});//every side seperately - TYPES.put("s_", new ITextureNamer(){//all sides, same texture + + static + { + TYPES.put("all6_", new ITextureNamer() + { + });//every side seperately + TYPES.put("s_", new ITextureNamer() + {//all sides, same texture @Override public String nameFromSide(EnumFacing side, SideConfig cfg) { return "side"; } }); - TYPES.put("hud_", new ITextureNamer(){//horizontal, up, down + TYPES.put("hud_", new ITextureNamer() + {//horizontal, up, down @Override public String nameFromSide(EnumFacing side, SideConfig cfg) { - return side.ordinal()<2?side.getName():"side"; + return side.ordinal() < 2?side.getName(): "side"; } }); - TYPES.put("hv_", new ITextureNamer(){//horizontal, vertical + TYPES.put("hv_", new ITextureNamer() + {//horizontal, vertical @Override public String nameFromSide(EnumFacing side, SideConfig cfg) { - return side.ordinal()<2?"up":"side"; + return side.ordinal() < 2?"up": "side"; } }); - TYPES.put("ud_", new ITextureNamer(){//up, down, sides not configureable + TYPES.put("ud_", new ITextureNamer() + {//up, down, sides not configureable @Override public String nameFromSide(EnumFacing side, SideConfig cfg) { - return side.ordinal()<2?side.getName():"side"; + return side.ordinal() < 2?side.getName(): "side"; } + @Override public String nameFromCfg(EnumFacing side, SideConfig cfg) { - return side.ordinal()<2?cfg.getTextureName():null; + return side.ordinal() < 2?cfg.getTextureName(): null; } }); - TYPES.put("v_", new ITextureNamer(){//vertical, sides not configureable + TYPES.put("v_", new ITextureNamer() + {//vertical, sides not configureable @Override public String nameFromSide(EnumFacing side, SideConfig cfg) { - return side.ordinal()<2?"up":"side"; + return side.ordinal() < 2?"up": "side"; } + @Override public String nameFromCfg(EnumFacing side, SideConfig cfg) { - return side.ordinal()<2?cfg.getTextureName():null; + return side.ordinal() < 2?cfg.getTextureName(): null; } }); } @@ -109,13 +120,13 @@ public ModelConfigurableSides(String name, TextureAtlasSprite[][] textures) public List getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) { TextureAtlasSprite[] tex = new TextureAtlasSprite[6]; - for(int i=0; i getQuads(@Nullable IBlockState state, @Nullable EnumFacin } } } - String key = name + String.copyValueOf(keyArray); + String key = name+String.copyValueOf(keyArray); if(!modelCache.containsKey(key)) modelCache.put(key, bakeQuads(tex)); return modelCache.get(key); } + private static List bakeQuads(TextureAtlasSprite[] sprites) { List quads = Lists.newArrayListWithExpectedSize(6); @@ -158,11 +170,13 @@ public boolean isAmbientOcclusion() { return true; } + @Override public boolean isGui3d() { return true; } + @Override public boolean isBuiltInRenderer() { @@ -176,21 +190,23 @@ public TextureAtlasSprite getParticleTexture() } static final ItemCameraTransforms defaultTransforms = new ItemCameraTransforms( - new ItemTransformVec3f(new Vector3f(75,45,0),new Vector3f(0,.25f,0),new Vector3f(0.375f,0.375f,0.375f)), //thirdperson left - new ItemTransformVec3f(new Vector3f(75,45,0),new Vector3f(0,.15625f,0),new Vector3f(0.375f,0.375f,0.375f)), //thirdperson left + new ItemTransformVec3f(new Vector3f(75, 45, 0), new Vector3f(0, .25f, 0), new Vector3f(0.375f, 0.375f, 0.375f)), //thirdperson left + new ItemTransformVec3f(new Vector3f(75, 45, 0), new Vector3f(0, .15625f, 0), new Vector3f(0.375f, 0.375f, 0.375f)), //thirdperson left + + new ItemTransformVec3f(new Vector3f(0, 45, 0), new Vector3f(0, 0, 0), new Vector3f(.4f, .4f, .4f)), //firstperson left + new ItemTransformVec3f(new Vector3f(0, 225, 0), new Vector3f(0, 0, 0), new Vector3f(.4f, .4f, .4f)), //firstperson right - new ItemTransformVec3f(new Vector3f(0,45,0),new Vector3f(0,0,0),new Vector3f(.4f,.4f,.4f)), //firstperson left - new ItemTransformVec3f(new Vector3f(0,225,0),new Vector3f(0,0,0),new Vector3f(.4f,.4f,.4f)), //firstperson right + new ItemTransformVec3f(new Vector3f(0, 0, 0), new Vector3f(0, 0, 0), new Vector3f(1, 1, 1)), //head + new ItemTransformVec3f(new Vector3f(30, 225, 0), new Vector3f(0, 0, 0), new Vector3f(.625f, .625f, .625f)), //gui + new ItemTransformVec3f(new Vector3f(0, 0, 0), new Vector3f(0, .1875f, 0), new Vector3f(.25f, .25f, .25f)), //ground + new ItemTransformVec3f(new Vector3f(0, 0, 0), new Vector3f(0, 0, 0), new Vector3f(.5f, .5f, .5f))); //fixed - new ItemTransformVec3f(new Vector3f(0,0,0),new Vector3f(0,0,0),new Vector3f(1,1,1)), //head - new ItemTransformVec3f(new Vector3f(30,225,0),new Vector3f(0,0,0),new Vector3f(.625f,.625f,.625f)), //gui - new ItemTransformVec3f(new Vector3f(0,0,0),new Vector3f(0,.1875f,0),new Vector3f(.25f,.25f,.25f)), //ground - new ItemTransformVec3f(new Vector3f(0,0,0),new Vector3f(0,0,0),new Vector3f(.5f,.5f,.5f))); //fixed @Override public ItemCameraTransforms getItemCameraTransforms() { return defaultTransforms; } + @Override public ItemOverrideList getOverrides() { @@ -216,7 +232,7 @@ public IModel loadModel(ResourceLocation modelLocation) { String resourcePath = modelLocation.getResourcePath(); int pos = resourcePath.indexOf(MODEL_PREFIX); - if(pos>=0) + if(pos >= 0) { pos += MODEL_PREFIX.length(); String sub = resourcePath.substring(pos); @@ -231,7 +247,7 @@ public IModel loadModel(ResourceLocation modelLocation) for(EnumFacing f : EnumFacing.VALUES) for(SideConfig cfg : SideConfig.values()) { - String key = f.getName() + "_" + cfg.getTextureName(); + String key = f.getName()+"_"+cfg.getTextureName(); String tex = name+"_"+e.getValue().getTextureName(f, cfg); builder.put(key, new ResourceLocation(ImmersiveEngineering.MODID, "blocks/"+tex)); } @@ -268,7 +284,7 @@ public Collection getTextures() } @Override - public IBakedModel bake(IModelState state, VertexFormat format, Function bakedTextureGetter) + public IBakedModel bake(IModelState state, VertexFormat format, Function bakedTextureGetter) { TextureAtlasSprite[][] tex = new TextureAtlasSprite[6][3]; for(EnumFacing f : EnumFacing.VALUES) @@ -309,7 +325,7 @@ else if(textures.containsKey("name")) ITextureNamer namer = TYPES.get(type); newName = textures.get("name"); if(namer!=null) - rl = new ResourceLocation(newName+"_"+namer.getTextureName(f,cfg)); + rl = new ResourceLocation(newName+"_"+namer.getTextureName(f, cfg)); } builder.put(key, rl); } @@ -321,9 +337,9 @@ interface ITextureNamer { default String getTextureName(EnumFacing side, SideConfig cfg) { - String s = nameFromSide(side,cfg); - String c = nameFromCfg(side,cfg); - if(s!=null && c!=null) + String s = nameFromSide(side, cfg); + String c = nameFromCfg(side, cfg); + if(s!=null&&c!=null) return s+"_"+c; else if(s!=null) return s; @@ -336,6 +352,7 @@ default String nameFromSide(EnumFacing side, SideConfig cfg) { return side.getName(); } + default String nameFromCfg(EnumFacing side, SideConfig cfg) { return cfg.getTextureName(); diff --git a/src/main/java/blusunrize/immersiveengineering/client/models/ModelConveyor.java b/src/main/java/blusunrize/immersiveengineering/client/models/ModelConveyor.java index 720bd95f94..76bd17e7e2 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/models/ModelConveyor.java +++ b/src/main/java/blusunrize/immersiveengineering/client/models/ModelConveyor.java @@ -68,47 +68,47 @@ public List getQuads(@Nullable IBlockState blockState, @Nullable Enum TileEntity tile = null; String key = "default"; EnumFacing facing = EnumFacing.NORTH; - if(blockState == null) - key = conveyor != null ? ConveyorHandler.reverseClassRegistry.get(conveyor.getClass()).toString() : "immersiveengineering:conveyor"; + if(blockState==null) + key = conveyor!=null?ConveyorHandler.reverseClassRegistry.get(conveyor.getClass()).toString(): "immersiveengineering:conveyor"; else { facing = blockState.getValue(IEProperties.FACING_ALL); if(blockState instanceof IExtendedBlockState) { - IExtendedBlockState exState = (IExtendedBlockState) blockState; + IExtendedBlockState exState = (IExtendedBlockState)blockState; if(exState.getUnlistedNames().contains(BlockConveyor.ICONEYOR_PASSTHROUGH)) - conveyor = ((IExtendedBlockState) blockState).getValue(BlockConveyor.ICONEYOR_PASSTHROUGH); + conveyor = ((IExtendedBlockState)blockState).getValue(BlockConveyor.ICONEYOR_PASSTHROUGH); if(exState.getUnlistedNames().contains(IEProperties.TILEENTITY_PASSTHROUGH)) - tile = ((IExtendedBlockState) blockState).getValue(IEProperties.TILEENTITY_PASSTHROUGH); - if(conveyor != null && tile != null) + tile = ((IExtendedBlockState)blockState).getValue(IEProperties.TILEENTITY_PASSTHROUGH); + if(conveyor!=null&&tile!=null) key = conveyor.getModelCacheKey(tile, facing); } } List cachedQuads = modelCache.get(key); - if(cachedQuads != null) + if(cachedQuads!=null) return Collections.synchronizedList(Lists.newArrayList(cachedQuads)); else { - if (conveyor==null) + if(conveyor==null) conveyor = ConveyorHandler.getConveyor(new ResourceLocation(key), tile); cachedQuads = Collections.synchronizedList(Lists.newArrayList()); Matrix4f facingMatrix = TRSRTransformation.getMatrix(facing); - if(conveyor != null) + if(conveyor!=null) facingMatrix = conveyor.modifyBaseRotationMatrix(facingMatrix, tile, facing); Matrix4 matrix = new Matrix4(facingMatrix); - ConveyorDirection conDir = conveyor != null ? conveyor.getConveyorDirection() : ConveyorDirection.HORIZONTAL; - boolean[] walls = conveyor != null && tile != null ? new boolean[]{conveyor.renderWall(tile, facing, 0), conveyor.renderWall(tile, facing, 1)} : new boolean[]{true, true}; + ConveyorDirection conDir = conveyor!=null?conveyor.getConveyorDirection(): ConveyorDirection.HORIZONTAL; + boolean[] walls = conveyor!=null&&tile!=null?new boolean[]{conveyor.renderWall(tile, facing, 0), conveyor.renderWall(tile, facing, 1)}: new boolean[]{true, true}; TextureAtlasSprite tex_conveyor = ClientUtils.mc().getTextureMapBlocks().getMissingSprite(); TextureAtlasSprite tex_conveyor_colour = null; int colourStripes = -1; - if(conveyor != null) + if(conveyor!=null) { - tex_conveyor = ClientUtils.getSprite(tile != null ? (conveyor.isActive(tile) ? conveyor.getActiveTexture() : conveyor.getInactiveTexture()) : conveyor.getActiveTexture()); + tex_conveyor = ClientUtils.getSprite(tile!=null?(conveyor.isActive(tile)?conveyor.getActiveTexture(): conveyor.getInactiveTexture()): conveyor.getActiveTexture()); if((colourStripes = conveyor.getDyeColour()) >= 0) tex_conveyor_colour = ClientUtils.getSprite(conveyor.getColouredStripesTexture()); } cachedQuads.addAll(getBaseConveyor(facing, 1, matrix, conDir, tex_conveyor, walls, new boolean[]{true, true}, tex_conveyor_colour, colourStripes)); - if(conveyor != null) + if(conveyor!=null) cachedQuads = conveyor.modifyQuads(cachedQuads, tile, facing); modelCache.put(key, cachedQuads); return Collections.synchronizedList(Lists.newArrayList(cachedQuads)); @@ -119,171 +119,171 @@ public static Set getBaseConveyor(EnumFacing facing, float length, Ma { Set quads = new LinkedHashSet(); - Vector3f[] vertices = {new Vector3f(.0625f, 0, 1 - length), new Vector3f(.0625f, 0, 1), new Vector3f(.9375f, 0, 1), new Vector3f(.9375f, 0, 1 - length)}; + Vector3f[] vertices = {new Vector3f(.0625f, 0, 1-length), new Vector3f(.0625f, 0, 1), new Vector3f(.9375f, 0, 1), new Vector3f(.9375f, 0, 1-length)}; TextureAtlasSprite tex_casing0 = ClientUtils.getSprite(rl_casing[0]); TextureAtlasSprite tex_casing1 = ClientUtils.getSprite(rl_casing[1]); TextureAtlasSprite tex_casing2 = ClientUtils.getSprite(rl_casing[2]); float[] colour = {1, 1, 1, 1}; - float[] colourStripes = {(stripeColour >> 16 & 255) / 255f, (stripeColour >> 8 & 255) / 255f, (stripeColour & 255) / 255f, 1}; + float[] colourStripes = {(stripeColour >> 16&255)/255f, (stripeColour >> 8&255)/255f, (stripeColour&255)/255f, 1}; /** * Bottom & Top */ //Shift if up/down for(int i = 0; i < 4; i++) - if((i == 0 || i == 3) ? conDir == ConveyorDirection.UP : conDir == ConveyorDirection.DOWN) + if((i==0||i==3)?conDir==ConveyorDirection.UP: conDir==ConveyorDirection.DOWN) vertices[i].translate(0, length, 0); //Draw bottom - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.DOWN,facing), tex_conveyor, new double[]{1, 0, 15, length * 16}, colour, true)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.DOWN, facing), tex_conveyor, new double[]{1, 0, 15, length*16}, colour, true)); //Expand verts to side for(Vector3f v : vertices) - v.setX(v.getX() < .5f ? 0 : 1); + v.setX(v.getX() < .5f?0: 1); //Draw bottom casing - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.DOWN,facing), tex_casing2, new double[]{0, 0, 16, length * 16}, colour, true)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.DOWN, facing), tex_casing2, new double[]{0, 0, 16, length*16}, colour, true)); //Shift verts to top for(Vector3f v : vertices) v.translate(0, .125f, 0); //Draw top - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.UP,facing), tex_conveyor, new double[]{0, length * 16, 16, 0}, colour, false)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.UP, facing), tex_conveyor, new double[]{0, length*16, 16, 0}, colour, false)); if(corners[0]) { vertices = new Vector3f[]{new Vector3f(0, .1875f, .9375f), new Vector3f(0, .1875f, 1), new Vector3f(1, .1875f, 1), new Vector3f(1, .1875f, .9375f)}; //Shift if up/down for(int i = 0; i < 4; i++) - vertices[i].translate(0, i == 0 || i == 3 ? (conDir == ConveyorDirection.UP ? .0625f : conDir == ConveyorDirection.DOWN ? length - .0625f : 0) : (conDir == ConveyorDirection.DOWN ? length : 0), 0); + vertices[i].translate(0, i==0||i==3?(conDir==ConveyorDirection.UP?.0625f: conDir==ConveyorDirection.DOWN?length-.0625f: 0): (conDir==ConveyorDirection.DOWN?length: 0), 0); //Draw top casing back - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.UP,facing), tex_casing0, new double[]{0, 1, 16, 0}, colour, false)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.UP, facing), tex_casing0, new double[]{0, 1, 16, 0}, colour, false)); } if(corners[1]) { - vertices = new Vector3f[]{new Vector3f(0, .1875f, 1 - length), new Vector3f(0, .1875f, 1.0625f - length), new Vector3f(1, .1875f, 1.0625f - length), new Vector3f(1, .1875f, 1 - length)}; + vertices = new Vector3f[]{new Vector3f(0, .1875f, 1-length), new Vector3f(0, .1875f, 1.0625f-length), new Vector3f(1, .1875f, 1.0625f-length), new Vector3f(1, .1875f, 1-length)}; //Shift if up/down for(int i = 0; i < 4; i++) - vertices[i].translate(0, i == 1 || i == 2 ? (conDir == ConveyorDirection.UP ? length - .0625f : conDir == ConveyorDirection.DOWN ? .0625f : 0) : (conDir == ConveyorDirection.UP ? length : 0), 0); + vertices[i].translate(0, i==1||i==2?(conDir==ConveyorDirection.UP?length-.0625f: conDir==ConveyorDirection.DOWN?.0625f: 0): (conDir==ConveyorDirection.UP?length: 0), 0); //Draw top casing front - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.UP,facing), tex_casing0, new double[]{0, 1, 16, 0}, colour, false)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.UP, facing), tex_casing0, new double[]{0, 1, 16, 0}, colour, false)); } /** * Sides */ - vertices = new Vector3f[]{new Vector3f(0, 0, 1 - length), new Vector3f(0, 0, 1), new Vector3f(0, .125f, 1), new Vector3f(0, .125f, 1 - length)}; + vertices = new Vector3f[]{new Vector3f(0, 0, 1-length), new Vector3f(0, 0, 1), new Vector3f(0, .125f, 1), new Vector3f(0, .125f, 1-length)}; for(int i = 0; i < 4; i++) - if((i == 0 || i == 3) ? conDir == ConveyorDirection.UP : conDir == ConveyorDirection.DOWN) + if((i==0||i==3)?conDir==ConveyorDirection.UP: conDir==ConveyorDirection.DOWN) vertices[i].translate(0, length, 0); //Draw left side - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.WEST,facing), tex_casing1, new double[]{0, 0, 2, length * 16}, colour, false)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.WEST, facing), tex_casing1, new double[]{0, 0, 2, length*16}, colour, false)); //Shift upwards for(int i = 0; i < 4; i++) - vertices[i].setY(vertices[i].getY() + ((i == 0 || i == 1) ? .125f : .0625f)); + vertices[i].setY(vertices[i].getY()+((i==0||i==1)?.125f: .0625f)); //Shift back down and to the other side for(int i = 0; i < 4; i++) - vertices[i].set(1, vertices[i].getY() - ((i == 0 || i == 1) ? .125f : .0625f)); + vertices[i].set(1, vertices[i].getY()-((i==0||i==1)?.125f: .0625f)); //Draw right side - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.EAST,facing), tex_casing1, new double[]{0, 0, 2, length * 16}, colour, true)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.EAST, facing), tex_casing1, new double[]{0, 0, 2, length*16}, colour, true)); //Shift upwards for(int i = 0; i < 4; i++) - vertices[i].setY(vertices[i].getY() + ((i == 0 || i == 1) ? .125f : .0625f)); + vertices[i].setY(vertices[i].getY()+((i==0||i==1)?.125f: .0625f)); /** * Corners */ if(corners[0]) { vertices = new Vector3f[]{new Vector3f(0, .125f, .9375f), new Vector3f(0, .125f, 1), new Vector3f(0, .1875f, 1), new Vector3f(0, .1875f, .9375f)}; - if(conDir != ConveyorDirection.HORIZONTAL) + if(conDir!=ConveyorDirection.HORIZONTAL) for(int i = 0; i < 4; i++) - vertices[i].translate(0, i == 0 || i == 3 ? (conDir == ConveyorDirection.UP ? .0625f : conDir == ConveyorDirection.DOWN ? length - .0625f : 0) : (conDir == ConveyorDirection.DOWN ? length : 0), 0); + vertices[i].translate(0, i==0||i==3?(conDir==ConveyorDirection.UP?.0625f: conDir==ConveyorDirection.DOWN?length-.0625f: 0): (conDir==ConveyorDirection.DOWN?length: 0), 0); //Back left - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.WEST,facing), tex_casing0, new double[]{0, 0, 1, 1}, colour, false)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.WEST, facing), tex_casing0, new double[]{0, 0, 1, 1}, colour, false)); for(Vector3f v : vertices) v.translate(.0625f, 0, 0); - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.EAST,facing), tex_casing0, new double[]{0, 0, 1, 1}, colour, true)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.EAST, facing), tex_casing0, new double[]{0, 0, 1, 1}, colour, true)); //Shift right for(Vector3f v : vertices) v.setX(1); //Back right - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.EAST,facing), tex_casing0, new double[]{0, 0, 1, 1}, colour, true)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.EAST, facing), tex_casing0, new double[]{0, 0, 1, 1}, colour, true)); for(Vector3f v : vertices) v.translate(-.0625f, 0, 0); - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.WEST,facing), tex_casing0, new double[]{0, 0, 1, 1}, colour, false)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.WEST, facing), tex_casing0, new double[]{0, 0, 1, 1}, colour, false)); } if(corners[1]) { - vertices = new Vector3f[]{new Vector3f(0, .125f, 1 - length), new Vector3f(0, .125f, 1.0625f - length), new Vector3f(0, .1875f, 1.0625f - length), new Vector3f(0, .1875f, 1 - length)}; - if(conDir != ConveyorDirection.HORIZONTAL) + vertices = new Vector3f[]{new Vector3f(0, .125f, 1-length), new Vector3f(0, .125f, 1.0625f-length), new Vector3f(0, .1875f, 1.0625f-length), new Vector3f(0, .1875f, 1-length)}; + if(conDir!=ConveyorDirection.HORIZONTAL) for(int i = 0; i < 4; i++) - vertices[i].translate(0, i == 1 || i == 2 ? (conDir == ConveyorDirection.UP ? length - .0625f : conDir == ConveyorDirection.DOWN ? .0625f : 0) : (conDir == ConveyorDirection.UP ? length : 0), 0); + vertices[i].translate(0, i==1||i==2?(conDir==ConveyorDirection.UP?length-.0625f: conDir==ConveyorDirection.DOWN?.0625f: 0): (conDir==ConveyorDirection.UP?length: 0), 0); //Front left - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.WEST,facing), tex_casing0, new double[]{0, 15, 1, 16}, colour, false)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.WEST, facing), tex_casing0, new double[]{0, 15, 1, 16}, colour, false)); for(Vector3f v : vertices) v.translate(.0625f, 0, 0); - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.EAST,facing), tex_casing0, new double[]{0, 15, 1, 16}, colour, true)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.EAST, facing), tex_casing0, new double[]{0, 15, 1, 16}, colour, true)); //Shift right for(Vector3f v : vertices) v.setX(1); //Front right - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.EAST,facing), tex_casing0, new double[]{0, 15, 1, 16}, colour, true)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.EAST, facing), tex_casing0, new double[]{0, 15, 1, 16}, colour, true)); for(Vector3f v : vertices) v.translate(-.0625f, 0, 0); - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.WEST,facing), tex_casing0, new double[]{0, 15, 1, 16}, colour, false)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.WEST, facing), tex_casing0, new double[]{0, 15, 1, 16}, colour, false)); } /** * Front & Back */ - vertices = new Vector3f[]{new Vector3f(.0625f, 0, 1 - length), new Vector3f(.0625f, .125f, 1 - length), new Vector3f(.9375f, .125f, 1 - length), new Vector3f(.9375f, 0, 1 - length)}; + vertices = new Vector3f[]{new Vector3f(.0625f, 0, 1-length), new Vector3f(.0625f, .125f, 1-length), new Vector3f(.9375f, .125f, 1-length), new Vector3f(.9375f, 0, 1-length)}; //Shift if up/down - if(conDir == ConveyorDirection.UP) + if(conDir==ConveyorDirection.UP) for(Vector3f v : vertices) v.translate(0, length, 0); //Draw front - double frontUMax = (1 - length) * 16; - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), facing, tex_conveyor, new double[]{1, frontUMax + 2, 15, frontUMax}, colour, false)); + double frontUMax = (1-length)*16; + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), facing, tex_conveyor, new double[]{1, frontUMax+2, 15, frontUMax}, colour, false)); //Expand to side and up for(int i = 0; i < 4; i++) - vertices[i].set(vertices[i].getX() < .5f ? 0 : 1, vertices[i].getY() + (i == 1 || i == 2 ? .0625f : 0)); + vertices[i].set(vertices[i].getX() < .5f?0: 1, vertices[i].getY()+(i==1||i==2?.0625f: 0)); //Draw front casing quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), facing, tex_casing2, new double[]{0, 3, 16, 0}, colour, false)); for(Vector3f v : vertices) - v.translate(0, (conDir == ConveyorDirection.UP ? -.0625f : conDir == ConveyorDirection.DOWN ? .0625f : 0), .0625f); + v.translate(0, (conDir==ConveyorDirection.UP?-.0625f: conDir==ConveyorDirection.DOWN?.0625f: 0), .0625f); quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), facing, tex_casing2, new double[]{0, 3, 16, 0}, colour, true)); //Undo expand, shift if up/down, shift to back for(int i = 0; i < 4; i++) { Vector3f v = vertices[i]; - v.setX(v.getX() < .5f ? .0625f : .9375f); - v.setY(v.getY() - (i == 1 || i == 2 ? .0625f : 0)); - if(conDir == ConveyorDirection.UP) - v.translate(0, -(length - .0625f), 0); - if(conDir == ConveyorDirection.DOWN) - v.translate(0, (length - .0625f), 0); - v.translate(0, 0, length - .0625f); + v.setX(v.getX() < .5f?.0625f: .9375f); + v.setY(v.getY()-(i==1||i==2?.0625f: 0)); + if(conDir==ConveyorDirection.UP) + v.translate(0, -(length-.0625f), 0); + if(conDir==ConveyorDirection.DOWN) + v.translate(0, (length-.0625f), 0); + v.translate(0, 0, length-.0625f); } //Draw back quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), facing.getOpposite(), tex_conveyor, new double[]{1, 0, 15, 2}, colour, true)); //Expand to side and up for(int i = 0; i < 4; i++) - vertices[i].set(vertices[i].getX() < .5f ? 0 : 1, vertices[i].getY() + (i == 1 || i == 2 ? .0625f : 0)); + vertices[i].set(vertices[i].getX() < .5f?0: 1, vertices[i].getY()+(i==1||i==2?.0625f: 0)); //Draw back casing quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), facing.getOpposite(), tex_casing2, new double[]{0, 0, 16, 3}, colour, true)); for(Vector3f v : vertices) - v.translate(0, conDir == ConveyorDirection.UP ? .0625f : conDir == ConveyorDirection.DOWN ? -.0625f : 0, -.0625f); + v.translate(0, conDir==ConveyorDirection.UP?.0625f: conDir==ConveyorDirection.DOWN?-.0625f: 0, -.0625f); quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), facing.getOpposite(), tex_casing2, new double[]{0, 0, 16, 3}, colour, false)); /** * Walls */ - float wallLength = length - .125f; - vertices = new Vector3f[]{new Vector3f(0, .1875f, .9375f - wallLength), new Vector3f(0, .1875f, .9375f), new Vector3f(.0625f, .1875f, .9375f), new Vector3f(.0625f, .1875f, .9375f - wallLength)}; - Vector3f[] vertices2 = new Vector3f[]{new Vector3f(0, .125f, .9375f - wallLength), new Vector3f(0, .125f, .9375f), new Vector3f(0, .1875f, .9375f), new Vector3f(0, .1875f, .9375f - wallLength)}; - Vector3f[] vertices3 = new Vector3f[]{new Vector3f(.0625f, .125f, .9375f - wallLength), new Vector3f(.0625f, .125f, .9375f), new Vector3f(.0625f, .1875f, .9375f), new Vector3f(.0625f, .1875f, .9375f - wallLength)}; - Vector3f[] verticesColour = new Vector3f[]{new Vector3f(0, .1876f, corners[1] ? (1 - length) : (.9375f - wallLength)), new Vector3f(0, .1876f, corners[0] ? 1 : .9375f), new Vector3f(.0625f, .1876f, corners[0] ? 1 : .9375f), new Vector3f(.0625f, .1876f, corners[1] ? (1 - length) : (.9375f - wallLength))}; + float wallLength = length-.125f; + vertices = new Vector3f[]{new Vector3f(0, .1875f, .9375f-wallLength), new Vector3f(0, .1875f, .9375f), new Vector3f(.0625f, .1875f, .9375f), new Vector3f(.0625f, .1875f, .9375f-wallLength)}; + Vector3f[] vertices2 = new Vector3f[]{new Vector3f(0, .125f, .9375f-wallLength), new Vector3f(0, .125f, .9375f), new Vector3f(0, .1875f, .9375f), new Vector3f(0, .1875f, .9375f-wallLength)}; + Vector3f[] vertices3 = new Vector3f[]{new Vector3f(.0625f, .125f, .9375f-wallLength), new Vector3f(.0625f, .125f, .9375f), new Vector3f(.0625f, .1875f, .9375f), new Vector3f(.0625f, .1875f, .9375f-wallLength)}; + Vector3f[] verticesColour = new Vector3f[]{new Vector3f(0, .1876f, corners[1]?(1-length): (.9375f-wallLength)), new Vector3f(0, .1876f, corners[0]?1: .9375f), new Vector3f(.0625f, .1876f, corners[0]?1: .9375f), new Vector3f(.0625f, .1876f, corners[1]?(1-length): (.9375f-wallLength))}; for(int i = 0; i < 4; i++) - if(conDir != ConveyorDirection.HORIZONTAL) + if(conDir!=ConveyorDirection.HORIZONTAL) { - float f = (i == 0 || i == 3) ? (conDir == ConveyorDirection.UP ? length - .0625f : .0625f) : (conDir == ConveyorDirection.UP ? .0625f : length - .0625f); + float f = (i==0||i==3)?(conDir==ConveyorDirection.UP?length-.0625f: .0625f): (conDir==ConveyorDirection.UP?.0625f: length-.0625f); vertices[i].translate(0, f, 0); vertices2[i].translate(0, f, 0); vertices3[i].translate(0, f, 0); @@ -292,11 +292,11 @@ public static Set getBaseConveyor(EnumFacing facing, float length, Ma //Draw left walls if(walls[0]) { - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.UP,facing), tex_casing2, new double[]{0, 15, 1, 1}, colour, false)); - if(tex_conveyor_colour != null && stripeColour >= 0) - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, verticesColour), Utils.rotateFacingTowardsDir(EnumFacing.UP,facing), tex_conveyor_colour, new double[]{0, 15, 1, 1}, colourStripes, false)); - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices2), Utils.rotateFacingTowardsDir(EnumFacing.WEST,facing), tex_casing1, new double[]{2, 15, 3, 1}, colour, false)); - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices3), Utils.rotateFacingTowardsDir(EnumFacing.EAST,facing), tex_casing1, new double[]{2, 15, 3, 1}, colour, true)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.UP, facing), tex_casing2, new double[]{0, 15, 1, 1}, colour, false)); + if(tex_conveyor_colour!=null&&stripeColour >= 0) + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, verticesColour), Utils.rotateFacingTowardsDir(EnumFacing.UP, facing), tex_conveyor_colour, new double[]{0, 15, 1, 1}, colourStripes, false)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices2), Utils.rotateFacingTowardsDir(EnumFacing.WEST, facing), tex_casing1, new double[]{2, 15, 3, 1}, colour, false)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices3), Utils.rotateFacingTowardsDir(EnumFacing.EAST, facing), tex_casing1, new double[]{2, 15, 3, 1}, colour, true)); } for(int i = 0; i < 4; i++) { @@ -308,11 +308,11 @@ public static Set getBaseConveyor(EnumFacing facing, float length, Ma //Draw right walls if(walls[1]) { - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.UP,facing), tex_casing2, new double[]{15, 15, 16, 1}, colour, false)); - if(tex_conveyor_colour != null && stripeColour >= 0) - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, verticesColour), Utils.rotateFacingTowardsDir(EnumFacing.UP,facing), tex_conveyor_colour, new double[]{15,15, 16, 1}, colourStripes, false)); - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices2), Utils.rotateFacingTowardsDir(EnumFacing.WEST,facing), tex_casing1, new double[]{2, 15, 3, 1}, colour, false)); - quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices3), Utils.rotateFacingTowardsDir(EnumFacing.EAST,facing), tex_casing1, new double[]{2, 15, 3, 1}, colour, true)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.UP, facing), tex_casing2, new double[]{15, 15, 16, 1}, colour, false)); + if(tex_conveyor_colour!=null&&stripeColour >= 0) + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, verticesColour), Utils.rotateFacingTowardsDir(EnumFacing.UP, facing), tex_conveyor_colour, new double[]{15, 15, 16, 1}, colourStripes, false)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices2), Utils.rotateFacingTowardsDir(EnumFacing.WEST, facing), tex_casing1, new double[]{2, 15, 3, 1}, colour, false)); + quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices3), Utils.rotateFacingTowardsDir(EnumFacing.EAST, facing), tex_casing1, new double[]{2, 15, 3, 1}, colour, true)); } return quads; @@ -337,11 +337,12 @@ public boolean isBuiltInRenderer() } TextureAtlasSprite tex_particle; + @Override public TextureAtlasSprite getParticleTexture() { - if(tex_particle == null) - tex_particle = ClientUtils.getSprite(conveyor != null ? conveyor.getInactiveTexture() : new ResourceLocation(ImmersiveEngineering.MODID, "blocks/conveyor_off")); + if(tex_particle==null) + tex_particle = ClientUtils.getSprite(conveyor!=null?conveyor.getInactiveTexture(): new ResourceLocation(ImmersiveEngineering.MODID, "blocks/conveyor_off")); return tex_particle; } @@ -365,7 +366,7 @@ public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, W { String key = ItemNBTHelper.getString(stack, "conveyorType"); IBakedModel model = itemModelCache.get(key); - if(model == null) + if(model==null) { model = new ModelConveyor(ConveyorHandler.getConveyor(new ResourceLocation(key), null)); itemModelCache.put(key, model); @@ -390,7 +391,7 @@ public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, W @Override public Pair handlePerspective(TransformType cameraTransformType) { - Matrix4 matrix = transformationMap.containsKey(cameraTransformType) ? transformationMap.get(cameraTransformType) : new Matrix4(); + Matrix4 matrix = transformationMap.containsKey(cameraTransformType)?transformationMap.get(cameraTransformType): new Matrix4(); return Pair.of(this, matrix.toMatrix4f()); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/client/models/ModelCoresample.java b/src/main/java/blusunrize/immersiveengineering/client/models/ModelCoresample.java index e2577316d2..1ff6f8a2f8 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/models/ModelCoresample.java +++ b/src/main/java/blusunrize/immersiveengineering/client/models/ModelCoresample.java @@ -52,10 +52,12 @@ public ModelCoresample(MineralMix mineral) { this.mineral = mineral; } + public ModelCoresample() { this(null); } + public static final HashMap modelCache = new HashMap<>(); // @Override // public List getFaceQuads(EnumFacing p_177551_1_) @@ -66,9 +68,10 @@ public ModelCoresample() @Override public List getQuads(@Nullable IBlockState blockState, @Nullable EnumFacing side, long rand) { - if(bakedQuads == null) + if(bakedQuads==null) { - try{ + try + { bakedQuads = Collections.synchronizedSet(new LinkedHashSet()); float width = .25f; float depth = .25f; @@ -77,76 +80,76 @@ public List getQuads(@Nullable IBlockState blockState, @Nullable Enum int pixelLength = 0; HashMap textureOre = new HashMap(); - if(mineral!=null && mineral.oreOutput!=null) + if(mineral!=null&&mineral.oreOutput!=null) { - for(int i=0; i8?16-weight:8; + int v = weight > 8?16-weight: 8; Vector2f[][] uvs = new Vector2f[4][]; - for(int j=0; j<4; j++) + for(int j = 0; j < 4; j++) uvs[j] = new Vector2f[]{ - new Vector2f(sprite.getInterpolatedU(j*4),sprite.getInterpolatedV(v)), - new Vector2f(sprite.getInterpolatedU(j*4),sprite.getInterpolatedV(v+weight)), - new Vector2f(sprite.getInterpolatedU((j+1)*4),sprite.getInterpolatedV(v+weight)), - new Vector2f(sprite.getInterpolatedU((j+1)*4),sprite.getInterpolatedV(v))}; + new Vector2f(sprite.getInterpolatedU(j*4), sprite.getInterpolatedV(v)), + new Vector2f(sprite.getInterpolatedU(j*4), sprite.getInterpolatedV(v+weight)), + new Vector2f(sprite.getInterpolatedU((j+1)*4), sprite.getInterpolatedV(v+weight)), + new Vector2f(sprite.getInterpolatedU((j+1)*4), sprite.getInterpolatedV(v))}; float h1 = weight/(float)pixelLength; - putVertexData(new Vector3f(0, 0, -1), new Vector3f[]{new Vector3f(wOff, h, dOff), new Vector3f(wOff, h + h1, dOff), new Vector3f(wOff + width, h + h1, dOff), new Vector3f(wOff + width, h, dOff)}, uvs[0], sprite); - putVertexData(new Vector3f(0, 0, 1), new Vector3f[]{new Vector3f(wOff + width, h, dOff + depth), new Vector3f(wOff + width, h + h1, dOff + depth), new Vector3f(wOff, h + h1, dOff + depth), new Vector3f(wOff, h, dOff + depth)}, uvs[2], sprite); - putVertexData(new Vector3f(-1, 0, 0), new Vector3f[]{new Vector3f(wOff, h, dOff + depth), new Vector3f(wOff, h + h1, dOff + depth), new Vector3f(wOff, h + h1, dOff), new Vector3f(wOff, h, dOff)}, uvs[3], sprite); - putVertexData(new Vector3f(1, 0, 0), new Vector3f[]{new Vector3f(wOff + width, h, dOff), new Vector3f(wOff + width, h + h1, dOff), new Vector3f(wOff + width, h + h1, dOff + depth), new Vector3f(wOff + width, h, dOff + depth)}, uvs[1], sprite); + putVertexData(new Vector3f(0, 0, -1), new Vector3f[]{new Vector3f(wOff, h, dOff), new Vector3f(wOff, h+h1, dOff), new Vector3f(wOff+width, h+h1, dOff), new Vector3f(wOff+width, h, dOff)}, uvs[0], sprite); + putVertexData(new Vector3f(0, 0, 1), new Vector3f[]{new Vector3f(wOff+width, h, dOff+depth), new Vector3f(wOff+width, h+h1, dOff+depth), new Vector3f(wOff, h+h1, dOff+depth), new Vector3f(wOff, h, dOff+depth)}, uvs[2], sprite); + putVertexData(new Vector3f(-1, 0, 0), new Vector3f[]{new Vector3f(wOff, h, dOff+depth), new Vector3f(wOff, h+h1, dOff+depth), new Vector3f(wOff, h+h1, dOff), new Vector3f(wOff, h, dOff)}, uvs[3], sprite); + putVertexData(new Vector3f(1, 0, 0), new Vector3f[]{new Vector3f(wOff+width, h, dOff), new Vector3f(wOff+width, h+h1, dOff), new Vector3f(wOff+width, h+h1, dOff+depth), new Vector3f(wOff+width, h, dOff+depth)}, uvs[1], sprite); h += h1; } } - }catch(Exception e) + } catch(Exception e) { e.printStackTrace(); } } - if(bakedQuads!=null && !bakedQuads.isEmpty()) + if(bakedQuads!=null&&!bakedQuads.isEmpty()) { List quadList = Collections.synchronizedList(Lists.newArrayList(bakedQuads)); return quadList; @@ -160,7 +163,7 @@ protected final void putVertexData(Vector3f normal, Vector3f[] vertices, Vector2 builder.setQuadOrientation(EnumFacing.getFacingFromVector(normal.x, normal.y, normal.z)); builder.setTexture(sprite); // builder.setQuadColored(); - for(int i=0; i transformationMap = new HashMap(); - static{ + + static + { transformationMap.put(TransformType.FIRST_PERSON_LEFT_HAND, new Matrix4().translate(0, .28, 0).rotate(Math.toRadians(180), 1, 0, 0).rotate(Math.toRadians(-90), 0, 1, 0)); transformationMap.put(TransformType.FIRST_PERSON_RIGHT_HAND, new Matrix4().translate(0, .28, 0).rotate(Math.toRadians(180), 1, 0, 0).rotate(Math.toRadians(-90), 0, 1, 0)); transformationMap.put(TransformType.THIRD_PERSON_LEFT_HAND, new Matrix4().translate(0, .0625, -.125).scale(.625, .625, .625).rotate(Math.toRadians(30), 1, 0, 0).rotate(Math.toRadians(130), 0, 1, 0)); transformationMap.put(TransformType.THIRD_PERSON_RIGHT_HAND, new Matrix4().translate(0, .0625, -.125).scale(.625, .625, .625).rotate(Math.toRadians(30), 1, 0, 0).rotate(Math.toRadians(130), 0, 1, 0)); - transformationMap.put(TransformType.GUI, new Matrix4().scale(1.25,1.25,1.25).rotate(Math.toRadians(180), 1,0,0).rotate(Math.toRadians(20), 0,1,0).rotate(Math.toRadians(-30), 0,0,1)); - transformationMap.put(TransformType.FIXED, new Matrix4().scale(1.5,1.5,1.5).rotate(Math.toRadians(180), 1,0,0)); - transformationMap.put(TransformType.GROUND, new Matrix4().scale(1.5,1.5,1.5).rotate(Math.toRadians(180), 1,0,0)); + transformationMap.put(TransformType.GUI, new Matrix4().scale(1.25, 1.25, 1.25).rotate(Math.toRadians(180), 1, 0, 0).rotate(Math.toRadians(20), 0, 1, 0).rotate(Math.toRadians(-30), 0, 0, 1)); + transformationMap.put(TransformType.FIXED, new Matrix4().scale(1.5, 1.5, 1.5).rotate(Math.toRadians(180), 1, 0, 0)); + transformationMap.put(TransformType.GROUND, new Matrix4().scale(1.5, 1.5, 1.5).rotate(Math.toRadians(180), 1, 0, 0)); } + @Override public Pair handlePerspective(TransformType cameraTransformType) { // if(transformationMap==null) - return Pair.of(this, TRSRTransformation.identity().getMatrix()); + return Pair.of(this, TRSRTransformation.identity().getMatrix()); // Matrix4 matrix = transformationMap.containsKey(cameraTransformType)?transformationMap.get(cameraTransformType):new Matrix4(); // return Pair.of(this, matrix.toMatrix4f()); } diff --git a/src/main/java/blusunrize/immersiveengineering/client/models/ModelEarmuffs.java b/src/main/java/blusunrize/immersiveengineering/client/models/ModelEarmuffs.java index e328972ba9..903f302173 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/models/ModelEarmuffs.java +++ b/src/main/java/blusunrize/immersiveengineering/client/models/ModelEarmuffs.java @@ -17,60 +17,61 @@ public class ModelEarmuffs extends ModelIEArmorBase public ModelEarmuffs(float modelSize, float p_i1149_2_, int textureWidthIn, int textureHeightIn) { - super(modelSize,p_i1149_2_,textureWidthIn,textureHeightIn); + super(modelSize, p_i1149_2_, textureWidthIn, textureHeightIn); modelParts = new ModelRenderer[8]; colouredParts = new ModelRenderer[4]; this.modelParts[0] = new ModelRenderer(this, 0, 16); - this.modelParts[0].addBox(-4.5f,-8.5f,0f, 9, 1, 1, modelSize); + this.modelParts[0].addBox(-4.5f, -8.5f, 0f, 9, 1, 1, modelSize); this.bipedHead.addChild(modelParts[0]); this.modelParts[1] = new ModelRenderer(this, 0, 18); - this.modelParts[1].addBox(-4.5f,-7.5f,0f, 1, 4, 1, modelSize); + this.modelParts[1].addBox(-4.5f, -7.5f, 0f, 1, 4, 1, modelSize); this.modelParts[0].addChild(modelParts[1]); this.modelParts[2] = new ModelRenderer(this, 0, 18); - this.modelParts[2].addBox(3.5f,-7.5f,0f, 1, 4, 1, modelSize); + this.modelParts[2].addBox(3.5f, -7.5f, 0f, 1, 4, 1, modelSize); this.modelParts[0].addChild(modelParts[2]); - + this.modelParts[3] = new ModelRenderer(this, 0, 16); - this.modelParts[3].addBox(-4.5f,-8.5f,-1.5f, 9, 1, 1, modelSize); + this.modelParts[3].addBox(-4.5f, -8.5f, -1.5f, 9, 1, 1, modelSize); this.bipedHead.addChild(modelParts[3]); this.modelParts[4] = new ModelRenderer(this, 0, 18); - this.modelParts[4].addBox(-4.5f,-7.5f,-1.5f, 1, 4, 1, modelSize); + this.modelParts[4].addBox(-4.5f, -7.5f, -1.5f, 1, 4, 1, modelSize); this.modelParts[3].addChild(modelParts[4]); this.modelParts[5] = new ModelRenderer(this, 0, 18); - this.modelParts[5].addBox(3.5f,-7.5f,-1.5f, 1, 4, 1, modelSize); + this.modelParts[5].addBox(3.5f, -7.5f, -1.5f, 1, 4, 1, modelSize); this.modelParts[3].addChild(modelParts[5]); this.modelParts[6] = new ModelRenderer(this, 20, 24); - this.modelParts[6].addBox(-4.375f,-5.5f,-1.75f, 1, 4, 3, modelSize+.125f); + this.modelParts[6].addBox(-4.375f, -5.5f, -1.75f, 1, 4, 3, modelSize+.125f); this.bipedHead.addChild(modelParts[6]); this.colouredParts[0] = new ModelRenderer(this, 20, 16); - this.colouredParts[0].addBox(-4.875f,-6.5f,-1.75f, 1, 5, 3, modelSize); + this.colouredParts[0].addBox(-4.875f, -6.5f, -1.75f, 1, 5, 3, modelSize); this.bipedHead.addChild(colouredParts[0]); this.colouredParts[1] = new ModelRenderer(this, 28, 16); - this.colouredParts[1].addBox(-5.25f,-5f,-1.25f, 1, 3, 2, modelSize+.125f); + this.colouredParts[1].addBox(-5.25f, -5f, -1.25f, 1, 3, 2, modelSize+.125f); this.colouredParts[0].addChild(colouredParts[1]); this.modelParts[7] = new ModelRenderer(this, 20, 24); - this.modelParts[7].addBox(3.375f,-5.5f,-1.75f, 1, 4, 3, modelSize+.125f); + this.modelParts[7].addBox(3.375f, -5.5f, -1.75f, 1, 4, 3, modelSize+.125f); this.bipedHead.addChild(modelParts[7]); this.colouredParts[2] = new ModelRenderer(this, 20, 16); - this.colouredParts[2].addBox(3.875f,-6.5f,-1.75f, 1, 5, 3, modelSize); + this.colouredParts[2].addBox(3.875f, -6.5f, -1.75f, 1, 5, 3, modelSize); this.bipedHead.addChild(colouredParts[2]); this.colouredParts[3] = new ModelRenderer(this, 28, 16); - this.colouredParts[3].addBox(4.25f,-5f,-1.25f, 1, 3, 2, modelSize+.125f); + this.colouredParts[3].addBox(4.25f, -5f, -1.25f, 1, 3, 2, modelSize+.125f); this.colouredParts[2].addChild(colouredParts[3]); - this.bipedHeadwear.isHidden=true; + this.bipedHeadwear.isHidden = true; this.bipedBody.isHidden = true; this.bipedLeftLeg.isHidden = true; this.bipedRightLeg.isHidden = true; } static ModelEarmuffs modelInstance; + public static ModelEarmuffs getModel() { if(modelInstance==null) - modelInstance = new ModelEarmuffs(.0625f,0,64,32); + modelInstance = new ModelEarmuffs(.0625f, 0, 64, 32); return modelInstance; } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/client/models/ModelIEArmorBase.java b/src/main/java/blusunrize/immersiveengineering/client/models/ModelIEArmorBase.java index 37a439cc70..e3c7c67b2a 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/models/ModelIEArmorBase.java +++ b/src/main/java/blusunrize/immersiveengineering/client/models/ModelIEArmorBase.java @@ -23,7 +23,7 @@ public ModelIEArmorBase(float modelSize, float p_i1149_2_, int textureWidthIn, i { super(modelSize, p_i1149_2_, textureWidthIn, textureHeightIn); } - + @Override public void render(Entity entity, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float scale) { @@ -44,7 +44,7 @@ public void setRotationAngles(float p_78087_1_, float p_78087_2_, float p_78087_ swingProgress = ((EntityLivingBase)entity).getSwingProgress(ClientUtils.timer().renderPartialTicks); if(entity instanceof EntityArmorStand) setRotationAnglesStand(p_78087_1_, p_78087_2_, p_78087_3_, p_78087_4_, p_78087_5_, p_78087_6_, entity); - else if(entity instanceof EntitySkeleton || entity instanceof EntityZombie) + else if(entity instanceof EntitySkeleton||entity instanceof EntityZombie) setRotationAnglesZombie(p_78087_1_, p_78087_2_, p_78087_3_, p_78087_4_, p_78087_5_, p_78087_6_, entity); else super.setRotationAngles(p_78087_1_, p_78087_2_, p_78087_3_, p_78087_4_, p_78087_5_, p_78087_6_, entity); @@ -53,47 +53,47 @@ else if(entity instanceof EntitySkeleton || entity instanceof EntityZombie) public void setRotationAnglesZombie(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity p_78087_7_) { super.setRotationAngles(p_78087_1_, p_78087_2_, p_78087_3_, p_78087_4_, p_78087_5_, p_78087_6_, p_78087_7_); - float f6 = MathHelper.sin(this.swingProgress * 3.141593F); - float f7 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * 3.141593F); + float f6 = MathHelper.sin(this.swingProgress*3.141593F); + float f7 = MathHelper.sin((1.0F-(1.0F-this.swingProgress)*(1.0F-this.swingProgress))*3.141593F); this.bipedRightArm.rotateAngleZ = 0.0F; this.bipedLeftArm.rotateAngleZ = 0.0F; - this.bipedRightArm.rotateAngleY = (-(0.1F - f6 * 0.6F)); - this.bipedLeftArm.rotateAngleY = (0.1F - f6 * 0.6F); + this.bipedRightArm.rotateAngleY = (-(0.1F-f6*0.6F)); + this.bipedLeftArm.rotateAngleY = (0.1F-f6*0.6F); this.bipedRightArm.rotateAngleX = -1.570796F; this.bipedLeftArm.rotateAngleX = -1.570796F; - this.bipedRightArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; - this.bipedLeftArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; - this.bipedRightArm.rotateAngleZ += MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F; - this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F; - this.bipedRightArm.rotateAngleX += MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F; - this.bipedLeftArm.rotateAngleX -= MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F; + this.bipedRightArm.rotateAngleX -= f6*1.2F-f7*0.4F; + this.bipedLeftArm.rotateAngleX -= f6*1.2F-f7*0.4F; + this.bipedRightArm.rotateAngleZ += MathHelper.cos(p_78087_3_*0.09F)*0.05F+0.05F; + this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(p_78087_3_*0.09F)*0.05F+0.05F; + this.bipedRightArm.rotateAngleX += MathHelper.sin(p_78087_3_*0.067F)*0.05F; + this.bipedLeftArm.rotateAngleX -= MathHelper.sin(p_78087_3_*0.067F)*0.05F; } public void setRotationAnglesStand(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity entity) { - if ((entity instanceof EntityArmorStand)) + if((entity instanceof EntityArmorStand)) { EntityArmorStand entityarmorstand = (EntityArmorStand)entity; - this.bipedHead.rotateAngleX = (0.01745329F * entityarmorstand.getHeadRotation().getX()); - this.bipedHead.rotateAngleY = (0.01745329F * entityarmorstand.getHeadRotation().getY()); - this.bipedHead.rotateAngleZ = (0.01745329F * entityarmorstand.getHeadRotation().getZ()); + this.bipedHead.rotateAngleX = (0.01745329F*entityarmorstand.getHeadRotation().getX()); + this.bipedHead.rotateAngleY = (0.01745329F*entityarmorstand.getHeadRotation().getY()); + this.bipedHead.rotateAngleZ = (0.01745329F*entityarmorstand.getHeadRotation().getZ()); this.bipedHead.setRotationPoint(0.0F, 1.0F, 0.0F); - this.bipedBody.rotateAngleX = (0.01745329F * entityarmorstand.getBodyRotation().getX()); - this.bipedBody.rotateAngleY = (0.01745329F * entityarmorstand.getBodyRotation().getY()); - this.bipedBody.rotateAngleZ = (0.01745329F * entityarmorstand.getBodyRotation().getZ()); - this.bipedLeftArm.rotateAngleX = (0.01745329F * entityarmorstand.getLeftArmRotation().getX()); - this.bipedLeftArm.rotateAngleY = (0.01745329F * entityarmorstand.getLeftArmRotation().getY()); - this.bipedLeftArm.rotateAngleZ = (0.01745329F * entityarmorstand.getLeftArmRotation().getZ()); - this.bipedRightArm.rotateAngleX = (0.01745329F * entityarmorstand.getRightArmRotation().getX()); - this.bipedRightArm.rotateAngleY = (0.01745329F * entityarmorstand.getRightArmRotation().getY()); - this.bipedRightArm.rotateAngleZ = (0.01745329F * entityarmorstand.getRightArmRotation().getZ()); - this.bipedLeftLeg.rotateAngleX = (0.01745329F * entityarmorstand.getLeftLegRotation().getX()); - this.bipedLeftLeg.rotateAngleY = (0.01745329F * entityarmorstand.getLeftLegRotation().getY()); - this.bipedLeftLeg.rotateAngleZ = (0.01745329F * entityarmorstand.getLeftLegRotation().getZ()); + this.bipedBody.rotateAngleX = (0.01745329F*entityarmorstand.getBodyRotation().getX()); + this.bipedBody.rotateAngleY = (0.01745329F*entityarmorstand.getBodyRotation().getY()); + this.bipedBody.rotateAngleZ = (0.01745329F*entityarmorstand.getBodyRotation().getZ()); + this.bipedLeftArm.rotateAngleX = (0.01745329F*entityarmorstand.getLeftArmRotation().getX()); + this.bipedLeftArm.rotateAngleY = (0.01745329F*entityarmorstand.getLeftArmRotation().getY()); + this.bipedLeftArm.rotateAngleZ = (0.01745329F*entityarmorstand.getLeftArmRotation().getZ()); + this.bipedRightArm.rotateAngleX = (0.01745329F*entityarmorstand.getRightArmRotation().getX()); + this.bipedRightArm.rotateAngleY = (0.01745329F*entityarmorstand.getRightArmRotation().getY()); + this.bipedRightArm.rotateAngleZ = (0.01745329F*entityarmorstand.getRightArmRotation().getZ()); + this.bipedLeftLeg.rotateAngleX = (0.01745329F*entityarmorstand.getLeftLegRotation().getX()); + this.bipedLeftLeg.rotateAngleY = (0.01745329F*entityarmorstand.getLeftLegRotation().getY()); + this.bipedLeftLeg.rotateAngleZ = (0.01745329F*entityarmorstand.getLeftLegRotation().getZ()); this.bipedLeftLeg.setRotationPoint(1.9F, 11.0F, 0.0F); - this.bipedRightLeg.rotateAngleX = (0.01745329F * entityarmorstand.getRightLegRotation().getX()); - this.bipedRightLeg.rotateAngleY = (0.01745329F * entityarmorstand.getRightLegRotation().getY()); - this.bipedRightLeg.rotateAngleZ = (0.01745329F * entityarmorstand.getRightLegRotation().getZ()); + this.bipedRightLeg.rotateAngleX = (0.01745329F*entityarmorstand.getRightLegRotation().getX()); + this.bipedRightLeg.rotateAngleY = (0.01745329F*entityarmorstand.getRightLegRotation().getY()); + this.bipedRightLeg.rotateAngleZ = (0.01745329F*entityarmorstand.getRightLegRotation().getZ()); this.bipedRightLeg.setRotationPoint(-1.9F, 11.0F, 0.0F); copyModelAngles(this.bipedHead, this.bipedHeadwear); } diff --git a/src/main/java/blusunrize/immersiveengineering/client/models/ModelItemDynamicOverride.java b/src/main/java/blusunrize/immersiveengineering/client/models/ModelItemDynamicOverride.java index 3802b7b60b..1b1314abed 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/models/ModelItemDynamicOverride.java +++ b/src/main/java/blusunrize/immersiveengineering/client/models/ModelItemDynamicOverride.java @@ -46,7 +46,7 @@ public class ModelItemDynamicOverride implements IBakedModel public ModelItemDynamicOverride(IBakedModel itemModel, @Nullable List textures) { this.itemModel = itemModel; - if(textures != null) + if(textures!=null) { ImmutableList.Builder builder = ImmutableList.builder(); Optional transform = Optional.of(TRSRTransformation.identity()); @@ -59,7 +59,7 @@ public ModelItemDynamicOverride(IBakedModel itemModel, @Nullable List getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) { - if(quads != null) + if(quads!=null) return quads; return itemModel.getQuads(state, side, rand); } @@ -113,14 +113,14 @@ public Pair handlePerspective(TransformType cam @Override public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) { - if(!stack.isEmpty() && stack.getItem() instanceof IEItemInterfaces.ITextureOverride) + if(!stack.isEmpty()&&stack.getItem() instanceof IEItemInterfaces.ITextureOverride) { - IEItemInterfaces.ITextureOverride texOverride = (IEItemInterfaces.ITextureOverride) stack.getItem(); + IEItemInterfaces.ITextureOverride texOverride = (IEItemInterfaces.ITextureOverride)stack.getItem(); String key = texOverride.getModelCacheKey(stack); - if(key != null) + if(key!=null) { IBakedModel model = modelCache.get(key); - if(model == null) + if(model==null) { model = new ModelItemDynamicOverride(originalModel, texOverride.getTextures(stack, key)); modelCache.put(key, model); diff --git a/src/main/java/blusunrize/immersiveengineering/client/models/ModelManeuverGear.java b/src/main/java/blusunrize/immersiveengineering/client/models/ModelManeuverGear.java index 47905c72f4..1a29b36a7d 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/models/ModelManeuverGear.java +++ b/src/main/java/blusunrize/immersiveengineering/client/models/ModelManeuverGear.java @@ -16,56 +16,56 @@ public class ModelManeuverGear extends ModelIEArmorBase public ModelManeuverGear(float modelSize, float p_i1149_2_, int textureWidthIn, int textureHeightIn) { - super(modelSize,p_i1149_2_,textureWidthIn,textureHeightIn); + super(modelSize, p_i1149_2_, textureWidthIn, textureHeightIn); cannisters = new ModelRenderer[8]; this.cannisters[0] = new ModelRenderer(this, 0, 0); - this.cannisters[0].addBox(-.5f,-1.5f,-3, 2, 3, 5, modelSize); + this.cannisters[0].addBox(-.5f, -1.5f, -3, 2, 3, 5, modelSize); this.cannisters[0].setRotationPoint(-5.5f, 14, 0); - this.cannisters[0].rotateAngleX=(float)Math.toRadians(-20); + this.cannisters[0].rotateAngleX = (float)Math.toRadians(-20); this.bipedBody.addChild(cannisters[0]); this.cannisters[1] = new ModelRenderer(this, 0, 0); this.cannisters[1].mirror = true; - this.cannisters[1].addBox(-1.5f,-1.5f,-3, 2, 3, 5, modelSize); + this.cannisters[1].addBox(-1.5f, -1.5f, -3, 2, 3, 5, modelSize); this.cannisters[1].setRotationPoint(5.5f, 14, 0); - this.cannisters[1].rotateAngleX=(float)Math.toRadians(-20); + this.cannisters[1].rotateAngleX = (float)Math.toRadians(-20); this.bipedBody.addChild(cannisters[1]); this.cannisters[2] = new ModelRenderer(this, 14, 10); this.cannisters[2].mirror = true; - this.cannisters[2].addBox(-3.5f,-4.5f,2.5f, 7, 3, 3, modelSize); + this.cannisters[2].addBox(-3.5f, -4.5f, 2.5f, 7, 3, 3, modelSize); this.cannisters[2].setRotationPoint(0, 14, 0); - this.cannisters[2].rotateAngleZ=(float)Math.toRadians(15); + this.cannisters[2].rotateAngleZ = (float)Math.toRadians(15); this.bipedBody.addChild(cannisters[2]); this.cannisters[3] = new ModelRenderer(this, 6, 10); this.cannisters[3].mirror = true; - this.cannisters[3].addBox(-6.5f,-3.5f,3, 3, 1, 1, modelSize); - this.cannisters[3].setRotationPoint(0,-1.5f,-0.5f); - this.cannisters[3].rotateAngleX=(float)Math.toRadians(-22.5); + this.cannisters[3].addBox(-6.5f, -3.5f, 3, 3, 1, 1, modelSize); + this.cannisters[3].setRotationPoint(0, -1.5f, -0.5f); + this.cannisters[3].rotateAngleX = (float)Math.toRadians(-22.5); this.cannisters[2].addChild(cannisters[3]); this.cannisters[4] = new ModelRenderer(this, 6, 8); this.cannisters[4].mirror = true; - this.cannisters[4].addBox(-6f,-4.5f,3, 1, 1, 1, modelSize); + this.cannisters[4].addBox(-6f, -4.5f, 3, 1, 1, 1, modelSize); this.cannisters[3].addChild(cannisters[4]); this.cannisters[5] = new ModelRenderer(this, 14, 6); this.cannisters[5].mirror = true; - this.cannisters[5].addBox(-7f,-5f,2, 3, 1, 3, modelSize); + this.cannisters[5].addBox(-7f, -5f, 2, 3, 1, 3, modelSize); this.cannisters[3].addChild(cannisters[5]); this.cannisters[6] = new ModelRenderer(this, 0, 8); - this.cannisters[6].addBox(1,7,2, 2, 4, 1, modelSize); + this.cannisters[6].addBox(1, 7, 2, 2, 4, 1, modelSize); this.bipedBody.addChild(cannisters[6]); this.cannisters[7] = new ModelRenderer(this, 0, 8); this.cannisters[7].mirror = true; - this.cannisters[7].addBox(-3,7,2, 2, 4, 1, modelSize); + this.cannisters[7].addBox(-3, 7, 2, 2, 4, 1, modelSize); this.bipedBody.addChild(cannisters[7]); - this.bipedHead.isHidden=true; - this.bipedHeadwear.isHidden=true; + this.bipedHead.isHidden = true; + this.bipedHeadwear.isHidden = true; } // @Override @@ -82,10 +82,11 @@ public ModelManeuverGear(float modelSize, float p_i1149_2_, int textureWidthIn, // } static ModelManeuverGear modelInstance; + public static ModelManeuverGear getModel() { if(modelInstance==null) - modelInstance = new ModelManeuverGear(.0625f,0,64,32); + modelInstance = new ModelManeuverGear(.0625f, 0, 64, 32); return modelInstance; } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/client/models/ModelPowerpack.java b/src/main/java/blusunrize/immersiveengineering/client/models/ModelPowerpack.java index 48232a5a26..a61606ecb8 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/models/ModelPowerpack.java +++ b/src/main/java/blusunrize/immersiveengineering/client/models/ModelPowerpack.java @@ -44,7 +44,7 @@ public class ModelPowerpack extends ModelIEArmorBase public ModelPowerpack(float modelSize, float p_i1149_2_, int textureWidthIn, int textureHeightIn) { - super(modelSize,p_i1149_2_,textureWidthIn,textureHeightIn); + super(modelSize, p_i1149_2_, textureWidthIn, textureHeightIn); modelParts = new ModelRenderer[8]; colouredParts = new ModelRenderer[4]; @@ -66,7 +66,7 @@ public ModelPowerpack(float modelSize, float p_i1149_2_, int textureWidthIn, int this.modelParts[3] = new ModelRenderer(this, 0, 0); this.modelParts[3].addBox(-1f, -4.0f, -1f, 2, 8, 2, 0); this.modelParts[3].setRotationPoint(5f, 5, 3f); - this.modelParts[3].rotateAngleZ=3.14159f; + this.modelParts[3].rotateAngleZ = 3.14159f; this.bipedBody.addChild(modelParts[3]); @@ -120,28 +120,28 @@ public ModelPowerpack(float modelSize, float p_i1149_2_, int textureWidthIn, int connector = new ModelRenderer(this, 17, 9); connector.addBox(-1f, -1.5f, -1.5f, 3, 3, 3, 0); connector.setRotationPoint(4.5f, 0f, 0f); - connector.rotateAngleY=3.14159f; + connector.rotateAngleY = 3.14159f; this.modelParts[1].addChild(connector); connector = new ModelRenderer(this, 17, 9); connector.addBox(-1f, -1.5f, -1.5f, 3, 3, 3, -.375f); connector.setRotationPoint(6f, 0f, 0); - connector.rotateAngleY=3.14159f; + connector.rotateAngleY = 3.14159f; this.modelParts[1].addChild(connector); connector = new ModelRenderer(this, 29, 9); connector.addBox(-1f, -1.5f, -1.5f, 1, 3, 3, 0); connector.setRotationPoint(6.25f, 0f, 0); - connector.rotateAngleY=3.14159f; + connector.rotateAngleY = 3.14159f; this.modelParts[1].addChild(connector); connector = new ModelRenderer(this, 12, 8); connector.addBox(-.5f, -1f, -1f, 2, 2, 2, 0); connector.setRotationPoint(7.5f, 0f, 0f); - connector.rotateAngleY=3.14159f; + connector.rotateAngleY = 3.14159f; this.modelParts[1].addChild(connector); - for(int i=0; i<3; i++) + for(int i = 0; i < 3; i++) { float pos = 3.125f-i*2.25f; ModelRenderer tube = new ModelRenderer(this, 56, 19); @@ -172,7 +172,7 @@ public ModelPowerpack(float modelSize, float p_i1149_2_, int textureWidthIn, int } this.bipedHead.isHidden = true; - this.bipedHeadwear.isHidden=true; + this.bipedHeadwear.isHidden = true; this.bipedLeftArm.isHidden = true; this.bipedRightArm.isHidden = true; this.bipedLeftLeg.isHidden = true; @@ -186,7 +186,7 @@ public void render(Entity entity, float p_78088_2_, float p_78088_3_, float p_78 { ItemStack chest = ((EntityLivingBase)entity).getItemStackFromSlot(EntityEquipmentSlot.CHEST); float storage = 0; - if(!chest.isEmpty() && chest.getItem() instanceof ItemArmor) + if(!chest.isEmpty()&&chest.getItem() instanceof ItemArmor) { if(!(chest.getItem() instanceof ItemPowerpack)) chest = ItemNBTHelper.getItemStack(chest, "IE:Powerpack"); @@ -194,7 +194,7 @@ public void render(Entity entity, float p_78088_2_, float p_78088_3_, float p_78 if(chest.getItem() instanceof ItemPowerpack) { float max = EnergyHelper.getMaxEnergyStored(chest); - storage = max<=0?0:EnergyHelper.getEnergyStored(chest)/max; + storage = max <= 0?0: EnergyHelper.getEnergyStored(chest)/max; } this.modelParts[7].rotateAngleZ = 0.5235987f-(1.047197f*storage); } @@ -209,48 +209,48 @@ public void render(Entity entity, float p_78088_2_, float p_78088_3_, float p_78 for(EnumHand hand : EnumHand.values()) { ItemStack stack = ((EntityLivingBase)entity).getHeldItem(hand); - if(!stack.isEmpty() && EnergyHelper.isFluxItem(stack)) + if(!stack.isEmpty()&&EnergyHelper.isFluxItem(stack)) { boolean right = (hand==EnumHand.MAIN_HAND)==(((EntityLivingBase)entity).getPrimaryHand()==EnumHandSide.RIGHT); - float angleX = (right?bipedRightArm:bipedLeftArm).rotateAngleX; - float angleZ = (right?bipedRightArm:bipedLeftArm).rotateAngleZ; + float angleX = (right?bipedRightArm: bipedLeftArm).rotateAngleX; + float angleZ = (right?bipedRightArm: bipedLeftArm).rotateAngleZ; String cacheKey = keyFormat.format(angleX)+"_"+keyFormat.format(angleZ); Vec3d[] vex = new Vec3d[0]; try { - vex = (right?catenaryCacheRight:catenaryCacheLeft).get(cacheKey, ()-> + vex = (right?catenaryCacheRight: catenaryCacheLeft).get(cacheKey, () -> { double armLength = .75f; double x = .3125+(right?1: -1)*armLength*Math.sin(angleZ); double y = armLength*Math.cos(angleX); double z = armLength*Math.sin(angleX); - return ApiUtils.getConnectionCatenary(new Vec3d(.484375,-.75,.25), new Vec3d(x,-y,z), 1.5); + return ApiUtils.getConnectionCatenary(new Vec3d(.484375, -.75, .25), new Vec3d(x, -y, z), 1.5); }); } catch(Exception e) { } float vStep = 1f/vex.length; - int i=0; + int i = 0; Tessellator tes = ClientUtils.tes(); BufferBuilder worldrenderer = tes.getBuffer(); // float[] colour = {.7f,.42f,.25f,1}; - float[] colour = {.93f,.63f,.27f,1}; + float[] colour = {.93f, .63f, .27f, 1}; worldrenderer.begin(GL11.GL_QUAD_STRIP, DefaultVertexFormats.POSITION_TEX_COLOR); for(Vec3d v : vex) { - worldrenderer.pos((right?-v.x:v.x)-.015625, -v.y, v.z).tex(vStep*i,0).color(colour[0],colour[1],colour[2],colour[3]).endVertex(); - worldrenderer.pos((right?-v.x:v.x)+.015625, -v.y, v.z).tex(vStep*i++,1).color(colour[0],colour[1],colour[2],colour[3]).endVertex(); + worldrenderer.pos((right?-v.x: v.x)-.015625, -v.y, v.z).tex(vStep*i, 0).color(colour[0], colour[1], colour[2], colour[3]).endVertex(); + worldrenderer.pos((right?-v.x: v.x)+.015625, -v.y, v.z).tex(vStep*i++, 1).color(colour[0], colour[1], colour[2], colour[3]).endVertex(); } tes.draw(); worldrenderer.begin(GL11.GL_QUAD_STRIP, DefaultVertexFormats.POSITION_TEX_COLOR); - i=0; + i = 0; for(Vec3d v : vex) { - worldrenderer.pos((right?-v.x:v.x), -v.y-.015625, v.z).tex(vStep*i,0).color(colour[0],colour[1],colour[2],colour[3]).endVertex(); - worldrenderer.pos((right?-v.x:v.x), -v.y+.015625, v.z).tex(vStep*i++,1).color(colour[0],colour[1],colour[2],colour[3]).endVertex(); + worldrenderer.pos((right?-v.x: v.x), -v.y-.015625, v.z).tex(vStep*i, 0).color(colour[0], colour[1], colour[2], colour[3]).endVertex(); + worldrenderer.pos((right?-v.x: v.x), -v.y+.015625, v.z).tex(vStep*i++, 1).color(colour[0], colour[1], colour[2], colour[3]).endVertex(); } tes.draw(); } @@ -259,18 +259,19 @@ public void render(Entity entity, float p_78088_2_, float p_78088_3_, float p_78 } static final DecimalFormat keyFormat = new DecimalFormat("0.0000"); - public static final Cache catenaryCacheLeft = CacheBuilder.newBuilder() + public static final Cache catenaryCacheLeft = CacheBuilder.newBuilder() .expireAfterAccess(5, TimeUnit.MINUTES) .build(); - public static final Cache catenaryCacheRight = CacheBuilder.newBuilder() + public static final Cache catenaryCacheRight = CacheBuilder.newBuilder() .expireAfterAccess(5, TimeUnit.MINUTES) .build(); static ModelPowerpack modelInstance; + public static ModelPowerpack getModel() { if(modelInstance==null) - modelInstance = new ModelPowerpack(.0625f,0,64,32); + modelInstance = new ModelPowerpack(.0625f, 0, 64, 32); return modelInstance; } } diff --git a/src/main/java/blusunrize/immersiveengineering/client/models/ModelShaderMinecart.java b/src/main/java/blusunrize/immersiveengineering/client/models/ModelShaderMinecart.java index 3b52ba33fc..1023d8e87b 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/models/ModelShaderMinecart.java +++ b/src/main/java/blusunrize/immersiveengineering/client/models/ModelShaderMinecart.java @@ -40,7 +40,7 @@ public ModelShaderMinecart(ModelMinecart model) sideModelsMirrored[4].mirror = true; ArrayList newCubes = new ArrayList(); for(ModelBox cube : sideModelsMirrored[4].cubeList) - newCubes.add(new ModelBox(sideModelsMirrored[4], 0,0, cube.posX1,cube.posY1,cube.posZ1, (int)(cube.posX2-cube.posX1),(int)(cube.posY2-cube.posY1),(int)(cube.posZ2-cube.posZ1), 0)); + newCubes.add(new ModelBox(sideModelsMirrored[4], 0, 0, cube.posX1, cube.posY1, cube.posZ1, (int)(cube.posX2-cube.posX1), (int)(cube.posY2-cube.posY1), (int)(cube.posZ2-cube.posZ1), 0)); sideModelsMirrored[4].cubeList = newCubes; } @@ -52,17 +52,17 @@ public void render(Entity entity, float f0, float f1, float f2, float f3, float if(shadedCarts.containsKey(entity.getEntityId())) { shader = shadedCarts.get(entity.getEntityId()); - if(shader != null && !shader.isEmpty() && shader.getItem() instanceof IShaderItem) - sCase = ((IShaderItem)shader.getItem()).getShaderCase(shader,null,"immersiveengineering:minecart"); + if(shader!=null&&!shader.isEmpty()&&shader.getItem() instanceof IShaderItem) + sCase = ((IShaderItem)shader.getItem()).getShaderCase(shader, null, "immersiveengineering:minecart"); } if(sCase!=null) { GlStateManager.enableBlend(); OpenGlHelper.glBlendFunc(770, 771, 0, 1); - sideModels[5].rotationPointY = 4.0F - f2; - sideModelsMirrored[5].rotationPointY = 4.0F - f2; - for(int part=0;part>16&255)/255f,(col>>8&255)/255f,(col&255)/255f,(col>>24&255)/255f); + GlStateManager.scale(scale, scale, scale); + GlStateManager.color((col >> 16&255)/255f, (col >> 8&255)/255f, (col&255)/255f, (col >> 24&255)/255f); // if(pass==maxPasses-1) // ClientUtils.bindTexture("immersiveengineering:textures/models/shaders/minecart_uncoloured.png"); @@ -101,8 +101,8 @@ public void render(Entity entity, float f0, float f1, float f2, float f3, float if(layers[pass].isDynamicLayer()) layers[pass].modifyRender(false, part); - GlStateManager.color(1,1,1,1); - GlStateManager.scale(1/scale,1/scale,1/scale); + GlStateManager.color(1, 1, 1, 1); + GlStateManager.scale(1/scale, 1/scale, 1/scale); // if(upScale) // scale += .001f; } diff --git a/src/main/java/blusunrize/immersiveengineering/client/models/SmartLightingQuad.java b/src/main/java/blusunrize/immersiveengineering/client/models/SmartLightingQuad.java index 4055f8c2ea..6456af8672 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/models/SmartLightingQuad.java +++ b/src/main/java/blusunrize/immersiveengineering/client/models/SmartLightingQuad.java @@ -26,6 +26,7 @@ public class SmartLightingQuad extends BakedQuad { private static Field parent; private static Field blockInfo; + static { try @@ -34,28 +35,30 @@ public class SmartLightingQuad extends BakedQuad blockInfo.setAccessible(true); parent = QuadGatheringTransformer.class.getDeclaredField("parent"); parent.setAccessible(true); - } - catch (Exception x) + } catch(Exception x) { x.printStackTrace(); } } + BlockPos blockPos; int[][] relativePos; boolean ignoreLight; public static int staticBrightness; + public SmartLightingQuad(int[] vertexDataIn, int tintIndexIn, EnumFacing faceIn, TextureAtlasSprite spriteIn, VertexFormat format, BlockPos p) { super(vertexDataIn, tintIndexIn, faceIn, spriteIn, false, format); blockPos = p; relativePos = new int[4][]; ignoreLight = false; - for (int i = 0;i<4;i++) + for(int i = 0; i < 4; i++) relativePos[i] = new int[]{(int)Math.floor(Float.intBitsToFloat(vertexDataIn[7*i])), (int)Math.floor(Float.intBitsToFloat(vertexDataIn[7*i+1])), (int)Math.floor(Float.intBitsToFloat(vertexDataIn[7*i+2])) - }; + }; } + public SmartLightingQuad(int[] vertexDataIn, int tintIndexIn, EnumFacing faceIn, TextureAtlasSprite spriteIn, VertexFormat format) { super(vertexDataIn, tintIndexIn, faceIn, spriteIn, false, format); @@ -67,17 +70,16 @@ public void pipe(IVertexConsumer consumer) { IBlockAccess world = null; BlockInfo info = null; - if (consumer instanceof VertexLighterFlat) + if(consumer instanceof VertexLighterFlat) { try { - info = (BlockInfo) blockInfo.get(consumer); + info = (BlockInfo)blockInfo.get(consumer); world = info.getWorld(); - if (world instanceof ChunkCache) + if(world instanceof ChunkCache) world = ((ChunkCache)world).world; - consumer = (IVertexConsumer) parent.get(consumer); - } - catch (Throwable e) + consumer = (IVertexConsumer)parent.get(consumer); + } catch(Throwable e) { e.printStackTrace(); } @@ -93,20 +95,20 @@ public void pipe(IVertexConsumer consumer) eMap[eMap.length-1] = 2; for(int v = 0; v < 4; v++) for(int e = 0; e < count; e++) - if(eMap[e] != itemCount) + if(eMap[e]!=itemCount) { - if (format.getElement(e).getUsage()==EnumUsage.UV&&format.getElement(e).getType()==EnumType.SHORT)//lightmap is UV with 2 shorts + if(format.getElement(e).getUsage()==EnumUsage.UV&&format.getElement(e).getType()==EnumType.SHORT)//lightmap is UV with 2 shorts { int brightness; - if (!ignoreLight&&world!=null&&!(world instanceof ChunkCache)) + if(!ignoreLight&&world!=null&&!(world instanceof ChunkCache)) { BlockPos here = blockPos.add(relativePos[v][0], relativePos[v][1], relativePos[v][2]); brightness = world.getCombinedLight(here, 0); } else brightness = staticBrightness; - data[0] = ((float)((brightness >> 0x04) & 0xF) * 0x20) / 0xFFFF; - data[1] = ((float)((brightness >> 0x14) & 0xF) * 0x20) / 0xFFFF; + data[0] = ((float)((brightness >> 0x04)&0xF)*0x20)/0xFFFF; + data[1] = ((float)((brightness >> 0x14)&0xF)*0x20)/0xFFFF; } else LightUtil.unpack(this.getVertexData(), data, DefaultVertexFormats.ITEM, v, eMap[e]); diff --git a/src/main/java/blusunrize/immersiveengineering/client/models/obj/IEOBJLoader.java b/src/main/java/blusunrize/immersiveengineering/client/models/obj/IEOBJLoader.java index 5f9a09820d..a8c724d32d 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/models/obj/IEOBJLoader.java +++ b/src/main/java/blusunrize/immersiveengineering/client/models/obj/IEOBJLoader.java @@ -37,7 +37,7 @@ public void addDomain(String domain) @Override public boolean accepts(@Nonnull ResourceLocation modelLocation) { - return enabledDomains.contains(modelLocation.getResourceDomain()) && modelLocation.getResourcePath().endsWith(".obj.ie"); + return enabledDomains.contains(modelLocation.getResourceDomain())&&modelLocation.getResourcePath().endsWith(".obj.ie"); } @Nonnull @@ -54,7 +54,7 @@ public IModel loadModel(@Nonnull ResourceLocation modelLocation) throws Exceptio } } IEOBJModel model = cache.get(modelLocation); - if(model == null) + if(model==null) return ModelLoaderRegistry.getMissingModel(); return model; } @@ -62,8 +62,8 @@ public IModel loadModel(@Nonnull ResourceLocation modelLocation) throws Exceptio @Override public void onResourceManagerReload(@Nonnull IResourceManager resourceManager) { - this.manager = resourceManager; - cache.clear(); - errors.clear(); + this.manager = resourceManager; + cache.clear(); + errors.clear(); } } diff --git a/src/main/java/blusunrize/immersiveengineering/client/models/obj/IEOBJModel.java b/src/main/java/blusunrize/immersiveengineering/client/models/obj/IEOBJModel.java index a40cde7e48..1d692549f8 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/models/obj/IEOBJModel.java +++ b/src/main/java/blusunrize/immersiveengineering/client/models/obj/IEOBJModel.java @@ -56,9 +56,11 @@ public IModel retexture(ImmutableMap textures) } static Field f_modelLocation; + public ResourceLocation getResourceLocation() { - try{ + try + { if(f_modelLocation==null) { f_modelLocation = OBJModel.class.getDeclaredField("modelLocation"); @@ -66,15 +68,19 @@ public ResourceLocation getResourceLocation() } if(f_modelLocation!=null) return (ResourceLocation)f_modelLocation.get(this); - }catch(Exception e){ + } catch(Exception e) + { e.printStackTrace(); } return null; } + static Field f_customData; + public Object getCustomData() { - try{ + try + { if(f_customData==null) { f_customData = OBJModel.class.getDeclaredField("customData"); @@ -82,14 +88,17 @@ public Object getCustomData() } if(f_customData!=null) return f_customData.get(this); - }catch(Exception e){ + } catch(Exception e) + { e.printStackTrace(); } return null; } + public void setCustomData(Object data) { - try{ + try + { if(f_customData==null) { f_customData = OBJModel.class.getDeclaredField("customData"); @@ -97,7 +106,8 @@ public void setCustomData(Object data) } if(f_customData!=null) f_customData.set(this, data); - }catch(Exception e){ + } catch(Exception e) + { e.printStackTrace(); } } diff --git a/src/main/java/blusunrize/immersiveengineering/client/models/smart/ConnLoader.java b/src/main/java/blusunrize/immersiveengineering/client/models/smart/ConnLoader.java index 087b45ce7d..68b40f7a2c 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/models/smart/ConnLoader.java +++ b/src/main/java/blusunrize/immersiveengineering/client/models/smart/ConnLoader.java @@ -33,17 +33,18 @@ public class ConnLoader implements ICustomModelLoader //Do not manually write to these in IE 0.12-77+. Use blusunrize.immersiveengineering.api.energy.wires.WireApi.registerConnectorForRender() public static Map> textureReplacements = new HashMap<>(); public static Map baseModels = new HashMap<>(); + static { WireApi.registerConnectorForRender("conn_lv", new ResourceLocation("immersiveengineering:block/connector/connector_lv.obj"), null); WireApi.registerConnectorForRender("rel_lv", new ResourceLocation("immersiveengineering:block/connector/connector_lv.obj"), ImmutableMap.of("#immersiveengineering:blocks/connector_connector_lv", - "immersiveengineering:blocks/connector_relay_lv")); + "immersiveengineering:blocks/connector_relay_lv")); WireApi.registerConnectorForRender("conn_mv", new ResourceLocation("immersiveengineering:block/connector/connector_mv.obj"), null); WireApi.registerConnectorForRender("rel_mv", new ResourceLocation("immersiveengineering:block/connector/connector_mv.obj"), ImmutableMap.of("#immersiveengineering:blocks/connector_connector_mv", - "immersiveengineering:blocks/connector_relay_mv")); + "immersiveengineering:blocks/connector_relay_mv")); WireApi.registerConnectorForRender("conn_hv", new ResourceLocation("immersiveengineering:block/connector/connector_hv.obj"), null); WireApi.registerConnectorForRender("rel_hv", new ResourceLocation("immersiveengineering:block/connector/relay_hv.obj"), null); @@ -85,7 +86,7 @@ public class ConnLoader implements ICustomModelLoader new ResourceLocation("immersiveengineering:block/metal_device/floodlight.obj.ie"), ImmutableMap.of("#immersiveengineering:blocks/metal_device1_floodlight", "immersiveengineering:blocks/metal_device1_floodlight_on")); - + WireApi.registerConnectorForRender("balloon", new ResourceLocation("immersiveengineering:block/balloon.obj.ie"), null); @@ -114,14 +115,14 @@ public IModel loadModel(@Nonnull ResourceLocation modelLocation) { String resourcePath = modelLocation.getResourcePath(); int pos = resourcePath.indexOf("conn_"); - if (pos >= 0) + if(pos >= 0) { pos += 5;// length of "conn_" String name = resourcePath.substring(pos); ResourceLocation r = baseModels.get(name); - if (r != null) + if(r!=null) { - if (textureReplacements.containsKey(name)) + if(textureReplacements.containsKey(name)) return new ConnModelBase(r, textureReplacements.get(name)); else return new ConnModelBase(r); @@ -160,12 +161,11 @@ public Collection getTextures() try { List ret = new ArrayList<>(ModelLoaderRegistry.getModel(base).getTextures()); - for (String tex:texReplace.values()) + for(String tex : texReplace.values()) ret.add(new ResourceLocation(tex)); - ret.add(new ResourceLocation(ImmersiveEngineering.MODID.toLowerCase(Locale.ENGLISH) + ":blocks/wire")); + ret.add(new ResourceLocation(ImmersiveEngineering.MODID.toLowerCase(Locale.ENGLISH)+":blocks/wire")); return ret; - } - catch (Exception e) + } catch(Exception e) { throw new RuntimeException(e); } @@ -178,15 +178,14 @@ public IBakedModel bake(@Nonnull IModelState state, @Nonnull VertexFormat format try { IModel model = ModelLoaderRegistry.getModel(base); - if (model instanceof OBJModel) + if(model instanceof OBJModel) { model = model.retexture(texReplace); - OBJModel obj = (OBJModel) model; + OBJModel obj = (OBJModel)model; model = obj.process(ImmutableMap.of("flip-v", "true")); } return new ConnModelReal(model.bake(state, format, bakedTextureGetter)); - } - catch (Exception e) + } catch(Exception e) { throw new RuntimeException(e); } diff --git a/src/main/java/blusunrize/immersiveengineering/client/models/smart/ConnModelReal.java b/src/main/java/blusunrize/immersiveengineering/client/models/smart/ConnModelReal.java index 93486b275c..e2e8aa6648 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/models/smart/ConnModelReal.java +++ b/src/main/java/blusunrize/immersiveengineering/client/models/smart/ConnModelReal.java @@ -46,7 +46,7 @@ public class ConnModelReal implements IBakedModel { TextureAtlasSprite textureAtlasSprite = Minecraft.getMinecraft().getTextureMapBlocks() - .getAtlasSprite(ImmersiveEngineering.MODID.toLowerCase(Locale.ENGLISH) + ":blocks/wire"); + .getAtlasSprite(ImmersiveEngineering.MODID.toLowerCase(Locale.ENGLISH)+":blocks/wire"); public static final Cache, IBakedModel> cache = CacheBuilder.newBuilder() .expireAfterAccess(2, TimeUnit.MINUTES) .maximumSize(100) @@ -63,19 +63,19 @@ public List getQuads(@Nullable IBlockState state, @Nullable EnumFacin { if(side==null&&state instanceof IExtendedBlockState) { - IExtendedBlockState ext = (IExtendedBlockState) state; + IExtendedBlockState ext = (IExtendedBlockState)state; Object[] additional = null; - if (ext.getUnlistedProperties().containsKey(IEProperties.TILEENTITY_PASSTHROUGH)) + if(ext.getUnlistedProperties().containsKey(IEProperties.TILEENTITY_PASSTHROUGH)) { TileEntity te = ext.getValue(IEProperties.TILEENTITY_PASSTHROUGH); - if (te instanceof IEBlockInterfaces.ICacheData) - additional = ((IEBlockInterfaces.ICacheData) te).getCacheData(); + if(te instanceof IEBlockInterfaces.ICacheData) + additional = ((IEBlockInterfaces.ICacheData)te).getCacheData(); } int x = 0, z = 0; - if (ext.getUnlistedProperties().containsKey(IEProperties.CONNECTIONS)) + if(ext.getUnlistedProperties().containsKey(IEProperties.CONNECTIONS)) { Set conns = ext.getValue(IEProperties.CONNECTIONS); - if (conns!=null&&conns.size()>0) + if(conns!=null&&conns.size() > 0) { BlockPos tmp = conns.iterator().next().start; x = (tmp.getX()%16+16)%16; @@ -86,10 +86,9 @@ public List getQuads(@Nullable IBlockState state, @Nullable EnumFacin Pair key = new ImmutablePair<>((byte)((x<<4)|z), ad); try { - IBakedModel ret = cache.get(key, ()->new AssembledBakedModel(ext, textureAtlasSprite, base, rand)); + IBakedModel ret = cache.get(key, () -> new AssembledBakedModel(ext, textureAtlasSprite, base, rand)); return ret.getQuads(state, null, rand); - } - catch (ExecutionException e) + } catch(ExecutionException e) { e.printStackTrace(); } @@ -151,11 +150,11 @@ public AssembledBakedModel(IExtendedBlockState iExtendedBlockState, TextureAtlas public List getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) { BlockRenderLayer layer = MinecraftForgeClient.getRenderLayer(); - if (layer != BlockRenderLayer.SOLID&&layer!=BlockRenderLayer.TRANSLUCENT) + if(layer!=BlockRenderLayer.SOLID&&layer!=BlockRenderLayer.TRANSLUCENT) return basic.getQuads(state, side, rand); if(lists==null) lists = ClientUtils.convertConnectionFromBlockstate(extendedState, texture); - List l = new ArrayList<>(lists[layer==BlockRenderLayer.SOLID?0:1]); + List l = new ArrayList<>(lists[layer==BlockRenderLayer.SOLID?0: 1]); l.addAll(basic.getQuads(state, side, rand)); return Collections.synchronizedList(l); } @@ -208,32 +207,33 @@ public static class ExtBlockstateAdapter final String extraCacheKey; final Set ignoredProperties; Object[] additionalProperties = null; + public ExtBlockstateAdapter(IExtendedBlockState s, BlockRenderLayer l, Set ignored) { state = s; layer = l; ignoredProperties = ignored; - if (s.getUnlistedNames().contains(IOBJModelCallback.PROPERTY)) + if(s.getUnlistedNames().contains(IOBJModelCallback.PROPERTY)) { IOBJModelCallback callback = s.getValue(IOBJModelCallback.PROPERTY); - if (callback!=null) + if(callback!=null) extraCacheKey = callback.getClass()+";"+callback.getCacheKey(state); else extraCacheKey = null; } else extraCacheKey = null; - if (Config.IEConfig.enableDebug) + if(Config.IEConfig.enableDebug) { //Debug code for #2887 - if (!this.equals(this)||this.hashCode()!=this.hashCode()) + if(!this.equals(this)||this.hashCode()!=this.hashCode()) { String debug = "Basic state:\n"; debug += toStringDebug(state); debug += "Layer: "+layer+"\n"; debug += "Cache key: "+extraCacheKey+"\nAdditional:\n"; debug += "Ignored:\n"; - for (Object o:ignoredProperties) + for(Object o : ignoredProperties) debug += toStringDebug(o); throw new IllegalStateException(debug); } @@ -242,40 +242,41 @@ public ExtBlockstateAdapter(IExtendedBlockState s, BlockRenderLayer l, Set o) { - if (o==null) + if(o==null) return "PROPERTY WAS NULL"; return o.getClass()+": listed, Type: "+o.getValueClass()+", Name: "+o.getName(); } private String toStringProp(IUnlistedProperty o) { - if (o==null) + if(o==null) return "PROPERTY WAS NULL"; return o.getClass()+": unlisted, Type: "+o.getType()+", Name: "+o.getName(); } - private String toStringDebug(Object o) { - if (o==null) + private String toStringDebug(Object o) + { + if(o==null) return "NULL"; - if (o instanceof IBlockState) + if(o instanceof IBlockState) { String ret = ""; - for (IProperty p:((IBlockState) o).getPropertyKeys()) + for(IProperty p : ((IBlockState)o).getPropertyKeys()) { - ret += toStringProp(p)+" has value "+toStringDebug(((IBlockState) o).getValue(p))+"\n"; + ret += toStringProp(p)+" has value "+toStringDebug(((IBlockState)o).getValue(p))+"\n"; } - if (o instanceof IExtendedBlockState) + if(o instanceof IExtendedBlockState) { - for (Map.Entry, Optional> p:((IExtendedBlockState) o).getUnlistedProperties().entrySet()) + for(Map.Entry, Optional> p : ((IExtendedBlockState)o).getUnlistedProperties().entrySet()) { ret += toStringProp(p.getKey())+" has value "+toStringDebug(p.getValue().orElse(null))+"\n"; } } return ret; } - if (o instanceof IUnlistedProperty) + if(o instanceof IUnlistedProperty) return toStringProp((IUnlistedProperty)o); - if (o instanceof IProperty) + if(o instanceof IProperty) return toStringProp((IProperty)o); return o.getClass()+": "+o; } @@ -284,20 +285,20 @@ public ExtBlockstateAdapter(IExtendedBlockState s, BlockRenderLayer l, Set getDependencies() { - return INFOS.values().stream().map((i)->i.modelLoc).collect(Collectors.toCollection(ArrayList::new)); + return INFOS.values().stream().map((i) -> i.modelLoc).collect(Collectors.toCollection(ArrayList::new)); } @Nonnull diff --git a/src/main/java/blusunrize/immersiveengineering/client/models/smart/FeedthroughModel.java b/src/main/java/blusunrize/immersiveengineering/client/models/smart/FeedthroughModel.java index 37750d1a48..55c523efda 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/models/smart/FeedthroughModel.java +++ b/src/main/java/blusunrize/immersiveengineering/client/models/smart/FeedthroughModel.java @@ -66,12 +66,13 @@ public class FeedthroughModel implements IBakedModel .expireAfterAccess(2, TimeUnit.MINUTES) .maximumSize(100) .build(); + public FeedthroughModel() { //TODO find a better place to put this Function bakedTextureGetter = (rl) -> Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(rl.toString()); - for (WireApi.FeedthroughModelInfo f : INFOS.values()) + for(WireApi.FeedthroughModelInfo f : INFOS.values()) f.onResourceReload(bakedTextureGetter, DefaultVertexFormats.ITEM); } @@ -86,15 +87,15 @@ public List getQuads(@Nullable IBlockState state, @Nullable EnumFacin int offset = 1; BlockPos p = null; World w = null; - if (state instanceof IExtendedBlockState) + if(state instanceof IExtendedBlockState) { - TileEntity te = ((IExtendedBlockState) state).getValue(IEProperties.TILEENTITY_PASSTHROUGH); - if (te instanceof TileEntityFeedthrough) + TileEntity te = ((IExtendedBlockState)state).getValue(IEProperties.TILEENTITY_PASSTHROUGH); + if(te instanceof TileEntityFeedthrough) { - baseState = ((TileEntityFeedthrough) te).stateForMiddle; - wire = ((TileEntityFeedthrough) te).reference; - facing = ((TileEntityFeedthrough) te).getFacing(); - offset = ((TileEntityFeedthrough) te).offset; + baseState = ((TileEntityFeedthrough)te).stateForMiddle; + wire = ((TileEntityFeedthrough)te).reference; + facing = ((TileEntityFeedthrough)te).getFacing(); + offset = ((TileEntityFeedthrough)te).offset; p = te.getPos(); w = te.getWorld(); } @@ -105,9 +106,8 @@ public List getQuads(@Nullable IBlockState state, @Nullable EnumFacin try { return CACHE.get(key, - ()->new SpecificFeedthroughModel(key, wFinal, pFinal)).getQuads(state, side, rand); - } - catch (ExecutionException e) + () -> new SpecificFeedthroughModel(key, wFinal, pFinal)).getQuads(state, side, rand); + } catch(ExecutionException e) { e.printStackTrace(); return ImmutableList.of(); @@ -148,6 +148,7 @@ public TextureAtlasSprite getParticleTexture() new ItemTransformVec3f(new Vector3f(30, 225, 0), new Vector3f(0, 0, 0), new Vector3f(.6F, .6F, .6F)),//GUI new ItemTransformVec3f(new Vector3f(), new Vector3f(0, .3F, 0), new Vector3f(.25F, .25F, .25F)),//Ground new ItemTransformVec3f(new Vector3f(0, 180, 45), new Vector3f(0, 0, -.1875F), new Vector3f(.5F, .5F, .5F))); + @Nonnull @Override public ItemCameraTransforms getItemCameraTransforms() @@ -163,6 +164,7 @@ public ItemOverrideList getOverrides() { return INSTANCE; } + private static class FeedthroughItemOverride extends ItemOverrideList { @@ -182,14 +184,13 @@ public FeedthroughItemOverride() public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) { Item connItem = Item.getItemFromBlock(IEContent.blockConnectors); - if (stack != null && stack.getItem() == connItem && stack.getMetadata() == BlockTypes_Connector.FEEDTHROUGH.ordinal()) + if(stack!=null&&stack.getItem()==connItem&&stack.getMetadata()==BlockTypes_Connector.FEEDTHROUGH.ordinal()) { try { return ITEM_MODEL_CACHE.get(stack, () -> new SpecificFeedthroughModel(stack)); - } - catch (ExecutionException e) + } catch(ExecutionException e) { e.printStackTrace(); } @@ -220,13 +221,13 @@ public FeedthroughCacheKey(WireType type, IBlockState baseState, int offset, Enu @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - FeedthroughCacheKey that = (FeedthroughCacheKey) o; - return offset == that.offset && - Objects.equals(type, that.type) && - Utils.areStatesEqual(baseState, that.baseState, ImmutableSet.of(), false) && - facing == that.facing && + if(this==o) return true; + if(o==null||getClass()!=o.getClass()) return false; + FeedthroughCacheKey that = (FeedthroughCacheKey)o; + return offset==that.offset&& + Objects.equals(type, that.type)&& + Utils.areStatesEqual(baseState, that.baseState, ImmutableSet.of(), false)&& + facing==that.facing&& Objects.equals(layer, that.layer); } @@ -237,6 +238,7 @@ public int hashCode() return 31*ret+Objects.hash(type, offset, facing, layer); } } + private static class SpecificFeedthroughModel extends FeedthroughModel { private static final float[] WHITE = {1, 1, 1, 1}; @@ -245,6 +247,7 @@ private static class SpecificFeedthroughModel extends FeedthroughModel new Vector3f(.25F, .001F, .25F), new Vector3f(.25F, .001F, .75F) }; List> quads = new ArrayList<>(6); + public SpecificFeedthroughModel(ItemStack stack) { WireType w = WireType.getValue(ItemNBTHelper.getString(stack, WIRE)); @@ -262,25 +265,25 @@ private void init(FeedthroughCacheKey k, @Nullable World world, @Nullable BlockP IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes() .getModelForState(k.baseState); Function colorMultiplier = null; - if (world!=null&&pos!=null) + if(world!=null&&pos!=null) { BlockColors colors = Minecraft.getMinecraft().getBlockColors(); - colorMultiplier = (i)->colors.colorMultiplier(k.baseState, world, pos, i); + colorMultiplier = (i) -> colors.colorMultiplier(k.baseState, world, pos, i); } else { ItemColors colors = Minecraft.getMinecraft().getItemColors(); ItemStack stack = new ItemStack(k.baseState.getBlock(), 1, k.baseState.getBlock().getMetaFromState(k.baseState)); - colorMultiplier = (i)->colors.colorMultiplier(stack, i); + colorMultiplier = (i) -> colors.colorMultiplier(stack, i); } - for (int j = 0; j < 7; j++) + for(int j = 0; j < 7; j++) { - EnumFacing side = j<6?EnumFacing.VALUES[j]:null; + EnumFacing side = j < 6?EnumFacing.VALUES[j]: null; EnumFacing facing = k.facing; - switch (k.offset) + switch(k.offset) { case 0: - if (k.layer==null||k.baseState.getBlock().canRenderInLayer(k.baseState, k.layer)) + if(k.layer==null||k.baseState.getBlock().canRenderInLayer(k.baseState, k.layer)) { Function tintTransformer = ApiUtils.transformQuad(new Matrix4(), DefaultVertexFormats.ITEM, colorMultiplier); @@ -291,7 +294,7 @@ private void init(FeedthroughCacheKey k, @Nullable World world, @Nullable BlockP case 1: facing = facing.getOpposite(); case -1: - if (k.layer==BlockRenderLayer.SOLID) + if(k.layer==BlockRenderLayer.SOLID) quads.add(getConnQuads(facing, side, k.type, new Matrix4())); break; case Integer.MAX_VALUE: @@ -308,7 +311,7 @@ private void init(FeedthroughCacheKey k, @Nullable World world, @Nullable BlockP quads.add(all); break; } - if (quads.size()<=j) + if(quads.size() <= j) quads.add(ImmutableList.of()); } } @@ -318,24 +321,24 @@ private List getConnQuads(EnumFacing facing, EnumFacing side, WireTyp //connector model+feedthrough border WireApi.FeedthroughModelInfo info = INFOS.get(type); mat.translate(.5, .5, .5); - if (facing.getAxis() == Y) + if(facing.getAxis()==Y) { - if (facing == EnumFacing.UP) + if(facing==EnumFacing.UP) mat.rotate(Math.PI, 1, 0, 0); } else { EnumFacing rotateAround = facing.rotateAround(Y); - mat.rotate(Math.PI / 2, rotateAround.getFrontOffsetX(), rotateAround.getFrontOffsetY(), + mat.rotate(Math.PI/2, rotateAround.getFrontOffsetX(), rotateAround.getFrontOffsetY(), rotateAround.getFrontOffsetZ()); } mat.translate(-.5, -.5, -.5); List conn = new ArrayList<>(info.model.getQuads(null, side, 0)); - if (side == facing) + if(side==facing) conn.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, vertices, facing, info.tex, info.uvs, WHITE, false)); Function transf = ApiUtils.transformQuad(mat, DefaultVertexFormats.ITEM, null);//I hope no one uses tint index for connectors - if (transf != null) + if(transf!=null) return conn.stream().map(transf).collect(Collectors.toList()); else return conn; @@ -345,7 +348,7 @@ private List getConnQuads(EnumFacing facing, EnumFacing side, WireTyp @Override public List getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) { - return quads.get(side==null?6:side.getIndex()); + return quads.get(side==null?6: side.getIndex()); } } } diff --git a/src/main/java/blusunrize/immersiveengineering/client/render/BakedModelTransformer.java b/src/main/java/blusunrize/immersiveengineering/client/render/BakedModelTransformer.java index 0add0edf9a..f03c91ad41 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/render/BakedModelTransformer.java +++ b/src/main/java/blusunrize/immersiveengineering/client/render/BakedModelTransformer.java @@ -30,7 +30,7 @@ /** * @author amadornes - * Blatantly stolen from Ama, since his stuff is good =3 + * Blatantly stolen from Ama, since his stuff is good =3 */ public class BakedModelTransformer { @@ -45,7 +45,7 @@ public static IBakedModel transform(IBakedModel model, IVertexTransformer transf for(int i = 0; i < quads.length; i++) { quads[i] = new ArrayList(); - for(BakedQuad quad : model.getQuads(state, (i == 6 ? null : EnumFacing.getFront(i)), rand)) + for(BakedQuad quad : model.getQuads(state, (i==6?null: EnumFacing.getFront(i)), rand)) quads[i].add(transform(quad, transformer, formatRemapper)); } return new TransformedModel(model, quads); @@ -84,12 +84,12 @@ private static BakedQuad transform(BakedQuad quad, IVertexTransformer transforme static float[][][] getUnpackedData(UnpackedBakedQuad unpackedQuad) throws Exception { - if(f_unpackedData == null) + if(f_unpackedData==null) { f_unpackedData = ReflectionHelper.findField(UnpackedBakedQuad.class, "unpackedData"); f_unpackedData.setAccessible(true); } - return (float[][][]) f_unpackedData.get(unpackedQuad); + return (float[][][])f_unpackedData.get(unpackedQuad); } private static final class TransformedModel implements IBakedModel @@ -106,7 +106,7 @@ public TransformedModel(IBakedModel parent, List[] quads) @Override public List getQuads(IBlockState state, EnumFacing side, long rand) { - return quads[side == null ? 6 : side.ordinal()]; + return quads[side==null?6: side.ordinal()]; } @Override diff --git a/src/main/java/blusunrize/immersiveengineering/client/render/EntityRenderChemthrowerShot.java b/src/main/java/blusunrize/immersiveengineering/client/render/EntityRenderChemthrowerShot.java index aae4130966..5d3294c163 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/render/EntityRenderChemthrowerShot.java +++ b/src/main/java/blusunrize/immersiveengineering/client/render/EntityRenderChemthrowerShot.java @@ -50,28 +50,28 @@ public void doRender(Entity entity, double x, double y, double z, float f0, floa Tessellator tessellator = ClientUtils.tes(); - GlStateManager.rotate(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + GlStateManager.rotate(180.0F-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); TextureAtlasSprite sprite = ClientUtils.mc().getTextureMapBlocks().getAtlasSprite(f.getFluid().getStill(f).toString()); if(sprite!=null) { int colour = f.getFluid().getColor(f); - float a = (colour>>24&255)/255f; - float r = (colour>>16&255)/255f; - float g = (colour>>8&255)/255f; + float a = (colour >> 24&255)/255f; + float r = (colour >> 16&255)/255f; + float g = (colour >> 8&255)/255f; float b = (colour&255)/255f; ClientUtils.bindAtlas(); int lightAll = entity.getBrightnessForRender(); - int lightA = (lightAll>>0x10)&0xffff; + int lightA = (lightAll >> 0x10)&0xffff; int lightB = lightAll&0xffff; GlStateManager.scale(.25f, .25f, .25f); BufferBuilder worldrenderer = ClientUtils.tes().getBuffer(); worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR); - worldrenderer.pos(-.25,-.25, 0).tex(sprite.getInterpolatedU(4), sprite.getInterpolatedV(4)).lightmap(lightA, lightB).color(r,g,b,a).endVertex(); - worldrenderer.pos( .25,-.25, 0).tex(sprite.getInterpolatedU(0), sprite.getInterpolatedV(4)).lightmap(lightA, lightB).color(r,g,b,a).endVertex(); - worldrenderer.pos( .25, .25, 0).tex(sprite.getInterpolatedU(0), sprite.getInterpolatedV(0)).lightmap(lightA, lightB).color(r,g,b,a).endVertex(); - worldrenderer.pos(-.25, .25, 0).tex(sprite.getInterpolatedU(4), sprite.getInterpolatedV(0)).lightmap(lightA, lightB).color(r,g,b,a).endVertex(); + worldrenderer.pos(-.25, -.25, 0).tex(sprite.getInterpolatedU(4), sprite.getInterpolatedV(4)).lightmap(lightA, lightB).color(r, g, b, a).endVertex(); + worldrenderer.pos(.25, -.25, 0).tex(sprite.getInterpolatedU(0), sprite.getInterpolatedV(4)).lightmap(lightA, lightB).color(r, g, b, a).endVertex(); + worldrenderer.pos(.25, .25, 0).tex(sprite.getInterpolatedU(0), sprite.getInterpolatedV(0)).lightmap(lightA, lightB).color(r, g, b, a).endVertex(); + worldrenderer.pos(-.25, .25, 0).tex(sprite.getInterpolatedU(4), sprite.getInterpolatedV(0)).lightmap(lightA, lightB).color(r, g, b, a).endVertex(); tessellator.draw(); } RenderHelper.enableStandardItemLighting(); diff --git a/src/main/java/blusunrize/immersiveengineering/client/render/EntityRenderFluorescentTube.java b/src/main/java/blusunrize/immersiveengineering/client/render/EntityRenderFluorescentTube.java index 857fc34de8..a25b8610fe 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/render/EntityRenderFluorescentTube.java +++ b/src/main/java/blusunrize/immersiveengineering/client/render/EntityRenderFluorescentTube.java @@ -33,11 +33,12 @@ public class EntityRenderFluorescentTube extends Render static double sqrt2Half = Math.sqrt(2)/2; public static final double[][] octagon = { {1, 0}, {sqrt2Half, sqrt2Half}, {0, 1}, {-sqrt2Half, sqrt2Half}, - {-1, 0}, {-sqrt2Half, -sqrt2Half}, {0, -1}, {sqrt2Half, -sqrt2Half} + {-1, 0}, {-sqrt2Half, -sqrt2Half}, {0, -1}, {sqrt2Half, -sqrt2Half} }; private static Random r = new Random(); ResourceLocation modelLocation = new ResourceLocation("immersiveengineering:fluorescent_tube.obj"); TextureAtlasSprite tex; + public EntityRenderFluorescentTube(RenderManager renderManager) { super(renderManager); @@ -50,9 +51,10 @@ protected ResourceLocation getEntityTexture(EntityFluorescentTube entity) { return null; } + @Override public void doRender(EntityFluorescentTube entity, double x, double y, double z, float entityYaw, - float partialTicks) + float partialTicks) { Tessellator tes = Tessellator.getInstance(); BufferBuilder wr = tes.getBuffer(); @@ -68,7 +70,7 @@ public void doRender(EntityFluorescentTube entity, double x, double y, double z, GlStateManager.popMatrix(); GlStateManager.translate(-0.25, -1, 0); GlStateManager.color(1, 1, 1); - if (tex==null) + if(tex==null) tex = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/iron_block"); wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); @@ -84,15 +86,15 @@ public void doRender(EntityFluorescentTube entity, double x, double y, double z, static void drawTube(boolean active, float[] rgb, double length, BufferBuilder wr, Tessellator tes) { - if (tube.isEmpty()) + if(tube.isEmpty()) tube = new ItemStack(IEContent.itemFluorescentTube); - if (tubeActive.isEmpty()) + if(tubeActive.isEmpty()) { tubeActive = new ItemStack(IEContent.itemFluorescentTube); ItemFluorescentTube.setLit(tubeActive, 1); } GlStateManager.translate(-.5, .25, -.5); - ItemStack renderStack = active?tubeActive:tube; + ItemStack renderStack = active?tubeActive: tube; ItemFluorescentTube.setRGB(renderStack, rgb); ItemRendererIEOBJ.INSTANCE.renderByItem(renderStack, mc().getRenderPartialTicks()); } diff --git a/src/main/java/blusunrize/immersiveengineering/client/render/EntityRenderIEExplosive.java b/src/main/java/blusunrize/immersiveengineering/client/render/EntityRenderIEExplosive.java index f0e3c1313b..3908c36254 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/render/EntityRenderIEExplosive.java +++ b/src/main/java/blusunrize/immersiveengineering/client/render/EntityRenderIEExplosive.java @@ -31,51 +31,51 @@ public void doRender(EntityIEExplosive entity, double x, double y, double z, flo { if(entity.block==null) return; - BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher(); - GlStateManager.pushMatrix(); - GlStateManager.translate((float)x, (float)y + 0.5F, (float)z); + BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher(); + GlStateManager.pushMatrix(); + GlStateManager.translate((float)x, (float)y+0.5F, (float)z); - if(entity.getFuse()-partialTicks+1 < 10) - { - float f = 1.0F - ((float)entity.getFuse() - partialTicks + 1.0F) / 10.0F; - f = MathHelper.clamp(f, 0.0F, 1.0F); - f = f * f; - f = f * f; - float f1 = 1.0F + f * 0.3F; - GlStateManager.scale(f1, f1, f1); - } - - float f2 = (1-(entity.getFuse()-partialTicks+1)/100F) * .8F; - this.bindEntityTexture(entity); - GlStateManager.translate(-0.5F, -0.5F, 0.5F); - blockrendererdispatcher.renderBlockBrightness(entity.block, entity.getBrightness()); - GlStateManager.translate(0.0F, 0.0F, 1.0F); + if(entity.getFuse()-partialTicks+1 < 10) + { + float f = 1.0F-((float)entity.getFuse()-partialTicks+1.0F)/10.0F; + f = MathHelper.clamp(f, 0.0F, 1.0F); + f = f*f; + f = f*f; + float f1 = 1.0F+f*0.3F; + GlStateManager.scale(f1, f1, f1); + } - if(entity.getFuse()/5%2 == 0) - { - GlStateManager.disableTexture2D(); - GlStateManager.disableLighting(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(770, 772); - GlStateManager.color(1.0F, 1.0F, 1.0F, f2); - GlStateManager.doPolygonOffset(-3.0F, -3.0F); - GlStateManager.enablePolygonOffset(); - blockrendererdispatcher.renderBlockBrightness(entity.block, 1.0F); - GlStateManager.doPolygonOffset(0.0F, 0.0F); - GlStateManager.disablePolygonOffset(); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - GlStateManager.disableBlend(); - GlStateManager.enableLighting(); - GlStateManager.enableTexture2D(); - } + float f2 = (1-(entity.getFuse()-partialTicks+1)/100F)*.8F; + this.bindEntityTexture(entity); + GlStateManager.translate(-0.5F, -0.5F, 0.5F); + blockrendererdispatcher.renderBlockBrightness(entity.block, entity.getBrightness()); + GlStateManager.translate(0.0F, 0.0F, 1.0F); - GlStateManager.popMatrix(); - super.doRender(entity, x, y, z, entityYaw, partialTicks); + if(entity.getFuse()/5%2==0) + { + GlStateManager.disableTexture2D(); + GlStateManager.disableLighting(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(770, 772); + GlStateManager.color(1.0F, 1.0F, 1.0F, f2); + GlStateManager.doPolygonOffset(-3.0F, -3.0F); + GlStateManager.enablePolygonOffset(); + blockrendererdispatcher.renderBlockBrightness(entity.block, 1.0F); + GlStateManager.doPolygonOffset(0.0F, 0.0F); + GlStateManager.disablePolygonOffset(); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.disableBlend(); + GlStateManager.enableLighting(); + GlStateManager.enableTexture2D(); + } + + GlStateManager.popMatrix(); + super.doRender(entity, x, y, z, entityYaw, partialTicks); } @Override - protected ResourceLocation getEntityTexture(EntityIEExplosive entity) - { - return TextureMap.LOCATION_BLOCKS_TEXTURE; - } + protected ResourceLocation getEntityTexture(EntityIEExplosive entity) + { + return TextureMap.LOCATION_BLOCKS_TEXTURE; + } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/client/render/EntityRenderRailgunShot.java b/src/main/java/blusunrize/immersiveengineering/client/render/EntityRenderRailgunShot.java index 275a331b1e..cf78e0342d 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/render/EntityRenderRailgunShot.java +++ b/src/main/java/blusunrize/immersiveengineering/client/render/EntityRenderRailgunShot.java @@ -33,18 +33,18 @@ public EntityRenderRailgunShot(RenderManager renderManager) @Override public void doRender(Entity entity, double x, double y, double z, float f0, float f1) { - double yaw = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * f1 - 90.0F; - double pitch = entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * f1; + double yaw = entity.prevRotationYaw+(entity.rotationYaw-entity.prevRotationYaw)*f1-90.0F; + double pitch = entity.prevRotationPitch+(entity.rotationPitch-entity.prevRotationPitch)*f1; ItemStack ammo = ((EntityRailgunShot)entity).getAmmo(); - int[][] colourMap = {{0x777777,0xa4a4a4}}; + int[][] colourMap = {{0x777777, 0xa4a4a4}}; if(!ammo.isEmpty()) { RailgunHandler.RailgunProjectileProperties prop = RailgunHandler.getProjectileProperties(ammo); - colourMap = prop!=null?prop.colourMap:colourMap; + colourMap = prop!=null?prop.colourMap: colourMap; } - - renderRailgunProjectile(x,y,z, yaw, pitch, colourMap); + + renderRailgunProjectile(x, y, z, yaw, pitch, colourMap); } public static void renderRailgunProjectile(double x, double y, double z, double yaw, double pitch, int[][] colourMap) @@ -68,79 +68,79 @@ public static void renderRailgunProjectile(double x, double y, double z, double if(colourMap.length==1) { - colourMap = new int[][]{colourMap[0],colourMap[0]}; + colourMap = new int[][]{colourMap[0], colourMap[0]}; } float height = .1875f; float halfWidth = height/2; float length = 2; int colWidth = colourMap[0].length; - for(int i=0; i>16)&255; - colG = (colourMap[0][i]>>8)&255; + colR = (colourMap[0][i] >> 16)&255; + colG = (colourMap[0][i] >> 8)&255; colB = colourMap[0][i]&255; - worldrenderer.pos(0,height,-halfWidth+widthStep*i).color(colR,colG,colB,255).endVertex(); - worldrenderer.pos(0,0 ,-halfWidth+widthStep*i).color(colR,colG,colB,255).endVertex(); - worldrenderer.pos(0,0 ,-halfWidth+widthStep*(i+1)).color(colR,colG,colB,255).endVertex(); - worldrenderer.pos(0,height,-halfWidth+widthStep*(i+1)).color(colR,colG,colB,255).endVertex(); + worldrenderer.pos(0, height, -halfWidth+widthStep*i).color(colR, colG, colB, 255).endVertex(); + worldrenderer.pos(0, 0, -halfWidth+widthStep*i).color(colR, colG, colB, 255).endVertex(); + worldrenderer.pos(0, 0, -halfWidth+widthStep*(i+1)).color(colR, colG, colB, 255).endVertex(); + worldrenderer.pos(0, height, -halfWidth+widthStep*(i+1)).color(colR, colG, colB, 255).endVertex(); - colR = colourMap[colLength-1][i]>>16&255; - colG = colourMap[colLength-1][i]>>8&255; + colR = colourMap[colLength-1][i] >> 16&255; + colG = colourMap[colLength-1][i] >> 8&255; colB = colourMap[colLength-1][i]&255; - worldrenderer.pos(length,0 ,-halfWidth+widthStep*i).color(colR,colG,colB,255).endVertex(); - worldrenderer.pos(length,height,-halfWidth+widthStep*i).color(colR,colG,colB,255).endVertex(); - worldrenderer.pos(length,height,-halfWidth+widthStep*(i+1)).color(colR,colG,colB,255).endVertex(); - worldrenderer.pos(length,0 ,-halfWidth+widthStep*(i+1)).color(colR,colG,colB,255).endVertex(); + worldrenderer.pos(length, 0, -halfWidth+widthStep*i).color(colR, colG, colB, 255).endVertex(); + worldrenderer.pos(length, height, -halfWidth+widthStep*i).color(colR, colG, colB, 255).endVertex(); + worldrenderer.pos(length, height, -halfWidth+widthStep*(i+1)).color(colR, colG, colB, 255).endVertex(); + worldrenderer.pos(length, 0, -halfWidth+widthStep*(i+1)).color(colR, colG, colB, 255).endVertex(); } //Sides - for(int i=0; i>16&255; - colG = colourMap[i][0]>>8&255; + colR = colourMap[i][0] >> 16&255; + colG = colourMap[i][0] >> 8&255; colB = colourMap[i][0]&255; - worldrenderer.pos(lengthStep*i ,0 ,-halfWidth).color(colR,colG,colB,255).endVertex(); - worldrenderer.pos(lengthStep*i ,height,-halfWidth).color(colR,colG,colB,255).endVertex(); - worldrenderer.pos(lengthStep*(i+1),height,-halfWidth).color(colR,colG,colB,255).endVertex(); - worldrenderer.pos(lengthStep*(i+1),0 ,-halfWidth).color(colR,colG,colB,255).endVertex(); + worldrenderer.pos(lengthStep*i, 0, -halfWidth).color(colR, colG, colB, 255).endVertex(); + worldrenderer.pos(lengthStep*i, height, -halfWidth).color(colR, colG, colB, 255).endVertex(); + worldrenderer.pos(lengthStep*(i+1), height, -halfWidth).color(colR, colG, colB, 255).endVertex(); + worldrenderer.pos(lengthStep*(i+1), 0, -halfWidth).color(colR, colG, colB, 255).endVertex(); - colR = colourMap[i][colWidth-1]>>16&255; - colG = colourMap[i][colWidth-1]>>8&255; + colR = colourMap[i][colWidth-1] >> 16&255; + colG = colourMap[i][colWidth-1] >> 8&255; colB = colourMap[i][colWidth-1]&255; - worldrenderer.pos(lengthStep*i ,height,halfWidth).color(colR,colG,colB,255).endVertex(); - worldrenderer.pos(lengthStep*i ,0 ,halfWidth).color(colR,colG,colB,255).endVertex(); - worldrenderer.pos(lengthStep*(i+1),0 ,halfWidth).color(colR,colG,colB,255).endVertex(); - worldrenderer.pos(lengthStep*(i+1),height,halfWidth).color(colR,colG,colB,255).endVertex(); + worldrenderer.pos(lengthStep*i, height, halfWidth).color(colR, colG, colB, 255).endVertex(); + worldrenderer.pos(lengthStep*i, 0, halfWidth).color(colR, colG, colB, 255).endVertex(); + worldrenderer.pos(lengthStep*(i+1), 0, halfWidth).color(colR, colG, colB, 255).endVertex(); + worldrenderer.pos(lengthStep*(i+1), height, halfWidth).color(colR, colG, colB, 255).endVertex(); } //Top&Bottom - for(int i=0; i>16&255; - colG = colourMap[i][j]>>8&255; + colR = colourMap[i][j] >> 16&255; + colG = colourMap[i][j] >> 8&255; colB = colourMap[i][j]&255; - worldrenderer.pos(lengthStep*(i+1),height,-halfWidth+widthStep*j).color(colR,colG,colB,255).endVertex(); - worldrenderer.pos(lengthStep*i ,height,-halfWidth+widthStep*j).color(colR,colG,colB,255).endVertex(); - worldrenderer.pos(lengthStep*i ,height,-halfWidth+widthStep*(j+1)).color(colR,colG,colB,255).endVertex(); - worldrenderer.pos(lengthStep*(i+1),height,-halfWidth+widthStep*(j+1)).color(colR,colG,colB,255).endVertex(); - - worldrenderer.pos(lengthStep*i ,0 ,-halfWidth+widthStep*j).color(colR,colG,colB,255).endVertex(); - worldrenderer.pos(lengthStep*(i+1),0 ,-halfWidth+widthStep*j).color(colR,colG,colB,255).endVertex(); - worldrenderer.pos(lengthStep*(i+1),0 ,-halfWidth+widthStep*(j+1)).color(colR,colG,colB,255).endVertex(); - worldrenderer.pos(lengthStep*i ,0 ,-halfWidth+widthStep*(j+1)).color(colR,colG,colB,255).endVertex(); + worldrenderer.pos(lengthStep*(i+1), height, -halfWidth+widthStep*j).color(colR, colG, colB, 255).endVertex(); + worldrenderer.pos(lengthStep*i, height, -halfWidth+widthStep*j).color(colR, colG, colB, 255).endVertex(); + worldrenderer.pos(lengthStep*i, height, -halfWidth+widthStep*(j+1)).color(colR, colG, colB, 255).endVertex(); + worldrenderer.pos(lengthStep*(i+1), height, -halfWidth+widthStep*(j+1)).color(colR, colG, colB, 255).endVertex(); + + worldrenderer.pos(lengthStep*i, 0, -halfWidth+widthStep*j).color(colR, colG, colB, 255).endVertex(); + worldrenderer.pos(lengthStep*(i+1), 0, -halfWidth+widthStep*j).color(colR, colG, colB, 255).endVertex(); + worldrenderer.pos(lengthStep*(i+1), 0, -halfWidth+widthStep*(j+1)).color(colR, colG, colB, 255).endVertex(); + worldrenderer.pos(lengthStep*i, 0, -halfWidth+widthStep*(j+1)).color(colR, colG, colB, 255).endVertex(); } tes.draw(); diff --git a/src/main/java/blusunrize/immersiveengineering/client/render/EntityRenderRevolvershot.java b/src/main/java/blusunrize/immersiveengineering/client/render/EntityRenderRevolvershot.java index 58dee06c2a..bba605b307 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/render/EntityRenderRevolvershot.java +++ b/src/main/java/blusunrize/immersiveengineering/client/render/EntityRenderRevolvershot.java @@ -48,8 +48,8 @@ public void doRender(Entity entity, double x, double y, double z, float f0, floa // GlStateManager.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); // GlStateManager.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); GlStateManager.disableCull(); - GlStateManager.rotate(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * f1 - 90.0F, 0.0F, 1.0F, 0.0F); - GlStateManager.rotate(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * f1, 0.0F, 0.0F, 1.0F); + GlStateManager.rotate(entity.prevRotationYaw+(entity.rotationYaw-entity.prevRotationYaw)*f1-90.0F, 0.0F, 1.0F, 0.0F); + GlStateManager.rotate(entity.prevRotationPitch+(entity.rotationPitch-entity.prevRotationPitch)*f1, 0.0F, 0.0F, 1.0F); // tessellator.startDrawingQuads(); // tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f8); @@ -68,26 +68,26 @@ public void doRender(Entity entity, double x, double y, double z, float f0, floa GlStateManager.scale(.25f, .25f, .25f); worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - worldrenderer.pos(0, .0,-.25).tex(5/32d, 10/32d).endVertex(); + worldrenderer.pos(0, .0, -.25).tex(5/32d, 10/32d).endVertex(); worldrenderer.pos(0, .0, .25).tex(0/32d, 10/32d).endVertex(); worldrenderer.pos(0, .5, .25).tex(0/32d, 5/32d).endVertex(); - worldrenderer.pos(0, .5,-.25).tex(5/32d, 5/32d).endVertex(); + worldrenderer.pos(0, .5, -.25).tex(5/32d, 5/32d).endVertex(); tessellator.draw(); worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - worldrenderer.pos(.375, .125,0).tex(8/32d, 5/32d).endVertex(); - worldrenderer.pos(0, .125,0).tex(0/32d, 5/32d).endVertex(); - worldrenderer.pos(0, .375,0).tex(0/32d, 0/32d).endVertex(); - worldrenderer.pos(.375, .375,0).tex(8/32d, 0/32d).endVertex(); + worldrenderer.pos(.375, .125, 0).tex(8/32d, 5/32d).endVertex(); + worldrenderer.pos(0, .125, 0).tex(0/32d, 5/32d).endVertex(); + worldrenderer.pos(0, .375, 0).tex(0/32d, 0/32d).endVertex(); + worldrenderer.pos(.375, .375, 0).tex(8/32d, 0/32d).endVertex(); tessellator.draw(); worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - worldrenderer.pos(.375, .25,-.25).tex(8/32d, 5/32d).endVertex(); - worldrenderer.pos(0, .25,-.25).tex(0/32d, 5/32d).endVertex(); - worldrenderer.pos(0, .25, .25).tex(0/32d, 0/32d).endVertex(); - worldrenderer.pos(.375, .25, .25).tex(8/32d, 0/32d).endVertex(); + worldrenderer.pos(.375, .25, -.25).tex(8/32d, 5/32d).endVertex(); + worldrenderer.pos(0, .25, -.25).tex(0/32d, 5/32d).endVertex(); + worldrenderer.pos(0, .25, .25).tex(0/32d, 0/32d).endVertex(); + worldrenderer.pos(.375, .25, .25).tex(8/32d, 0/32d).endVertex(); tessellator.draw(); - + GlStateManager.enableCull(); GlStateManager.disableRescaleNormal(); GlStateManager.popMatrix(); diff --git a/src/main/java/blusunrize/immersiveengineering/client/render/IEBipedLayerRenderer.java b/src/main/java/blusunrize/immersiveengineering/client/render/IEBipedLayerRenderer.java index a566fdb9af..2602813d4e 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/render/IEBipedLayerRenderer.java +++ b/src/main/java/blusunrize/immersiveengineering/client/render/IEBipedLayerRenderer.java @@ -40,7 +40,7 @@ public void doRenderLayer(EntityLivingBase living, float limbSwing, float prevLi // } // } - if(!living.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty() && ItemNBTHelper.hasKey(living.getItemStackFromSlot(EntityEquipmentSlot.HEAD), "IE:Earmuffs")) + if(!living.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty()&&ItemNBTHelper.hasKey(living.getItemStackFromSlot(EntityEquipmentSlot.HEAD), "IE:Earmuffs")) { ItemStack earmuffs = ItemNBTHelper.getItemStack(living.getItemStackFromSlot(EntityEquipmentSlot.HEAD), Lib.NBT_Earmuffs); if(!earmuffs.isEmpty()) @@ -50,14 +50,14 @@ public void doRenderLayer(EntityLivingBase living, float limbSwing, float prevLi ClientUtils.bindTexture(IEContent.itemEarmuffs.getArmorTexture(earmuffs, living, EntityEquipmentSlot.HEAD, "overlay")); model.render(living, limbSwing, prevLimbSwing, rotation, yaw, pitch, scale); int colour = ((IColouredItem)earmuffs.getItem()).getColourForIEItem(earmuffs, 0); - GlStateManager.color((colour >> 16 & 255) / 255f, (colour >> 8 & 255) / 255f, (colour & 255) / 255f); + GlStateManager.color((colour >> 16&255)/255f, (colour >> 8&255)/255f, (colour&255)/255f); ClientUtils.bindTexture(IEContent.itemEarmuffs.getArmorTexture(earmuffs, living, EntityEquipmentSlot.HEAD, null)); model.render(living, limbSwing, prevLimbSwing, rotation, yaw, pitch, scale); GlStateManager.popMatrix(); } } - if(!living.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty() && ItemNBTHelper.hasKey(living.getItemStackFromSlot(EntityEquipmentSlot.CHEST), "IE:Powerpack")) + if(!living.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty()&&ItemNBTHelper.hasKey(living.getItemStackFromSlot(EntityEquipmentSlot.CHEST), "IE:Powerpack")) { ItemStack powerpack = ItemNBTHelper.getItemStack(living.getItemStackFromSlot(EntityEquipmentSlot.CHEST), Lib.NBT_Powerpack); if(!powerpack.isEmpty()) diff --git a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderArcFurnace.java b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderArcFurnace.java index 26f641fd5a..2b60cef706 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderArcFurnace.java +++ b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderArcFurnace.java @@ -21,7 +21,6 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraftforge.client.model.obj.OBJModel.OBJState; import net.minecraftforge.common.property.IExtendedBlockState; @@ -35,13 +34,14 @@ public class TileRenderArcFurnace extends TileEntitySpecialRenderer renderedParts = null; - for(int i=0; i<3; i++) + for(int i = 0; i < 3; i++) if(!te.getInventory().get(23+i).isEmpty()) { if(renderedParts==null) @@ -53,11 +53,11 @@ public void render(TileEntityArcFurnace te, double x, double y, double z, float return; if(te.shouldRenderAsActive()) renderedParts.add("active"); - + final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher(); BlockPos blockPos = te.getPos(); IBlockState state = getWorld().getBlockState(blockPos); - if(state.getBlock() != IEContent.blockMetalMultiblock) + if(state.getBlock()!=IEContent.blockMetalMultiblock) return; state = state.getBlock().getActualState(state, getWorld(), blockPos); state = state.withProperty(IEProperties.DYNAMICRENDER, true); @@ -82,54 +82,55 @@ public void render(TileEntityArcFurnace te, double x, double y, double z, float else GlStateManager.shadeModel(7424); worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); - worldRenderer.setTranslation( -.5-blockPos.getX(), -.5- blockPos.getY(), -.5-blockPos.getZ()); + worldRenderer.setTranslation(-.5-blockPos.getX(), -.5-blockPos.getY(), -.5-blockPos.getZ()); worldRenderer.color(255, 255, 255, 255); blockRenderer.getBlockModelRenderer().renderModel(te.getWorld(), model, state, blockPos, worldRenderer, true); worldRenderer.setTranslation(0.0D, 0.0D, 0.0D); tessellator.draw(); RenderHelper.enableStandardItemLighting(); - if(te.pouringMetal>0) + if(te.pouringMetal > 0) { - if (hotMetal_flow==null) { + if(hotMetal_flow==null) + { hotMetal_still = ApiUtils.getRegisterSprite(ClientUtils.mc().getTextureMapBlocks(), "immersiveengineering:blocks/fluid/hot_metal_still"); hotMetal_flow = ApiUtils.getRegisterSprite(ClientUtils.mc().getTextureMapBlocks(), "immersiveengineering:blocks/fluid/hot_metal_flow"); } - GlStateManager.rotate(-te.facing.getHorizontalAngle()+180, 0,1,0); - int process= 40; + GlStateManager.rotate(-te.facing.getHorizontalAngle()+180, 0, 1, 0); + int process = 40; float speed = 5f; int pour = process-te.pouringMetal; Vector3f tmp = new Vector3f(); - float h = (pour>(process-speed)?((process-pour)/speed*27): pour>speed?27: (pour/speed*27))/16f; - GlStateManager.translate(-.5f,1.25-.6875f,1.5f); + float h = (pour > (process-speed)?((process-pour)/speed*27): pour > speed?27: (pour/speed*27))/16f; + GlStateManager.translate(-.5f, 1.25-.6875f, 1.5f); worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); GlStateManager.disableLighting(); setLightmapDisabled(true); - if(pour>(process-speed)) - addTranslation(tmp, worldRenderer, 0,-1.6875f+h,0); - if(h>1) + if(pour > (process-speed)) + addTranslation(tmp, worldRenderer, 0, -1.6875f+h, 0); + if(h > 1) { - addTranslation(tmp, worldRenderer, 0,-h,0); - ClientUtils.renderTexturedBox(worldRenderer, .375,0,.375, .625, 1,.625, hotMetal_flow, true); - addTranslation(tmp, worldRenderer, 0,1,0); - ClientUtils.renderTexturedBox(worldRenderer, .375,0,.375, .625,h-1,.625, hotMetal_flow, true); - addTranslation(tmp, worldRenderer, 0,-1,0); - addTranslation(tmp, worldRenderer, 0,h,0); + addTranslation(tmp, worldRenderer, 0, -h, 0); + ClientUtils.renderTexturedBox(worldRenderer, .375, 0, .375, .625, 1, .625, hotMetal_flow, true); + addTranslation(tmp, worldRenderer, 0, 1, 0); + ClientUtils.renderTexturedBox(worldRenderer, .375, 0, .375, .625, h-1, .625, hotMetal_flow, true); + addTranslation(tmp, worldRenderer, 0, -1, 0); + addTranslation(tmp, worldRenderer, 0, h, 0); } else { - addTranslation(tmp, worldRenderer, 0,-h,0); - ClientUtils.renderTexturedBox(worldRenderer, .375,0,.375, .625,h,.625, hotMetal_flow, true); - addTranslation(tmp, worldRenderer, 0,h,0); + addTranslation(tmp, worldRenderer, 0, -h, 0); + ClientUtils.renderTexturedBox(worldRenderer, .375, 0, .375, .625, h, .625, hotMetal_flow, true); + addTranslation(tmp, worldRenderer, 0, h, 0); } - if(pour>(process-speed)) - addTranslation(tmp, worldRenderer, 0,1.6875f-h,0); - if(pour>speed) + if(pour > (process-speed)) + addTranslation(tmp, worldRenderer, 0, 1.6875f-h, 0); + if(pour > speed) { - float h2 = (pour>(process-speed)?.625f: pour/(process-speed)*.625f); - addTranslation(tmp, worldRenderer, 0,-1.6875f,0); - ClientUtils.renderTexturedBox(worldRenderer, .125,0,.125, .875,h2,.875, hotMetal_still, false); - addTranslation(tmp, worldRenderer, 0,1.6875f,0); + float h2 = (pour > (process-speed)?.625f: pour/(process-speed)*.625f); + addTranslation(tmp, worldRenderer, 0, -1.6875f, 0); + ClientUtils.renderTexturedBox(worldRenderer, .125, 0, .125, .875, h2, .875, hotMetal_still, false); + addTranslation(tmp, worldRenderer, 0, 1.6875f, 0); } worldRenderer.setTranslation(0, 0, 0); tessellator.draw(); diff --git a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderAutoWorkbench.java b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderAutoWorkbench.java index c2a141c62c..0118e99b57 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderAutoWorkbench.java +++ b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderAutoWorkbench.java @@ -50,14 +50,14 @@ public class TileRenderAutoWorkbench extends TileEntitySpecialRenderer process = te.processQueue.get(i); - if(process==null || process.processTick<=0 || process.processTick==process.maxTicks) + if(process==null||process.processTick <= 0||process.processTick==process.maxTicks) continue; //+partialTicks - float processTimer = ((float)process.processTick)/process.maxTicks * 180; - if(processTimer<=9) + float processTimer = ((float)process.processTick)/process.maxTicks*180; + if(processTimer <= 9) continue; float itemX = -1; @@ -102,15 +102,18 @@ public void render(TileEntityAutoWorkbench te, double x, double y, double z, flo { itemZ += .25+(19-processTimer)/10f*.5f; itemY += .25+(19-processTimer)/10f*.21875f; - } else + } + else { itemZ += (24-processTimer)/5f*.25f; itemY += (24-processTimer)/5f*.25f; } - } else if(processTimer <= 40) + } + else if(processTimer <= 40) { itemX += (processTimer-24)/16f; - } else if(processTimer <= 100) + } + else if(processTimer <= 100) { itemX += 1; float drillStep = 0; @@ -118,11 +121,13 @@ public void render(TileEntityAutoWorkbench te, double x, double y, double z, flo { lift = (processTimer-40)/20f*.3125f; drillStep = 4+(60-processTimer)*4; - } else if(processTimer <= 80) + } + else if(processTimer <= 80) { lift = .3125f; drillStep = 4; - } else + } + else { lift = (100-processTimer)/20f*.3125f; drillStep = 4+(processTimer-80)*4; @@ -130,15 +135,18 @@ public void render(TileEntityAutoWorkbench te, double x, double y, double z, flo if(drillStep > 0) drill = processTimer%drillStep/drillStep*360; itemY += Math.max(0, lift-.0625); - } else if(processTimer <= 116) + } + else if(processTimer <= 116) { itemX += 1; itemZ += (processTimer-100)/16f; - } else if(processTimer <= 132) + } + else if(processTimer <= 132) { itemX += 1+(processTimer-116)/16f; itemZ += 1; - } else if(processTimer <= 172) + } + else if(processTimer <= 172) { itemX += 2; itemZ += 1; @@ -150,12 +158,13 @@ else if(processTimer <= 162) press = (172-processTimer)/10f; liftPress = press*.0625f; itemY += liftPress; - } else if(processTimer <= 180) + } + else if(processTimer <= 180) { itemX += 2+(processTimer-172)/16f; itemZ += 1; } - itemDisplays[i] = new float[]{processTimer,itemX,itemY,itemZ,itemAngle}; + itemDisplays[i] = new float[]{processTimer, itemX, itemY, itemZ, itemAngle}; } @@ -171,20 +180,20 @@ else if(processTimer <= 162) GlStateManager.translate(0, -lift, 0); EnumFacing f = te.getFacing(); - float tx = f == EnumFacing.WEST ? -.9375f : f == EnumFacing.EAST ? .9375f : 0; - float tz = f == EnumFacing.NORTH ? -.9375f : f == EnumFacing.SOUTH ? .9375f : 0; + float tx = f==EnumFacing.WEST?-.9375f: f==EnumFacing.EAST?.9375f: 0; + float tz = f==EnumFacing.NORTH?-.9375f: f==EnumFacing.SOUTH?.9375f: 0; GlStateManager.translate(tx, 0, tz); GlStateManager.rotate(drill, 0, 1, 0); renderModelPart(blockRenderer, tessellator, worldRenderer, te.getWorld(), state, model, blockPos, "drill"); GlStateManager.rotate(-drill, 0, 1, 0); GlStateManager.translate(-tx, 0, -tz); - tx = f == EnumFacing.WEST ? -.59375f : f == EnumFacing.EAST ? .59375f : 0; - tz = f == EnumFacing.NORTH ? -.59375f : f == EnumFacing.SOUTH ? .59375f : 0; + tx = f==EnumFacing.WEST?-.59375f: f==EnumFacing.EAST?.59375f: 0; + tz = f==EnumFacing.NORTH?-.59375f: f==EnumFacing.SOUTH?.59375f: 0; GlStateManager.translate(tx, -.21875, tz); - GlStateManager.rotate(press * 90, -f.getFrontOffsetZ(), 0, f.getFrontOffsetX()); + GlStateManager.rotate(press*90, -f.getFrontOffsetZ(), 0, f.getFrontOffsetX()); renderModelPart(blockRenderer, tessellator, worldRenderer, te.getWorld(), state, model, blockPos, "press"); - GlStateManager.rotate(-press * 90, -f.getFrontOffsetZ(), 0, f.getFrontOffsetX()); + GlStateManager.rotate(-press*90, -f.getFrontOffsetZ(), 0, f.getFrontOffsetX()); GlStateManager.translate(-tx, .21875, -tz); GlStateManager.translate(0, liftPress, 0); @@ -210,11 +219,11 @@ else if(processTimer <= 162) } //DRAW ITEMS HERE - for(int i=0; i process = te.processQueue.get(i); - if(process==null || !(process instanceof MultiblockProcessInWorld)) + if(process==null||!(process instanceof MultiblockProcessInWorld)) continue; float scale = .3125f; @@ -253,7 +262,8 @@ else if(processTimer <= 162) { localItemZ = -1+.25f+(19-subProcess)/10f*.5f; localItemY = -.34375f+.25f+(19-subProcess)/10f*.21875f; - } else + } + else { localItemZ = -1+(oZ-(24-subProcess)/5f*oZ); localItemY = -.34375f+(24-subProcess)/5f*.25f; @@ -273,11 +283,11 @@ else if(processTimer <= 162) //Blueprint double playerDistanceSq = ClientUtils.mc().player.getDistanceSq(blockPos); - if(!blueprintStack.isEmpty() && playerDistanceSq<1000) + if(!blueprintStack.isEmpty()&&playerDistanceSq < 1000) { - BlueprintCraftingRecipe[] recipes = BlueprintCraftingRecipe.findRecipes(ItemNBTHelper.getString(blueprintStack,"blueprint")); - BlueprintCraftingRecipe recipe = (te.selectedRecipe<0||te.selectedRecipe>=recipes.length)?null:recipes[te.selectedRecipe]; - BlueprintLines blueprint = recipe==null?null:getBlueprintDrawable(recipe, te.getWorld()); + BlueprintCraftingRecipe[] recipes = BlueprintCraftingRecipe.findRecipes(ItemNBTHelper.getString(blueprintStack, "blueprint")); + BlueprintCraftingRecipe recipe = (te.selectedRecipe < 0||te.selectedRecipe >= recipes.length)?null: recipes[te.selectedRecipe]; + BlueprintLines blueprint = recipe==null?null: getBlueprintDrawable(recipe, te.getWorld()); if(blueprint!=null) { //Width depends on distance @@ -314,7 +324,7 @@ public static void renderModelPart(final BlockRendererDispatcher blockRenderer, else GlStateManager.shadeModel(7424); worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); - worldRenderer.setTranslation(-.5 - pos.getX(), -.5 - pos.getY(), -.5 - pos.getZ()); + worldRenderer.setTranslation(-.5-pos.getX(), -.5-pos.getY(), -.5-pos.getZ()); worldRenderer.color(255, 255, 255, 255); blockRenderer.getBlockModelRenderer().renderModel(world, model, state, pos, worldRenderer, true); worldRenderer.setTranslation(0.0D, 0.0D, 0.0D); @@ -322,6 +332,7 @@ public static void renderModelPart(final BlockRendererDispatcher blockRenderer, } public static HashMap blueprintCache = new HashMap(); + public static BlueprintLines getBlueprintDrawable(BlueprintCraftingRecipe recipe, World world) { if(recipe==null) @@ -347,7 +358,7 @@ public static BlueprintLines getBlueprintDrawable(ItemStack stack, World world) HashSet textures = new HashSet(); Collection quads = ibakedmodel.getQuads(null, null, 0); for(BakedQuad quad : quads) - if(quad != null && quad.getSprite() != null) + if(quad!=null&&quad.getSprite()!=null) textures.add(quad.getSprite().getIconName()); for(String s : textures) { @@ -355,7 +366,7 @@ public static BlueprintLines getBlueprintDrawable(ItemStack stack, World world) rl = new ResourceLocation(rl.getResourceDomain(), String.format("%s/%s%s", "textures", rl.getResourcePath(), ".png")); IResource resource = ClientUtils.mc().getResourceManager().getResource(rl); BufferedImage bufferedImage = TextureUtil.readBufferedImage(resource.getInputStream()); - if(bufferedImage != null) + if(bufferedImage!=null) images.add(bufferedImage); } } catch(Exception e) @@ -373,24 +384,24 @@ public static BlueprintLines getBlueprintDrawable(ItemStack stack, World world) int w = bufferedImage.getWidth(); int h = bufferedImage.getHeight(); - if(h>w) - h=w; - if(w>wMax) + if(h > w) + h = w; + if(w > wMax) wMax = w; - for(int hh=0; hh>16&255)/255f; - float g = (argb>>8&255)/255f; + float r = (argb >> 16&255)/255f; + float g = (argb >> 8&255)/255f; float b = (argb&255)/255f; - float intesity = (r+b+g) / 3f; - int alpha = (argb>>24)&255; + float intesity = (r+b+g)/3f; + int alpha = (argb >> 24)&255; if(alpha > 0) { boolean added = false; //Check colour sets for similar colour to shade it later - TexturePoint tp =new TexturePoint(ww, hh, w); + TexturePoint tp = new TexturePoint(ww, hh, w); if(!testSet.contains(tp)) { for(Integer key : area.keySet()) @@ -398,8 +409,8 @@ public static BlueprintLines getBlueprintDrawable(ItemStack stack, World world) for(Point p : area.get(key)) { int pColour = bufferedImage.getRGB(p.x, p.y); - float dR = (r-(pColour>>16&255)/255f); - float dG = (g-(pColour>>8&255)/255f); + float dR = (r-(pColour >> 16&255)/255f); + float dG = (g-(pColour >> 8&255)/255f); float dB = (b-(pColour&255)/255f); double delta = Math.sqrt(dR*dR+dG*dG+dB*dB); if(delta < .25) @@ -417,34 +428,34 @@ public static BlueprintLines getBlueprintDrawable(ItemStack stack, World world) testSet.add(tp); } //Compare to direct neighbour - for(int i=0; i<4; i++) + for(int i = 0; i < 4; i++) { int xx = (i==0?-1: i==1?1: 0); int yy = (i==2?-1: i==3?1: 0); - int u = ww + xx; - int v = hh + yy; + int u = ww+xx; + int v = hh+yy; int neighbour = 0; float delta = 1; boolean notTransparent = false; - if(u >= 0 && u < w && v >= 0 && v < h) + if(u >= 0&&u < w&&v >= 0&&v < h) { neighbour = bufferedImage.getRGB(u, v); - notTransparent = ((neighbour >> 24) & 255) > 0; + notTransparent = ((neighbour >> 24)&255) > 0; if(notTransparent) { - float neighbourIntesity = ((neighbour >> 16 & 255) + (neighbour >> 8 & 255) + (neighbour & 255)) / 765f; - float intesityDelta = Math.max(0, Math.min(1, Math.abs(intesity - neighbourIntesity))); - float rDelta = Math.max(0, Math.min(1, Math.abs(r - (neighbour >> 16 & 255) / 255f))); - float gDelta = Math.max(0, Math.min(1, Math.abs(g - (neighbour >> 8 & 255) / 255f))); - float bDelta = Math.max(0, Math.min(1, Math.abs(b - (neighbour & 255) / 255f))); + float neighbourIntesity = ((neighbour >> 16&255)+(neighbour >> 8&255)+(neighbour&255))/765f; + float intesityDelta = Math.max(0, Math.min(1, Math.abs(intesity-neighbourIntesity))); + float rDelta = Math.max(0, Math.min(1, Math.abs(r-(neighbour >> 16&255)/255f))); + float gDelta = Math.max(0, Math.min(1, Math.abs(g-(neighbour >> 8&255)/255f))); + float bDelta = Math.max(0, Math.min(1, Math.abs(b-(neighbour&255)/255f))); delta = Math.max(intesityDelta, Math.max(rDelta, Math.max(gDelta, bDelta))); - delta = delta < .25 ? 0 : delta > .4 ? 1 : delta; + delta = delta < .25?0: delta > .4?1: delta; } } if(delta > 0) { - Pair l = Pair.of(new TexturePoint(ww+(i==0?0:i==1?1:0), hh+(i==2?0:i==3?1:0), w), new TexturePoint(ww+(i==0?0:i==1?1:1), hh+(i==2?0:i==3?1:1), w)); + Pair l = Pair.of(new TexturePoint(ww+(i==0?0: i==1?1: 0), hh+(i==2?0: i==3?1: 0), w), new TexturePoint(ww+(i==0?0: i==1?1: 1), hh+(i==2?0: i==3?1: 1), w)); temp_lines.add(l); } } @@ -454,21 +465,21 @@ public static BlueprintLines getBlueprintDrawable(ItemStack stack, World world) } ArrayList lumiSort = new ArrayList<>(area.keySet()); - Collections.sort(lumiSort, (rgb1, rgb2) -> Double.compare(getLuminance(rgb1),getLuminance(rgb2))); + Collections.sort(lumiSort, (rgb1, rgb2) -> Double.compare(getLuminance(rgb1), getLuminance(rgb2))); HashMultimap complete_areaMap = HashMultimap.create(); int lineNumber = 2; int lineStyle = 0; for(Integer i : lumiSort) { - complete_areaMap.putAll(new ShadeStyle(lineNumber,lineStyle), area.get(i)); + complete_areaMap.putAll(new ShadeStyle(lineNumber, lineStyle), area.get(i)); ++lineStyle; lineStyle %= 3; if(lineStyle==0) - lineNumber+=1; + lineNumber += 1; } Set> complete_lines = new HashSet<>(); - for(Pair line : lines) + for(Pair line : lines) { TexturePoint p1 = line.getKey(); TexturePoint p2 = line.getValue(); @@ -519,6 +530,7 @@ public void draw(float lineWidth) } } } + private static class ShadeStyle { int stripeAmount = 1; @@ -534,13 +546,13 @@ void drawShading(Point pixel) { float step = 1/(float)stripeAmount; float offset = step/2; - if(stripeDirection>1) + if(stripeDirection > 1) { - int perSide = stripeAmount/2+(stripeAmount%2==1?1:0); + int perSide = stripeAmount/2+(stripeAmount%2==1?1: 0); step = 1/(float)(perSide); - offset = stripeAmount%2==1?step:step/2; + offset = stripeAmount%2==1?step: step/2; } - for(int i=0; i>16&255) + .691*(rgb>>8&255) + .068*(rgb&255)); + return Math.sqrt(.241*(rgb >> 16&255)+.691*(rgb >> 8&255)+.068*(rgb&255)); } } diff --git a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderBelljar.java b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderBelljar.java index af1afb26af..b6c2b23b3f 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderBelljar.java +++ b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderBelljar.java @@ -42,14 +42,14 @@ public class TileRenderBelljar extends TileEntitySpecialRenderer(plantModel.getQuads(s,null,0)); + plantQuadList = new ArrayList(plantModel.getQuads(s, null, 0)); for(EnumFacing f : EnumFacing.values()) - plantQuadList.addAll(plantModel.getQuads(s,f,0)); + plantQuadList.addAll(plantModel.getQuads(s, f, 0)); plantQuads.put(s, plantQuadList); } if(plantQuadList!=null) @@ -125,6 +125,7 @@ public void render(TileEntityBelljar tile, double x, double y, double z, float p GlStateManager.popMatrix(); RenderHelper.enableStandardItemLighting(); } + public static void reset() { quads.clear(); diff --git a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderBottlingMachine.java b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderBottlingMachine.java index 34fa8a4fc1..dfccb9e8cd 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderBottlingMachine.java +++ b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderBottlingMachine.java @@ -37,14 +37,14 @@ public class TileRenderBottlingMachine extends TileEntitySpecialRenderer { private static IBakedModel model = null; + @Override public void render(TileEntityBucketWheel tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { - if(!tile.formed || !tile.getWorld().isBlockLoaded(tile.getPos(), false) || tile.isDummy()) + if(!tile.formed||!tile.getWorld().isBlockLoaded(tile.getPos(), false)||tile.isDummy()) return; final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher(); IBlockState state = tile.getWorld().getBlockState(tile.getPos()); - if(state.getBlock() != IEContent.blockMetalMultiblock) + if(state.getBlock()!=IEContent.blockMetalMultiblock) return; - if (model==null) + if(model==null) { state = state.withProperty(IEProperties.DYNAMICRENDER, true); state = state.withProperty(IEProperties.FACING_HORIZONTAL, EnumFacing.NORTH); model = blockRenderer.getModelForState(state); } OBJState objState = null; - HashMap texMap = new HashMap<>(); + HashMap texMap = new HashMap<>(); if(state instanceof IExtendedBlockState) { ArrayList list = Lists.newArrayList("bucketWheel"); - synchronized (tile.digStacks) + synchronized(tile.digStacks) { - for(int i=0; i quads; - if (model instanceof IESmartObjModel) - quads = ((IESmartObjModel) model).getQuads(state, null, 0, objState, texMap, true); + if(model instanceof IESmartObjModel) + quads = ((IESmartObjModel)model).getQuads(state, null, 0, objState, texMap, true); else quads = model.getQuads(state, null, 0); ClientUtils.renderModelTESRFast(quads, worldRenderer, tile.getWorld(), tile.getPos()); diff --git a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderChargingStation.java b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderChargingStation.java index 74ed18c527..efbeeb3bbe 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderChargingStation.java +++ b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderChargingStation.java @@ -23,27 +23,27 @@ public void render(TileEntityChargingStation te, double x, double y, double z, f { GlStateManager.pushMatrix(); GlStateManager.translate(x+.5, y+.3125, z+.5); - GlStateManager.scale(.75f,.75f,.75f); + GlStateManager.scale(.75f, .75f, .75f); ClientUtils.bindAtlas(); switch(te.facing) { case NORTH: - GlStateManager.rotate(180, 0,1,0); + GlStateManager.rotate(180, 0, 1, 0); break; case SOUTH: break; case WEST: - GlStateManager.rotate(-90, 0,1,0); + GlStateManager.rotate(-90, 0, 1, 0); break; case EAST: - GlStateManager.rotate(90, 0,1,0); + GlStateManager.rotate(90, 0, 1, 0); break; } if(!te.inventory.get(0).isEmpty()) { GlStateManager.pushMatrix(); float scale = .625f; - GlStateManager.scale(scale,scale,1); + GlStateManager.scale(scale, scale, 1); ClientUtils.mc().getRenderItem().renderItem(te.inventory.get(0), TransformType.FIXED); GlStateManager.popMatrix(); diff --git a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderCoresample.java b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderCoresample.java index ccbae63e8e..173cac3672 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderCoresample.java +++ b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderCoresample.java @@ -20,14 +20,14 @@ public class TileRenderCoresample extends TileEntitySpecialRenderer0 && !te.isRSDisabled() && !te.processQueue.isEmpty(); // float angle = te.animation_barrelRotation+(b?18*partialTicks:0); - + Tessellator tessellator = Tessellator.getInstance(); BufferBuilder worldRenderer = tessellator.getBuffer(); - + ClientUtils.bindAtlas(); GlStateManager.pushMatrix(); GlStateManager.translate(x, y, z); GlStateManager.translate(.5, .6875, .5); - + RenderHelper.disableStandardItemLighting(); GlStateManager.blendFunc(770, 771); @@ -62,16 +62,16 @@ public void render(TileEntityDieselGenerator te, double x, double y, double z, f // float angle = ClientUtils.mc().player.ticksExisted%100/100f; // GlStateManager.rotate(angle*360, te.facing.getFrontOffsetX(), 0, te.facing.getFrontOffsetZ()); GlStateManager.rotate(te.animation_fanRotation+(te.animation_fanRotationStep*partialTicks), te.facing.getFrontOffsetX(), 0, te.facing.getFrontOffsetZ()); - + worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); - worldRenderer.setTranslation( -.5-blockPos.getX(), - blockPos.getY(), -.5-blockPos.getZ()); + worldRenderer.setTranslation(-.5-blockPos.getX(), -blockPos.getY(), -.5-blockPos.getZ()); worldRenderer.color(255, 255, 255, 255); - blockRenderer.getBlockModelRenderer().renderModel(te.getWorld(), model, state, blockPos, worldRenderer,true); + blockRenderer.getBlockModelRenderer().renderModel(te.getWorld(), model, state, blockPos, worldRenderer, true); worldRenderer.setTranslation(0.0D, 0.0D, 0.0D); tessellator.draw(); - + RenderHelper.enableStandardItemLighting(); - + GlStateManager.popMatrix(); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderMetalPress.java b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderMetalPress.java index adbfaf5f83..59503cb46e 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderMetalPress.java +++ b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderMetalPress.java @@ -33,13 +33,13 @@ public class TileRenderMetalPress extends TileEntitySpecialRenderer=transportTime&&fProcess<(1-transportTime)) + if(fProcess >= transportTime&&fProcess < (1-transportTime)) { - if(fProcess<(transportTime+pressTime)) + if(fProcess < (transportTime+pressTime)) piston = (fProcess-transportTime)/pressTime; - else if(fProcess<(1-transportTime-pressTime)) + else if(fProcess < (1-transportTime-pressTime)) piston = 1; else - piston = 1 - (fProcess-(1-transportTime-pressTime))/pressTime; + piston = 1-(fProcess-(1-transportTime-pressTime))/pressTime; } } - GlStateManager.translate(0,-piston*.6875f,0); + GlStateManager.translate(0, -piston*.6875f, 0); RenderHelper.disableStandardItemLighting(); GlStateManager.blendFunc(770, 771); @@ -90,36 +90,36 @@ else if(fProcess<(1-transportTime-pressTime)) else GlStateManager.shadeModel(7424); worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); - worldRenderer.setTranslation( -.5-blockPos.getX(), -.5- blockPos.getY(), -.5-blockPos.getZ()); + worldRenderer.setTranslation(-.5-blockPos.getX(), -.5-blockPos.getY(), -.5-blockPos.getZ()); worldRenderer.color(255, 255, 255, 255); blockRenderer.getBlockModelRenderer().renderModel(te.getWorld(), model, state, blockPos, worldRenderer, true); worldRenderer.setTranslation(0.0D, 0.0D, 0.0D); tessellator.draw(); RenderHelper.enableStandardItemLighting(); - GlStateManager.rotate(te.facing==EnumFacing.SOUTH?180: te.facing==EnumFacing.WEST?90: te.facing==EnumFacing.EAST?-90: 0, 0,1,0); + GlStateManager.rotate(te.facing==EnumFacing.SOUTH?180: te.facing==EnumFacing.WEST?90: te.facing==EnumFacing.EAST?-90: 0, 0, 1, 0); if(!te.mold.isEmpty()) { GlStateManager.pushMatrix(); - GlStateManager.translate(0,.34,0); - GlStateManager.rotate(-90, 1,0,0); + GlStateManager.translate(0, .34, 0); + GlStateManager.rotate(-90, 1, 0, 0); float scale = .75f; - GlStateManager.scale(scale,scale,1); + GlStateManager.scale(scale, scale, 1); ClientUtils.mc().getRenderItem().renderItem(te.mold, ItemCameraTransforms.TransformType.FIXED); - GlStateManager.scale(1/scale,1/scale,1); + GlStateManager.scale(1/scale, 1/scale, 1); GlStateManager.popMatrix(); } - GlStateManager.translate(0,piston*.6875f,0); - GlStateManager.translate(0,-.35,1.25); - for(int i=0; i.92) - GlStateManager.translate(0,.92-piston,0); + GlStateManager.translate(0, 0, -2.5*shift[i]); + if(piston > .92) + GlStateManager.translate(0, .92-piston, 0); List displays = ((MultiblockProcessInWorld)process).getDisplayItem(); if(!displays.isEmpty()) diff --git a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderMixer.java b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderMixer.java index fa253acc2d..c3f8640a85 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderMixer.java +++ b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderMixer.java @@ -28,13 +28,13 @@ public class TileRenderMixer extends TileEntitySpecialRenderer @Override public void render(TileEntityMixer te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { - if(!te.formed || te.isDummy() || !te.getWorld().isBlockLoaded(te.getPos(), false)) + if(!te.formed||te.isDummy()||!te.getWorld().isBlockLoaded(te.getPos(), false)) return; final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher(); BlockPos blockPos = te.getPos(); IBlockState state = getWorld().getBlockState(blockPos); - if(state.getBlock() != IEContent.blockMetalMultiblock) + if(state.getBlock()!=IEContent.blockMetalMultiblock) return; state = state.getBlock().getActualState(state, getWorld(), blockPos); state = state.withProperty(IEProperties.DYNAMICRENDER, true); @@ -48,12 +48,12 @@ public void render(TileEntityMixer te, double x, double y, double z, float parti GlStateManager.translate(x+.5, y+.5, z+.5); if(te.mirrored) - GlStateManager.scale(te.facing.getFrontOffsetX()==0?-1:1,1,te.facing.getFrontOffsetZ()==0?-1:1); + GlStateManager.scale(te.facing.getFrontOffsetX()==0?-1: 1, 1, te.facing.getFrontOffsetZ()==0?-1: 1); GlStateManager.pushMatrix(); - GlStateManager.translate(te.facing==EnumFacing.SOUTH||te.facing==EnumFacing.WEST?-.5:.5, 0, te.facing==EnumFacing.SOUTH||te.facing==EnumFacing.EAST?.5:-.5); - float agitator = te.animation_agitator-(!te.shouldRenderAsActive()?0:(1-partialTicks)*9f); - GlStateManager.rotate(agitator, 0,1,0); + GlStateManager.translate(te.facing==EnumFacing.SOUTH||te.facing==EnumFacing.WEST?-.5: .5, 0, te.facing==EnumFacing.SOUTH||te.facing==EnumFacing.EAST?.5: -.5); + float agitator = te.animation_agitator-(!te.shouldRenderAsActive()?0: (1-partialTicks)*9f); + GlStateManager.rotate(agitator, 0, 1, 0); RenderHelper.disableStandardItemLighting(); GlStateManager.blendFunc(770, 771); @@ -64,7 +64,7 @@ public void render(TileEntityMixer te, double x, double y, double z, float parti else GlStateManager.shadeModel(7424); worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); - worldRenderer.setTranslation( -.5-blockPos.getX(), -.5- blockPos.getY(), -.5-blockPos.getZ()); + worldRenderer.setTranslation(-.5-blockPos.getX(), -.5-blockPos.getY(), -.5-blockPos.getZ()); worldRenderer.color(255, 255, 255, 255); blockRenderer.getBlockModelRenderer().renderModel(te.getWorld(), model, state, blockPos, worldRenderer, true); worldRenderer.setTranslation(0.0D, 0.0D, 0.0D); @@ -88,23 +88,23 @@ public void render(TileEntityMixer te, double x, double y, double z, float parti break; } - GlStateManager.scale(.0625f,1,.0625f); - GlStateManager.rotate(90, 1,0,0); - GlStateManager.translate(8,-8,.625f); + GlStateManager.scale(.0625f, 1, .0625f); + GlStateManager.rotate(90, 1, 0, 0); + GlStateManager.translate(8, -8, .625f); RenderHelper.disableStandardItemLighting(); - for(int i=te.tank.getFluidTypes()-1; i>=0; i--) + for(int i = te.tank.getFluidTypes()-1; i >= 0; i--) { FluidStack fs = te.tank.fluids.get(i); if(fs!=null&&fs.getFluid()!=null) { int col = fs.getFluid().getColor(fs); - GlStateManager.color((col>>16&255)/255.0f,(col>>8&255)/255.0f,(col&255)/255.0f, 1); + GlStateManager.color((col >> 16&255)/255.0f, (col >> 8&255)/255.0f, (col&255)/255.0f, 1); float yy = fs.amount/(float)te.tank.getCapacity()*1.125f; GlStateManager.translate(0, 0, -yy); - float w = (i=.125)?26: 16+yy/.0125f; + float w = (i < te.tank.getFluidTypes()-1||yy >= .125)?26: 16+yy/.0125f; ClientUtils.drawRepeatedFluidSprite(fs, -w/2, -w/2, w, w); } } diff --git a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderSampleDrill.java b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderSampleDrill.java index 4cae0b0a68..481a10297d 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderSampleDrill.java +++ b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderSampleDrill.java @@ -37,7 +37,7 @@ public void render(TileEntitySampleDrill tile, double x, double y, double z, flo IBlockState state = tile.getWorld().getBlockState(tile.getPos()); BlockPos blockPos = tile.getPos(); IBakedModel model = blockRenderer.getModelForState(state); - if(state.getBlock() != IEContent.blockMetalDevice1) + if(state.getBlock()!=IEContent.blockMetalDevice1) return; // .getModelFromBlockState(state, getWorld(), blockPos); if(state instanceof IExtendedBlockState) @@ -61,17 +61,17 @@ public void render(TileEntitySampleDrill tile, double x, double y, double z, flo // GlStateManager.rotate(rot, 0,0,1); int max = IEConfig.Machines.coredrill_time; - if(tile.process>0 && tile.process 0&&tile.process < max) { - GlStateManager.rotate( ((tile.process+partialTicks)*22.5f)%360f, 0,1,0); + GlStateManager.rotate(((tile.process+partialTicks)*22.5f)%360f, 0, 1, 0); float push = tile.process/(float)max; - if(tile.process>max/2) + if(tile.process > max/2) push = 1-push; - GlStateManager.translate(0,-2.8f*push,0); + GlStateManager.translate(0, -2.8f*push, 0); } worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); - worldRenderer.setTranslation( -.5-blockPos.getX(), -.5- blockPos.getY(), -.5-blockPos.getZ()); + worldRenderer.setTranslation(-.5-blockPos.getX(), -.5-blockPos.getY(), -.5-blockPos.getZ()); worldRenderer.color(255, 255, 255, 255); blockRenderer.getBlockModelRenderer().renderModel(tile.getWorld(), model, state, tile.getPos(), worldRenderer, true); worldRenderer.setTranslation(0.0D, 0.0D, 0.0D); diff --git a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderSheetmetalTank.java b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderSheetmetalTank.java index 34409925e5..3effb13085 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderSheetmetalTank.java +++ b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderSheetmetalTank.java @@ -23,24 +23,24 @@ public class TileRenderSheetmetalTank extends TileEntitySpecialRenderer @Override public void render(TileEntitySilo tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { - if(!tile.formed || tile.pos!=4||!tile.getWorld().isBlockLoaded(tile.getPos(), false)) + if(!tile.formed||tile.pos!=4||!tile.getWorld().isBlockLoaded(tile.getPos(), false)) return; GlStateManager.pushMatrix(); @@ -29,43 +29,43 @@ public void render(TileEntitySilo tile, double x, double y, double z, float part if(!tile.identStack.isEmpty()) { - GlStateManager.translate(0,5,0); + GlStateManager.translate(0, 5, 0); float baseScale = .0625f; float itemScale = .75f; float flatScale = .001f; baseScale *= itemScale; float textScale = .375f; - GlStateManager.scale(baseScale,-baseScale,baseScale); + GlStateManager.scale(baseScale, -baseScale, baseScale); ItemStack stack = Utils.copyStackWithAmount(tile.identStack, tile.storageAmount); - String s = "" + stack.getCount(); + String s = ""+stack.getCount(); float w = this.getFontRenderer().getStringWidth(s); float xx = -.5f*itemScale; float zz = 1.501f; - xx/=baseScale; - zz/=baseScale; - w*=textScale; - for(int i=0; i<4; i++) + xx /= baseScale; + zz /= baseScale; + w *= textScale; + for(int i = 0; i < 4; i++) { GlStateManager.pushMatrix(); - GlStateManager.translate(xx,0,zz); - GlStateManager.scale(1,1,flatScale); + GlStateManager.translate(xx, 0, zz); + GlStateManager.scale(1, 1, flatScale); ClientUtils.mc().getRenderItem().renderItemAndEffectIntoGUI(stack, 0, 0); - GlStateManager.scale(1,1,1/flatScale); - + GlStateManager.scale(1, 1, 1/flatScale); + GlStateManager.disableLighting(); GlStateManager.depthMask(false); - GlStateManager.translate(8-w/2,17,.001f); - GlStateManager.scale(textScale,textScale,1); - ClientUtils.font().drawString("" + stack.getCount(), 0,0,0x888888, true); - GlStateManager.scale(1/textScale,1/textScale,1); - GlStateManager.translate(-(8-w/2),-17,-.001f); + GlStateManager.translate(8-w/2, 17, .001f); + GlStateManager.scale(textScale, textScale, 1); + ClientUtils.font().drawString(""+stack.getCount(), 0, 0, 0x888888, true); + GlStateManager.scale(1/textScale, 1/textScale, 1); + GlStateManager.translate(-(8-w/2), -17, -.001f); GlStateManager.depthMask(true); GlStateManager.enableLighting(); - GlStateManager.translate(-xx,0,-zz); + GlStateManager.translate(-xx, 0, -zz); GlStateManager.popMatrix(); - GlStateManager.rotate(90, 0,1,0); + GlStateManager.rotate(90, 0, 1, 0); GlStateManager.enableAlpha(); GlStateManager.alphaFunc(516, 0.1F); diff --git a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderSqueezer.java b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderSqueezer.java index 1c4cf1a393..063cf069b7 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderSqueezer.java +++ b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderSqueezer.java @@ -26,30 +26,30 @@ public class TileRenderSqueezer extends TileEntitySpecialRenderer subs = animation.subPoints; - worldrenderer.pos(animation.startPos.x-tileX,animation.startPos.y-tileY,animation.startPos.z-tileZ).endVertex(); - - for(int i=0; i0) + if(((TileEntityTurretGun)tile).cycleRender > 0) { float cycle = 0; - if(((TileEntityTurretGun)tile).cycleRender>3) + if(((TileEntityTurretGun)tile).cycleRender > 3) cycle = (5-((TileEntityTurretGun)tile).cycleRender)/2f; else cycle = ((TileEntityTurretGun)tile).cycleRender/3f; diff --git a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderWatermill.java b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderWatermill.java index e7f5007a70..b0be272557 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderWatermill.java +++ b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderWatermill.java @@ -27,16 +27,17 @@ public class TileRenderWatermill extends TileEntitySpecialRenderer { private static List quads; + @Override public void render(TileEntityWatermill tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { - if (tile.isDummy()||!tile.getWorld().isBlockLoaded(tile.getPos(), false)) + if(tile.isDummy()||!tile.getWorld().isBlockLoaded(tile.getPos(), false)) return; - if (quads==null) + if(quads==null) { final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher(); IBlockState state = tile.getWorld().getBlockState(tile.getPos()); - if(state.getBlock() != IEContent.blockWoodenDevice1) + if(state.getBlock()!=IEContent.blockWoodenDevice1) return; state = state.withProperty(IEProperties.FACING_ALL, EnumFacing.NORTH); quads = blockRenderer.getModelForState(state).getQuads(state, null, 0); @@ -44,12 +45,12 @@ public void render(TileEntityWatermill tile, double x, double y, double z, float Tessellator tessellator = Tessellator.getInstance(); GlStateManager.pushMatrix(); - GlStateManager.translate(x + .5, y + .5, z + .5); + GlStateManager.translate(x+.5, y+.5, z+.5); GlStateManager.blendFunc(770, 771); GlStateManager.enableBlend(); GlStateManager.disableCull(); final float dir = (tile.facing.getHorizontalAngle()+180)%180; - float wheelRotation = 360 * (tile.rotation + (!tile.canTurn || tile.rotation == 0 ? 0 : partialTicks)*(float)tile.perTick); + float wheelRotation = 360*(tile.rotation+(!tile.canTurn||tile.rotation==0?0: partialTicks)*(float)tile.perTick); GlStateManager.rotate(dir, 0, 1, 0); GlStateManager.rotate(wheelRotation, 0, 0, 1); RenderHelper.disableStandardItemLighting(); @@ -65,6 +66,7 @@ public void render(TileEntityWatermill tile, double x, double y, double z, float GlStateManager.disableBlend(); GlStateManager.enableCull(); } + public static void reset() { quads = null; diff --git a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderWindmill.java b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderWindmill.java index 7aee88a130..e25a2564e0 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderWindmill.java +++ b/src/main/java/blusunrize/immersiveengineering/client/render/TileRenderWindmill.java @@ -30,11 +30,11 @@ import java.util.ArrayList; import java.util.List; -import java.util.WeakHashMap; public class TileRenderWindmill extends TileEntitySpecialRenderer { private static List[] quads = new List[9]; + @Override public void render(TileEntityWindmill tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { @@ -45,7 +45,7 @@ public void render(TileEntityWindmill tile, double x, double y, double z, float if(quads[tile.sails]==null) { IBlockState state = getWorld().getBlockState(blockPos); - if(state.getBlock() != IEContent.blockWoodenDevice1) + if(state.getBlock()!=IEContent.blockWoodenDevice1) return; state = state.getActualState(getWorld(), blockPos); state = state.withProperty(IEProperties.FACING_ALL, EnumFacing.NORTH); @@ -54,7 +54,7 @@ public void render(TileEntityWindmill tile, double x, double y, double z, float { List parts = new ArrayList<>(); parts.add("base"); - for(int i=1; i<=tile.sails; i++) + for(int i = 1; i <= tile.sails; i++) parts.add("sail_"+i); state = ((IExtendedBlockState)state).withProperty(Properties.AnimationProperty, new OBJState(parts, true)); } @@ -65,12 +65,12 @@ public void render(TileEntityWindmill tile, double x, double y, double z, float GlStateManager.enableBlend(); GlStateManager.disableCull(); GlStateManager.pushMatrix(); - GlStateManager.translate(x + .5, y + .5, z + .5); + GlStateManager.translate(x+.5, y+.5, z+.5); - float dir = tile.facing == EnumFacing.SOUTH ? 0 : tile.facing == EnumFacing.NORTH ? 180 : tile.facing == EnumFacing.EAST ? 90 : -90; - float rot = 360 * (tile.rotation + (!tile.canTurn || tile.rotation == 0 ? 0 : partialTicks)*tile.perTick); + float dir = tile.facing==EnumFacing.SOUTH?0: tile.facing==EnumFacing.NORTH?180: tile.facing==EnumFacing.EAST?90: -90; + float rot = 360*(tile.rotation+(!tile.canTurn||tile.rotation==0?0: partialTicks)*tile.perTick); - GlStateManager.rotate(rot, tile.facing.getAxis() == Axis.X ? 1 : 0, 0, tile.facing.getAxis() == Axis.Z ? 1 : 0); + GlStateManager.rotate(rot, tile.facing.getAxis()==Axis.X?1: 0, 0, tile.facing.getAxis()==Axis.Z?1: 0); GlStateManager.rotate(dir, 0, 1, 0); RenderHelper.disableStandardItemLighting(); @@ -86,9 +86,10 @@ public void render(TileEntityWindmill tile, double x, double y, double z, float GlStateManager.disableBlend(); GlStateManager.enableCull(); } + public static void reset() { - for(int i=0; i3?.5: facing==2&&mirror?1: facing==3&&!mirror?1:0, 0, facing<4?.5: facing==5&&mirror?1: facing==4&&!mirror?1:0); @@ -58,21 +58,22 @@ public void render(TileEntityModWorkbench te, double x, double y, double z, floa // GlStateManager.popMatrix(); GlStateManager.pushMatrix(); GlStateManager.disableLighting(); - GlStateManager.translate(.5,1.0625,.5); + GlStateManager.translate(.5, 1.0625, .5); // float offset = off * (mirror?1f:.825f); // GlStateManager.translate(facing<4?offset:0,0,facing>3?offset:0); - angle = facing==2?90:facing==4?180:facing==5?0:-90; - GlStateManager.rotate(180, 0,0,1); - GlStateManager.rotate(-angle, 0,1,0); - GlStateManager.rotate(-90, 1,0,0); - GlStateManager.translate(0,-.875,0); - GlStateManager.scale(.75f,.75f,.75f); + angle = facing==2?90: facing==4?180: facing==5?0: -90; + GlStateManager.rotate(180, 0, 0, 1); + GlStateManager.rotate(-angle, 0, 1, 0); + GlStateManager.rotate(-90, 1, 0, 0); + GlStateManager.translate(0, -.875, 0); + GlStateManager.scale(.75f, .75f, .75f); if(!te.getInventory().get(0).isEmpty()) { - try{ + try + { ItemStack is = te.getInventory().get(0); ClientUtils.mc().getRenderItem().renderItem(is, ItemCameraTransforms.TransformType.FIXED); - }catch(Exception e) + } catch(Exception e) { e.printStackTrace(); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/CommonProxy.java b/src/main/java/blusunrize/immersiveengineering/common/CommonProxy.java index 99db420a6b..3fdf165df4 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/CommonProxy.java +++ b/src/main/java/blusunrize/immersiveengineering/common/CommonProxy.java @@ -18,7 +18,6 @@ import blusunrize.immersiveengineering.ImmersiveEngineering; import blusunrize.immersiveengineering.api.Lib; -import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection; import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IGuiTile; import blusunrize.immersiveengineering.common.blocks.metal.*; import blusunrize.immersiveengineering.common.blocks.stone.TileEntityAlloySmelter; @@ -32,7 +31,6 @@ import blusunrize.immersiveengineering.common.items.IEItemInterfaces; import blusunrize.immersiveengineering.common.items.IEItemInterfaces.IGuiItem; import blusunrize.immersiveengineering.common.items.ItemToolbox; -import blusunrize.immersiveengineering.common.util.network.MessageObstructedConnection; import com.mojang.authlib.GameProfile; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; @@ -47,31 +45,43 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.network.IGuiHandler; -import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint; import javax.annotation.Nonnull; import java.util.UUID; public class CommonProxy implements IGuiHandler { - public void preInit(){} + public void preInit() + { + } public void preInitEnd() { } + public void init() - {} + { + } public void initEnd() { } - public void postInit(){} + + public void postInit() + { + } public void postInitEnd() { } - public void serverStarting(){} - public void onWorldLoad(){} + + public void serverStarting() + { + } + + public void onWorldLoad() + { + } public static void openGuiForTile(@Nonnull EntityPlayer player, @Nonnull T tile) { @@ -81,68 +91,68 @@ public static void openGuiForTile(@Nonnull Ent public static void openGuiForItem(@Nonnull EntityPlayer player, @Nonnull EntityEquipmentSlot slot) { ItemStack stack = player.getItemStackFromSlot(slot); - if(stack.isEmpty() || !(stack.getItem() instanceof IGuiItem)) + if(stack.isEmpty()||!(stack.getItem() instanceof IGuiItem)) return; IGuiItem gui = (IGuiItem)stack.getItem(); - player.openGui(ImmersiveEngineering.instance, 100*slot.ordinal() + gui.getGuiID(stack), player.world, (int)player.posX,(int)player.posY,(int)player.posZ); + player.openGui(ImmersiveEngineering.instance, 100*slot.ordinal()+gui.getGuiID(stack), player.world, (int)player.posX, (int)player.posY, (int)player.posZ); } @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - if(ID>=Lib.GUIID_Base_Item) + if(ID >= Lib.GUIID_Base_Item) { EntityEquipmentSlot slot = EntityEquipmentSlot.values()[ID/100]; ID %= 100;//Slot determined, get actual ID ItemStack item = player.getItemStackFromSlot(slot); - if(!item.isEmpty() && item.getItem() instanceof IGuiItem && ((IGuiItem)item.getItem()).getGuiID(item)==ID) + if(!item.isEmpty()&&item.getItem() instanceof IGuiItem&&((IGuiItem)item.getItem()).getGuiID(item)==ID) { - if(ID == Lib.GUIID_Revolver && item.getItem() instanceof IEItemInterfaces.IBulletContainer) + if(ID==Lib.GUIID_Revolver&&item.getItem() instanceof IEItemInterfaces.IBulletContainer) return new ContainerRevolver(player.inventory, world, slot, item); - if(ID == Lib.GUIID_Toolbox && item.getItem() instanceof ItemToolbox) + if(ID==Lib.GUIID_Toolbox&&item.getItem() instanceof ItemToolbox) return new ContainerToolbox(player.inventory, world, slot, item); } } else { - TileEntity te = world.getTileEntity(new BlockPos(x,y,z)); + TileEntity te = world.getTileEntity(new BlockPos(x, y, z)); if(te instanceof IGuiTile) { Object gui = null; - if(ID==Lib.GUIID_CokeOven && te instanceof TileEntityCokeOven) - gui = new ContainerCokeOven(player.inventory, (TileEntityCokeOven) te); - if(ID==Lib.GUIID_AlloySmelter && te instanceof TileEntityAlloySmelter) - gui = new ContainerAlloySmelter(player.inventory, (TileEntityAlloySmelter) te); - if(ID==Lib.GUIID_BlastFurnace && te instanceof TileEntityBlastFurnace) - gui = new ContainerBlastFurnace(player.inventory, (TileEntityBlastFurnace) te); - if(ID==Lib.GUIID_WoodenCrate && te instanceof TileEntityWoodenCrate) - gui = new ContainerCrate(player.inventory, (TileEntityWoodenCrate) te); - if(ID==Lib.GUIID_Workbench && te instanceof TileEntityModWorkbench) - gui = new ContainerModWorkbench(player.inventory, (TileEntityModWorkbench) te); - if(ID==Lib.GUIID_Sorter && te instanceof TileEntitySorter) - gui = new ContainerSorter(player.inventory, (TileEntitySorter) te); - if(ID==Lib.GUIID_Squeezer && te instanceof TileEntitySqueezer) - gui = new ContainerSqueezer(player.inventory, (TileEntitySqueezer) te); - if(ID==Lib.GUIID_Fermenter && te instanceof TileEntityFermenter) - gui = new ContainerFermenter(player.inventory, (TileEntityFermenter) te); - if(ID==Lib.GUIID_Refinery && te instanceof TileEntityRefinery) - gui = new ContainerRefinery(player.inventory, (TileEntityRefinery) te); - if(ID==Lib.GUIID_ArcFurnace && te instanceof TileEntityArcFurnace) - gui = new ContainerArcFurnace(player.inventory, (TileEntityArcFurnace) te); - if(ID==Lib.GUIID_Assembler && te instanceof TileEntityAssembler) - gui = new ContainerAssembler(player.inventory, (TileEntityAssembler) te); - if(ID==Lib.GUIID_AutoWorkbench && te instanceof TileEntityAutoWorkbench) - gui = new ContainerAutoWorkbench(player.inventory, (TileEntityAutoWorkbench) te); - if(ID==Lib.GUIID_Mixer && te instanceof TileEntityMixer) - gui = new ContainerMixer(player.inventory, (TileEntityMixer) te); - if(ID==Lib.GUIID_Turret && te instanceof TileEntityTurret) - gui = new ContainerTurret(player.inventory, (TileEntityTurret) te); - if(ID==Lib.GUIID_FluidSorter && te instanceof TileEntityFluidSorter) - gui = new ContainerFluidSorter(player.inventory, (TileEntityFluidSorter) te); - if(ID==Lib.GUIID_Belljar && te instanceof TileEntityBelljar) - gui = new ContainerBelljar(player.inventory, (TileEntityBelljar) te); - if(ID==Lib.GUIID_ToolboxBlock && te instanceof TileEntityToolbox) - gui = new ContainerToolboxBlock(player.inventory, (TileEntityToolbox) te); + if(ID==Lib.GUIID_CokeOven&&te instanceof TileEntityCokeOven) + gui = new ContainerCokeOven(player.inventory, (TileEntityCokeOven)te); + if(ID==Lib.GUIID_AlloySmelter&&te instanceof TileEntityAlloySmelter) + gui = new ContainerAlloySmelter(player.inventory, (TileEntityAlloySmelter)te); + if(ID==Lib.GUIID_BlastFurnace&&te instanceof TileEntityBlastFurnace) + gui = new ContainerBlastFurnace(player.inventory, (TileEntityBlastFurnace)te); + if(ID==Lib.GUIID_WoodenCrate&&te instanceof TileEntityWoodenCrate) + gui = new ContainerCrate(player.inventory, (TileEntityWoodenCrate)te); + if(ID==Lib.GUIID_Workbench&&te instanceof TileEntityModWorkbench) + gui = new ContainerModWorkbench(player.inventory, (TileEntityModWorkbench)te); + if(ID==Lib.GUIID_Sorter&&te instanceof TileEntitySorter) + gui = new ContainerSorter(player.inventory, (TileEntitySorter)te); + if(ID==Lib.GUIID_Squeezer&&te instanceof TileEntitySqueezer) + gui = new ContainerSqueezer(player.inventory, (TileEntitySqueezer)te); + if(ID==Lib.GUIID_Fermenter&&te instanceof TileEntityFermenter) + gui = new ContainerFermenter(player.inventory, (TileEntityFermenter)te); + if(ID==Lib.GUIID_Refinery&&te instanceof TileEntityRefinery) + gui = new ContainerRefinery(player.inventory, (TileEntityRefinery)te); + if(ID==Lib.GUIID_ArcFurnace&&te instanceof TileEntityArcFurnace) + gui = new ContainerArcFurnace(player.inventory, (TileEntityArcFurnace)te); + if(ID==Lib.GUIID_Assembler&&te instanceof TileEntityAssembler) + gui = new ContainerAssembler(player.inventory, (TileEntityAssembler)te); + if(ID==Lib.GUIID_AutoWorkbench&&te instanceof TileEntityAutoWorkbench) + gui = new ContainerAutoWorkbench(player.inventory, (TileEntityAutoWorkbench)te); + if(ID==Lib.GUIID_Mixer&&te instanceof TileEntityMixer) + gui = new ContainerMixer(player.inventory, (TileEntityMixer)te); + if(ID==Lib.GUIID_Turret&&te instanceof TileEntityTurret) + gui = new ContainerTurret(player.inventory, (TileEntityTurret)te); + if(ID==Lib.GUIID_FluidSorter&&te instanceof TileEntityFluidSorter) + gui = new ContainerFluidSorter(player.inventory, (TileEntityFluidSorter)te); + if(ID==Lib.GUIID_Belljar&&te instanceof TileEntityBelljar) + gui = new ContainerBelljar(player.inventory, (TileEntityBelljar)te); + if(ID==Lib.GUIID_ToolboxBlock&&te instanceof TileEntityToolbox) + gui = new ContainerToolboxBlock(player.inventory, (TileEntityToolbox)te); if(gui!=null) ((IGuiTile)te).onGuiOpened(player, false); return gui; @@ -160,33 +170,43 @@ public Object getClientGuiElement(int ID, EntityPlayer player, World world, int public void handleTileSound(SoundEvent soundEvent, TileEntity tile, boolean tileActive, float volume, float pitch) { } + public void stopTileSound(String soundName, TileEntity tile) { } + public void spawnBucketWheelFX(TileEntityBucketWheel tile, ItemStack stack) { } + public void spawnSparkFX(World world, double x, double y, double z, double mx, double my, double mz) { } + public void spawnRedstoneFX(World world, double x, double y, double z, double mx, double my, double mz, float size, float r, float g, float b) { } + public void spawnFluidSplashFX(World world, FluidStack fs, double x, double y, double z, double mx, double my, double mz) { } + public void spawnBubbleFX(World world, FluidStack fs, double x, double y, double z, double mx, double my, double mz) { } + public void spawnFractalFX(World world, double x, double y, double z, Vec3d direction, double scale, int prefixColour, float[][] colour) { } + public void draw3DBlockCauldron() { } + public void drawSpecificFluidPipe(String configuration) { } + public boolean armorHasCustomModel(ItemStack stack) { return false; @@ -205,18 +225,22 @@ public String[] splitStringOnWidth(String s, int w) { return new String[]{s}; } + public World getClientWorld() { return null; } + public EntityPlayer getClientPlayer() { return null; } + public String getNameFromUUID(String uuid) { return FMLCommonHandler.instance().getMinecraftServerInstance().getMinecraftSessionService().fillProfileProperties(new GameProfile(UUID.fromString(uuid.replaceAll("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5")), null), false).getName(); } + public void reInitGui() { } @@ -224,12 +248,15 @@ public void reInitGui() public void removeStateFromSmartModelCache(IExtendedBlockState state) { } + public void removeStateFromConnectionModelCache(IExtendedBlockState state) { } + public void clearConnectionModelCache() { } + public void clearRenderCaches() { } diff --git a/src/main/java/blusunrize/immersiveengineering/common/Config.java b/src/main/java/blusunrize/immersiveengineering/common/Config.java index e7e9ab5b65..619d35fe6b 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/Config.java +++ b/src/main/java/blusunrize/immersiveengineering/common/Config.java @@ -48,7 +48,7 @@ public class Config public static boolean seaonal_festive = false; - @net.minecraftforge.common.config.Config(modid=ImmersiveEngineering.MODID) + @net.minecraftforge.common.config.Config(modid = ImmersiveEngineering.MODID) public static class IEConfig { //Wire Stuff @@ -109,8 +109,8 @@ public static class IEConfig public static boolean stencilBufferEnabled = true; - @Comment({"A list of all mods that IE has integrated compatability for","Setting any of these to false disables the respective compat"}) - public static Map compat = Maps.newHashMap(Maps.toMap(IECompatModule.moduleClasses.keySet(), (s)->Boolean.TRUE)); + @Comment({"A list of all mods that IE has integrated compatability for", "Setting any of these to false disables the respective compat"}) + public static Map compat = Maps.newHashMap(Maps.toMap(IECompatModule.moduleClasses.keySet(), (s) -> Boolean.TRUE)); @Comment({"A config setting to enable debug features. These features may vary between releases, may cause crashes, and are unsupported. Do not enable unless asked to by a developer of IE."}) public static boolean enableDebug = false; @@ -155,7 +155,7 @@ public static class Machines @Comment({"Output modifier for the energy created by the Thermoelectric Generator"}) public static double thermoelectric_output = 1d; @Comment({"The Flux that will be output by the lightning rod when it is struck"}) - public static int lightning_output = 4 * 4000000; + public static int lightning_output = 4*4000000; @Comment({"The Flux per tick that the Diesel Generator will output. The burn time of the fuel determines the total output"}) @Mapped(mapClass = Config.class, mapName = "manual_int") public static int dieselGen_output = 4096; @@ -398,7 +398,7 @@ public static class Tools @Comment({"A whitelist of armor pieces to allow attaching the capacitor backpack, formatting: [mod id]:[item name]"}) public static String[] powerpack_whitelist = new String[]{}; @Comment({"A blacklist of armor pieces to allow attaching the capacitor backpack, formatting: [mod id]:[item name]. Whitelist has priority over this"}) - public static String[] powerpack_blacklist = new String[]{"embers:ashen_cloak_chest", "ic2:batpack","ic2:cf_pack","ic2:energy_pack","ic2:jetpack","ic2:jetpack_electric","ic2:lappack"}; + public static String[] powerpack_blacklist = new String[]{"embers:ashen_cloak_chest", "ic2:batpack", "ic2:cf_pack", "ic2:energy_pack", "ic2:jetpack", "ic2:jetpack_electric", "ic2:lappack"}; @Comment({"A whitelist of tools allowed in the toolbox, formatting: [mod id]:[item name]"}) public static String[] toolbox_tools = new String[]{}; @@ -411,6 +411,7 @@ public static class Tools } static Configuration config; + public static void preInit(FMLPreInitializationEvent event) { onConfigUpdate(); @@ -451,7 +452,7 @@ private static void onConfigUpdate() WireType.wireLossRatio = IEConfig.wireLossRatio; WireType.wireTransferRate = IEConfig.wireTransferRate; WireType.wireColouration = - (IEConfig.wireColouration.length!=IEConfig.wireColourationDefault.length)?IEConfig.wireColourationDefault:IEConfig.wireColouration; + (IEConfig.wireColouration.length!=IEConfig.wireColourationDefault.length)?IEConfig.wireColourationDefault: IEConfig.wireColouration; WireType.wireLength = IEConfig.wireLength; } @@ -471,10 +472,11 @@ public static void checkMappedValues(Class confClass) { Map map = (Map)mapField.get(null); if(map!=null) - map.put(f.getName(),f.get(null)); + map.put(f.getName(), f.get(null)); } } - }catch(Exception e){ + } catch(Exception e) + { e.printStackTrace(); } else if(f.getAnnotation(SubConfig.class)!=null) @@ -487,17 +489,21 @@ else if(f.getAnnotation(SubConfig.class)!=null) public @interface Mapped { Class mapClass(); + String mapName(); } @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface SubConfig - {} + { + } @SubscribeEvent - public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent ev) { - if (ev.getModID().equals(ImmersiveEngineering.MODID)) { + public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent ev) + { + if(ev.getModID().equals(ImmersiveEngineering.MODID)) + { ConfigManager.sync(ImmersiveEngineering.MODID, net.minecraftforge.common.config.Config.Type.INSTANCE); onConfigUpdate(); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/EventHandler.java b/src/main/java/blusunrize/immersiveengineering/common/EventHandler.java index 0cf22d8bf4..c392c8180d 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/EventHandler.java +++ b/src/main/java/blusunrize/immersiveengineering/common/EventHandler.java @@ -125,15 +125,17 @@ public void onLoad(WorldEvent.Load event) */ // } ImmersiveEngineering.proxy.onWorldLoad(); - if (IEConfig.blocksBreakWires) + if(IEConfig.blocksBreakWires) event.getWorld().addEventListener(ImmersiveNetHandler.INSTANCE.LISTENER); } + //transferPerTick @SubscribeEvent public void onSave(WorldEvent.Save event) { IESaveData.setDirty(0); } + @SubscribeEvent public void onUnload(WorldEvent.Unload event) { @@ -145,29 +147,31 @@ public void onCapabilitiesAttach(AttachCapabilitiesEvent event) { if(event.getObject() instanceof EntityMinecart) { - EntityMinecart entityMinecart = (EntityMinecart) event.getObject(); + EntityMinecart entityMinecart = (EntityMinecart)event.getObject(); event.addCapability(new ResourceLocation("immersiveengineering:shader"), new ShaderWrapper_Direct("immersiveengineering:minecart")); } } + @SubscribeEvent public void onMinecartInteraction(MinecartInteractEvent event) { - if(!event.getPlayer().world.isRemote && !event.getItem().isEmpty() && event.getItem().getItem() instanceof IShaderItem) + if(!event.getPlayer().world.isRemote&&!event.getItem().isEmpty()&&event.getItem().getItem() instanceof IShaderItem) if(event.getMinecart().hasCapability(CapabilityShader.SHADER_CAPABILITY, null)) // if(event.getMinecart().hasCapability(CapabilityHandler_CartShaders.SHADER_CAPABILITY, null)) { ShaderWrapper handler = event.getMinecart().getCapability(CapabilityShader.SHADER_CAPABILITY, null); - if(handler != null) + if(handler!=null) { handler.setShaderItem(Utils.copyStackWithAmount(event.getItem(), 1)); - ImmersiveEngineering.packetHandler.sendTo(new MessageMinecartShaderSync(event.getMinecart(), handler), (EntityPlayerMP) event.getPlayer()); + ImmersiveEngineering.packetHandler.sendTo(new MessageMinecartShaderSync(event.getMinecart(), handler), (EntityPlayerMP)event.getPlayer()); event.setCanceled(true); } } } - public static List lootInjections = Arrays.asList(new ResourceLocation(ImmersiveEngineering.MODID, "chests/stronghold_library"),new ResourceLocation(ImmersiveEngineering.MODID, "chests/village_blacksmith")); + public static List lootInjections = Arrays.asList(new ResourceLocation(ImmersiveEngineering.MODID, "chests/stronghold_library"), new ResourceLocation(ImmersiveEngineering.MODID, "chests/village_blacksmith")); static Field f_lootEntries; + @SubscribeEvent public void lootLoad(LootTableLoadEvent event) { @@ -177,7 +181,7 @@ public void lootLoad(LootTableLoadEvent event) { LootPool injectPool = Utils.loadBuiltinLootTable(inject, event.getLootTableManager()).getPool("immersiveengineering_loot_inject"); LootPool mainPool = event.getTable().getPool("main"); - if(injectPool!=null && mainPool!=null) + if(injectPool!=null&&mainPool!=null) try { if(f_lootEntries==null) @@ -187,11 +191,12 @@ public void lootLoad(LootTableLoadEvent event) } if(f_lootEntries!=null) { - List entryList = (List) f_lootEntries.get(injectPool); + List entryList = (List)f_lootEntries.get(injectPool); for(LootEntry entry : entryList) mainPool.addEntry(entry); } - }catch(Exception e){ + } catch(Exception e) + { e.printStackTrace(); } } @@ -200,8 +205,8 @@ public void lootLoad(LootTableLoadEvent event) @SubscribeEvent public void onEntityJoiningWorld(EntityJoinWorldEvent event) { - if(event.getEntity().world.isRemote && event.getEntity() instanceof EntityMinecart && event.getEntity().hasCapability(CapabilityShader.SHADER_CAPABILITY,null)) - ImmersiveEngineering.packetHandler.sendToServer(new MessageMinecartShaderSync(event.getEntity(),null)); + if(event.getEntity().world.isRemote&&event.getEntity() instanceof EntityMinecart&&event.getEntity().hasCapability(CapabilityShader.SHADER_CAPABILITY, null)) + ImmersiveEngineering.packetHandler.sendToServer(new MessageMinecartShaderSync(event.getEntity(), null)); } // @SubscribeEvent // public void onEntityInteract(EntityInteractEvent event) @@ -211,29 +216,29 @@ public void onEntityJoiningWorld(EntityJoinWorldEvent event) // } - @SubscribeEvent public void onWorldTick(WorldTickEvent event) { - if (event.phase==TickEvent.Phase.START && validateConnsNextTick && FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER) + if(event.phase==TickEvent.Phase.START&&validateConnsNextTick&&FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER) { boolean validateConnections = IEConfig.validateConnections; int invalidConnectionsDropped = 0; - for (int dim:ImmersiveNetHandler.INSTANCE.getRelevantDimensions()) + for(int dim : ImmersiveNetHandler.INSTANCE.getRelevantDimensions()) { - if (!validateConnections) + if(!validateConnections) { continue; } World world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(dim); - if (world==null) { + if(world==null) + { ImmersiveNetHandler.INSTANCE.directConnections.remove(dim); continue; } - for (Connection con:ImmersiveNetHandler.INSTANCE.getAllConnections(world)) + for(Connection con : ImmersiveNetHandler.INSTANCE.getAllConnections(world)) { - if (!(world.getTileEntity(con.start) instanceof IImmersiveConnectable - && world.getTileEntity(con.end) instanceof IImmersiveConnectable)) + if(!(world.getTileEntity(con.start) instanceof IImmersiveConnectable + &&world.getTileEntity(con.end) instanceof IImmersiveConnectable)) { ImmersiveNetHandler.INSTANCE.removeConnection(world, con); invalidConnectionsDropped++; @@ -243,33 +248,33 @@ public void onWorldTick(WorldTickEvent event) } int invalidProxies = 0; Set toRemove = new HashSet<>(); - for (Entry e:ImmersiveNetHandler.INSTANCE.proxies.entrySet()) + for(Entry e : ImmersiveNetHandler.INSTANCE.proxies.entrySet()) { - if (!validateConnections) + if(!validateConnections) { continue; } DimensionBlockPos p = e.getKey(); World w = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(p.dimension); - if (w!=null&&w.isBlockLoaded(p)) + if(w!=null&&w.isBlockLoaded(p)) toRemove.add(p); - if (validateConnections&&w==null) + if(validateConnections&&w==null) { invalidProxies++; toRemove.add(p); continue; } - if (validateConnections&&!(w.getTileEntity(p) instanceof IImmersiveConnectable)) + if(validateConnections&&!(w.getTileEntity(p) instanceof IImmersiveConnectable)) { invalidProxies++; toRemove.add(p); } } - if (invalidProxies>0) + if(invalidProxies > 0) IELogger.info("Removed "+invalidProxies+" invalid connector proxies (used to transfer power through unloaded chunks)"); validateConnsNextTick = false; } - if (event.phase==TickEvent.Phase.END && ArcRecyclingThreadHandler.recipesToAdd!=null) + if(event.phase==TickEvent.Phase.END&&ArcRecyclingThreadHandler.recipesToAdd!=null) { for(ArcFurnaceRecipe recipe : ArcRecyclingThreadHandler.recipesToAdd) { @@ -278,23 +283,23 @@ public void onWorldTick(WorldTickEvent event) } ArcRecyclingThreadHandler.recipesToAdd = null; } - if(event.phase==TickEvent.Phase.END && FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER) + if(event.phase==TickEvent.Phase.END&&FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER) { int dim = event.world.provider.getDimension(); for(Entry e : ImmersiveNetHandler.INSTANCE.getTransferedRates(dim).entrySet()) - if(e.getValue()>e.getKey().cableType.getTransferRate()) + if(e.getValue() > e.getKey().cableType.getTransferRate()) { if(event.world instanceof WorldServer) for(Vec3d vec : e.getKey().getSubVertices(event.world)) - ((WorldServer)event.world).spawnParticle(EnumParticleTypes.FLAME, false, vec.x,vec.y,vec.z, 0, 0,.02,0, 1, new int[0]); + ((WorldServer)event.world).spawnParticle(EnumParticleTypes.FLAME, false, vec.x, vec.y, vec.z, 0, 0, .02, 0, 1, new int[0]); ImmersiveNetHandler.INSTANCE.removeConnection(event.world, e.getKey()); } ImmersiveNetHandler.INSTANCE.getTransferedRates(dim).clear(); - if (!REMOVE_FROM_TICKING.isEmpty()) + if(!REMOVE_FROM_TICKING.isEmpty()) { event.world.tickableTileEntities.removeAll(REMOVE_FROM_TICKING); - REMOVE_FROM_TICKING.removeIf((te) -> te.getWorld().provider.getDimension() == dim); + REMOVE_FROM_TICKING.removeIf((te) -> te.getWorld().provider.getDimension()==dim); } } if(event.phase==TickEvent.Phase.START) @@ -310,14 +315,14 @@ public void onWorldTick(WorldTickEvent event) itExplosion.remove(); } } - while (!requestedBlockUpdates.isEmpty()) + while(!requestedBlockUpdates.isEmpty()) { Pair curr = requestedBlockUpdates.poll(); World w = DimensionManager.getWorld(curr.getLeft()); if(w!=null) { IBlockState state = w.getBlockState(curr.getRight()); - w.notifyBlockUpdate(curr.getRight(), state,state, 3); + w.notifyBlockUpdate(curr.getRight(), state, state, 3); } } } @@ -329,13 +334,14 @@ public void onLogin(PlayerLoggedInEvent event) ExcavatorHandler.allowPackets = true; if(!event.player.world.isRemote) { - HashMap packetMap = new HashMap(); - for(Entry e: ExcavatorHandler.mineralList.entrySet()) - if(e.getKey()!=null && e.getValue()!=null) + HashMap packetMap = new HashMap(); + for(Entry e : ExcavatorHandler.mineralList.entrySet()) + if(e.getKey()!=null&&e.getValue()!=null) packetMap.put(e.getKey(), e.getValue()); ImmersiveEngineering.packetHandler.sendToAll(new MessageMineralListSync(packetMap)); } } + @SubscribeEvent(priority = EventPriority.HIGH) public void onLogout(PlayerLoggedOutEvent event) { @@ -355,29 +361,33 @@ public void onLogout(PlayerLoggedOutEvent event) public static HashMap crusherMap = new HashMap(); public static HashSet> listOfBoringBosses = new HashSet(); - static{ + + static + { listOfBoringBosses.add(EntityWither.class); } - @SubscribeEvent(priority=EventPriority.LOWEST) + + @SubscribeEvent(priority = EventPriority.LOWEST) public void onLivingDropsLowest(LivingDropsEvent event) { - if(!event.isCanceled() && Lib.DMG_Crusher.equals(event.getSource().getDamageType())) + if(!event.isCanceled()&&Lib.DMG_Crusher.equals(event.getSource().getDamageType())) { TileEntityCrusher crusher = crusherMap.get(event.getEntityLiving().getUniqueID()); if(crusher!=null) { - for(EntityItem item: event.getDrops()) - if(item!=null && !item.getItem().isEmpty()) + for(EntityItem item : event.getDrops()) + if(item!=null&&!item.getItem().isEmpty()) crusher.doProcessOutput(item.getItem()); crusherMap.remove(event.getEntityLiving().getUniqueID()); event.setCanceled(true); } } } + @SubscribeEvent public void onLivingDrops(LivingDropsEvent event) { - if(!event.isCanceled() && !event.getEntityLiving().isNonBoss()) + if(!event.isCanceled()&&!event.getEntityLiving().isNonBoss()) { EnumRarity r = EnumRarity.EPIC; for(Class boring : listOfBoringBosses) @@ -394,9 +404,9 @@ public void onLivingAttacked(LivingAttackEvent event) { if(event.getEntityLiving() instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.getEntityLiving(); + EntityPlayer player = (EntityPlayer)event.getEntityLiving(); ItemStack activeStack = player.getActiveItemStack(); - if(!activeStack.isEmpty() && activeStack.getItem() instanceof ItemIEShield && event.getAmount()>=3 && Utils.canBlockDamageSource(player, event.getSource())) + if(!activeStack.isEmpty()&&activeStack.getItem() instanceof ItemIEShield&&event.getAmount() >= 3&&Utils.canBlockDamageSource(player, event.getSource())) { float amount = event.getAmount(); ((ItemIEShield)activeStack.getItem()).hitShield(activeStack, player, event.getSource(), amount, event); @@ -405,23 +415,26 @@ public void onLivingAttacked(LivingAttackEvent event) } - @SubscribeEvent(priority=EventPriority.LOWEST) + @SubscribeEvent(priority = EventPriority.LOWEST) public void onLivingHurt(LivingHurtEvent event) { - if(event.getSource().isFireDamage() && event.getEntityLiving().getActivePotionEffect(IEPotions.flammable)!=null) + if(event.getSource().isFireDamage()&&event.getEntityLiving().getActivePotionEffect(IEPotions.flammable)!=null) { int amp = event.getEntityLiving().getActivePotionEffect(IEPotions.flammable).getAmplifier(); - float mod = 1.5f + ((amp*amp)*.5f); + float mod = 1.5f+((amp*amp)*.5f); event.setAmount(event.getAmount()*mod); } if(("flux".equals(event.getSource().getDamageType())||IEDamageSources.razorShock.equals(event.getSource())|| - event.getSource() instanceof ElectricDamageSource) && event.getEntityLiving().getActivePotionEffect(IEPotions.conductive)!=null) + event.getSource() instanceof ElectricDamageSource)&&event.getEntityLiving().getActivePotionEffect(IEPotions.conductive)!=null) { int amp = event.getEntityLiving().getActivePotionEffect(IEPotions.conductive).getAmplifier(); - float mod = 1.5f + ((amp*amp)*.5f); + float mod = 1.5f+((amp*amp)*.5f); event.setAmount(event.getAmount()*mod); } + if(!event.isCanceled()&&!event.getEntityLiving().isNonBoss()&&event.getAmount() >= event.getEntityLiving().getHealth()&&event.getSource().getTrueSource() instanceof EntityPlayer&&((EntityPlayer)event.getSource().getTrueSource()).getHeldItem(EnumHand.MAIN_HAND).getItem() instanceof ItemDrill) + Utils.unlockIEAdvancement((EntityPlayer)event.getSource().getTrueSource(), "main/secret_drillbreak"); } + @SubscribeEvent public void onLivingJump(LivingJumpEvent event) { @@ -434,10 +447,11 @@ else if(event.getEntityLiving().getActivePotionEffect(IEPotions.concreteFeet)!=n event.getEntityLiving().motionZ = 0; } } + @SubscribeEvent public void onLivingUpdate(LivingUpdateEvent event) { - if(event.getEntityLiving() instanceof EntityPlayer && !event.getEntityLiving().getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty() && ItemNBTHelper.hasKey(event.getEntityLiving().getItemStackFromSlot(EntityEquipmentSlot.CHEST), Lib.NBT_Powerpack)) + if(event.getEntityLiving() instanceof EntityPlayer&&!event.getEntityLiving().getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty()&&ItemNBTHelper.hasKey(event.getEntityLiving().getItemStackFromSlot(EntityEquipmentSlot.CHEST), Lib.NBT_Powerpack)) { ItemStack powerpack = ItemNBTHelper.getItemStack(event.getEntityLiving().getItemStackFromSlot(EntityEquipmentSlot.CHEST), Lib.NBT_Powerpack); if(!powerpack.isEmpty()) @@ -451,23 +465,24 @@ public void onEnderTeleport(EnderTeleportEvent event) { if(event.getEntityLiving().isCreatureType(EnumCreatureType.MONSTER, false)) { - synchronized (interdictionTiles) { + synchronized(interdictionTiles) + { Iterator it = interdictionTiles.iterator(); while(it.hasNext()) { ISpawnInterdiction interdictor = it.next(); if(interdictor instanceof TileEntity) { - if(((TileEntity)interdictor).isInvalid() || ((TileEntity)interdictor).getWorld()==null) + if(((TileEntity)interdictor).isInvalid()||((TileEntity)interdictor).getWorld()==null) it.remove(); - else if( ((TileEntity)interdictor).getWorld().provider.getDimension()== event.getEntity().world.provider.getDimension() && ((TileEntity)interdictor).getDistanceSq(event.getEntity().posX, event.getEntity().posY, event.getEntity().posZ)<=interdictor.getInterdictionRangeSquared()) + else if(((TileEntity)interdictor).getWorld().provider.getDimension()==event.getEntity().world.provider.getDimension()&&((TileEntity)interdictor).getDistanceSq(event.getEntity().posX, event.getEntity().posY, event.getEntity().posZ) <= interdictor.getInterdictionRangeSquared()) event.setCanceled(true); } else if(interdictor instanceof Entity) { - if(((Entity)interdictor).isDead || ((Entity)interdictor).world==null) + if(((Entity)interdictor).isDead||((Entity)interdictor).world==null) it.remove(); - else if(((Entity)interdictor).world.provider.getDimension()== event.getEntity().world.provider.getDimension() && ((Entity)interdictor).getDistanceSq(event.getEntity())<=interdictor.getInterdictionRangeSquared()) + else if(((Entity)interdictor).world.provider.getDimension()==event.getEntity().world.provider.getDimension()&&((Entity)interdictor).getDistanceSq(event.getEntity()) <= interdictor.getInterdictionRangeSquared()) event.setCanceled(true); } } @@ -476,30 +491,32 @@ else if(((Entity)interdictor).world.provider.getDimension()== event.getEntity(). if(event.getEntityLiving().getActivePotionEffect(IEPotions.stunned)!=null) event.setCanceled(true); } + @SubscribeEvent public void onEntitySpawnCheck(LivingSpawnEvent.CheckSpawn event) { - if(event.getResult() == Event.Result.ALLOW||event.getResult() == Event.Result.DENY) + if(event.getResult()==Event.Result.ALLOW||event.getResult()==Event.Result.DENY) return; if(event.getEntityLiving().isCreatureType(EnumCreatureType.MONSTER, false)) { - synchronized (interdictionTiles) { + synchronized(interdictionTiles) + { Iterator it = interdictionTiles.iterator(); while(it.hasNext()) { ISpawnInterdiction interdictor = it.next(); if(interdictor instanceof TileEntity) { - if(((TileEntity)interdictor).isInvalid() || ((TileEntity)interdictor).getWorld()==null) + if(((TileEntity)interdictor).isInvalid()||((TileEntity)interdictor).getWorld()==null) it.remove(); - else if( ((TileEntity)interdictor).getWorld().provider.getDimension()== event.getEntity().world.provider.getDimension() && ((TileEntity)interdictor).getDistanceSq(event.getEntity().posX, event.getEntity().posY, event.getEntity().posZ)<=interdictor.getInterdictionRangeSquared()) + else if(((TileEntity)interdictor).getWorld().provider.getDimension()==event.getEntity().world.provider.getDimension()&&((TileEntity)interdictor).getDistanceSq(event.getEntity().posX, event.getEntity().posY, event.getEntity().posZ) <= interdictor.getInterdictionRangeSquared()) event.setResult(Event.Result.DENY); } else if(interdictor instanceof Entity) { - if(((Entity)interdictor).isDead || ((Entity)interdictor).world==null) + if(((Entity)interdictor).isDead||((Entity)interdictor).world==null) it.remove(); - else if(((Entity)interdictor).world.provider.getDimension()== event.getEntity().world.provider.getDimension() && ((Entity)interdictor).getDistanceSq(event.getEntity())<=interdictor.getInterdictionRangeSquared()) + else if(((Entity)interdictor).world.provider.getDimension()==event.getEntity().world.provider.getDimension()&&((Entity)interdictor).getDistanceSq(event.getEntity()) <= interdictor.getInterdictionRangeSquared()) event.setResult(Event.Result.DENY); } } @@ -512,41 +529,42 @@ public void digSpeedEvent(PlayerEvent.BreakSpeed event) { ItemStack current = event.getEntityPlayer().getHeldItem(EnumHand.MAIN_HAND); //Stop the combustion drill from working underwater - if(!current.isEmpty() && current.getItem().equals(IEContent.itemDrill) && current.getItemDamage()==0 && event.getEntityPlayer().isInsideOfMaterial(Material.WATER)) - if( ((ItemDrill)IEContent.itemDrill).getUpgrades(current).getBoolean("waterproof")) + if(!current.isEmpty()&¤t.getItem().equals(IEContent.itemDrill)&¤t.getItemDamage()==0&&event.getEntityPlayer().isInsideOfMaterial(Material.WATER)) + if(((ItemDrill)IEContent.itemDrill).getUpgrades(current).getBoolean("waterproof")) event.setNewSpeed(event.getOriginalSpeed()*5); else event.setCanceled(true); - if(event.getState().getBlock()==IEContent.blockMetalDecoration2 && IEContent.blockMetalDecoration2.getMetaFromState(event.getState())==BlockTypes_MetalDecoration2.RAZOR_WIRE.getMeta()) - if(!OreDictionary.itemMatches(new ItemStack(IEContent.itemTool,1,1), current, false)) + if(event.getState().getBlock()==IEContent.blockMetalDecoration2&&IEContent.blockMetalDecoration2.getMetaFromState(event.getState())==BlockTypes_MetalDecoration2.RAZOR_WIRE.getMeta()) + if(!OreDictionary.itemMatches(new ItemStack(IEContent.itemTool, 1, 1), current, false)) event.setCanceled(true); TileEntity te = event.getEntityPlayer().getEntityWorld().getTileEntity(event.getPos()); - if(te instanceof IEntityProof && !((IEntityProof)te).canEntityDestroy(event.getEntityPlayer())) + if(te instanceof IEntityProof&&!((IEntityProof)te).canEntityDestroy(event.getEntityPlayer())) event.setCanceled(true); } + @SubscribeEvent public void onAnvilChange(AnvilUpdateEvent event) { - if(!event.getLeft().isEmpty() && event.getLeft().getItem() instanceof IDrillHead && ((IDrillHead) event.getLeft().getItem()).getHeadDamage(event.getLeft())>0) + if(!event.getLeft().isEmpty()&&event.getLeft().getItem() instanceof IDrillHead&&((IDrillHead)event.getLeft().getItem()).getHeadDamage(event.getLeft()) > 0) { - if(!event.getRight().isEmpty() && event.getLeft().getItem().getIsRepairable(event.getLeft(), event.getRight())) + if(!event.getRight().isEmpty()&&event.getLeft().getItem().getIsRepairable(event.getLeft(), event.getRight())) { event.setOutput(event.getLeft().copy()); int repair = Math.min( ((IDrillHead)event.getOutput().getItem()).getHeadDamage(event.getOutput()), - ((IDrillHead) event.getOutput().getItem()).getMaximumHeadDamage(event.getOutput())/4); + ((IDrillHead)event.getOutput().getItem()).getMaximumHeadDamage(event.getOutput())/4); int cost = 0; - for(; repair>0&& cost < event.getRight().getCount(); ++cost) + for(; repair > 0&&cost < event.getRight().getCount(); ++cost) { - ((IDrillHead) event.getOutput().getItem()).damageHead(event.getOutput(), -repair); + ((IDrillHead)event.getOutput().getItem()).damageHead(event.getOutput(), -repair); event.setCost(Math.max(1, repair/200)); repair = Math.min( - ((IDrillHead) event.getOutput().getItem()).getHeadDamage(event.getOutput()), - ((IDrillHead) event.getOutput().getItem()).getMaximumHeadDamage(event.getOutput())/4); + ((IDrillHead)event.getOutput().getItem()).getHeadDamage(event.getOutput()), + ((IDrillHead)event.getOutput().getItem()).getMaximumHeadDamage(event.getOutput())/4); } event.setMaterialCost(cost); - if(event.getName()==null || event.getName().isEmpty()) + if(event.getName()==null||event.getName().isEmpty()) { if(event.getLeft().hasDisplayName()) { @@ -554,7 +572,7 @@ public void onAnvilChange(AnvilUpdateEvent event) event.getOutput().clearCustomName(); } } - else if (!event.getName().equals(event.getLeft().getDisplayName())) + else if(!event.getName().equals(event.getLeft().getDisplayName())) { event.setCost(event.getCost()+5); if(event.getLeft().hasDisplayName()) @@ -564,12 +582,16 @@ else if (!event.getName().equals(event.getLeft().getDisplayName())) } } } + @SubscribeEvent(priority = EventPriority.LOWEST) - public void breakLast(BlockEvent.BreakEvent event) { - if (event.getState().getBlock() instanceof BlockIEMultiblock) { + public void breakLast(BlockEvent.BreakEvent event) + { + if(event.getState().getBlock() instanceof BlockIEMultiblock) + { TileEntity te = event.getWorld().getTileEntity(event.getPos()); - if (te instanceof TileEntityMultiblockPart) { - ((TileEntityMultiblockPart) te).onlyLocalDissassembly = event.getWorld().getTotalWorldTime(); + if(te instanceof TileEntityMultiblockPart) + { + ((TileEntityMultiblockPart)te).onlyLocalDissassembly = event.getWorld().getTotalWorldTime(); } } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/IEContent.java b/src/main/java/blusunrize/immersiveengineering/common/IEContent.java index c924e55d86..679356033f 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/IEContent.java +++ b/src/main/java/blusunrize/immersiveengineering/common/IEContent.java @@ -319,7 +319,7 @@ public int quantityDropped(IBlockState state, int fortune, Random random) itemPowerpack = new ItemPowerpack(); itemShield = new ItemIEShield(); - itemFakeIcons = new ItemIEBase("fake_icon", 1, "birthday", "lucky") + itemFakeIcons = new ItemIEBase("fake_icon", 1, "birthday", "lucky", "drillbreak") { @Override public void getSubItems(CreativeTabs tab, NonNullList list) diff --git a/src/main/java/blusunrize/immersiveengineering/common/IERecipes.java b/src/main/java/blusunrize/immersiveengineering/common/IERecipes.java index 9e78e33cb4..3db55837eb 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/IERecipes.java +++ b/src/main/java/blusunrize/immersiveengineering/common/IERecipes.java @@ -64,8 +64,8 @@ public static void initCraftingRecipes(IForgeRegistry registry) registry.register(new RecipeShaderBags().setRegistryName(ImmersiveEngineering.MODID, "shader_bags")); registry.register(new RecipeEarmuffs().setRegistryName(ImmersiveEngineering.MODID, "earmuffs")); registry.register(new RecipePowerpack().setRegistryName(ImmersiveEngineering.MODID, "powerpack")); - final ItemStack stripCurtain = new ItemStack(IEContent.blockClothDevice,1,BlockTypes_ClothDevice.STRIPCURTAIN.getMeta()); - registry.register(new RecipeRGBColouration((s)->(OreDictionary.itemMatches(stripCurtain,s,true)), (s)->(ItemNBTHelper.hasKey(s,"colour")?ItemNBTHelper.getInt(s,"colour"):0xffffff), (s, i)->ItemNBTHelper.setInt(s, "colour", i) ).setRegistryName(ImmersiveEngineering.MODID, "stripcurtain_colour")); + final ItemStack stripCurtain = new ItemStack(IEContent.blockClothDevice, 1, BlockTypes_ClothDevice.STRIPCURTAIN.getMeta()); + registry.register(new RecipeRGBColouration((s) -> (OreDictionary.itemMatches(stripCurtain, s, true)), (s) -> (ItemNBTHelper.hasKey(s, "colour")?ItemNBTHelper.getInt(s, "colour"): 0xffffff), (s, i) -> ItemNBTHelper.setInt(s, "colour", i)).setRegistryName(ImmersiveEngineering.MODID, "stripcurtain_colour")); } public static void addShapelessOredictRecipe(String registryName, ItemStack output, Object... recipe) @@ -92,17 +92,17 @@ public static void initBlueprintRecipes() // //MATERIALS // - BlueprintCraftingRecipe.addRecipe("components", new ItemStack(IEContent.itemMaterial,1,8), "plateIron","plateIron","ingotCopper"); - BlueprintCraftingRecipe.addRecipe("components", new ItemStack(IEContent.itemMaterial,1,9), "plateSteel","plateSteel","ingotCopper"); - BlueprintCraftingRecipe.addRecipe("components", new ItemStack(IEContent.itemMaterial,3,26), "blockGlass","wireCopper","wireCopper","dustRedstone"); - BlueprintCraftingRecipe.addRecipe("components", new ItemStack(IEContent.itemMaterial,1,27), new ItemStack(IEContent.blockStoneDecoration,1, BlockTypes_StoneDecoration.INSULATING_GLASS.getMeta()),"plateCopper","electronTube","electronTube"); + BlueprintCraftingRecipe.addRecipe("components", new ItemStack(IEContent.itemMaterial, 1, 8), "plateIron", "plateIron", "ingotCopper"); + BlueprintCraftingRecipe.addRecipe("components", new ItemStack(IEContent.itemMaterial, 1, 9), "plateSteel", "plateSteel", "ingotCopper"); + BlueprintCraftingRecipe.addRecipe("components", new ItemStack(IEContent.itemMaterial, 3, 26), "blockGlass", "wireCopper", "wireCopper", "dustRedstone"); + BlueprintCraftingRecipe.addRecipe("components", new ItemStack(IEContent.itemMaterial, 1, 27), new ItemStack(IEContent.blockStoneDecoration, 1, BlockTypes_StoneDecoration.INSULATING_GLASS.getMeta()), "plateCopper", "electronTube", "electronTube"); // //MOLDS // - for(int i=0; i oreOutputModifier = new HashMap(); public static HashMap oreOutputSecondaries = new HashMap(); public static ArrayList hammerCrushingList = new ArrayList(); + public static void initCrusherRecipes() { - oreOutputSecondaries.put("Iron", new Object[]{"dustNickel",.1f}); - oreOutputSecondaries.put("Gold", new Object[]{"crystalCinnabar",.05f}); - oreOutputSecondaries.put("Copper", new Object[]{"dustGold",.1f}); - oreOutputSecondaries.put("Lead", new Object[]{"dustSilver",.1f}); - oreOutputSecondaries.put("Silver", new Object[]{"dustLead",.1f}); - oreOutputSecondaries.put("Nickel", new Object[]{"dustPlatinum",.1f}); - - oreOutputModifier.put("Lapis", new ItemStack(Items.DYE,9,4)); - oreOutputSecondaries.put("Lapis", new Object[]{"dustSulfur",.15f}); - oreOutputModifier.put("Diamond", new ItemStack(Items.DIAMOND,2)); - oreOutputModifier.put("Redstone", new ItemStack(Items.REDSTONE,6)); - oreOutputSecondaries.put("Redstone", new Object[]{"crystalCinnabar",.25f}); - oreOutputModifier.put("Emerald", new ItemStack(Items.EMERALD,2)); - oreOutputModifier.put("Quartz", new ItemStack(Items.QUARTZ,3)); - oreOutputSecondaries.put("Quartz", new Object[]{"dustSulfur",.15f}); - oreOutputModifier.put("Coal", new ItemStack(Items.COAL,4)); - - oreOutputSecondaries.put("Platinum", new Object[]{"dustNickel",.1f}); - oreOutputSecondaries.put("Tungsten", new Object[]{"dustManganese",.1f}); - oreOutputSecondaries.put("Uranium", new Object[]{"dustLead",.1f}); - oreOutputSecondaries.put("Yellorium", new Object[]{"dustLead",.1f}); - oreOutputSecondaries.put("Plutonium", new Object[]{"dustUranium",.1f}); + oreOutputSecondaries.put("Iron", new Object[]{"dustNickel", .1f}); + oreOutputSecondaries.put("Gold", new Object[]{"crystalCinnabar", .05f}); + oreOutputSecondaries.put("Copper", new Object[]{"dustGold", .1f}); + oreOutputSecondaries.put("Lead", new Object[]{"dustSilver", .1f}); + oreOutputSecondaries.put("Silver", new Object[]{"dustLead", .1f}); + oreOutputSecondaries.put("Nickel", new Object[]{"dustPlatinum", .1f}); + + oreOutputModifier.put("Lapis", new ItemStack(Items.DYE, 9, 4)); + oreOutputSecondaries.put("Lapis", new Object[]{"dustSulfur", .15f}); + oreOutputModifier.put("Diamond", new ItemStack(Items.DIAMOND, 2)); + oreOutputModifier.put("Redstone", new ItemStack(Items.REDSTONE, 6)); + oreOutputSecondaries.put("Redstone", new Object[]{"crystalCinnabar", .25f}); + oreOutputModifier.put("Emerald", new ItemStack(Items.EMERALD, 2)); + oreOutputModifier.put("Quartz", new ItemStack(Items.QUARTZ, 3)); + oreOutputSecondaries.put("Quartz", new Object[]{"dustSulfur", .15f}); + oreOutputModifier.put("Coal", new ItemStack(Items.COAL, 4)); + + oreOutputSecondaries.put("Platinum", new Object[]{"dustNickel", .1f}); + oreOutputSecondaries.put("Tungsten", new Object[]{"dustManganese", .1f}); + oreOutputSecondaries.put("Uranium", new Object[]{"dustLead", .1f}); + oreOutputSecondaries.put("Yellorium", new Object[]{"dustLead", .1f}); + oreOutputSecondaries.put("Plutonium", new Object[]{"dustUranium", .1f}); Item item = GameRegistry.findRegistry(Item.class).getValue(new ResourceLocation("IC2", "itemOreIridium")); - oreOutputSecondaries.put("Osmium", new Object[]{item,.01f}); - oreOutputSecondaries.put("Iridium", new Object[]{"dustPlatium",.1f}); - oreOutputSecondaries.put("FzDarkIron", new Object[]{"dustIron",.1f}); + oreOutputSecondaries.put("Osmium", new Object[]{item, .01f}); + oreOutputSecondaries.put("Iridium", new Object[]{"dustPlatium", .1f}); + oreOutputSecondaries.put("FzDarkIron", new Object[]{"dustIron", .1f}); item = GameRegistry.findRegistry(Item.class).getValue(new ResourceLocation("Railcraft", "firestone.raw")); if(item!=null) oreOutputModifier.put("Firestone", new ItemStack(item)); - oreOutputSecondaries.put("Nikolite", new Object[]{Items.DIAMOND,.025f}); + oreOutputSecondaries.put("Nikolite", new Object[]{Items.DIAMOND, .025f}); addCrusherRecipe(new ItemStack(Blocks.GRAVEL), "cobblestone", 1600); addCrusherRecipe(new ItemStack(Blocks.SAND), Blocks.GRAVEL, 1600); addCrusherRecipe(new ItemStack(Blocks.SAND), "itemSlag", 1600); addCrusherRecipe(new ItemStack(Blocks.SAND), "blockGlass", 3200); - addCrusherRecipe(new ItemStack(Blocks.SAND,2), "sandstone", 1600, new ItemStack(IEContent.itemMaterial,1,24),.5f); - addCrusherRecipe(new ItemStack(Items.QUARTZ,4), "blockQuartz", 3200); - addCrusherRecipe(new ItemStack(Items.GLOWSTONE_DUST,4), "glowstone", 3200); - addCrusherRecipe(new ItemStack(Items.BLAZE_POWDER,4), "rodBlaze", 3200, new ItemStack(IEContent.itemMaterial,1,25),.5f); - addCrusherRecipe(new ItemStack(Items.DYE,6,15), Items.BONE, 3200); - addCrusherRecipe(new ItemStack(IEContent.itemMaterial,1,17), "fuelCoke", 2400); + addCrusherRecipe(new ItemStack(Blocks.SAND, 2), "sandstone", 1600, new ItemStack(IEContent.itemMaterial, 1, 24), .5f); + addCrusherRecipe(new ItemStack(Items.QUARTZ, 4), "blockQuartz", 3200); + addCrusherRecipe(new ItemStack(Items.GLOWSTONE_DUST, 4), "glowstone", 3200); + addCrusherRecipe(new ItemStack(Items.BLAZE_POWDER, 4), "rodBlaze", 3200, new ItemStack(IEContent.itemMaterial, 1, 25), .5f); + addCrusherRecipe(new ItemStack(Items.DYE, 6, 15), Items.BONE, 3200); + addCrusherRecipe(new ItemStack(IEContent.itemMaterial, 1, 17), "fuelCoke", 2400); addCrusherRecipe(new ItemStack(IEContent.itemMaterial, 9, 17), "blockFuelCoke", 4800); - addItemToOreDictCrusherRecipe("dustCoal",1, new ItemStack(Items.COAL), 2400); - addItemToOreDictCrusherRecipe("dustObsidian",4, Blocks.OBSIDIAN, 6000); - for(int i=0; i<16; i++) + addItemToOreDictCrusherRecipe("dustCoal", 1, new ItemStack(Items.COAL), 2400); + addItemToOreDictCrusherRecipe("dustObsidian", 4, Blocks.OBSIDIAN, 6000); + for(int i = 0; i < 16; i++) { - CrusherRecipe r = CrusherRecipe.addRecipe(new ItemStack(Items.STRING,4), new ItemStack(Blocks.WOOL,1,i), 3200); + CrusherRecipe r = CrusherRecipe.addRecipe(new ItemStack(Items.STRING, 4), new ItemStack(Blocks.WOOL, 1, i), 3200); if(i!=0) - r.addToSecondaryOutput(new ItemStack(Items.DYE,1,15-i), .05f); + r.addToSecondaryOutput(new ItemStack(Items.DYE, 1, 15-i), .05f); } } + public static void postInitOreDictRecipes() { boolean allowHammerCrushing = !IEConfig.Tools.disableHammerCrushing; - ComparableItemStack compMoldPlate = ApiUtils.createComparableItemStack(new ItemStack(IEContent.itemMold,1,0), false); - ComparableItemStack compMoldGear = ApiUtils.createComparableItemStack(new ItemStack(IEContent.itemMold,1,1), false); - ComparableItemStack compMoldRod = ApiUtils.createComparableItemStack(new ItemStack(IEContent.itemMold,1,2), false); - ComparableItemStack compMoldWire = ApiUtils.createComparableItemStack(new ItemStack(IEContent.itemMold,1,4), false); + ComparableItemStack compMoldPlate = ApiUtils.createComparableItemStack(new ItemStack(IEContent.itemMold, 1, 0), false); + ComparableItemStack compMoldGear = ApiUtils.createComparableItemStack(new ItemStack(IEContent.itemMold, 1, 1), false); + ComparableItemStack compMoldRod = ApiUtils.createComparableItemStack(new ItemStack(IEContent.itemMold, 1, 2), false); + ComparableItemStack compMoldWire = ApiUtils.createComparableItemStack(new ItemStack(IEContent.itemMold, 1, 4), false); for(String name : OreDictionary.getOreNames()) if(ApiUtils.isExistingOreName(name)) @@ -287,7 +289,7 @@ public static void postInitOreDictRecipes() { String ore = name.substring("ore".length()); ItemStack out = oreOutputModifier.get(ore); - if(out == null || out.isEmpty()) + if(out==null||out.isEmpty()) { if(ApiUtils.isExistingOreName("gem"+ore)) out = Utils.copyStackWithAmount(IEApi.getPreferredOreStack("gem"+ore), 2); @@ -299,49 +301,49 @@ public static void postInitOreDictRecipes() out = Utils.copyStackWithAmount(preferredDust, 2); if(allowHammerCrushing) { - addShapelessOredictRecipe("hammercrushing_"+ore, preferredDust, name,new ItemStack(IEContent.itemTool)); + addShapelessOredictRecipe("hammercrushing_"+ore, preferredDust, name, new ItemStack(IEContent.itemTool)); hammerCrushingList.add(ore); } } } } - if(out != null && !out.isEmpty()) + if(out!=null&&!out.isEmpty()) { Object[] secondaries = oreOutputSecondaries.get(ore); - Object s = secondaries!=null&&secondaries.length>1?secondaries[0]: null; - Float f = secondaries!=null&&secondaries.length>1&&secondaries[1] instanceof Float?(Float)secondaries[1]: 0; + Object s = secondaries!=null&&secondaries.length > 1?secondaries[0]: null; + Float f = secondaries!=null&&secondaries.length > 1&&secondaries[1] instanceof Float?(Float)secondaries[1]: 0; addOreProcessingRecipe(out, ore, 6000, true, s, f); } out = arcOutputModifier.get(ore); - if(out == null || out.isEmpty()) + if(out==null||out.isEmpty()) { if(ApiUtils.isExistingOreName("ingot"+ore)) - out = Utils.copyStackWithAmount(IEApi.getPreferredOreStack("ingot"+ore),2); + out = Utils.copyStackWithAmount(IEApi.getPreferredOreStack("ingot"+ore), 2); } - if(out != null && !out.isEmpty() && !arcBlacklist.contains(ore)) + if(out!=null&&!out.isEmpty()&&!arcBlacklist.contains(ore)) addArcOreSmelting(out, ore); } else if(name.startsWith("gem")) { String ore = name.substring("gem".length()); if(ApiUtils.isExistingOreName("dust"+ore)) - addCrusherRecipe(IEApi.getPreferredOreStack("dust"+ore), "gem"+ore, 6000, null,0); + addCrusherRecipe(IEApi.getPreferredOreStack("dust"+ore), "gem"+ore, 6000, null, 0); } else if(name.startsWith("dust")) { String ore = name.substring("dust".length()); ItemStack out = arcOutputModifier.get(ore); - if(out == null || out.isEmpty()) + if(out==null||out.isEmpty()) { if(ApiUtils.isExistingOreName("ingot"+ore)) out = IEApi.getPreferredOreStack("ingot"+ore); } else - out = Utils.copyStackWithAmount(out, out.getCount() / 2); - if(out != null && !out.isEmpty() && !arcBlacklist.contains(ore)) - addArcRecipe(out, "dust"+ore, 100,512, ItemStack.EMPTY); + out = Utils.copyStackWithAmount(out, out.getCount()/2); + if(out!=null&&!out.isEmpty()&&!arcBlacklist.contains(ore)) + addArcRecipe(out, "dust"+ore, 100, 512, ItemStack.EMPTY); if(ApiUtils.isExistingOreName("ingot"+ore)) - addCrusherRecipe(IEApi.getPreferredOreStack("dust"+ore), "ingot"+ore, 3600, null,0); + addCrusherRecipe(IEApi.getPreferredOreStack("dust"+ore), "ingot"+ore, 3600, null, 0); } else if(name.startsWith("plate")) { @@ -358,16 +360,16 @@ else if(name.startsWith("gear")) } else if(name.startsWith("stick")||name.startsWith("rod")) { - String ore = name.startsWith("stick")?name.substring("stick".length()):name.substring("rod".length()); + String ore = name.startsWith("stick")?name.substring("stick".length()): name.substring("rod".length()); boolean priorityStick = !name.startsWith("rod")||!ApiUtils.isExistingOreName("stick"+ore); - if(priorityStick && ApiUtils.isExistingOreName("ingot"+ore)) - MetalPressRecipe.addRecipe(Utils.copyStackWithAmount(IEApi.getPreferredOreStack(name),2), "ingot"+ore, compMoldRod, 2400); + if(priorityStick&&ApiUtils.isExistingOreName("ingot"+ore)) + MetalPressRecipe.addRecipe(Utils.copyStackWithAmount(IEApi.getPreferredOreStack(name), 2), "ingot"+ore, compMoldRod, 2400); } else if(name.startsWith("wire")) { String ore = name.substring("wire".length()); if(ApiUtils.isExistingOreName("ingot"+ore)) - MetalPressRecipe.addRecipe(Utils.copyStackWithAmount(IEApi.getPreferredOreStack(name),2), "ingot"+ore, compMoldWire, 2400); + MetalPressRecipe.addRecipe(Utils.copyStackWithAmount(IEApi.getPreferredOreStack(name), 2), "ingot"+ore, compMoldWire, 2400); } Config.manual_bool.put("crushingOreRecipe", !hammerCrushingList.isEmpty()); } @@ -375,29 +377,31 @@ else if(name.startsWith("wire")) public static CrusherRecipe addCrusherRecipe(ItemStack output, Object input, int energy, Object... secondary) { CrusherRecipe r = CrusherRecipe.addRecipe(output, input, energy); - if(secondary!=null && secondary.length>0) + if(secondary!=null&&secondary.length > 0) r.addToSecondaryOutput(secondary); return r; } + public static void addOreProcessingRecipe(ItemStack output, String ore, int energy, boolean ingot, Object secondary, float secChance) { - if(ingot && ApiUtils.isExistingOreName("ingot"+ore)) - addCrusherRecipe(Utils.copyStackWithAmount(output, output.getCount() / 2), "ingot"+ore, (int)(energy*.6f)); + if(ingot&&ApiUtils.isExistingOreName("ingot"+ore)) + addCrusherRecipe(Utils.copyStackWithAmount(output, output.getCount()/2), "ingot"+ore, (int)(energy*.6f)); if(ApiUtils.isExistingOreName("ore"+ore)) - addCrusherRecipe(output, "ore"+ore, energy, secondary,secChance); + addCrusherRecipe(output, "ore"+ore, energy, secondary, secChance); // if(ApiUtils.isExistingOreName("oreNether"+ore)) // addCrusherRecipe(Utils.copyStackWithAmount(output, NetherOresHelper.getCrushingResult(ore)), "oreNether"+ore, energy, secondary,secChance,Blocks.netherrack,.15f); //YAY GregTech! if(ApiUtils.isExistingOreName("oreNetherrack"+ore)) - addCrusherRecipe(output, "oreNetherrack"+ore, energy, secondary,secChance, new ItemStack(Blocks.NETHERRACK),.15f); + addCrusherRecipe(output, "oreNetherrack"+ore, energy, secondary, secChance, new ItemStack(Blocks.NETHERRACK), .15f); if(ApiUtils.isExistingOreName("oreEndstone"+ore)) - addCrusherRecipe(output, "oreEndstone"+ore, energy, secondary,secChance, "dustEndstone",.5f); + addCrusherRecipe(output, "oreEndstone"+ore, energy, secondary, secChance, "dustEndstone", .5f); if(ApiUtils.isExistingOreName("oreBlackgranite"+ore)) - addCrusherRecipe(output, "oreBlackgranite"+ore, energy, secondary,secChance, "dustGraniteBlack",.5f); + addCrusherRecipe(output, "oreBlackgranite"+ore, energy, secondary, secChance, "dustGraniteBlack", .5f); if(ApiUtils.isExistingOreName("oreRedgranite"+ore)) - addCrusherRecipe(output, "oreRedgranite"+ore, energy, secondary,secChance, "dustGraniteBlack",.5f); + addCrusherRecipe(output, "oreRedgranite"+ore, energy, secondary, secChance, "dustGraniteBlack", .5f); } + public static void addOreDictCrusherRecipe(String ore, Object secondary, float chance) { if(!ApiUtils.isExistingOreName("dust"+ore)) @@ -406,7 +410,7 @@ public static void addOreDictCrusherRecipe(String ore, Object secondary, float c if(dust.isEmpty()) return; if(ApiUtils.isExistingOreName("ore"+ore)) - addCrusherRecipe(Utils.copyStackWithAmount(dust, 2), "ore"+ore, 6000, secondary,chance); + addCrusherRecipe(Utils.copyStackWithAmount(dust, 2), "ore"+ore, 6000, secondary, chance); if(ApiUtils.isExistingOreName("ingot"+ore)) addCrusherRecipe(Utils.copyStackWithAmount(dust, 1), "ingot"+ore, 3600); // if(ApiUtils.isExistingOreName("oreNether"+ore)) @@ -414,14 +418,15 @@ public static void addOreDictCrusherRecipe(String ore, Object secondary, float c //YAY GregTech! if(ApiUtils.isExistingOreName("oreNetherrack"+ore)) - addCrusherRecipe(Utils.copyStackWithAmount(dust, 2), "oreNetherrack"+ore, 6000, secondary,chance, new ItemStack(Blocks.NETHERRACK),.15f); + addCrusherRecipe(Utils.copyStackWithAmount(dust, 2), "oreNetherrack"+ore, 6000, secondary, chance, new ItemStack(Blocks.NETHERRACK), .15f); if(ApiUtils.isExistingOreName("oreEndstone"+ore)) - addCrusherRecipe(Utils.copyStackWithAmount(dust, 2), "oreEndstone"+ore, 6000, secondary,chance, "dustEndstone",.5f); + addCrusherRecipe(Utils.copyStackWithAmount(dust, 2), "oreEndstone"+ore, 6000, secondary, chance, "dustEndstone", .5f); if(ApiUtils.isExistingOreName("oreBlackgranite"+ore)) - addCrusherRecipe(Utils.copyStackWithAmount(dust, 2), "oreBlackgranite"+ore, 6000, secondary,chance, "dustGraniteBlack",.5f); + addCrusherRecipe(Utils.copyStackWithAmount(dust, 2), "oreBlackgranite"+ore, 6000, secondary, chance, "dustGraniteBlack", .5f); if(ApiUtils.isExistingOreName("oreRedgranite"+ore)) - addCrusherRecipe(Utils.copyStackWithAmount(dust, 2), "oreRedgranite"+ore, 6000, secondary,chance, "dustGraniteRed",.5f); + addCrusherRecipe(Utils.copyStackWithAmount(dust, 2), "oreRedgranite"+ore, 6000, secondary, chance, "dustGraniteRed", .5f); } + public static CrusherRecipe addItemToOreDictCrusherRecipe(String oreName, int outSize, Object input, int energy) { if(!ApiUtils.isExistingOreName(oreName)) @@ -435,16 +440,17 @@ public static CrusherRecipe addItemToOreDictCrusherRecipe(String oreName, int ou public static void initAlloySmeltingRecipes() { //IE Alloys - addAlloyingRecipe(new ItemStack(IEContent.itemMetal,2,6), "Copper",1,"Nickel",1, 200); - addAlloyingRecipe(new ItemStack(IEContent.itemMetal,2,7), "Gold",1,"Silver",1, 200); + addAlloyingRecipe(new ItemStack(IEContent.itemMetal, 2, 6), "Copper", 1, "Nickel", 1, 200); + addAlloyingRecipe(new ItemStack(IEContent.itemMetal, 2, 7), "Gold", 1, "Silver", 1, 200); //Common Alloys - addOreDictAlloyingRecipe("ingotInvar",3, "Iron",2, "Nickel",1, 200); - addOreDictAlloyingRecipe("ingotBronze",4, "Copper",3, "Tin",1, 200); - addOreDictAlloyingRecipe("ingotBrass",4, "Copper",3, "Zinc",1, 200); - addOreDictAlloyingRecipe("ingotBlueAlloy",1, "Silver",1, "Nikolite",4, 200); - addOreDictAlloyingRecipe("ingotRedAlloy",1, "Copper",1, "Redstone",4, 200); + addOreDictAlloyingRecipe("ingotInvar", 3, "Iron", 2, "Nickel", 1, 200); + addOreDictAlloyingRecipe("ingotBronze", 4, "Copper", 3, "Tin", 1, 200); + addOreDictAlloyingRecipe("ingotBrass", 4, "Copper", 3, "Zinc", 1, 200); + addOreDictAlloyingRecipe("ingotBlueAlloy", 1, "Silver", 1, "Nikolite", 4, 200); + addOreDictAlloyingRecipe("ingotRedAlloy", 1, "Copper", 1, "Redstone", 4, 200); } + public static void addOreDictAlloyingRecipe(String outName, int outSize, String input0, int size0, String input1, int size1, int time) { if(!ApiUtils.isExistingOreName(outName)) @@ -452,84 +458,88 @@ public static void addOreDictAlloyingRecipe(String outName, int outSize, String ItemStack out = IEApi.getPreferredOreStack(outName); if(out.isEmpty()) return; - addAlloyingRecipe(Utils.copyStackWithAmount(out, outSize), input0,size0, input1,size1, time); + addAlloyingRecipe(Utils.copyStackWithAmount(out, outSize), input0, size0, input1, size1, time); } + public static void addAlloyingRecipe(ItemStack output, String input0, int size0, String input1, int size1, int time) { boolean ingot0 = ApiUtils.isExistingOreName("ingot"+input0); boolean ingot1 = ApiUtils.isExistingOreName("ingot"+input1); boolean dust0 = ApiUtils.isExistingOreName("dust"+input0); boolean dust1 = ApiUtils.isExistingOreName("dust"+input1); - if(ingot0 && ingot1) + if(ingot0&&ingot1) AlloyRecipe.addRecipe(output, new IngredientStack("ingot"+input0, size0), new IngredientStack("ingot"+input1, size1), time); - if(dust0 && dust1) + if(dust0&&dust1) AlloyRecipe.addRecipe(output, new IngredientStack("dust"+input0, size0), new IngredientStack("dust"+input1, size1), time); - if(ingot0 && dust1) + if(ingot0&&dust1) AlloyRecipe.addRecipe(output, new IngredientStack("ingot"+input0, size0), new IngredientStack("dust"+input1, size1), time); - if(dust0 && ingot1) + if(dust0&&ingot1) AlloyRecipe.addRecipe(output, new IngredientStack("dust"+input0, size0), new IngredientStack("ingot"+input1, size1), time); } public static HashMap arcOutputModifier = new HashMap(); public static HashSet arcBlacklist = new HashSet(); + public static void initArcSmeltingRecipes() { //Steel - ArcFurnaceRecipe.addRecipe(new ItemStack(IEContent.itemMetal,1,8), "ingotIron", new ItemStack(IEContent.itemMaterial,1,7), 400,512, "dustCoke"); - ArcFurnaceRecipe.addRecipe(new ItemStack(IEContent.itemMetal,1,8), "dustIron", new ItemStack(IEContent.itemMaterial,1,7), 400,512, "dustCoke"); + ArcFurnaceRecipe.addRecipe(new ItemStack(IEContent.itemMetal, 1, 8), "ingotIron", new ItemStack(IEContent.itemMaterial, 1, 7), 400, 512, "dustCoke"); + ArcFurnaceRecipe.addRecipe(new ItemStack(IEContent.itemMetal, 1, 8), "dustIron", new ItemStack(IEContent.itemMaterial, 1, 7), 400, 512, "dustCoke"); //Vanilla+IE Ores - arcOutputModifier.put("Iron", new ItemStack(Items.IRON_INGOT,2)); - arcOutputModifier.put("Gold", new ItemStack(Items.GOLD_INGOT,2)); - arcOutputModifier.put("Copper", new ItemStack(IEContent.itemMetal,2,0)); - arcOutputModifier.put("Aluminum", new ItemStack(IEContent.itemMetal,2,1)); - arcOutputModifier.put("Aluminium", new ItemStack(IEContent.itemMetal,2,1)); - arcOutputModifier.put("Lead", new ItemStack(IEContent.itemMetal,2,2)); - arcOutputModifier.put("Silver", new ItemStack(IEContent.itemMetal,2,3)); - arcOutputModifier.put("Nickel", new ItemStack(IEContent.itemMetal,2,4)); + arcOutputModifier.put("Iron", new ItemStack(Items.IRON_INGOT, 2)); + arcOutputModifier.put("Gold", new ItemStack(Items.GOLD_INGOT, 2)); + arcOutputModifier.put("Copper", new ItemStack(IEContent.itemMetal, 2, 0)); + arcOutputModifier.put("Aluminum", new ItemStack(IEContent.itemMetal, 2, 1)); + arcOutputModifier.put("Aluminium", new ItemStack(IEContent.itemMetal, 2, 1)); + arcOutputModifier.put("Lead", new ItemStack(IEContent.itemMetal, 2, 2)); + arcOutputModifier.put("Silver", new ItemStack(IEContent.itemMetal, 2, 3)); + arcOutputModifier.put("Nickel", new ItemStack(IEContent.itemMetal, 2, 4)); //IE Alloys addOreDictArcAlloyingRecipe(new ItemStack(IEContent.itemMetal, 2, 6), "Copper", 100, 512, "dustNickel"); addOreDictArcAlloyingRecipe(new ItemStack(IEContent.itemMetal, 2, 6), "Nickel", 100, 512, "dustCopper"); addOreDictArcAlloyingRecipe(new ItemStack(IEContent.itemMetal, 2, 7), "Gold", 100, 512, "dustSilver"); addOreDictArcAlloyingRecipe(new ItemStack(IEContent.itemMetal, 2, 7), "Silver", 100, 512, "dustGold"); //Common Alloys - addOreDictArcAlloyingRecipe("ingotInvar",3, "Nickel", 200,512, "dustIron","dustIron"); - addOreDictArcAlloyingRecipe("ingotBronze",4, "Tin", 200,512, "dustCopper","dustCopper","dustCopper"); - addOreDictArcAlloyingRecipe("ingotBrass",4, "Zinc", 200,512, "dustCopper","dustCopper","dustCopper"); - addOreDictArcAlloyingRecipe("ingotBlueAlloy",1, "Silver", 100,512, "dustNikolite","dustNikolite","dustNikolite","dustNikolite"); - addOreDictArcAlloyingRecipe("ingotRedAlloy",1, "Copper", 100,512, "dustRedstone","dustRedstone","dustRedstone","dustRedstone"); + addOreDictArcAlloyingRecipe("ingotInvar", 3, "Nickel", 200, 512, "dustIron", "dustIron"); + addOreDictArcAlloyingRecipe("ingotBronze", 4, "Tin", 200, 512, "dustCopper", "dustCopper", "dustCopper"); + addOreDictArcAlloyingRecipe("ingotBrass", 4, "Zinc", 200, 512, "dustCopper", "dustCopper", "dustCopper"); + addOreDictArcAlloyingRecipe("ingotBlueAlloy", 1, "Silver", 100, 512, "dustNikolite", "dustNikolite", "dustNikolite", "dustNikolite"); + addOreDictArcAlloyingRecipe("ingotRedAlloy", 1, "Copper", 100, 512, "dustRedstone", "dustRedstone", "dustRedstone", "dustRedstone"); //Recycling - ArcFurnaceRecipe.allowItemForRecycling(new ItemStack(IEContent.itemWireCoil,1,OreDictionary.WILDCARD_VALUE)); - ArcFurnaceRecipe.allowItemForRecycling(new ItemStack(IEContent.itemDrillhead,1,OreDictionary.WILDCARD_VALUE)); - - ArcFurnaceRecipe.allowItemForRecycling(new ItemStack(IEContent.blockMetalDecoration0,1,OreDictionary.WILDCARD_VALUE)); - ArcFurnaceRecipe.allowItemForRecycling(new ItemStack(IEContent.blockMetalDecoration1,1,OreDictionary.WILDCARD_VALUE)); - ArcFurnaceRecipe.allowItemForRecycling(new ItemStack(IEContent.blockMetalDecoration2,1,OreDictionary.WILDCARD_VALUE)); - ArcFurnaceRecipe.allowItemForRecycling(new ItemStack(IEContent.blockMetalDevice0,1,OreDictionary.WILDCARD_VALUE)); - ArcFurnaceRecipe.allowItemForRecycling(new ItemStack(IEContent.blockMetalDevice1,1,OreDictionary.WILDCARD_VALUE)); + ArcFurnaceRecipe.allowItemForRecycling(new ItemStack(IEContent.itemWireCoil, 1, OreDictionary.WILDCARD_VALUE)); + ArcFurnaceRecipe.allowItemForRecycling(new ItemStack(IEContent.itemDrillhead, 1, OreDictionary.WILDCARD_VALUE)); + + ArcFurnaceRecipe.allowItemForRecycling(new ItemStack(IEContent.blockMetalDecoration0, 1, OreDictionary.WILDCARD_VALUE)); + ArcFurnaceRecipe.allowItemForRecycling(new ItemStack(IEContent.blockMetalDecoration1, 1, OreDictionary.WILDCARD_VALUE)); + ArcFurnaceRecipe.allowItemForRecycling(new ItemStack(IEContent.blockMetalDecoration2, 1, OreDictionary.WILDCARD_VALUE)); + ArcFurnaceRecipe.allowItemForRecycling(new ItemStack(IEContent.blockMetalDevice0, 1, OreDictionary.WILDCARD_VALUE)); + ArcFurnaceRecipe.allowItemForRecycling(new ItemStack(IEContent.blockMetalDevice1, 1, OreDictionary.WILDCARD_VALUE)); } public static ArcFurnaceRecipe addArcRecipe(ItemStack output, Object input, int time, int energyPerTick, @Nonnull ItemStack slag, Object... additives) { return ArcFurnaceRecipe.addRecipe(output, input, slag, time, energyPerTick, additives); } + public static void addArcOreSmelting(ItemStack output, String ore) { if(ApiUtils.isExistingOreName("ore"+ore)) - addArcRecipe(output, "ore"+ore, 200,512, new ItemStack(IEContent.itemMaterial,1,7)).setSpecialRecipeType("Ores"); + addArcRecipe(output, "ore"+ore, 200, 512, new ItemStack(IEContent.itemMaterial, 1, 7)).setSpecialRecipeType("Ores"); // if(ApiUtils.isExistingOreName("oreNether"+ore)) // addArcRecipe(Utils.copyStackWithAmount(output, NetherOresHelper.getCrushingResult(ore)), "oreNether"+ore, 200,512, new ItemStack(IEContent.itemMaterial,1,13)).setSpecialRecipeType("Ores"); //YAY GregTech! if(ApiUtils.isExistingOreName("oreNetherrack"+ore)) - addArcRecipe(output, "oreNetherrack"+ore, 200,512, new ItemStack(IEContent.itemMaterial,1,7)).setSpecialRecipeType("Ores"); + addArcRecipe(output, "oreNetherrack"+ore, 200, 512, new ItemStack(IEContent.itemMaterial, 1, 7)).setSpecialRecipeType("Ores"); if(ApiUtils.isExistingOreName("oreEndstone"+ore)) - addArcRecipe(output, "oreEndstone"+ore, 200,512, new ItemStack(IEContent.itemMaterial,1,7)).setSpecialRecipeType("Ores"); + addArcRecipe(output, "oreEndstone"+ore, 200, 512, new ItemStack(IEContent.itemMaterial, 1, 7)).setSpecialRecipeType("Ores"); if(ApiUtils.isExistingOreName("oreBlackgranite"+ore)) - addArcRecipe(output, "oreBlackgranite"+ore, 200,512, new ItemStack(IEContent.itemMaterial,1,7)).setSpecialRecipeType("Ores"); + addArcRecipe(output, "oreBlackgranite"+ore, 200, 512, new ItemStack(IEContent.itemMaterial, 1, 7)).setSpecialRecipeType("Ores"); if(ApiUtils.isExistingOreName("oreRedgranite"+ore)) - addArcRecipe(output, "oreRedgranite"+ore, 200,512, new ItemStack(IEContent.itemMaterial,1,7)).setSpecialRecipeType("Ores"); + addArcRecipe(output, "oreRedgranite"+ore, 200, 512, new ItemStack(IEContent.itemMaterial, 1, 7)).setSpecialRecipeType("Ores"); } + public static void addOreDictArcAlloyingRecipe(String outName, int outSize, String inputName, int time, int energyPerTick, Object... additives) { if(!ApiUtils.isExistingOreName(outName)) @@ -537,8 +547,9 @@ public static void addOreDictArcAlloyingRecipe(String outName, int outSize, Stri ItemStack out = IEApi.getPreferredOreStack(outName); if(out.isEmpty()) return; - addOreDictArcAlloyingRecipe(Utils.copyStackWithAmount(out, outSize), inputName, time,energyPerTick, additives); + addOreDictArcAlloyingRecipe(Utils.copyStackWithAmount(out, outSize), inputName, time, energyPerTick, additives); } + public static void addOreDictArcAlloyingRecipe(ItemStack out, String inputName, int time, int energyPerTick, Object... additives) { if(ApiUtils.isExistingOreName("ingot"+inputName)) diff --git a/src/main/java/blusunrize/immersiveengineering/common/IESaveData.java b/src/main/java/blusunrize/immersiveengineering/common/IESaveData.java index cd62a595d5..799c686d3b 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/IESaveData.java +++ b/src/main/java/blusunrize/immersiveengineering/common/IESaveData.java @@ -40,10 +40,10 @@ public void readFromNBT(NBTTagCompound nbt) { //Load new info from NBT int[] savedDimensions = nbt.getIntArray("savedDimensions"); - for(int dim: savedDimensions) + for(int dim : savedDimensions) { NBTTagList connectionList = nbt.getTagList("connectionList"+dim, 10); - for(int i=0; i e: ExcavatorHandler.mineralCache.entrySet()) - if(e.getKey()!=null && e.getValue()!=null) + for(Map.Entry e : ExcavatorHandler.mineralCache.entrySet()) + if(e.getKey()!=null&&e.getValue()!=null) { NBTTagCompound tag = e.getKey().writeToNBT(); tag.setTag("info", e.getValue().writeToNBT()); @@ -133,7 +133,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) tag.setString("player", player); NBTTagList playerReceived = new NBTTagList(); for(String shader : ShaderRegistry.receivedShaders.get(player)) - if(shader!=null && !shader.isEmpty()) + if(shader!=null&&!shader.isEmpty()) playerReceived.appendTag(new NBTTagString(shader)); tag.setTag("received", playerReceived); receivedShaderList.appendTag(tag); @@ -149,15 +149,16 @@ public static void setDirty(int dimension) // { // INSTANCE.get(dimension).markDirty(); // } - if(FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER && INSTANCE!=null) + if(FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER&&INSTANCE!=null) INSTANCE.markDirty(); } + public static void setInstance(int dimension, IESaveData in) { // if(FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER) // INSTANCE.put(dimension, in); if(FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER) - INSTANCE=in; + INSTANCE = in; } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/NameRemapper.java b/src/main/java/blusunrize/immersiveengineering/common/NameRemapper.java index caeff8dfad..cba2579bcb 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/NameRemapper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/NameRemapper.java @@ -20,7 +20,9 @@ public class NameRemapper { private static final Map nameMap = new HashMap<>(); - static{ + + static + { nameMap.put("woodendecoration", "wooden_decoration"); nameMap.put("storageslab", "storage_slab"); nameMap.put("stonedecorationstairs_concrete_leaded", "stone_decoration_stairs_concrete_leaded"); @@ -81,7 +83,8 @@ public static void remap(MissingMappings ev) else miss.warn(); - } else + } + else { IELogger.error("Couldn't remap "+miss.key); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/asm/IEClassTransformer.java b/src/main/java/blusunrize/immersiveengineering/common/asm/IEClassTransformer.java index f8a0d814e7..cbf734ec9e 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/asm/IEClassTransformer.java +++ b/src/main/java/blusunrize/immersiveengineering/common/asm/IEClassTransformer.java @@ -26,7 +26,8 @@ public class IEClassTransformer implements IClassTransformer { private static Map transformerMap = Maps.newHashMap(); - static{ + static + { transformerMap.put("net.minecraft.client.model.ModelBiped", new MethodTransformer[]{ new MethodTransformer("setRotationAngles", "func_78087_a", "(FFFFFFLnet/minecraft/entity/Entity;)V", methodNode -> { @@ -50,13 +51,13 @@ public class IEClassTransformer implements IClassTransformer { //INVOKEVIRTUAL net/minecraft/block/Block.onEntityCollidedWithBlock (Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/state/IBlockState;Lnet/minecraft/entity/Entity;)V Iterator iterator = m.instructions.iterator(); - while (iterator.hasNext()) + while(iterator.hasNext()) { AbstractInsnNode anode = iterator.next(); - if (anode.getOpcode() == Opcodes.INVOKEVIRTUAL) + if(anode.getOpcode()==Opcodes.INVOKEVIRTUAL) { - MethodInsnNode n = (MethodInsnNode) anode; - if (n.name.equals("onEntityCollidedWithBlock")||n.name.equals("func_180634_a")) + MethodInsnNode n = (MethodInsnNode)anode; + if(n.name.equals("onEntityCollidedWithBlock")||n.name.equals("func_180634_a")) { InsnList newInstructions = new InsnList(); newInstructions.add(new VarInsnNode(Opcodes.ALOAD, 4)); @@ -84,10 +85,10 @@ public byte[] transform(String name, String transformedName, byte[] basicClass) for(MethodNode method : node.methods) for(MethodTransformer methodTransformer : transformers) - if((methodTransformer.functionName.equals(method.name)||methodTransformer.srgName.equals(method.name)) && methodTransformer.functionDesc.equals(method.desc)) + if((methodTransformer.functionName.equals(method.name)||methodTransformer.srgName.equals(method.name))&&methodTransformer.functionDesc.equals(method.desc)) methodTransformer.function.accept(method); - ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); + ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS|ClassWriter.COMPUTE_FRAMES); node.accept(writer); return writer.toByteArray(); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockFakeLight.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockFakeLight.java index 1d90f44d3e..76152a7249 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockFakeLight.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockFakeLight.java @@ -39,7 +39,7 @@ public BlockFakeLight() super("fake_light", Material.AIR, PropertyEnum.create("type", BlockTypes_FakeLight.class), ItemBlockIEBase.class); setAllNotNormalBlock(); } - + @Override public boolean isAir(IBlockState state, IBlockAccess world, BlockPos pos) { @@ -52,6 +52,7 @@ public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAcces { return null; } + @Override public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World world, BlockPos pos) { @@ -62,27 +63,31 @@ public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World world, Bloc public void getDrops(NonNullList drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { } - + @Override public boolean canCollideCheck(IBlockState state, boolean b) { return false; } + @Override public boolean isCollidable() { return false; } + @Override public RayTraceResult collisionRayTrace(IBlockState state, World par1World, BlockPos pos, Vec3d par5Vec3, Vec3d par6Vec3) { return null; } + @Override public EnumPushReaction getMobilityFlag(IBlockState state) { return EnumPushReaction.DESTROY; } + @Override public boolean canBeReplacedByLeaves(IBlockState state, IBlockAccess world, BlockPos pos) { @@ -98,28 +103,31 @@ public TileEntity createBasicTE(World worldIn, BlockTypes_FakeLight meta) public static class TileEntityFakeLight extends TileEntityIEBase implements ITickable, ISpawnInterdiction, ILightValue { - public int[] floodlightCoords = {-1,-1,-1}; + public int[] floodlightCoords = {-1, -1, -1}; + public TileEntityFakeLight() { if(IEConfig.Machines.floodlight_spawnPrevent) - synchronized (EventHandler.interdictionTiles) { - if (!EventHandler.interdictionTiles.contains(this)) + synchronized(EventHandler.interdictionTiles) + { + if(!EventHandler.interdictionTiles.contains(this)) EventHandler.interdictionTiles.add(this); } } + @Override public void update() { if(world.getTotalWorldTime()%256==((getPos().getX()^getPos().getZ())&255)) { - if(floodlightCoords==null || floodlightCoords.length<3) + if(floodlightCoords==null||floodlightCoords.length < 3) { world.setBlockToAir(getPos()); return; } BlockPos floodlightPos = new BlockPos(floodlightCoords[0], floodlightCoords[1], floodlightCoords[2]); TileEntity tile = Utils.getExistingTileEntity(world, floodlightPos); - if( !(tile instanceof TileEntityFloodlight) || !((TileEntityFloodlight)tile).active) + if(!(tile instanceof TileEntityFloodlight)||!((TileEntityFloodlight)tile).active) { world.setBlockToAir(getPos()); return; @@ -127,40 +135,49 @@ public void update() } } + @Override public int getLightValue() { return 15; } + @Override public double getInterdictionRangeSquared() { return 1024; } + @Override public void invalidate() { - synchronized (EventHandler.interdictionTiles) { + synchronized(EventHandler.interdictionTiles) + { EventHandler.interdictionTiles.remove(this); } super.invalidate(); } + @Override - public void onChunkUnload(){ - synchronized (EventHandler.interdictionTiles) { + public void onChunkUnload() + { + synchronized(EventHandler.interdictionTiles) + { EventHandler.interdictionTiles.remove(this); } super.onChunkUnload(); } + @Override public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) { floodlightCoords = nbt.getIntArray("floodlightCoords"); } + @Override public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { - nbt.setIntArray("floodlightCoords",floodlightCoords); + nbt.setIntArray("floodlightCoords", floodlightCoords); } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIEBase.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIEBase.java index 9b0fec2671..84016a7880 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIEBase.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIEBase.java @@ -63,6 +63,7 @@ public class BlockIEBase & BlockIEBase.IBlockEnum> extends Blo protected boolean[] canHammerHarvest; protected boolean[] metaNotNormalBlock; private boolean opaqueCube = false; + public BlockIEBase(String name, Material material, PropertyEnum mainProperty, Class itemBlock, Object... additionalProperties) { super(setTempProperties(material, mainProperty, additionalProperties)); @@ -100,9 +101,13 @@ public BlockIEBase(String name, Material material, PropertyEnum mainProperty, // ImmersiveEngineering.registerBlockByFullName(this, itemBlock, registryName); IEContent.registeredIEBlocks.add(this); - try{ + try + { IEContent.registeredIEItems.add(itemBlock.getConstructor(Block.class).newInstance(this)); - }catch(Exception e){e.printStackTrace();} + } catch(Exception e) + { + e.printStackTrace(); + } lightOpacity = 255; } @@ -111,31 +116,37 @@ public String getIEBlockName() { return this.name; } + @Override public Enum[] getMetaEnums() { return enumValues; } + @Override public IBlockState getInventoryState(int meta) { return getStateFromMeta(meta); } + @Override public PropertyEnum getMetaProperty() { return this.property; } + @Override public boolean useCustomStateMapper() { return false; } + @Override public String getCustomStateMapping(int meta, boolean itemBlock) { return null; } + @Override @SideOnly(Side.CLIENT) public StateMapperBase getCustomMapper() @@ -152,7 +163,7 @@ public boolean appendPropertiesToState() public String getUnlocalizedName(ItemStack stack) { String subName = getStateFromMeta(stack.getItemDamage()).getValue(property).toString().toLowerCase(Locale.US); - return super.getUnlocalizedName() + "." + subName; + return super.getUnlocalizedName()+"."+subName; } protected static Material setTempProperties(Material material, PropertyEnum property, Object... additionalProperties) @@ -177,12 +188,13 @@ protected static Material setTempProperties(Material material, PropertyEnum p tempUnlistedProperties = unlistedPropList.toArray(new IUnlistedProperty[unlistedPropList.size()]); return material; } + protected static Object[] combineProperties(Object[] currentProperties, Object... addedProperties) { - Object[] array = new Object[currentProperties.length + addedProperties.length]; - for(int i=0; i=0 && i= 0&&i < this.isMetaHidden.length) this.isMetaHidden[i] = true; return this; } + public BlockIEBase setMetaUnhidden(int... meta) { for(int i : meta) - if(i>=0 && i= 0&&i < this.isMetaHidden.length) this.isMetaHidden[i] = false; return this; } + public boolean isMetaHidden(int meta) { return this.isMetaHidden[Math.max(0, Math.min(meta, this.isMetaHidden.length-1))]; @@ -208,15 +222,16 @@ public boolean isMetaHidden(int meta) public BlockIEBase setHasFlavour(int... meta) { - if(meta==null||meta.length<1) - for(int i=0; i=0 && i= 0&&i < this.hasFlavour.length) this.hasFlavour[i] = false; return this; } + public boolean hasFlavour(ItemStack stack) { return this.hasFlavour[Math.max(0, Math.min(stack.getItemDamage(), this.hasFlavour.length-1))]; @@ -227,6 +242,7 @@ public BlockIEBase setBlockLayer(BlockRenderLayer... layer) this.renderLayers = Sets.newHashSet(layer); return this; } + public BlockIEBase setMetaBlockLayer(int meta, BlockRenderLayer... layer) { this.metaRenderLayers[Math.max(0, Math.min(meta, this.metaRenderLayers.length-1))] = Sets.newHashSet(layer); @@ -237,22 +253,24 @@ public BlockIEBase setMetaBlockLayer(int meta, BlockRenderLayer... layer) public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer) { int meta = this.getMetaFromState(state); - if (meta >= 0 && meta < metaRenderLayers.length && metaRenderLayers[meta] != null) + if(meta >= 0&&meta < metaRenderLayers.length&&metaRenderLayers[meta]!=null) return metaRenderLayers[meta].contains(layer); return renderLayers.contains(layer); } + public BlockIEBase setMetaLightOpacity(int meta, int opacity) { metaLightOpacities.put(meta, opacity); return this; } + @Override public int getLightOpacity(IBlockState state, IBlockAccess w, BlockPos pos) { int meta = getMetaFromState(state); if(metaLightOpacities.containsKey(meta)) return metaLightOpacities.get(meta); - return super.getLightOpacity(state,w,pos); + return super.getLightOpacity(state, w, pos); } public BlockIEBase setMetaHardness(int meta, float hardness) @@ -260,6 +278,7 @@ public BlockIEBase setMetaHardness(int meta, float hardness) metaHardness.put(meta, hardness); return this; } + @Override public float getBlockHardness(IBlockState state, World world, BlockPos pos) { @@ -274,6 +293,7 @@ public BlockIEBase setMetaExplosionResistance(int meta, int resistance) metaResistances.put(meta, resistance); return this; } + @Override public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion) { @@ -289,6 +309,7 @@ public BlockIEBase setMetaMobilityFlag(int meta, EnumPushReaction flag) metaMobilityFlags[meta] = flag; return this; } + @Override public EnumPushReaction getMobilityFlag(IBlockState state) { @@ -300,36 +321,41 @@ public EnumPushReaction getMobilityFlag(IBlockState state) public BlockIEBase setNotNormalBlock(int meta) { - if(metaNotNormalBlock == null) + if(metaNotNormalBlock==null) metaNotNormalBlock = new boolean[this.enumValues.length]; metaNotNormalBlock[meta] = true; return this; } + public BlockIEBase setAllNotNormalBlock() { - if(metaNotNormalBlock == null) + if(metaNotNormalBlock==null) metaNotNormalBlock = new boolean[this.enumValues.length]; for(int i = 0; i < metaNotNormalBlock.length; i++) metaNotNormalBlock[i] = true; return this; } + protected boolean normalBlockCheck(IBlockState state) { - if(metaNotNormalBlock == null) + if(metaNotNormalBlock==null) return true; int meta = getMetaFromState(state); - return (meta < 0 || meta >= metaNotNormalBlock.length) || !metaNotNormalBlock[meta]; + return (meta < 0||meta >= metaNotNormalBlock.length)||!metaNotNormalBlock[meta]; } + @Override public boolean isFullBlock(IBlockState state) { return normalBlockCheck(state); } + @Override public boolean isFullCube(IBlockState state) { return normalBlockCheck(state); } + @Override public boolean isOpaqueCube(IBlockState state) { @@ -339,14 +365,15 @@ public boolean isOpaqueCube(IBlockState state) @Override public boolean causesSuffocation(IBlockState state) { - if(metaNotNormalBlock == null) + if(metaNotNormalBlock==null) return true; int majority = 0; for(boolean b : metaNotNormalBlock) if(b) majority++; - return majority0) + if(this.additionalUnlistedProperties.length > 0) return new ExtendedBlockState(this, array, additionalUnlistedProperties); return new BlockStateContainer(this, array); } + protected IBlockState getInitDefaultState() { IBlockState state = this.blockState.getBaseState().withProperty(this.property, enumValues[0]); - for(int i=0; i> IBlockState applyProperty(IBlockState in, IP public void onIEBlockPlacedBy(World world, BlockPos pos, IBlockState state, EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase placer, ItemStack stack) { } + public boolean canIEBlockBePlaced(World world, BlockPos pos, IBlockState newState, EnumFacing side, float hitX, float hitY, float hitZ, EntityPlayer player, ItemStack stack) { return true; @@ -390,25 +419,28 @@ protected BlockStateContainer createBlockState() { if(this.property!=null) return createNotTempBlockState(); - if(tempUnlistedProperties.length>0) + if(tempUnlistedProperties.length > 0) return new ExtendedBlockState(this, tempProperties, tempUnlistedProperties); return new BlockStateContainer(this, tempProperties); } + @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { super.onBlockPlacedBy(worldIn, pos, state, placer, stack); } + @Override public int getMetaFromState(IBlockState state) { - if(state==null || !this.equals(state.getBlock())) + if(state==null||!this.equals(state.getBlock())) return 0; return state.getValue(this.property).getMeta(); } + protected E fromMeta(int meta) { - if(meta<0||meta>=enumValues.length) + if(meta < 0||meta >= enumValues.length) meta = 0; return enumValues[meta]; } @@ -424,12 +456,13 @@ public int damageDropped(IBlockState state) { return getMetaFromState(state); } + @SideOnly(Side.CLIENT) @Override public void getSubBlocks(CreativeTabs tab, NonNullList list) { for(E type : this.enumValues) - if(type.listForCreative() && !this.isMetaHidden[type.getMeta()]) + if(type.listForCreative()&&!this.isMetaHidden[type.getMeta()]) list.add(new ItemStack(this, 1, type.getMeta())); } @@ -460,9 +493,9 @@ else if(this.blockMaterial==Material.WOOD||this.blockMaterial==Material.CACTUS) @Override public boolean eventReceived(IBlockState state, World worldIn, BlockPos pos, int eventID, int eventParam) { - if (worldIn.isRemote&&eventID==255) + if(worldIn.isRemote&&eventID==255) { - worldIn.notifyBlockUpdate(pos,state,state,3); + worldIn.notifyBlockUpdate(pos, state, state, 3); return true; } return super.eventReceived(state, worldIn, pos, eventID, eventParam); @@ -473,27 +506,32 @@ public BlockIEBase setMetaHammerHarvest(int meta) canHammerHarvest[meta] = true; return this; } + public BlockIEBase setHammerHarvest() { for(int i = 0; i < metaNotNormalBlock.length; i++) canHammerHarvest[i] = true; return this; } + public boolean allowHammerHarvest(IBlockState blockState) { int meta = getMetaFromState(blockState); - if(meta>=0&&meta= 0&&meta < canHammerHarvest.length) return canHammerHarvest[meta]; return false; } + public boolean allowWirecutterHarvest(IBlockState blockState) { return false; } + public boolean isOpaqueCube() { return opaqueCube; } + public BlockIEBase setOpaque(boolean isOpaque) { opaqueCube = isOpaque; @@ -504,12 +542,13 @@ public BlockIEBase setOpaque(boolean isOpaque) @Override public boolean isToolEffective(String type, IBlockState state) { - if(allowHammerHarvest(state) && type.equals(Lib.TOOL_HAMMER)) + if(allowHammerHarvest(state)&&type.equals(Lib.TOOL_HAMMER)) return true; - if(allowWirecutterHarvest(state) && type.equals(Lib.TOOL_WIRECUTTER)) + if(allowWirecutterHarvest(state)&&type.equals(Lib.TOOL_WIRECUTTER)) return true; return super.isToolEffective(type, state); } + public String createRegistryName() { return ImmersiveEngineering.MODID+":"+name; @@ -518,8 +557,10 @@ public String createRegistryName() public interface IBlockEnum extends IStringSerializable { int getMeta(); + boolean listForCreative(); } + public abstract static class IELadderBlock & IBlockEnum> extends BlockIEBase { public IELadderBlock(String name, Material material, PropertyEnum mainProperty, @@ -532,29 +573,29 @@ public IELadderBlock(String name, Material material, PropertyEnum mainPropert public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) { super.onEntityCollidedWithBlock(worldIn, pos, state, entityIn); - if (entityIn instanceof EntityLivingBase&&!((EntityLivingBase) entityIn).isOnLadder()&&isLadder(state, worldIn, pos, (EntityLivingBase)entityIn)) + if(entityIn instanceof EntityLivingBase&&!((EntityLivingBase)entityIn).isOnLadder()&&isLadder(state, worldIn, pos, (EntityLivingBase)entityIn)) { float f5 = 0.15F; - if (entityIn.motionX < -f5) + if(entityIn.motionX < -f5) entityIn.motionX = -f5; - if (entityIn.motionX > f5) + if(entityIn.motionX > f5) entityIn.motionX = f5; - if (entityIn.motionZ < -f5) + if(entityIn.motionZ < -f5) entityIn.motionZ = -f5; - if (entityIn.motionZ > f5) + if(entityIn.motionZ > f5) entityIn.motionZ = f5; entityIn.fallDistance = 0.0F; - if (entityIn.motionY < -0.15D) + if(entityIn.motionY < -0.15D) entityIn.motionY = -0.15D; - if(entityIn.motionY<0 && entityIn instanceof EntityPlayer && entityIn.isSneaking()) + if(entityIn.motionY < 0&&entityIn instanceof EntityPlayer&&entityIn.isSneaking()) { - entityIn.motionY=0; + entityIn.motionY = 0; return; } if(entityIn.collidedHorizontally) - entityIn.motionY=.2; + entityIn.motionY = .2; } } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIEFluid.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIEFluid.java index 6a2e6eca1d..6725f96169 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIEFluid.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIEFluid.java @@ -35,7 +35,7 @@ public class BlockIEFluid extends BlockFluidClassic public BlockIEFluid(String name, Fluid fluid, Material material) { super(fluid, material); - this.setUnlocalizedName(ImmersiveEngineering.MODID + "." + name); + this.setUnlocalizedName(ImmersiveEngineering.MODID+"."+name); this.setCreativeTab(ImmersiveEngineering.creativeTab); // ImmersiveEngineering.registerBlock(this, ItemBlock.class, name); IEContent.registeredIEBlocks.add(this); @@ -48,6 +48,7 @@ public BlockIEFluid setFlammability(int flammability, int fireSpread) this.fireSpread = fireSpread; return this; } + public BlockIEFluid setPotionEffects(PotionEffect... potionEffects) { this.potionEffects = potionEffects; @@ -59,22 +60,24 @@ public int getFlammability(IBlockAccess world, BlockPos pos, EnumFacing face) { return this.flammability; } + @Override public int getFireSpreadSpeed(IBlockAccess world, BlockPos pos, EnumFacing face) { return fireSpread; } + @Override public boolean isFlammable(IBlockAccess world, BlockPos pos, EnumFacing face) { - return this.flammability>0; + return this.flammability > 0; } @Override public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) { - if(potionEffects!=null && entity instanceof EntityLivingBase) + if(potionEffects!=null&&entity instanceof EntityLivingBase) { for(PotionEffect effect : potionEffects) if(effect!=null) diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIEFluidConcrete.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIEFluidConcrete.java index 5b2ad1922f..2ab5349038 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIEFluidConcrete.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIEFluidConcrete.java @@ -44,43 +44,43 @@ public BlockIEFluidConcrete(String name, Fluid fluid, Material material) @Override protected BlockStateContainer createBlockState() { - return new ExtendedBlockState(this, new IProperty[] { LEVEL, IEProperties.INT_16}, FLUID_RENDER_PROPS.toArray(new IUnlistedProperty[0])); + return new ExtendedBlockState(this, new IProperty[]{LEVEL, IEProperties.INT_16}, FLUID_RENDER_PROPS.toArray(new IUnlistedProperty[0])); } @Override public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) { - if(!isSourceBlock(world, pos) && ForgeEventFactory.canCreateFluidSource(world, pos, state, false)) + if(!isSourceBlock(world, pos)&&ForgeEventFactory.canCreateFluidSource(world, pos, state, false)) { int adjacentSourceBlocks = - (isSourceBlock(world, pos.north()) ? 1 : 0) + - (isSourceBlock(world, pos.south()) ? 1 : 0) + - (isSourceBlock(world, pos.east()) ? 1 : 0) + - (isSourceBlock(world, pos.west()) ? 1 : 0); - if(adjacentSourceBlocks >= 2 && (world.getBlockState(pos.up(densityDir)).getMaterial().isSolid() || isSourceBlock(world, pos.up(densityDir)))) + (isSourceBlock(world, pos.north())?1: 0)+ + (isSourceBlock(world, pos.south())?1: 0)+ + (isSourceBlock(world, pos.east())?1: 0)+ + (isSourceBlock(world, pos.west())?1: 0); + if(adjacentSourceBlocks >= 2&&(world.getBlockState(pos.up(densityDir)).getMaterial().isSolid()||isSourceBlock(world, pos.up(densityDir)))) world.setBlockState(pos, state.withProperty(LEVEL, 0)); } int level = state.getValue(LEVEL); int timer = state.getValue(IEProperties.INT_16); - int quantaRemaining = quantaPerBlock - level; + int quantaRemaining = quantaPerBlock-level; int expQuanta = -101; - if(timer>=Math.min(14,quantaRemaining)) + if(timer >= Math.min(14, quantaRemaining)) { IBlockState solidState; - if(level>=14) + if(level >= 14) solidState = IEContent.blockStoneDevice.getStateFromMeta(BlockTypes_StoneDevices.CONCRETE_SHEET.getMeta()); - else if(level>=10) + else if(level >= 10) solidState = IEContent.blockStoneDevice.getStateFromMeta(BlockTypes_StoneDevices.CONCRETE_QUARTER.getMeta()); - else if(level>=6) + else if(level >= 6) solidState = IEContent.blockStoneDecorationSlabs.getStateFromMeta(BlockTypes_StoneDecoration.CONCRETE.getMeta()); - else if(level>=2) + else if(level >= 2) solidState = IEContent.blockStoneDevice.getStateFromMeta(BlockTypes_StoneDevices.CONCRETE_THREEQUARTER.getMeta()); else solidState = IEContent.blockStoneDecoration.getStateFromMeta(BlockTypes_StoneDecoration.CONCRETE.getMeta()); world.setBlockState(pos, solidState); - for(EntityLivingBase living : world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(pos,pos.add(1,1,1)))) - living.addPotionEffect(new PotionEffect(IEPotions.concreteFeet,Integer.MAX_VALUE)); + for(EntityLivingBase living : world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(pos, pos.add(1, 1, 1)))) + living.addPotionEffect(new PotionEffect(IEPotions.concreteFeet, Integer.MAX_VALUE)); return; } else @@ -93,23 +93,23 @@ else if(level>=2) // check adjacent block levels if non-source if(quantaRemaining < quantaPerBlock) { - if(world.getBlockState(pos.add( 0, -densityDir, 0)).getBlock() == this || - world.getBlockState(pos.add(-1, -densityDir, 0)).getBlock() == this || - world.getBlockState(pos.add( 1, -densityDir, 0)).getBlock() == this || - world.getBlockState(pos.add( 0, -densityDir, -1)).getBlock() == this || - world.getBlockState(pos.add( 0, -densityDir, 1)).getBlock() == this) + if(world.getBlockState(pos.add(0, -densityDir, 0)).getBlock()==this|| + world.getBlockState(pos.add(-1, -densityDir, 0)).getBlock()==this|| + world.getBlockState(pos.add(1, -densityDir, 0)).getBlock()==this|| + world.getBlockState(pos.add(0, -densityDir, -1)).getBlock()==this|| + world.getBlockState(pos.add(0, -densityDir, 1)).getBlock()==this) { - expQuanta = quantaPerBlock - 1; + expQuanta = quantaPerBlock-1; } else { int maxQuanta = -100; - maxQuanta = getLargerQuanta(world, pos.add(-1, 0, 0), maxQuanta); - maxQuanta = getLargerQuanta(world, pos.add( 1, 0, 0), maxQuanta); - maxQuanta = getLargerQuanta(world, pos.add( 0, 0, -1), maxQuanta); - maxQuanta = getLargerQuanta(world, pos.add( 0, 0, 1), maxQuanta); + maxQuanta = getLargerQuanta(world, pos.add(-1, 0, 0), maxQuanta); + maxQuanta = getLargerQuanta(world, pos.add(1, 0, 0), maxQuanta); + maxQuanta = getLargerQuanta(world, pos.add(0, 0, -1), maxQuanta); + maxQuanta = getLargerQuanta(world, pos.add(0, 0, 1), maxQuanta); - expQuanta = maxQuanta - 1; + expQuanta = maxQuanta-1; } int total = level; @@ -133,7 +133,7 @@ else if(level>=2) } // decay calculation - if(expQuanta != quantaRemaining) + if(expQuanta!=quantaRemaining) { quantaRemaining = expQuanta; @@ -141,7 +141,7 @@ else if(level>=2) world.setBlockToAir(pos); else { - world.setBlockState(pos, state.withProperty(LEVEL, quantaPerBlock - expQuanta), 2); + world.setBlockState(pos, state.withProperty(LEVEL, quantaPerBlock-expQuanta), 2); world.scheduleUpdate(pos, this, tickRate); world.notifyNeighborsOfStateChange(pos, this, true); } @@ -159,7 +159,7 @@ else if(quantaRemaining >= quantaPerBlock) } // Flow outward if possible - int flowMeta = quantaPerBlock - quantaRemaining + 1; + int flowMeta = quantaPerBlock-quantaRemaining+1; if(flowMeta >= quantaPerBlock) { world.setBlockState(pos, state.withProperty(IEProperties.INT_16, Math.min(15, timer+1))); @@ -167,20 +167,20 @@ else if(quantaRemaining >= quantaPerBlock) return; } - if(isSourceBlock(world, pos) || !isFlowingVertically(world, pos)) + if(isSourceBlock(world, pos)||!isFlowingVertically(world, pos)) { - if(world.getBlockState(pos.down(densityDir)).getBlock() == this) + if(world.getBlockState(pos.down(densityDir)).getBlock()==this) flowMeta = 1; boolean flowTo[] = getOptimalFlowDirections(world, pos); boolean hasFlown = false; if(flowTo[0]) - hasFlown |= flowIntoBlockRet(world, pos.add(-1, 0, 0), flowMeta, timer); + hasFlown |= flowIntoBlockRet(world, pos.add(-1, 0, 0), flowMeta, timer); if(flowTo[1]) - hasFlown |= flowIntoBlockRet(world, pos.add( 1, 0, 0), flowMeta, timer); + hasFlown |= flowIntoBlockRet(world, pos.add(1, 0, 0), flowMeta, timer); if(flowTo[2]) - hasFlown |= flowIntoBlockRet(world, pos.add( 0, 0, -1), flowMeta, timer); + hasFlown |= flowIntoBlockRet(world, pos.add(0, 0, -1), flowMeta, timer); if(flowTo[3]) - hasFlown |= flowIntoBlockRet(world, pos.add( 0, 0, 1), flowMeta, timer); + hasFlown |= flowIntoBlockRet(world, pos.add(0, 0, 1), flowMeta, timer); if(!hasFlown) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIEScaffoldSlab.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIEScaffoldSlab.java index 302915161d..4a1c147151 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIEScaffoldSlab.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIEScaffoldSlab.java @@ -24,7 +24,7 @@ import javax.annotation.Nullable; import java.util.List; -public class BlockIEScaffoldSlab&BlockIEBase.IBlockEnum> extends BlockIESlab +public class BlockIEScaffoldSlab & BlockIEBase.IBlockEnum> extends BlockIESlab { public BlockIEScaffoldSlab(String name, Material material, PropertyEnum property) { @@ -58,43 +58,43 @@ public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, Block { int type = ((TileEntityIESlab)te).slabType; if(type==0) - return new AxisAlignedBB(0,0,0, 1,.5f,1); + return new AxisAlignedBB(0, 0, 0, 1, .5f, 1); else if(type==1) - return new AxisAlignedBB(0,.5f,0, 1,1,1); + return new AxisAlignedBB(0, .5f, 0, 1, 1, 1); else return FULL_BLOCK_AABB; } else - return new AxisAlignedBB(0,0,0,1,.5f,1); + return new AxisAlignedBB(0, 0, 0, 1, .5f, 1); } @Override public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) { super.onEntityCollidedWithBlock(worldIn, pos, state, entityIn); - if (entityIn instanceof EntityLivingBase&&!((EntityLivingBase) entityIn).isOnLadder()&&isLadder(state, worldIn, pos, (EntityLivingBase)entityIn)) + if(entityIn instanceof EntityLivingBase&&!((EntityLivingBase)entityIn).isOnLadder()&&isLadder(state, worldIn, pos, (EntityLivingBase)entityIn)) { float f5 = 0.15F; - if (entityIn.motionX < -f5) + if(entityIn.motionX < -f5) entityIn.motionX = -f5; - if (entityIn.motionX > f5) + if(entityIn.motionX > f5) entityIn.motionX = f5; - if (entityIn.motionZ < -f5) + if(entityIn.motionZ < -f5) entityIn.motionZ = -f5; - if (entityIn.motionZ > f5) + if(entityIn.motionZ > f5) entityIn.motionZ = f5; entityIn.fallDistance = 0.0F; - if (entityIn.motionY < -0.15D) + if(entityIn.motionY < -0.15D) entityIn.motionY = -0.15D; - if(entityIn.motionY<0 && entityIn instanceof EntityPlayer && entityIn.isSneaking()) + if(entityIn.motionY < 0&&entityIn instanceof EntityPlayer&&entityIn.isSneaking()) { - entityIn.motionY=0; + entityIn.motionY = 0; return; } if(entityIn.collidedHorizontally) - entityIn.motionY=.2; + entityIn.motionY = .2; } } @@ -102,8 +102,8 @@ public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState s public boolean isLadder(IBlockState state, IBlockAccess world, BlockPos pos, EntityLivingBase entity) { TileEntity te = world.getTileEntity(pos); - if(te instanceof TileEntityIESlab && ((TileEntityIESlab)te).slabType==0) - return entity.posY-pos.getY()<.5; + if(te instanceof TileEntityIESlab&&((TileEntityIESlab)te).slabType==0) + return entity.posY-pos.getY() < .5; return true; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIESlab.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIESlab.java index 5b818b3053..2e07238ecb 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIESlab.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIESlab.java @@ -23,9 +23,9 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class BlockIESlab&BlockIEBase.IBlockEnum> extends BlockIETileProvider +public class BlockIESlab & BlockIEBase.IBlockEnum> extends BlockIETileProvider { - public static final PropertyInteger prop_SlabType = PropertyInteger.create("slabtype", 0,2); + public static final PropertyInteger prop_SlabType = PropertyInteger.create("slabtype", 0, 2); public BlockIESlab(String name, Material material, PropertyEnum property) { @@ -80,9 +80,9 @@ public void getDrops(NonNullList drops, IBlockAccess world, BlockPos @Override public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity tile, ItemStack stack) { - if(tile instanceof TileEntityIESlab && !player.capabilities.isCreativeMode) + if(tile instanceof TileEntityIESlab&&!player.capabilities.isCreativeMode) { - spawnAsEntity(world, pos, new ItemStack(this, ((TileEntityIESlab)tile).slabType==2?2:1 , this.getMetaFromState(state))); + spawnAsEntity(world, pos, new ItemStack(this, ((TileEntityIESlab)tile).slabType==2?2: 1, this.getMetaFromState(state))); return; } super.harvestBlock(world, player, pos, state, tile, stack); @@ -128,13 +128,13 @@ public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, Block { int type = ((TileEntityIESlab)te).slabType; if(type==0) - return new AxisAlignedBB(0,0,0, 1,.5f,1); + return new AxisAlignedBB(0, 0, 0, 1, .5f, 1); else if(type==1) - return new AxisAlignedBB(0,.5f,0, 1,1,1); + return new AxisAlignedBB(0, .5f, 0, 1, 1, 1); else - return FULL_BLOCK_AABB; + return FULL_BLOCK_AABB; } else - return new AxisAlignedBB(0,0,0,1,.5f,1); + return new AxisAlignedBB(0, 0, 0, 1, .5f, 1); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIEStairs.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIEStairs.java index d3f8393d36..b5c2f8741f 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIEStairs.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIEStairs.java @@ -27,7 +27,7 @@ public class BlockIEStairs extends BlockStairs public String name; float explosionResistance; BlockRenderLayer renderLayer = BlockRenderLayer.SOLID; - + public BlockIEStairs(String name, IBlockState state) { super(state); @@ -40,13 +40,13 @@ public BlockIEStairs(String name, IBlockState state) IEContent.registeredIEBlocks.add(this); IEContent.registeredIEItems.add(new ItemBlockIEStairs(this)); } - + public BlockIEStairs setFlammable(boolean b) { this.isFlammable = b; return this; } - + public BlockIEStairs setHasFlavour(boolean hasFlavour) { this.hasFlavour = hasFlavour; @@ -58,6 +58,7 @@ public float getExplosionResistance(Entity exploder) { return explosionResistance; } + public BlockIEStairs setExplosionResistance(float explosionResistance) { this.explosionResistance = explosionResistance; diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIETileProvider.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIETileProvider.java index 4e1437be06..7fa9e92f46 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIETileProvider.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/BlockIETileProvider.java @@ -29,7 +29,6 @@ import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.BlockFaceShape; import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -48,11 +47,9 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraft.world.WorldServer; import net.minecraftforge.client.model.obj.OBJModel.OBJState; import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.common.property.Properties; -import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; @@ -76,15 +73,17 @@ public BlockIETileProvider(String name, Material material, PropertyEnum mainP } private static final Map tempTile = new HashMap<>(); + @SubscribeEvent public static void onTick(TickEvent.ServerTickEvent ev) { - if (ev.phase== TickEvent.Phase.END) + if(ev.phase==TickEvent.Phase.END) tempTile.clear(); } @Override - public boolean hasTileEntity(IBlockState state) { + public boolean hasTileEntity(IBlockState state) + { return true; } @@ -94,42 +93,42 @@ public TileEntity createTileEntity(World world, IBlockState state) { TileEntity basic = createBasicTE(world, state.getValue(property)); Collection> keys = state.getPropertyKeys(); - if (basic instanceof IDirectionalTile) + if(basic instanceof IDirectionalTile) { EnumFacing newFacing = null; - if (keys.contains(IEProperties.FACING_HORIZONTAL)) + if(keys.contains(IEProperties.FACING_HORIZONTAL)) newFacing = state.getValue(IEProperties.FACING_HORIZONTAL); - else if (keys.contains(IEProperties.FACING_ALL)) + else if(keys.contains(IEProperties.FACING_ALL)) newFacing = state.getValue(IEProperties.FACING_ALL); - int type = ((IDirectionalTile) basic).getFacingLimitation(); - if (newFacing!=null) + int type = ((IDirectionalTile)basic).getFacingLimitation(); + if(newFacing!=null) { - switch (type) + switch(type) { case 2: case 4: case 5: case 6: - if (newFacing.getAxis()==Axis.Y) + if(newFacing.getAxis()==Axis.Y) newFacing = null; break; case 3: - if (newFacing.getAxis()!=Axis.Y) + if(newFacing.getAxis()!=Axis.Y) newFacing = null; break; } - if (newFacing!=null) - ((IDirectionalTile) basic).setFacing(newFacing); + if(newFacing!=null) + ((IDirectionalTile)basic).setFacing(newFacing); } } - if (basic instanceof IAttachedIntegerProperies) + if(basic instanceof IAttachedIntegerProperies) { - IAttachedIntegerProperies tileIntProps = (IAttachedIntegerProperies) basic; - String[] names = ((IAttachedIntegerProperies) basic).getIntPropertyNames(); - for (String propertyName:names) + IAttachedIntegerProperies tileIntProps = (IAttachedIntegerProperies)basic; + String[] names = ((IAttachedIntegerProperies)basic).getIntPropertyNames(); + for(String propertyName : names) { PropertyInteger property = tileIntProps.getIntProperty(propertyName); - if (keys.contains(property)) + if(keys.contains(property)) tileIntProps.setValue(propertyName, state.getValue(property)); } } @@ -141,9 +140,9 @@ else if (keys.contains(IEProperties.FACING_ALL)) protected IBlockState getInitDefaultState() { IBlockState ret = super.getInitDefaultState(); - if (ret.getPropertyKeys().contains(IEProperties.FACING_ALL)) + if(ret.getPropertyKeys().contains(IEProperties.FACING_ALL)) ret = ret.withProperty(IEProperties.FACING_ALL, getDefaultFacing()); - else if (ret.getPropertyKeys().contains(IEProperties.FACING_HORIZONTAL)) + else if(ret.getPropertyKeys().contains(IEProperties.FACING_HORIZONTAL)) ret = ret.withProperty(IEProperties.FACING_HORIZONTAL, getDefaultFacing()); return ret; } @@ -156,12 +155,12 @@ public void getDrops(NonNullList drops, IBlockAccess world, BlockPos // public List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { TileEntity tile = world.getTileEntity(pos); - DimensionBlockPos dpos = new DimensionBlockPos(pos, world instanceof World?((World) world).provider.getDimension():0); - if(tile==null && tempTile.containsKey(dpos)) + DimensionBlockPos dpos = new DimensionBlockPos(pos, world instanceof World?((World)world).provider.getDimension(): 0); + if(tile==null&&tempTile.containsKey(dpos)) tile = tempTile.get(dpos); - if(tile != null && ( !(tile instanceof ITileDrop) || !((ITileDrop)tile).preventInventoryDrop())) + if(tile!=null&&(!(tile instanceof ITileDrop)||!((ITileDrop)tile).preventInventoryDrop())) { - if(tile instanceof IIEInventory && ((IIEInventory)tile).getDroppedItems()!=null) + if(tile instanceof IIEInventory&&((IIEInventory)tile).getDroppedItems()!=null) { for(ItemStack s : ((IIEInventory)tile).getDroppedItems()) if(!s.isEmpty()) @@ -196,8 +195,8 @@ public void breakBlock(World world, BlockPos pos, IBlockState state) TileEntity tile = world.getTileEntity(pos); if(tile instanceof IHasDummyBlocks) ((IHasDummyBlocks)tile).breakDummies(pos, state); - if(tile instanceof IImmersiveConnectable && !world.isRemote) - ImmersiveNetHandler.INSTANCE.clearAllConnectionsFor(Utils.toCC(tile), world, world.getGameRules().getBoolean("doTileDrops")); + if(tile instanceof IImmersiveConnectable&&!world.isRemote) + ImmersiveNetHandler.INSTANCE.clearAllConnectionsFor(Utils.toCC(tile), world, world.getGameRules().getBoolean("doTileDrops")); tempTile.put(new DimensionBlockPos(pos, world.provider.getDimension()), tile); super.breakBlock(world, pos, state); world.removeTileEntity(pos); @@ -209,7 +208,7 @@ public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockS if(tile instanceof IAdditionalDrops) { Collection stacks = ((IAdditionalDrops)tile).getExtraDrops(player, state); - if(stacks!=null && !stacks.isEmpty()) + if(stacks!=null&&!stacks.isEmpty()) for(ItemStack s : stacks) if(!s.isEmpty()) spawnAsEntity(world, pos, s); @@ -237,7 +236,7 @@ public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World wo return s; } Item item = Item.getItemFromBlock(this); - return item == Items.AIR ? ItemStack.EMPTY : new ItemStack(item, 1, this.damageDropped(world.getBlockState(pos))); + return item==Items.AIR?ItemStack.EMPTY: new ItemStack(item, 1, this.damageDropped(world.getBlockState(pos))); } @@ -246,7 +245,7 @@ public boolean eventReceived(IBlockState state, World worldIn, BlockPos pos, int { super.eventReceived(state, worldIn, pos, eventID, eventParam); TileEntity tileentity = worldIn.getTileEntity(pos); - return tileentity != null && tileentity.receiveClientEvent(eventID, eventParam); + return tileentity!=null&&tileentity.receiveClientEvent(eventID, eventParam); } protected EnumFacing getDefaultFacing() @@ -263,26 +262,26 @@ public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPo if(tile instanceof IAttachedIntegerProperies) { for(String s : ((IAttachedIntegerProperies)tile).getIntPropertyNames()) - state = applyProperty(state, ((IAttachedIntegerProperies)tile).getIntProperty(s), ((IAttachedIntegerProperies)tile).getIntPropertyValue(s)); + state = applyProperty(state, ((IAttachedIntegerProperies)tile).getIntProperty(s), ((IAttachedIntegerProperies)tile).getIntPropertyValue(s)); } - if(tile instanceof IDirectionalTile && (state.getPropertyKeys().contains(IEProperties.FACING_ALL) || state.getPropertyKeys().contains(IEProperties.FACING_HORIZONTAL))) + if(tile instanceof IDirectionalTile&&(state.getPropertyKeys().contains(IEProperties.FACING_ALL)||state.getPropertyKeys().contains(IEProperties.FACING_HORIZONTAL))) { PropertyDirection prop = state.getPropertyKeys().contains(IEProperties.FACING_HORIZONTAL)?IEProperties.FACING_HORIZONTAL: IEProperties.FACING_ALL; state = applyProperty(state, prop, ((IDirectionalTile)tile).getFacing()); } if(tile instanceof IActiveState) { - IProperty boolProp = ((IActiveState) tile).getBoolProperty(IActiveState.class); + IProperty boolProp = ((IActiveState)tile).getBoolProperty(IActiveState.class); if(state.getPropertyKeys().contains(boolProp)) - state = applyProperty(state, boolProp, ((IActiveState) tile).getIsActive()); + state = applyProperty(state, boolProp, ((IActiveState)tile).getIsActive()); } if(tile instanceof IDualState) { - IProperty boolProp = ((IDualState) tile).getBoolProperty(IDualState.class); + IProperty boolProp = ((IDualState)tile).getBoolProperty(IDualState.class); if(state.getPropertyKeys().contains(boolProp)) - state = applyProperty(state, boolProp, ((IDualState) tile).getIsSecondState()); + state = applyProperty(state, boolProp, ((IDualState)tile).getIsSecondState()); } if(tile instanceof TileEntityMultiblockPart) @@ -305,23 +304,23 @@ public boolean rotateBlock(World world, BlockPos pos, EnumFacing axis) if(!((IDirectionalTile)tile).canRotate(axis)) return false; IBlockState state = world.getBlockState(pos); - if(state.getPropertyKeys().contains(IEProperties.FACING_ALL) || state.getPropertyKeys().contains(IEProperties.FACING_HORIZONTAL)) + if(state.getPropertyKeys().contains(IEProperties.FACING_ALL)||state.getPropertyKeys().contains(IEProperties.FACING_HORIZONTAL)) { PropertyDirection prop = state.getPropertyKeys().contains(IEProperties.FACING_HORIZONTAL)?IEProperties.FACING_HORIZONTAL: IEProperties.FACING_ALL; EnumFacing f = ((IDirectionalTile)tile).getFacing(); int limit = ((IDirectionalTile)tile).getFacingLimitation(); if(limit==0) - f = EnumFacing.VALUES[(f.ordinal() + 1) % EnumFacing.VALUES.length]; + f = EnumFacing.VALUES[(f.ordinal()+1)%EnumFacing.VALUES.length]; else if(limit==1) - f = axis.getAxisDirection()==AxisDirection.POSITIVE?f.rotateAround(axis.getAxis()).getOpposite():f.rotateAround(axis.getAxis()); - else if(limit == 2 || limit == 5) - f = axis.getAxisDirection()==AxisDirection.POSITIVE?f.rotateY():f.rotateYCCW(); - if(f != ((IDirectionalTile)tile).getFacing()) + f = axis.getAxisDirection()==AxisDirection.POSITIVE?f.rotateAround(axis.getAxis()).getOpposite(): f.rotateAround(axis.getAxis()); + else if(limit==2||limit==5) + f = axis.getAxisDirection()==AxisDirection.POSITIVE?f.rotateY(): f.rotateYCCW(); + if(f!=((IDirectionalTile)tile).getFacing()) { EnumFacing old = ((IDirectionalTile)tile).getFacing(); ((IDirectionalTile)tile).setFacing(f); - ((IDirectionalTile)tile).afterRotation(old,f); + ((IDirectionalTile)tile).afterRotation(old, f); state = applyProperty(state, prop, ((IDirectionalTile)tile).getFacing()); world.setBlockState(pos, state.cycleProperty(prop)); } @@ -354,9 +353,9 @@ else if(te instanceof IHasObjProperty) extended = extended.withProperty(IOBJModelCallback.PROPERTY, (IOBJModelCallback)te); if(te.hasCapability(CapabilityShader.SHADER_CAPABILITY, null)) extended = extended.withProperty(CapabilityShader.BLOCKSTATE_PROPERTY, te.getCapability(CapabilityShader.SHADER_CAPABILITY, null)); - if(te instanceof IPropertyPassthrough && ((IExtendedBlockState)state).getUnlistedNames().contains(IEProperties.TILEENTITY_PASSTHROUGH)) + if(te instanceof IPropertyPassthrough&&((IExtendedBlockState)state).getUnlistedNames().contains(IEProperties.TILEENTITY_PASSTHROUGH)) extended = extended.withProperty(IEProperties.TILEENTITY_PASSTHROUGH, te); - if(te instanceof TileEntityImmersiveConnectable && ((IExtendedBlockState)state).getUnlistedNames().contains(IEProperties.CONNECTIONS)) + if(te instanceof TileEntityImmersiveConnectable&&((IExtendedBlockState)state).getUnlistedNames().contains(IEProperties.CONNECTIONS)) extended = extended.withProperty(IEProperties.CONNECTIONS, ((TileEntityImmersiveConnectable)te).genConnBlockstate()); } state = extended; @@ -392,32 +391,32 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En { ItemStack heldItem = player.getHeldItem(hand); TileEntity tile = world.getTileEntity(pos); - if(tile instanceof IConfigurableSides && Utils.isHammer(heldItem) && !world.isRemote) + if(tile instanceof IConfigurableSides&&Utils.isHammer(heldItem)&&!world.isRemote) { - int iSide = player.isSneaking()?side.getOpposite().ordinal():side.ordinal(); + int iSide = player.isSneaking()?side.getOpposite().ordinal(): side.ordinal(); if(((IConfigurableSides)tile).toggleSide(iSide, player)) return true; } - if(tile instanceof IDirectionalTile && Utils.isHammer(heldItem) && ((IDirectionalTile)tile).canHammerRotate(side, hitX, hitY, hitZ, player) && !world.isRemote) + if(tile instanceof IDirectionalTile&&Utils.isHammer(heldItem)&&((IDirectionalTile)tile).canHammerRotate(side, hitX, hitY, hitZ, player)&&!world.isRemote) { EnumFacing f = ((IDirectionalTile)tile).getFacing(); EnumFacing oldF = f; int limit = ((IDirectionalTile)tile).getFacingLimitation(); if(limit==0) - f = EnumFacing.VALUES[(f.ordinal() + 1) % EnumFacing.VALUES.length]; + f = EnumFacing.VALUES[(f.ordinal()+1)%EnumFacing.VALUES.length]; else if(limit==1) - f = player.isSneaking()?f.rotateAround(side.getAxis()).getOpposite():f.rotateAround(side.getAxis()); - else if(limit == 2 || limit == 5) - f = player.isSneaking()?f.rotateYCCW():f.rotateY(); + f = player.isSneaking()?f.rotateAround(side.getAxis()).getOpposite(): f.rotateAround(side.getAxis()); + else if(limit==2||limit==5) + f = player.isSneaking()?f.rotateYCCW(): f.rotateY(); ((IDirectionalTile)tile).setFacing(f); - ((IDirectionalTile)tile).afterRotation(oldF,f); + ((IDirectionalTile)tile).afterRotation(oldF, f); tile.markDirty(); - world.notifyBlockUpdate(pos,state,state,3); + world.notifyBlockUpdate(pos, state, state, 3); world.addBlockEvent(tile.getPos(), tile.getBlockType(), 255, 0); return true; } - if(tile instanceof IHammerInteraction && Utils.isHammer(heldItem) && !world.isRemote) + if(tile instanceof IHammerInteraction&&Utils.isHammer(heldItem)&&!world.isRemote) { boolean b = ((IHammerInteraction)tile).hammerUseSide(side, player, hitX, hitY, hitZ); if(b) @@ -429,11 +428,11 @@ else if(limit == 2 || limit == 5) if(b) return b; } - if(tile instanceof IGuiTile && hand == EnumHand.MAIN_HAND && !player.isSneaking()) + if(tile instanceof IGuiTile&&hand==EnumHand.MAIN_HAND&&!player.isSneaking()) { TileEntity master = ((IGuiTile)tile).getGuiMaster(); - if(!world.isRemote && master!=null && ((IGuiTile)master).canOpenGui(player)) - CommonProxy.openGuiForTile(player,(TileEntity & IGuiTile)master); + if(!world.isRemote&&master!=null&&((IGuiTile)master).canOpenGui(player)) + CommonProxy.openGuiForTile(player, (TileEntity & IGuiTile)master); return true; } return false; @@ -442,14 +441,14 @@ else if(limit == 2 || limit == 5) @Override public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos fromPos) { - if (!world.isRemote) + if(!world.isRemote) ApiUtils.addFutureServerTask(world, () -> { - if (world.isBlockLoaded(pos)) + if(world.isBlockLoaded(pos)) { TileEntity tile = world.getTileEntity(pos); - if (tile instanceof INeighbourChangeTile && !tile.getWorld().isRemote) - ((INeighbourChangeTile) tile).onNeighborBlockChange(fromPos); + if(tile instanceof INeighbourChangeTile&&!tile.getWorld().isRemote) + ((INeighbourChangeTile)tile).onNeighborBlockChange(fromPos); } }); } @@ -468,15 +467,17 @@ public BlockIETileProvider setHasColours() this.hasColours = true; return this; } + @Override public boolean hasCustomBlockColours() { return hasColours; } + @Override public int getRenderColour(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex) { - if(worldIn!=null && pos!=null) + if(worldIn!=null&&pos!=null) { TileEntity tile = worldIn.getTileEntity(pos); if(tile instanceof IColouredTile) @@ -502,18 +503,18 @@ else if(side!=null) double wMax = side.getAxis()==Axis.X?bb.maxZ: bb.maxX; double hMin = side.getAxis()==Axis.Y?bb.minZ: bb.minY; double hMax = side.getAxis()==Axis.Y?bb.maxZ: bb.maxY; - if(wMin==0&&hMin==0 && wMax==1&&hMax==1) + if(wMin==0&&hMin==0&&wMax==1&&hMax==1) return BlockFaceShape.SOLID; - else if(hMin==0&&hMax==1 && wMin==(1-wMax)) + else if(hMin==0&&hMax==1&&wMin==(1-wMax)) { - if(wMin>.375) + if(wMin > .375) return BlockFaceShape.MIDDLE_POLE_THIN; - else if(wMin>.3125) + else if(wMin > .3125) return BlockFaceShape.MIDDLE_POLE; else return BlockFaceShape.MIDDLE_POLE_THICK; } - else if(hMin==wMin && hMax==wMax) + else if(hMin==wMin&&hMax==wMax) { if(wMin > .375) return BlockFaceShape.CENTER_SMALL; @@ -540,11 +541,12 @@ public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, Block { float[] bounds = ((IBlockBounds)te).getBlockBounds(); if(bounds!=null) - return new AxisAlignedBB(bounds[0],bounds[1],bounds[2],bounds[3],bounds[4],bounds[5]); + return new AxisAlignedBB(bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]); } } return super.getBoundingBox(state, world, pos); } + @Override public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB mask, List list, @Nullable Entity ent, boolean p_185477_7_) { @@ -552,16 +554,17 @@ public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, if(te instanceof IAdvancedCollisionBounds) { List bounds = ((IAdvancedCollisionBounds)te).getAdvancedColisionBounds(); - if(bounds!=null && !bounds.isEmpty()) + if(bounds!=null&&!bounds.isEmpty()) { for(AxisAlignedBB aabb : bounds) - if(aabb!=null && mask.intersects(aabb)) + if(aabb!=null&&mask.intersects(aabb)) list.add(aabb); return; } } super.addCollisionBoxToList(state, world, pos, mask, list, ent, p_185477_7_); } + @Override public RayTraceResult collisionRayTrace(IBlockState state, World world, BlockPos pos, Vec3d start, Vec3d end) { @@ -569,17 +572,17 @@ public RayTraceResult collisionRayTrace(IBlockState state, World world, BlockPos if(te instanceof IAdvancedSelectionBounds) { List list = ((IAdvancedSelectionBounds)te).getAdvancedSelectionBounds(); - if(list!=null && !list.isEmpty()) + if(list!=null&&!list.isEmpty()) { RayTraceResult min = null; double minDist = Double.POSITIVE_INFINITY; for(AxisAlignedBB aabb : list) { - RayTraceResult mop = this.rayTrace(pos, start, end, aabb.offset(-pos.getX(),-pos.getY(),-pos.getZ())); + RayTraceResult mop = this.rayTrace(pos, start, end, aabb.offset(-pos.getX(), -pos.getY(), -pos.getZ())); if(mop!=null) { double dist = mop.hitVec.squareDistanceTo(start); - if (dist drops = getTileDrops(player, state); - return drops.size()>0?drops.get(0):ItemStack.EMPTY; + return drops.size() > 0?drops.get(0): ItemStack.EMPTY; } default NonNullList getTileDrops(@Nullable EntityPlayer player, IBlockState state) @@ -199,8 +225,12 @@ default ItemStack getPickBlock(@Nullable EntityPlayer player, IBlockState state, void readOnPlacement(@Nullable EntityLivingBase placer, ItemStack stack); - default boolean preventInventoryDrop() { return false; } + default boolean preventInventoryDrop() + { + return false; + } } + public interface IAdditionalDrops { Collection getExtraDrops(EntityPlayer player, IBlockState state); @@ -245,11 +275,14 @@ public interface IFaceShape { BlockFaceShape getFaceShape(EnumFacing side); } + public interface IAdvancedSelectionBounds extends IBlockBounds { List getAdvancedSelectionBounds(); + boolean isOverrideBox(AxisAlignedBB box, EntityPlayer player, RayTraceResult mop, ArrayList list); } + public interface IAdvancedCollisionBounds extends IBlockBounds { List getAdvancedColisionBounds(); @@ -258,14 +291,18 @@ public interface IAdvancedCollisionBounds extends IBlockBounds public interface IHasDummyBlocks extends IGeneralMultiblock { void placeDummies(BlockPos pos, IBlockState state, EnumFacing side, float hitX, float hitY, float hitZ); + void breakDummies(BlockPos pos, IBlockState state); + boolean isDummy(); + @Override default boolean isLogicDummy() { return isDummy(); } } + /** * super-interface for {@link TileEntityMultiblockPart} and {@link IHasDummyBlocks} */ @@ -278,14 +315,16 @@ public interface IHasObjProperty { ArrayList compileDisplayList(); } + public interface IAdvancedHasObjProperty { OBJState getOBJState(); } + public interface IDynamicTexture { @SideOnly(Side.CLIENT) - HashMap getTextureReplacements(); + HashMap getTextureReplacements(); } public interface IGuiTile @@ -294,8 +333,11 @@ default boolean canOpenGui(EntityPlayer player) { return canOpenGui(); } + boolean canOpenGui(); + int getGuiID(); + @Nullable TileEntity getGuiMaster(); @@ -307,6 +349,7 @@ default void onGuiOpened(EntityPlayer player, boolean clientside) public interface IProcessTile { int[] getCurrentProcessesStep(); + int[] getCurrentProcessesMax(); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/ItemBlockIEBase.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/ItemBlockIEBase.java index 8d55d93eb9..0389f90ccb 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/ItemBlockIEBase.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/ItemBlockIEBase.java @@ -43,13 +43,13 @@ public class ItemBlockIEBase extends ItemBlock public ItemBlockIEBase(Block b) { super(b); - if(((BlockIEBase)b).enumValues.length>1) + if(((BlockIEBase)b).enumValues.length > 1) setHasSubtypes(true); - this.burnTime = new int[((BlockIEBase)b).enumValues!=null?((BlockIEBase)b).enumValues.length:1]; + this.burnTime = new int[((BlockIEBase)b).enumValues!=null?((BlockIEBase)b).enumValues.length: 1]; } @Override - public int getMetadata (int damageValue) + public int getMetadata(int damageValue) { return damageValue; } @@ -60,10 +60,11 @@ public void getSubItems(CreativeTabs tab, NonNullList itemList) if(this.isInCreativeTab(tab)) this.block.getSubBlocks(tab, itemList); } + @Override public String getUnlocalizedName(ItemStack stack) { - return ((BlockIEBase) this.block).getUnlocalizedName(stack); + return ((BlockIEBase)this.block).getUnlocalizedName(stack); } @Override @@ -80,7 +81,7 @@ public void addInformation(ItemStack stack, @Nullable World world, List { String subName = ((BlockIEBase)this.block).getStateFromMeta(stack.getItemDamage()).getValue(((BlockIEBase)this.block).property).toString().toLowerCase(Locale.US); String flavourKey = Lib.DESC_FLAVOUR+((BlockIEBase)this.block).name+"."+subName; - tooltip.add(TextFormatting.GRAY.toString()+ I18n.format(flavourKey)); + tooltip.add(TextFormatting.GRAY.toString()+I18n.format(flavourKey)); } super.addInformation(stack, world, tooltip, tooltipFlag); if(ItemNBTHelper.hasKey(stack, "energyStorage")) @@ -96,10 +97,11 @@ public void addInformation(ItemStack stack, @Nullable World world, List public ItemBlockIEBase setBurnTime(int meta, int burnTime) { - if(meta>=0 && meta= 0&&meta < this.burnTime.length) this.burnTime[meta] = burnTime; return this; } + @Override public int getItemBurnTime(ItemStack itemStack) { @@ -109,12 +111,12 @@ public int getItemBurnTime(ItemStack itemStack) @Override public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) { - if(!((BlockIEBase)this.block).canIEBlockBePlaced(world, pos, newState, side, hitX,hitY,hitZ, player, stack)) + if(!((BlockIEBase)this.block).canIEBlockBePlaced(world, pos, newState, side, hitX, hitY, hitZ, player, stack)) return false; boolean ret = super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState); if(ret) { - ((BlockIEBase)this.block).onIEBlockPlacedBy(world, pos, newState, side, hitX,hitY,hitZ, player, stack); + ((BlockIEBase)this.block).onIEBlockPlacedBy(world, pos, newState, side, hitX, hitY, hitZ, player, stack); } return ret; } @@ -125,16 +127,16 @@ public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos ItemStack stack = player.getHeldItem(hand); IBlockState iblockstate = world.getBlockState(pos); Block block = iblockstate.getBlock(); - if (!block.isReplaceable(world, pos)) + if(!block.isReplaceable(world, pos)) pos = pos.offset(side); - if(stack.getCount() > 0 && player.canPlayerEdit(pos, side, stack) && canBlockBePlaced(world, pos, side, stack)) + if(stack.getCount() > 0&&player.canPlayerEdit(pos, side, stack)&&canBlockBePlaced(world, pos, side, stack)) { int i = this.getMetadata(stack.getMetadata()); IBlockState iblockstate1 = this.block.getStateForPlacement(world, pos, side, hitX, hitY, hitZ, i, player); if(placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, iblockstate1)) { SoundType soundtype = world.getBlockState(pos).getBlock().getSoundType(world.getBlockState(pos), world, pos, player); - world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); + world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume()+1.0F)/2.0F, soundtype.getPitch()*0.8F); if(!player.capabilities.isCreativeMode) stack.shrink(1); } @@ -142,28 +144,31 @@ public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos } return EnumActionResult.FAIL; } + @Override public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack) { Block block = worldIn.getBlockState(pos).getBlock(); - if(block == Blocks.SNOW_LAYER && block.isReplaceable(worldIn, pos)) + if(block==Blocks.SNOW_LAYER&&block.isReplaceable(worldIn, pos)) { side = EnumFacing.UP; - } else if(!block.isReplaceable(worldIn, pos)) + } + else if(!block.isReplaceable(worldIn, pos)) { pos = pos.offset(side); } return canBlockBePlaced(worldIn, pos, side, stack); } + private boolean canBlockBePlaced(World w, BlockPos pos, EnumFacing side, ItemStack stack) { - BlockIEBase blockIn = (BlockIEBase) this.block; + BlockIEBase blockIn = (BlockIEBase)this.block; Block block = w.getBlockState(pos).getBlock(); - AxisAlignedBB axisalignedbb = blockIn.getCollisionBoundingBox( blockIn.getStateFromMeta(stack.getItemDamage()), w, pos); - if (axisalignedbb != null && !w.checkNoEntityCollision(axisalignedbb.offset(pos), null)) return false; - return block.isReplaceable(w, pos) && blockIn.canPlaceBlockOnSide(w, pos, side); + AxisAlignedBB axisalignedbb = blockIn.getCollisionBoundingBox(blockIn.getStateFromMeta(stack.getItemDamage()), w, pos); + if(axisalignedbb!=null&&!w.checkNoEntityCollision(axisalignedbb.offset(pos), null)) return false; + return block.isReplaceable(w, pos)&&blockIn.canPlaceBlockOnSide(w, pos, side); } public static class ItemBlockIENoInventory extends ItemBlockIEBase @@ -178,7 +183,8 @@ public ItemBlockIENoInventory(Block b) public NBTTagCompound getNBTShareTag(ItemStack stack) { NBTTagCompound ret = super.getNBTShareTag(stack); - if (ret!=null) { + if(ret!=null) + { ret = ret.copy(); ret.removeTag("inventory"); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/ItemBlockIESlabs.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/ItemBlockIESlabs.java index 8415738822..9c9e5d4195 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/ItemBlockIESlabs.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/ItemBlockIESlabs.java @@ -45,44 +45,44 @@ public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos { ItemStack stack = player.getHeldItem(hand); IBlockState iblockstate = world.getBlockState(pos); - Block localBlock = iblockstate.getBlock(); + Block localBlock = iblockstate.getBlock(); BlockPos posThere = pos; BlockPos posOffset = pos.offset(side); - if(localBlock == Blocks.SNOW_LAYER && localBlock.isReplaceable(world, pos)) - side = EnumFacing.UP; - else if(!localBlock.isReplaceable(world, pos)) - pos = pos.offset(side); - + if(localBlock==Blocks.SNOW_LAYER&&localBlock.isReplaceable(world, pos)) + side = EnumFacing.UP; + else if(!localBlock.isReplaceable(world, pos)) + pos = pos.offset(side); + TileEntityIESlab stackSlab = null; - if(side.getAxis().isVertical() && this.block.equals(world.getBlockState(posThere).getBlock()) && world.getBlockState(posThere).getBlock().getMetaFromState(world.getBlockState(posThere))==stack.getItemDamage() ) + if(side.getAxis().isVertical()&&this.block.equals(world.getBlockState(posThere).getBlock())&&world.getBlockState(posThere).getBlock().getMetaFromState(world.getBlockState(posThere))==stack.getItemDamage()) { TileEntity te = world.getTileEntity(posThere); - if(te instanceof TileEntityIESlab && ((TileEntityIESlab)te).slabType+side.ordinal()==1) + if(te instanceof TileEntityIESlab&&((TileEntityIESlab)te).slabType+side.ordinal()==1) stackSlab = ((TileEntityIESlab)te); } - else if(this.block.equals(world.getBlockState(posOffset).getBlock()) && world.getBlockState(posOffset).getBlock().getMetaFromState(world.getBlockState(posOffset))==stack.getItemDamage() ) + else if(this.block.equals(world.getBlockState(posOffset).getBlock())&&world.getBlockState(posOffset).getBlock().getMetaFromState(world.getBlockState(posOffset))==stack.getItemDamage()) { TileEntity te = world.getTileEntity(posOffset); if(te instanceof TileEntityIESlab) { int type = ((TileEntityIESlab)te).slabType; - if((type==0&&(side==EnumFacing.DOWN||hitY>=.5))||(type==1&&(side==EnumFacing.UP||hitY<=.5))) + if((type==0&&(side==EnumFacing.DOWN||hitY >= .5))||(type==1&&(side==EnumFacing.UP||hitY <= .5))) stackSlab = ((TileEntityIESlab)te); } } else - return super.onItemUse(player,world,pos,hand,side,hitX,hitY,hitZ); + return super.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ); if(stackSlab!=null) { - stackSlab.slabType=2; + stackSlab.slabType = 2; stackSlab.markContainingBlockForUpdate(null); - world.playSound(stackSlab.getPos().getX()+.5, stackSlab.getPos().getY()+.5, stackSlab.getPos().getZ()+.5, this.block.getSoundType().getPlaceSound(), SoundCategory.BLOCKS, (this.block.getSoundType().getVolume() + 1.0F) / 2.0F, this.block.getSoundType().getPitch() * 0.8F, false); + world.playSound(stackSlab.getPos().getX()+.5, stackSlab.getPos().getY()+.5, stackSlab.getPos().getZ()+.5, this.block.getSoundType().getPlaceSound(), SoundCategory.BLOCKS, (this.block.getSoundType().getVolume()+1.0F)/2.0F, this.block.getSoundType().getPitch()*0.8F, false); stack.shrink(1); return EnumActionResult.SUCCESS; } else - return super.onItemUse(player,world,pos,hand,side,hitX,hitY,hitZ); + return super.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ); } @Override @@ -100,7 +100,7 @@ public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, B { TileEntity tileEntity = world.getTileEntity(pos); if(tileEntity instanceof TileEntityIESlab) - ((TileEntityIESlab) tileEntity).slabType = (side==EnumFacing.DOWN||(side!=EnumFacing.UP&&hitY>=.5))? 1: 0; + ((TileEntityIESlab)tileEntity).slabType = (side==EnumFacing.DOWN||(side!=EnumFacing.UP&&hitY >= .5))?1: 0; } return ret; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/ItemBlockIEStairs.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/ItemBlockIEStairs.java index 9f32ddaf2b..834258aaf1 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/ItemBlockIEStairs.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/ItemBlockIEStairs.java @@ -29,16 +29,18 @@ public ItemBlockIEStairs(Block b) } @Override - public int getMetadata (int damageValue) + public int getMetadata(int damageValue) { return damageValue; } + @Override public void getSubItems(CreativeTabs tab, NonNullList itemList) { if(this.isInCreativeTab(tab)) this.block.getSubBlocks(tab, itemList); } + @Override public String getUnlocalizedName(ItemStack itemstack) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/TileEntityIEBase.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/TileEntityIEBase.java index abf5a4e38d..b1404fe7bf 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/TileEntityIEBase.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/TileEntityIEBase.java @@ -38,7 +38,9 @@ public void readFromNBT(NBTTagCompound nbt) super.readFromNBT(nbt); this.readCustomNBT(nbt, false); } + public abstract void readCustomNBT(NBTTagCompound nbt, boolean descPacket); + @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { @@ -46,6 +48,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) this.writeCustomNBT(nbt, false); return nbt; } + public abstract void writeCustomNBT(NBTTagCompound nbt, boolean descPacket); @Override @@ -55,6 +58,7 @@ public SPacketUpdateTileEntity getUpdatePacket() this.writeCustomNBT(nbttagcompound, true); return new SPacketUpdateTileEntity(this.pos, 3, nbttagcompound); } + @Override public NBTTagCompound getUpdateTag() { @@ -62,6 +66,7 @@ public NBTTagCompound getUpdateTag() writeCustomNBT(nbt, true); return nbt; } + @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { @@ -72,7 +77,7 @@ public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) @Override public void rotate(Rotation rot) { - if(rot!=Rotation.NONE && this instanceof IDirectionalTile && ((IDirectionalTile)this).canRotate(EnumFacing.UP)) + if(rot!=Rotation.NONE&&this instanceof IDirectionalTile&&((IDirectionalTile)this).canRotate(EnumFacing.UP)) { EnumFacing f = ((IDirectionalTile)this).getFacing(); switch(rot) @@ -97,7 +102,7 @@ public void rotate(Rotation rot) @Override public void mirror(Mirror mirrorIn) { - if(mirrorIn==Mirror.FRONT_BACK && this instanceof IDirectionalTile) + if(mirrorIn==Mirror.FRONT_BACK&&this instanceof IDirectionalTile) { ((IDirectionalTile)this).setFacing(((IDirectionalTile)this).getFacing()); this.markDirty(); @@ -110,6 +115,7 @@ public void mirror(Mirror mirrorIn) public void receiveMessageFromClient(NBTTagCompound message) { } + public void receiveMessageFromServer(NBTTagCompound message) { } @@ -117,44 +123,48 @@ public void receiveMessageFromServer(NBTTagCompound message) public void onEntityCollision(World world, Entity entity) { } + @Override public boolean receiveClientEvent(int id, int type) { - if(id == 0 || id == 255) + if(id==0||id==255) { markContainingBlockForUpdate(null); return true; - } else if(id == 254) + } + else if(id==254) { IBlockState state = world.getBlockState(pos); if(state instanceof IExtendedBlockState) - ImmersiveEngineering.proxy.removeStateFromSmartModelCache((IExtendedBlockState) state); + ImmersiveEngineering.proxy.removeStateFromSmartModelCache((IExtendedBlockState)state); world.notifyBlockUpdate(pos, state, state, 3); return true; } return super.receiveClientEvent(id, type); } + @Override public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState) { - if (world.isBlockLoaded(pos)) + if(world.isBlockLoaded(pos)) newState = world.getBlockState(pos); - if (oldState.getBlock()!=newState.getBlock()||!(oldState.getBlock() instanceof BlockIEBase)||!(newState.getBlock() instanceof BlockIEBase)) + if(oldState.getBlock()!=newState.getBlock()||!(oldState.getBlock() instanceof BlockIEBase)||!(newState.getBlock() instanceof BlockIEBase)) return true; IProperty type = ((BlockIEBase)oldState.getBlock()).getMetaProperty(); - return oldState.getValue(type) != newState.getValue(type); + return oldState.getValue(type)!=newState.getValue(type); } public void markContainingBlockForUpdate(@Nullable IBlockState newState) { markBlockForUpdate(getPos(), newState); } + public void markBlockForUpdate(BlockPos pos, @Nullable IBlockState newState) { IBlockState state = world.getBlockState(pos); if(newState==null) newState = state; - world.notifyBlockUpdate(pos,state,newState,3); + world.notifyBlockUpdate(pos, state, newState, 3); world.notifyNeighborsOfStateChange(pos, newState.getBlock(), true); } @@ -162,21 +172,23 @@ public void markBlockForUpdate(BlockPos pos, @Nullable IBlockState newState) @Override public boolean hasCapability(Capability capability, @Nullable EnumFacing facing) { - if(capability==CapabilityEnergy.ENERGY && this instanceof EnergyHelper.IIEInternalFluxConnector) + if(capability==CapabilityEnergy.ENERGY&&this instanceof EnergyHelper.IIEInternalFluxConnector) return ((EnergyHelper.IIEInternalFluxConnector)this).getCapabilityWrapper(facing)!=null; return super.hasCapability(capability, facing); } + @Override public T getCapability(Capability capability, @Nullable EnumFacing facing) { - if(capability==CapabilityEnergy.ENERGY && this instanceof EnergyHelper.IIEInternalFluxConnector) + if(capability==CapabilityEnergy.ENERGY&&this instanceof EnergyHelper.IIEInternalFluxConnector) return (T)((EnergyHelper.IIEInternalFluxConnector)this).getCapabilityWrapper(facing); return super.getCapability(capability, facing); } + @Override public double getMaxRenderDistanceSquared() { - return super.getMaxRenderDistanceSquared() * - Config.IEConfig.increasedTileRenderdistance * Config.IEConfig.increasedTileRenderdistance; + return super.getMaxRenderDistanceSquared()* + Config.IEConfig.increasedTileRenderdistance*Config.IEConfig.increasedTileRenderdistance; } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/TileEntityIESlab.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/TileEntityIESlab.java index ed7656e9f8..9d094c565d 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/TileEntityIESlab.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/TileEntityIESlab.java @@ -12,15 +12,16 @@ public class TileEntityIESlab extends TileEntityIEBase { - public int slabType=0; - + public int slabType = 0; + @Override public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) { slabType = nbt.getInteger("slabType"); - if(descPacket && world!=null) + if(descPacket&&world!=null) this.markContainingBlockForUpdate(null); } + @Override public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/TileEntityMultiblockPart.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/TileEntityMultiblockPart.java index 31dc6a1d76..3a4f999bae 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/TileEntityMultiblockPart.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/TileEntityMultiblockPart.java @@ -38,15 +38,18 @@ public abstract class TileEntityMultiblockPart capability, @Nullable EnumFacing facing) { - if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && facing!=null&&this.getAccessibleFluidTanks(facing).length>0) + if(capability==CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY&&facing!=null&&this.getAccessibleFluidTanks(facing).length > 0) return true; return super.hasCapability(capability, facing); } + @Override public T getCapability(Capability capability, @Nullable EnumFacing facing) { - if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && facing!=null&&this.getAccessibleFluidTanks(facing).length>0) + if(capability==CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY&&facing!=null&&this.getAccessibleFluidTanks(facing).length > 0) return (T)new MultiblockFluidWrapper(this, facing); return super.getCapability(capability, facing); } @@ -126,7 +136,9 @@ public T getCapability(Capability capability, @Nullable EnumFacing facing // ================================= @Nonnull protected abstract IFluidTank[] getAccessibleFluidTanks(EnumFacing side); + protected abstract boolean canFillTankFrom(int iTank, EnumFacing side, FluidStack resource); + protected abstract boolean canDrainTankFrom(int iTank, EnumFacing side); public static class MultiblockFluidWrapper implements IFluidHandler @@ -139,6 +151,7 @@ public MultiblockFluidWrapper(TileEntityMultiblockPart multiblock, EnumFacing si this.multiblock = multiblock; this.side = side; } + @Override public IFluidTankProperties[] getTankProperties() { @@ -146,54 +159,56 @@ public IFluidTankProperties[] getTankProperties() return new IFluidTankProperties[0]; IFluidTank[] tanks = this.multiblock.getAccessibleFluidTanks(side); IFluidTankProperties[] array = new IFluidTankProperties[tanks.length]; - for(int i=0; i0) + if(fill > 0) break; } } if(fill==-1) - for(int i=0; i0) + if(fill > 0) break; } } - if(fill>0) + if(fill > 0) this.multiblock.updateMasterBlock(null, true); - return fill<0?0:fill; + return fill < 0?0: fill; } + @Nullable @Override public FluidStack drain(FluidStack resource, boolean doDrain) { - if(!this.multiblock.formed || resource==null) + if(!this.multiblock.formed||resource==null) return null; IFluidTank[] tanks = this.multiblock.getAccessibleFluidTanks(side); FluidStack drain = null; - for(int i=0; i if(ItemNBTHelper.hasKey(stack, "colour")) { String hexCol = Integer.toHexString(ItemNBTHelper.getInt(stack, "colour")); - tooltip.add(I18n.translateToLocalFormatted(Lib.DESC_INFO + "colour", "")); + tooltip.add(I18n.translateToLocalFormatted(Lib.DESC_INFO+"colour", "")); } } @@ -75,6 +75,7 @@ public boolean useCustomStateMapper() { return true; } + @Override public String getCustomStateMapping(int meta, boolean itemBlock) { @@ -95,15 +96,16 @@ public void onFallenUpon(World worldIn, BlockPos pos, Entity entityIn, float fal entityIn.fall(fallDistance, 0.0F); // } } + @Override public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) { state = super.getExtendedState(state, world, pos); - if (state instanceof IExtendedBlockState) + if(state instanceof IExtendedBlockState) { - IExtendedBlockState ext = (IExtendedBlockState) state; + IExtendedBlockState ext = (IExtendedBlockState)state; TileEntity te = world.getTileEntity(pos); - if (te instanceof TileEntityImmersiveConnectable) + if(te instanceof TileEntityImmersiveConnectable) ext = ext.withProperty(IEProperties.CONNECTIONS, ((TileEntityImmersiveConnectable)te).genConnBlockstate()); state = ext; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/cloth/BlockTypes_ClothDevice.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/cloth/BlockTypes_ClothDevice.java index fad7db10a9..41e1e76c6c 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/cloth/BlockTypes_ClothDevice.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/cloth/BlockTypes_ClothDevice.java @@ -24,11 +24,13 @@ public String getName() { return this.toString().toLowerCase(Locale.ENGLISH); } + @Override public int getMeta() { return ordinal(); } + @Override public boolean listForCreative() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/cloth/ItemBlockClothDevice.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/cloth/ItemBlockClothDevice.java index 5a9cab4d3a..d3dc9b8183 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/cloth/ItemBlockClothDevice.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/cloth/ItemBlockClothDevice.java @@ -29,6 +29,7 @@ public ItemBlockClothDevice(Block b) { super(b); } + @Override public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) { @@ -42,9 +43,9 @@ public ActionResult onItemRightClick(World worldIn, EntityPlayer play Vec3d pos = playerIn.getPositionVector().addVector(0, playerIn.getEyeHeight(), 0).add(playerIn.getLookVec()); BlockPos bPos = new BlockPos(pos); NBTTagCompound nbt = itemStackIn.getTagCompound(); - int offset = nbt==null?0:nbt.getByte("offset"); + int offset = nbt==null?0: nbt.getByte("offset"); bPos = bPos.up(offset); - if (worldIn.isAirBlock(bPos)) + if(worldIn.isAirBlock(bPos)) { if(!worldIn.isRemote) { @@ -58,33 +59,36 @@ public ActionResult onItemRightClick(World worldIn, EntityPlayer play } return new ActionResult(EnumActionResult.PASS, itemStackIn); } + @Override public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack stack = playerIn.getHeldItem(hand); - if(stack.getMetadata()==BlockTypes_ClothDevice.BALLOON.getMeta() && playerIn.isSneaking()) + if(stack.getMetadata()==BlockTypes_ClothDevice.BALLOON.getMeta()&&playerIn.isSneaking()) { increaseOffset(stack); return EnumActionResult.SUCCESS; } return super.onItemUse(playerIn, worldIn, pos, hand, side, hitX, hitY, hitZ); } + @Override public String getItemStackDisplayName(ItemStack stack) { String ret = super.getItemStackDisplayName(stack); NBTTagCompound nbt = stack.getTagCompound(); - if (nbt!=null&&nbt.getByte("offset")!=0) - ret+=" (+"+nbt.getByte("offset")+")"; + if(nbt!=null&&nbt.getByte("offset")!=0) + ret += " (+"+nbt.getByte("offset")+")"; return ret; } + private void increaseOffset(ItemStack s) { - if (s.getTagCompound()==null) + if(s.getTagCompound()==null) s.setTagCompound(new NBTTagCompound()); NBTTagCompound tag = s.getTagCompound(); byte offset = tag.getByte("offset"); - tag.setByte("offset", (byte) ((offset+1)%5)); - + tag.setByte("offset", (byte)((offset+1)%5)); + } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/cloth/TileEntityBalloon.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/cloth/TileEntityBalloon.java index 4b57dac564..46c49f36ca 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/cloth/TileEntityBalloon.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/cloth/TileEntityBalloon.java @@ -46,10 +46,10 @@ public int getLightValue() @Override public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) { - super.readCustomNBT(nbt,descPacket); + super.readCustomNBT(nbt, descPacket); //to prevent old ballons from going black int nbtVersion = nbt.getInteger("nbtVersion"); - if(nbtVersion>=1) + if(nbtVersion >= 1) { style = nbt.getInteger("style"); colour0 = nbt.getInteger("colour0"); @@ -65,18 +65,18 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) @Override public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { - super.writeCustomNBT(nbt,descPacket); + super.writeCustomNBT(nbt, descPacket); nbt.setInteger("nbtVersion", 1); - nbt.setInteger("style",style); - nbt.setInteger("colour0",colour0); - nbt.setInteger("colour1",colour1); + nbt.setInteger("style", style); + nbt.setInteger("colour0", colour0); + nbt.setInteger("colour1", colour1); nbt.setTag("shader", shader.serializeNBT()); } @Override public float[] getBlockBounds() { - return new float[]{.125f,0,.125f,.875f,.9375f,.875f}; + return new float[]{.125f, 0, .125f, .875f, .9375f, .875f}; } @Override @@ -93,21 +93,23 @@ public boolean receiveClientEvent(int id, int arg) @Override public boolean hasCapability(Capability capability, @Nullable EnumFacing facing) { - if(capability == CapabilityShader.SHADER_CAPABILITY) + if(capability==CapabilityShader.SHADER_CAPABILITY) return true; return super.hasCapability(capability, facing); } + @Override public T getCapability(Capability capability, @Nullable EnumFacing facing) { - if(capability == CapabilityShader.SHADER_CAPABILITY) + if(capability==CapabilityShader.SHADER_CAPABILITY) return (T)shader; return super.getCapability(capability, facing); } @Override - public String getCacheKey(IBlockState object) { - if(shader!=null && !shader.getShaderItem().isEmpty() && shader.getShaderItem().getItem() instanceof IShaderItem) + public String getCacheKey(IBlockState object) + { + if(shader!=null&&!shader.getShaderItem().isEmpty()&&shader.getShaderItem().getItem() instanceof IShaderItem) return ((IShaderItem)shader.getShaderItem().getItem()).getShaderName(shader.getShaderItem()); return colour0+":"+colour1+":"+style; } @@ -115,20 +117,20 @@ public String getCacheKey(IBlockState object) { @Override public int getRenderColour(IBlockState object, String group) { - if(shader!=null && !shader.getShaderItem().isEmpty() && shader.getShaderItem().getItem() instanceof IShaderItem) + if(shader!=null&&!shader.getShaderItem().isEmpty()&&shader.getShaderItem().getItem() instanceof IShaderItem) return 0xffffffff; - if (style==0) + if(style==0) { - if (group.startsWith("balloon1_")) + if(group.startsWith("balloon1_")) return 0xff000000|colour1; - if (group.startsWith("balloon0_")) + if(group.startsWith("balloon0_")) return 0xff000000|colour0; } else { - if (group.endsWith("_1")) + if(group.endsWith("_1")) return 0xff000000|colour1; - if (group.endsWith("_0")) + if(group.endsWith("_0")) return 0xff000000|colour0; } return 0xffffffff; @@ -137,47 +139,48 @@ public int getRenderColour(IBlockState object, String group) @Override public Vec3d getConnectionOffset(Connection con) { - int xDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(this.getPos())&&con.end!=null)? con.end.getX()-getPos().getX(): (con.end.equals(this.getPos())&& con.start!=null)?con.start.getX()-getPos().getX(): 0; - int zDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(this.getPos())&&con.end!=null)? con.end.getZ()-getPos().getZ(): (con.end.equals(this.getPos())&& con.start!=null)?con.start.getZ()-getPos().getZ(): 0; - int yDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(this.getPos())&&con.end!=null)? con.end.getY()-getPos().getY(): (con.end.equals(this.getPos())&& con.start!=null)?con.start.getY()-getPos().getY(): 0; - if(yDif<0) + int xDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(this.getPos())&&con.end!=null)?con.end.getX()-getPos().getX(): (con.end.equals(this.getPos())&&con.start!=null)?con.start.getX()-getPos().getX(): 0; + int zDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(this.getPos())&&con.end!=null)?con.end.getZ()-getPos().getZ(): (con.end.equals(this.getPos())&&con.start!=null)?con.start.getZ()-getPos().getZ(): 0; + int yDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(this.getPos())&&con.end!=null)?con.end.getY()-getPos().getY(): (con.end.equals(this.getPos())&&con.start!=null)?con.start.getY()-getPos().getY(): 0; + if(yDif < 0) { - double dist = Math.sqrt(xDif*xDif + zDif*zDif); - if(dist/Math.abs(yDif)<2.5) - return new Vec3d(.5,.09375,.5); + double dist = Math.sqrt(xDif*xDif+zDif*zDif); + if(dist/Math.abs(yDif) < 2.5) + return new Vec3d(.5, .09375, .5); } - if(Math.abs(zDif)>Math.abs(xDif)) - return new Vec3d(.5,.09375,zDif>0?.78125:.21875); + if(Math.abs(zDif) > Math.abs(xDif)) + return new Vec3d(.5, .09375, zDif > 0?.78125: .21875); else - return new Vec3d(xDif>0?.78125:.21875,.09375,.5); + return new Vec3d(xDif > 0?.78125: .21875, .09375, .5); } + @Override public boolean interact(EnumFacing side, EntityPlayer player, EnumHand hand, ItemStack heldItem, float hitX, float hitY, float hitZ) { - if(!heldItem.isEmpty() && heldItem.getItem() instanceof IShaderItem) + if(!heldItem.isEmpty()&&heldItem.getItem() instanceof IShaderItem) { if(this.shader==null) this.shader = new ShaderWrapper_Direct("immersiveengineering:balloon"); - this.shader.setShaderItem(Utils.copyStackWithAmount(heldItem,1)); + this.shader.setShaderItem(Utils.copyStackWithAmount(heldItem, 1)); markContainingBlockForUpdate(null); return true; } int target = 0; - if(side.getAxis()==Axis.Y && style==0) - target = (hitX<.375||hitX>.625)&&(hitZ<.375||hitZ>.625)?1:0; + if(side.getAxis()==Axis.Y&&style==0) + target = (hitX < .375||hitX > .625)&&(hitZ < .375||hitZ > .625)?1: 0; else if(side.getAxis()==Axis.Z) { if(style==0) - target = (hitX<.375||hitX>.625)?1:0; + target = (hitX < .375||hitX > .625)?1: 0; else - target =(hitY>.5625&&hitY<.75)?1:0; + target = (hitY > .5625&&hitY < .75)?1: 0; } else if(side.getAxis()==Axis.X) { if(style==0) - target = (hitZ<.375||hitZ>.625)?1:0; + target = (hitZ < .375||hitZ > .625)?1: 0; else - target =(hitY>.5625&&hitY<.75)?1:0; + target = (hitY > .5625&&hitY < .75)?1: 0; } int heldDye = Utils.getDye(heldItem); if(heldDye==-1) @@ -198,6 +201,7 @@ else if(side.getAxis()==Axis.X) markContainingBlockForUpdate(null); return true; } + @Override public boolean hammerUseSide(EnumFacing side, EntityPlayer player, float hitX, float hitY, float hitZ) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/cloth/TileEntityStripCurtain.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/cloth/TileEntityStripCurtain.java index 482403816c..88a3862cca 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/cloth/TileEntityStripCurtain.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/cloth/TileEntityStripCurtain.java @@ -45,20 +45,20 @@ public class TileEntityStripCurtain extends TileEntityIEBase implements ITickabl @Override public void update() { - if(!world.isRemote &&world.getTotalWorldTime()%4==((getPos().getX()^getPos().getZ())&3)) + if(!world.isRemote&&world.getTotalWorldTime()%4==((getPos().getX()^getPos().getZ())&3)) { List entities = null; - AxisAlignedBB aabb = bounds[ceilingAttached?(facing.getAxis()== Axis.Z?4:5):((facing.ordinal()-2)%4)]; - aabb = new AxisAlignedBB(aabb.minX,aabb.minY-.8125,aabb.minZ, aabb.maxX,aabb.maxY,aabb.maxZ).offset(getPos()); + AxisAlignedBB aabb = bounds[ceilingAttached?(facing.getAxis()==Axis.Z?4: 5): ((facing.ordinal()-2)%4)]; + aabb = new AxisAlignedBB(aabb.minX, aabb.minY-.8125, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ).offset(getPos()); entities = world.getEntitiesWithinAABB(Entity.class, aabb); - if(!ceilingAttached && !entities.isEmpty() && redstoneSignal==0) + if(!ceilingAttached&&!entities.isEmpty()&&redstoneSignal==0) { redstoneSignal = 15; markDirty(); world.notifyNeighborsOfStateChange(getPos(), getBlockType(), false); world.notifyNeighborsOfStateChange(getPos().offset(facing), getBlockType(), false); } - if(entities.isEmpty() && redstoneSignal!=0) + if(entities.isEmpty()&&redstoneSignal!=0) { redstoneSignal = 0; world.notifyNeighborsOfStateChange(getPos(), getBlockType(), false); @@ -66,13 +66,14 @@ public void update() } } } + @Override public void onEntityCollision(World world, Entity entity) { - if(ceilingAttached && !entity.isDead && redstoneSignal ==0) + if(ceilingAttached&&!entity.isDead&&redstoneSignal==0) { - AxisAlignedBB aabb = bounds[ceilingAttached ? (facing.getAxis() == Axis.Z ? 4 : 5) : ((facing.ordinal() - 2) % 4)]; - aabb = new AxisAlignedBB(aabb.minX, aabb.minY - .8125, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ).offset(getPos()); + AxisAlignedBB aabb = bounds[ceilingAttached?(facing.getAxis()==Axis.Z?4: 5): ((facing.ordinal()-2)%4)]; + aabb = new AxisAlignedBB(aabb.minX, aabb.minY-.8125, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ).offset(getPos()); if(entity.getEntityBoundingBox().intersects(aabb)) { redstoneSignal = 15; @@ -82,6 +83,7 @@ public void onEntityCollision(World world, Entity entity) } } } + @Override public int getStrongRSOutput(IBlockState state, EnumFacing side) { @@ -89,6 +91,7 @@ public int getStrongRSOutput(IBlockState state, EnumFacing side) return 0; return getWeakRSOutput(state, facing); } + @Override public int getWeakRSOutput(IBlockState state, EnumFacing side) { @@ -96,6 +99,7 @@ public int getWeakRSOutput(IBlockState state, EnumFacing side) return 0; return redstoneSignal; } + @Override public boolean canConnectRedstone(IBlockState state, EnumFacing side) { @@ -114,29 +118,31 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { if(facing!=null) - nbt.setInteger("facing",facing.ordinal()); + nbt.setInteger("facing", facing.ordinal()); nbt.setBoolean("ceilingAttached", ceilingAttached); nbt.setInteger("colour", colour); } AxisAlignedBB[] bounds = { - new AxisAlignedBB(0,0,0,1,.1875f,.0625f), - new AxisAlignedBB(0,0,.9375f,1,.1875f,1), - new AxisAlignedBB(0,0,0,.0625f,.1875f,1), - new AxisAlignedBB(.9375f,0,0,1,.1875f,1), - new AxisAlignedBB(0,.8125f,.46875f,1,1,.53125f), - new AxisAlignedBB(.46875f,.8125f,0,.53125f,1,1) + new AxisAlignedBB(0, 0, 0, 1, .1875f, .0625f), + new AxisAlignedBB(0, 0, .9375f, 1, .1875f, 1), + new AxisAlignedBB(0, 0, 0, .0625f, .1875f, 1), + new AxisAlignedBB(.9375f, 0, 0, 1, .1875f, 1), + new AxisAlignedBB(0, .8125f, .46875f, 1, 1, .53125f), + new AxisAlignedBB(.46875f, .8125f, 0, .53125f, 1, 1) }; + @Override public float[] getBlockBounds() { - AxisAlignedBB aabb = bounds[ceilingAttached?(facing.getAxis()== Axis.Z?4:5):((facing.ordinal()-2)%4)]; - return new float[]{(float)aabb.minX,(float)aabb.minY,(float)aabb.minZ, (float)aabb.maxX,(float)aabb.maxY,(float)aabb.maxZ}; + AxisAlignedBB aabb = bounds[ceilingAttached?(facing.getAxis()==Axis.Z?4: 5): ((facing.ordinal()-2)%4)]; + return new float[]{(float)aabb.minX, (float)aabb.minY, (float)aabb.minZ, (float)aabb.maxX, (float)aabb.maxY, (float)aabb.maxZ}; } + @Override public List getAdvancedColisionBounds() { - return Lists.newArrayList(bounds[ceilingAttached?(facing.getAxis()== Axis.Z?4:5):((facing.ordinal()-2)%4)]); + return Lists.newArrayList(bounds[ceilingAttached?(facing.getAxis()==Axis.Z?4: 5): ((facing.ordinal()-2)%4)]); } @Override @@ -144,31 +150,37 @@ public EnumFacing getFacing() { return facing; } + @Override public void setFacing(EnumFacing facing) { this.facing = facing; } + @Override public int getFacingLimitation() { return 2; } + @Override public boolean mirrorFacingOnPlacement(EntityLivingBase placer) { return false; } + @Override public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) { return false; } + @Override public boolean canRotate(EnumFacing axis) { return false; } + @Override public void onDirectionalPlacement(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase placer) { @@ -181,6 +193,7 @@ public boolean getIsSecondState() { return ceilingAttached; } + @Override public PropertyBoolInverted getBoolProperty(Class inf) { @@ -198,11 +211,12 @@ public int getRenderColour(int tintIndex) @Override public ItemStack getTileDrop(EntityPlayer player, IBlockState state) { - ItemStack stack = new ItemStack(state.getBlock(),1,state.getBlock().getMetaFromState(state)); + ItemStack stack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)); if(colour!=0xffffff) ItemNBTHelper.setInt(stack, "colour", colour); return stack; } + @Override public void readOnPlacement(EntityLivingBase placer, ItemStack stack) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/cloth/package-info.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/cloth/package-info.java index 095c520b0d..5d1abe1a09 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/cloth/package-info.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/cloth/package-info.java @@ -3,4 +3,5 @@ package blusunrize.immersiveengineering.common.blocks.cloth; import mcp.MethodsReturnNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockConnector.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockConnector.java index 93c5db2456..042aa55fa9 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockConnector.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockConnector.java @@ -25,8 +25,6 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockConveyor.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockConveyor.java index f37d906a89..fe9528f3df 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockConveyor.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockConveyor.java @@ -114,7 +114,7 @@ public void addInformation(ItemStack stack, @Nullable World world, List public String getUnlocalizedName(ItemStack stack) { String subName = ItemNBTHelper.getString(stack, "conveyorType"); - return super.getUnlocalizedName() + "." + subName; + return super.getUnlocalizedName()+"."+subName; } @Override @@ -123,11 +123,11 @@ public IBlockState getExtendedState(IBlockState state, IBlockAccess world, Block state = super.getExtendedState(state, world, pos); if(state instanceof IExtendedBlockState) { - IExtendedBlockState ext = (IExtendedBlockState) state; + IExtendedBlockState ext = (IExtendedBlockState)state; TileEntity te = world.getTileEntity(pos); if(!(te instanceof TileEntityConveyorBelt)) return state; - state = ext.withProperty(ICONEYOR_PASSTHROUGH, ((TileEntityConveyorBelt) te).getConveyorSubtype()); + state = ext.withProperty(ICONEYOR_PASSTHROUGH, ((TileEntityConveyorBelt)te).getConveyorSubtype()); } return state; } @@ -157,18 +157,18 @@ public void onIEBlockPlacedBy(World world, BlockPos pos, IBlockState state, Enum { super.onIEBlockPlacedBy(world, pos, state, side, hitX, hitY, hitZ, placer, stack); TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntityConveyorBelt && !(tile instanceof TileEntityConveyorVertical)) + if(tile instanceof TileEntityConveyorBelt&&!(tile instanceof TileEntityConveyorVertical)) { - TileEntityConveyorBelt conveyor = (TileEntityConveyorBelt) tile; + TileEntityConveyorBelt conveyor = (TileEntityConveyorBelt)tile; EnumFacing f = conveyor.facing; ResourceLocation rl = new ResourceLocation(ItemNBTHelper.getString(stack, "conveyorType")); IConveyorBelt subType = ConveyorHandler.getConveyor(rl, conveyor); conveyor.setConveyorSubtype(subType); tile = world.getTileEntity(pos.offset(f)); TileEntity tileUp = world.getTileEntity(pos.offset(f).add(0, 1, 0)); - if(subType != null && (!(tile instanceof IConveyorTile) || ((IConveyorTile) tile).getFacing() == f.getOpposite()) && tileUp instanceof IConveyorTile && ((IConveyorTile) tileUp).getFacing() != f.getOpposite() && world.isAirBlock(pos.add(0, 1, 0))) + if(subType!=null&&(!(tile instanceof IConveyorTile)||((IConveyorTile)tile).getFacing()==f.getOpposite())&&tileUp instanceof IConveyorTile&&((IConveyorTile)tileUp).getFacing()!=f.getOpposite()&&world.isAirBlock(pos.add(0, 1, 0))) subType.setConveyorDirection(ConveyorDirection.UP); - tile = world.getTileEntity(pos.offset(f.getOpposite()).add(0,1,0)); + tile = world.getTileEntity(pos.offset(f.getOpposite()).add(0, 1, 0)); // if(tile instanceof TileEntityConveyorBelt&&!(tile instanceof TileEntityConveyorVertical) && ((TileEntityConveyorBelt)tile).facing==f) // conveyor.transportDown = true; // if(conveyor.transportUp && conveyor.transportDown) @@ -185,7 +185,7 @@ public boolean isSideSolid(IBlockState state, IBlockAccess world, BlockPos pos, return side==((TileEntityConveyorVertical)te).facing; else if(te instanceof TileEntityConveyorBelt) { - return side == EnumFacing.DOWN && (((TileEntityConveyorBelt) te).getConveyorSubtype() == null || ((TileEntityConveyorBelt) te).getConveyorSubtype().getConveyorDirection() == ConveyorDirection.HORIZONTAL); + return side==EnumFacing.DOWN&&(((TileEntityConveyorBelt)te).getConveyorSubtype()==null||((TileEntityConveyorBelt)te).getConveyorSubtype().getConveyorDirection()==ConveyorDirection.HORIZONTAL); } return false; } @@ -211,6 +211,7 @@ public boolean allowHammerHarvest(IBlockState blockState) { return true; } + @Override public boolean isToolEffective(String type, IBlockState state) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockMetalDecoration0.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockMetalDecoration0.java index 2115669ab2..ff8245a97b 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockMetalDecoration0.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockMetalDecoration0.java @@ -34,7 +34,7 @@ public boolean useCustomStateMapper() @Override public String getCustomStateMapping(int meta, boolean itemBlock) { - if(Loader.isModLoaded("ctm") && !itemBlock && meta > 2) + if(Loader.isModLoaded("ctm")&&!itemBlock&&meta > 2) return "ctm"; return null; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockMetalDecoration1.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockMetalDecoration1.java index 04eaf0ff29..26b4374b35 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockMetalDecoration1.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockMetalDecoration1.java @@ -36,7 +36,7 @@ public class BlockMetalDecoration1 extends IELadderBlock drops, IBlockAccess world, BlockPos return; super.getDrops(drops, world, pos, state, fortune); } + @Override public void breakBlock(World world, BlockPos pos, IBlockState state) { TileEntity tileEntity = world.getTileEntity(pos); if(tileEntity instanceof TileEntityWoodenPost) { - if(!((TileEntityWoodenPost)tileEntity).isDummy() && !world.isRemote && world.getGameRules().getBoolean("doTileDrops") && !world.restoringBlockSnapshots) - world.spawnEntity(new EntityItem(world, pos.getX()+.5,pos.getY()+.5,pos.getZ()+.5, new ItemStack(this,1,this.getMetaFromState(state)))); + if(!((TileEntityWoodenPost)tileEntity).isDummy()&&!world.isRemote&&world.getGameRules().getBoolean("doTileDrops")&&!world.restoringBlockSnapshots) + world.spawnEntity(new EntityItem(world, pos.getX()+.5, pos.getY()+.5, pos.getZ()+.5, new ItemStack(this, 1, this.getMetaFromState(state)))); } super.breakBlock(world, pos, state); } @@ -71,7 +72,7 @@ public void breakBlock(World world, BlockPos pos, IBlockState state) public boolean canBeConnectedTo(IBlockAccess world, BlockPos pos, EnumFacing facing) { int meta = this.getMetaFromState(world.getBlockState(pos)); - if(meta==BlockTypes_MetalDecoration2.STEEL_WALLMOUNT.getMeta() || meta==BlockTypes_MetalDecoration2.ALUMINUM_WALLMOUNT.getMeta()) + if(meta==BlockTypes_MetalDecoration2.STEEL_WALLMOUNT.getMeta()||meta==BlockTypes_MetalDecoration2.ALUMINUM_WALLMOUNT.getMeta()) { TileEntity te = world.getTileEntity(pos); if(te instanceof TileEntityWallmount) @@ -81,7 +82,7 @@ public boolean canBeConnectedTo(IBlockAccess world, BlockPos pos, EnumFacing fac else if(facing==EnumFacing.DOWN) return ((TileEntityWallmount)te).orientation==1||((TileEntityWallmount)te).orientation==3; else - return facing==(((TileEntityWallmount)te).orientation>1?((TileEntityWallmount)te).facing.getOpposite():((TileEntityWallmount)te).facing); + return facing==(((TileEntityWallmount)te).orientation > 1?((TileEntityWallmount)te).facing.getOpposite(): ((TileEntityWallmount)te).facing); } } return super.canBeConnectedTo(world, pos, facing); @@ -93,7 +94,7 @@ public boolean isSideSolid(IBlockState state, IBlockAccess world, BlockPos pos, TileEntity te = world.getTileEntity(pos); if(te instanceof TileEntityWoodenPost) { - return ((TileEntityWoodenPost)te).dummy==0?side==EnumFacing.DOWN: ((TileEntityWoodenPost)te).dummy==3?side==EnumFacing.UP: ((TileEntityWoodenPost)te).dummy>3?side.getAxis()==Axis.Y: side.getAxis()!=Axis.Y; + return ((TileEntityWoodenPost)te).dummy==0?side==EnumFacing.DOWN: ((TileEntityWoodenPost)te).dummy==3?side==EnumFacing.UP: ((TileEntityWoodenPost)te).dummy > 3?side.getAxis()==Axis.Y: side.getAxis()!=Axis.Y; } if(te instanceof TileEntityWallmount) { @@ -102,7 +103,7 @@ public boolean isSideSolid(IBlockState state, IBlockAccess world, BlockPos pos, else if(side==EnumFacing.DOWN) return ((TileEntityWallmount)te).orientation==1||((TileEntityWallmount)te).orientation==3; else - return side==(((TileEntityWallmount)te).orientation>1?((TileEntityWallmount)te).facing.getOpposite():((TileEntityWallmount)te).facing); + return side==(((TileEntityWallmount)te).orientation > 1?((TileEntityWallmount)te).facing.getOpposite(): ((TileEntityWallmount)te).facing); } return super.isSideSolid(state, world, pos, side); } @@ -112,17 +113,17 @@ else if(side==EnumFacing.DOWN) public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing side) { int meta = this.getMetaFromState(state); - if(meta==BlockTypes_MetalDecoration2.STEEL_WALLMOUNT.getMeta() || meta==BlockTypes_MetalDecoration2.ALUMINUM_WALLMOUNT.getMeta()) + if(meta==BlockTypes_MetalDecoration2.STEEL_WALLMOUNT.getMeta()||meta==BlockTypes_MetalDecoration2.ALUMINUM_WALLMOUNT.getMeta()) { TileEntity te = world.getTileEntity(pos); if(te instanceof TileEntityWallmount) { if(side==EnumFacing.UP) - return ((TileEntityWallmount)te).orientation==0||((TileEntityWallmount)te).orientation==2?BlockFaceShape.CENTER:BlockFaceShape.UNDEFINED; + return ((TileEntityWallmount)te).orientation==0||((TileEntityWallmount)te).orientation==2?BlockFaceShape.CENTER: BlockFaceShape.UNDEFINED; else if(side==EnumFacing.DOWN) - return ((TileEntityWallmount)te).orientation==1||((TileEntityWallmount)te).orientation==3?BlockFaceShape.CENTER:BlockFaceShape.UNDEFINED; + return ((TileEntityWallmount)te).orientation==1||((TileEntityWallmount)te).orientation==3?BlockFaceShape.CENTER: BlockFaceShape.UNDEFINED; else - return side==(((TileEntityWallmount)te).orientation>1?((TileEntityWallmount)te).facing.getOpposite():((TileEntityWallmount)te).facing)?BlockFaceShape.CENTER:BlockFaceShape.UNDEFINED; + return side==(((TileEntityWallmount)te).orientation > 1?((TileEntityWallmount)te).facing.getOpposite(): ((TileEntityWallmount)te).facing)?BlockFaceShape.CENTER: BlockFaceShape.UNDEFINED; } } return BlockFaceShape.SOLID; @@ -131,9 +132,9 @@ else if(side==EnumFacing.DOWN) @Override public boolean canIEBlockBePlaced(World world, BlockPos pos, IBlockState newState, EnumFacing side, float hitX, float hitY, float hitZ, EntityPlayer player, ItemStack stack) { - if(stack.getItemDamage()== BlockTypes_MetalDecoration2.STEEL_POST.getMeta() || stack.getItemDamage()== BlockTypes_MetalDecoration2.ALUMINUM_POST.getMeta()) + if(stack.getItemDamage()==BlockTypes_MetalDecoration2.STEEL_POST.getMeta()||stack.getItemDamage()==BlockTypes_MetalDecoration2.ALUMINUM_POST.getMeta()) { - for(int hh=1; hh<=3; hh++) + for(int hh = 1; hh <= 3; hh++) { BlockPos pos2 = pos.up(hh); if(world.isOutsideBuildHeight(pos2)||!world.getBlockState(pos2).getBlock().isReplaceable(world, pos2)) diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockMetalDevice0.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockMetalDevice0.java index 89ec777752..5184c5a322 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockMetalDevice0.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockMetalDevice0.java @@ -28,7 +28,7 @@ public class BlockMetalDevice0 extends BlockIETileProvider=18&&tile.pos<36); + return tile.pos==4||tile.pos==40||(tile.pos >= 18&&tile.pos < 36); } else if(te instanceof TileEntitySilo) { - return tile.pos==4||tile.pos==58||(tile.pos>=18&&tile.pos<54); + return tile.pos==4||tile.pos==58||(tile.pos >= 18&&tile.pos < 54); } - else if(te instanceof TileEntitySqueezer || te instanceof TileEntityFermenter) + else if(te instanceof TileEntitySqueezer||te instanceof TileEntityFermenter) { - return tile.pos==0||tile.pos==9 || tile.pos==5 || (tile.pos==11&&side.getOpposite()==tile.facing); + return tile.pos==0||tile.pos==9||tile.pos==5||(tile.pos==11&&side.getOpposite()==tile.facing); } else if(te instanceof TileEntityRefinery) { - return tile.pos==2 || tile.pos==5||tile.pos==9 || (tile.pos==19&&side.getOpposite()==tile.facing) || (tile.pos==27&&side==tile.facing); + return tile.pos==2||tile.pos==5||tile.pos==9||(tile.pos==19&&side.getOpposite()==tile.facing)||(tile.pos==27&&side==tile.facing); } else if(te instanceof TileEntityDieselGenerator) { if(tile.pos==0||tile.pos==2) return side.getAxis()==tile.facing.rotateY().getAxis(); - else if(tile.pos>=15&&tile.pos<=17) - return side == EnumFacing.UP; + else if(tile.pos >= 15&&tile.pos <= 17) + return side==EnumFacing.UP; else if(tile.pos==23) - return side==(tile.mirrored?tile.facing.rotateYCCW():tile.facing.rotateY()); + return side==(tile.mirrored?tile.facing.rotateYCCW(): tile.facing.rotateY()); } else if(te instanceof TileEntityExcavator) { - if(tile.pos%18<9 || (tile.pos>=18&&tile.pos<36)) + if(tile.pos%18 < 9||(tile.pos >= 18&&tile.pos < 36)) return true; } else if(te instanceof TileEntityArcFurnace) { - if(tile.pos==2 || tile.pos==25 || tile.pos==52) - return side.getOpposite()==tile.facing || (tile.pos == 52 && side == EnumFacing.UP); - if(tile.pos==82 || tile.pos==86 || tile.pos==88 || tile.pos==112) + if(tile.pos==2||tile.pos==25||tile.pos==52) + return side.getOpposite()==tile.facing||(tile.pos==52&&side==EnumFacing.UP); + if(tile.pos==82||tile.pos==86||tile.pos==88||tile.pos==112) return side==EnumFacing.UP; - if( (tile.pos>=21&&tile.pos<=23) || (tile.pos>=46&&tile.pos<=48) || (tile.pos>=71&&tile.pos<=73)) + if((tile.pos >= 21&&tile.pos <= 23)||(tile.pos >= 46&&tile.pos <= 48)||(tile.pos >= 71&&tile.pos <= 73)) return side==tile.facing; } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_Connector.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_Connector.java index 3ca3cff3e2..c8c0c53cee 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_Connector.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_Connector.java @@ -36,11 +36,13 @@ public String getName() { return this.toString().toLowerCase(Locale.ENGLISH); } + @Override public int getMeta() { return ordinal(); } + @Override public boolean listForCreative() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_Conveyor.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_Conveyor.java index ba3702e2d9..6616399e97 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_Conveyor.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_Conveyor.java @@ -25,11 +25,13 @@ public String getName() { return this.toString().toLowerCase(Locale.ENGLISH); } + @Override public int getMeta() { return ordinal(); } + @Override public boolean listForCreative() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalDecoration0.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalDecoration0.java index 220f973abe..058286f904 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalDecoration0.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalDecoration0.java @@ -29,11 +29,13 @@ public String getName() { return this.toString().toLowerCase(Locale.ENGLISH); } + @Override public int getMeta() { return ordinal(); } + @Override public boolean listForCreative() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalDecoration1.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalDecoration1.java index e1ba2a86f7..829a5029e9 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalDecoration1.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalDecoration1.java @@ -36,11 +36,13 @@ public String getName() { return this.toString().toLowerCase(Locale.ENGLISH); } + @Override public int getMeta() { return ordinal(); } + @Override public boolean listForCreative() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalDecoration2.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalDecoration2.java index d29fd7b4dc..12925000a9 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalDecoration2.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalDecoration2.java @@ -28,11 +28,13 @@ public String getName() { return this.toString().toLowerCase(Locale.ENGLISH); } + @Override public int getMeta() { return ordinal(); } + @Override public boolean listForCreative() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalDevice0.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalDevice0.java index 2e1b662732..e5d513bb25 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalDevice0.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalDevice0.java @@ -28,11 +28,13 @@ public String getName() { return this.toString().toLowerCase(Locale.ENGLISH); } + @Override public int getMeta() { return ordinal(); } + @Override public boolean listForCreative() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalDevice1.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalDevice1.java index aafe14ebfe..3241f9d225 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalDevice1.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalDevice1.java @@ -35,11 +35,13 @@ public String getName() { return this.toString().toLowerCase(Locale.ENGLISH); } + @Override public int getMeta() { return ordinal(); } + @Override public boolean listForCreative() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalLadder.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalLadder.java index f5c402b7f7..a4b3787c78 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalLadder.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalLadder.java @@ -24,11 +24,13 @@ public String getName() { return this.toString().toLowerCase(Locale.ENGLISH); } + @Override public int getMeta() { return ordinal(); } + @Override public boolean listForCreative() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalMultiblock.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalMultiblock.java index ab8106a5ad..5cc19e74f6 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalMultiblock.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/BlockTypes_MetalMultiblock.java @@ -33,31 +33,35 @@ public enum BlockTypes_MetalMultiblock implements IStringSerializable, BlockIEBa MIXER(true); private boolean needsCustomState; + BlockTypes_MetalMultiblock(boolean needsCustomState) { this.needsCustomState = needsCustomState; } - + @Override public String getName() { return this.toString().toLowerCase(Locale.ENGLISH); } + @Override public int getMeta() { return ordinal(); } + @Override public boolean listForCreative() { return false; } - + public boolean needsCustomState() { return this.needsCustomState; } + public String getCustomState() { /*String[] split = getName().split("_"); diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityArcFurnace.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityArcFurnace.java index 1d76efee97..ea50ac4ba7 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityArcFurnace.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityArcFurnace.java @@ -12,7 +12,6 @@ import blusunrize.immersiveengineering.api.Lib; import blusunrize.immersiveengineering.api.crafting.ArcFurnaceRecipe; import blusunrize.immersiveengineering.api.crafting.IMultiblockRecipe; -import blusunrize.immersiveengineering.common.Config.IEConfig; import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IAdvancedCollisionBounds; import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IAdvancedSelectionBounds; import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IGuiTile; @@ -43,13 +42,14 @@ import java.util.*; -public class TileEntityArcFurnace extends TileEntityMultiblockMetal implements ISoundTile,IGuiTile, IAdvancedSelectionBounds,IAdvancedCollisionBounds +public class TileEntityArcFurnace extends TileEntityMultiblockMetal implements ISoundTile, IGuiTile, IAdvancedSelectionBounds, IAdvancedCollisionBounds { public NonNullList inventory = NonNullList.withSize(26, ItemStack.EMPTY); public int pouringMetal = 0; + public TileEntityArcFurnace() { - super(MultiblockArcFurnace.instance, new int[]{5,5,5}, 64000, true); + super(MultiblockArcFurnace.instance, new int[]{5, 5, 5}, 64000, true); } @Override @@ -59,6 +59,7 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) if(!descPacket) inventory = Utils.readInventory(nbt.getTagList("inventory", 10), 26); } + @Override public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { @@ -71,47 +72,47 @@ public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) public void update() { super.update(); - if (isDummy()) + if(isDummy()) return; if(world.isRemote) { - if(pouringMetal>0) + if(pouringMetal > 0) pouringMetal--; if(shouldRenderAsActive()) - for(int i=0; i<4; i++) + for(int i = 0; i < 4; i++) { if(Utils.RAND.nextInt(6)==0) ImmersiveEngineering.proxy.spawnSparkFX(world, getPos().getX()+.5-.25*facing.getFrontOffsetX(), - getPos().getY()+2.9,getPos().getZ()+.5-.25*facing.getFrontOffsetZ(), + getPos().getY()+2.9, getPos().getZ()+.5-.25*facing.getFrontOffsetZ(), Utils.RAND.nextDouble()*.05-.025, .025, Utils.RAND.nextDouble()*.05-.025); if(Utils.RAND.nextInt(6)==0) - ImmersiveEngineering.proxy.spawnSparkFX(world, getPos().getX()+.5+(facing==EnumFacing.EAST?-.25:.25), - getPos().getY()+2.9,getPos().getZ()+.5+(facing==EnumFacing.SOUTH?.25:-.25), + ImmersiveEngineering.proxy.spawnSparkFX(world, getPos().getX()+.5+(facing==EnumFacing.EAST?-.25: .25), + getPos().getY()+2.9, getPos().getZ()+.5+(facing==EnumFacing.SOUTH?.25: -.25), Utils.RAND.nextDouble()*.05-.025, .025, Utils.RAND.nextDouble()*.05-.025); if(Utils.RAND.nextInt(6)==0) - ImmersiveEngineering.proxy.spawnSparkFX(world, getPos().getX()+.5+(facing==EnumFacing.WEST?.25:-.25), - getPos().getY()+2.9,getPos().getZ()+.5+(facing==EnumFacing.NORTH?-.25:.25), + ImmersiveEngineering.proxy.spawnSparkFX(world, getPos().getX()+.5+(facing==EnumFacing.WEST?.25: -.25), + getPos().getY()+2.9, getPos().getZ()+.5+(facing==EnumFacing.NORTH?-.25: .25), Utils.RAND.nextDouble()*.05-.025, .025, Utils.RAND.nextDouble()*.05-.025); } } - else if (!isRSDisabled() && energyStorage.getEnergyStored() > 0) + else if(!isRSDisabled()&&energyStorage.getEnergyStored() > 0) { - if (this.tickedProcesses > 0) - for (int i = 23; i < 26; i++) - if (this.inventory.get(i).attemptDamageItem(1, Utils.RAND, null)) + if(this.tickedProcesses > 0) + for(int i = 23; i < 26; i++) + if(this.inventory.get(i).attemptDamageItem(1, Utils.RAND, null)) { this.inventory.set(i, ItemStack.EMPTY); // updateClient = true; // update = true; } - if (this.processQueue.size() < this.getProcessQueueMaxLength()) + if(this.processQueue.size() < this.getProcessQueueMaxLength()) { Set usedInvSlots = new HashSet(); // final int[] usedInvSlots = new int[8]; - for (MultiblockProcess process : processQueue) - if (process instanceof MultiblockProcessInMachine) - for (int i : ((MultiblockProcessInMachine) process).inputSlots) + for(MultiblockProcess process : processQueue) + if(process instanceof MultiblockProcessInMachine) + for(int i : ((MultiblockProcessInMachine)process).inputSlots) usedInvSlots.add(i); // Integer[] preferredSlots = new Integer[]{0,1,2,3,4,5,6,7}; @@ -122,10 +123,10 @@ else if (!isRSDisabled() && energyStorage.getEnergyStored() > 0) // return Integer.compare(usedInvSlots[arg0],usedInvSlots[arg1]); // }}); NonNullList additives = NonNullList.withSize(4, ItemStack.EMPTY); - for (int i = 0; i < 4; i++) - additives.set(i, !inventory.get(12 + i).isEmpty() ? inventory.get(12 + i).copy() : ItemStack.EMPTY); - for (int slot = 0; slot < 12; slot++) - if (!usedInvSlots.contains(slot)) + for(int i = 0; i < 4; i++) + additives.set(i, !inventory.get(12+i).isEmpty()?inventory.get(12+i).copy(): ItemStack.EMPTY); + for(int slot = 0; slot < 12; slot++) + if(!usedInvSlots.contains(slot)) { ItemStack stack = this.getInventory().get(slot); // if(stack!=null) @@ -133,14 +134,14 @@ else if (!isRSDisabled() && energyStorage.getEnergyStored() > 0) // stack = stack.copy(); //// stack.stackSize-=usedInvSlots[slot]; // } - if (!stack.isEmpty() && stack.getCount() > 0) + if(!stack.isEmpty()&&stack.getCount() > 0) { ArcFurnaceRecipe recipe = ArcFurnaceRecipe.findRecipe(stack, additives); - if (recipe != null) + if(recipe!=null) { MultiblockProcessArcFurnace process = new MultiblockProcessArcFurnace(recipe, slot, 12, 13, 14, 15); - if (this.addProcessToQueue(process, true)) + if(this.addProcessToQueue(process, true)) { this.addProcessToQueue(process, false); usedInvSlots.add(slot); @@ -151,35 +152,35 @@ else if (!isRSDisabled() && energyStorage.getEnergyStored() > 0) } } - if (world.getTotalWorldTime() % 8 == 0) + if(world.getTotalWorldTime()%8==0) { BlockPos outputPos = this.getBlockPosForPos(2).offset(facing, -1); TileEntity outputTile = Utils.getExistingTileEntity(world, outputPos); - if (outputTile != null) - for (int j = 16; j < 22; j++) - if (!inventory.get(j).isEmpty()) + if(outputTile!=null) + for(int j = 16; j < 22; j++) + if(!inventory.get(j).isEmpty()) { ItemStack stack = Utils.copyStackWithAmount(inventory.get(j), 1); stack = Utils.insertStackIntoInventory(outputTile, stack, facing.getOpposite()); - if (stack.isEmpty()) + if(stack.isEmpty()) { this.inventory.get(j).shrink(1); - if (this.inventory.get(j).getCount() <= 0) + if(this.inventory.get(j).getCount() <= 0) this.inventory.set(j, ItemStack.EMPTY); } } outputPos = this.getBlockPosForPos(22).offset(facing); outputTile = Utils.getExistingTileEntity(world, outputPos); - if (outputTile != null) - if (!inventory.get(22).isEmpty()) + if(outputTile!=null) + if(!inventory.get(22).isEmpty()) { int out = Math.min(inventory.get(22).getCount(), 16); ItemStack stack = Utils.copyStackWithAmount(inventory.get(22), out); stack = Utils.insertStackIntoInventory(outputTile, stack, facing); - if (!stack.isEmpty()) + if(!stack.isEmpty()) out -= stack.getCount(); this.inventory.get(22).shrink(out); - if (this.inventory.get(22).getCount() <= 0) + if(this.inventory.get(22).getCount() <= 0) this.inventory.set(22, ItemStack.EMPTY); } } @@ -189,13 +190,14 @@ else if (!isRSDisabled() && energyStorage.getEnergyStored() > 0) @Override public boolean receiveClientEvent(int id, int type) { - if (id==0) + if(id==0) pouringMetal = type; return super.receiveClientEvent(id, type); } @SideOnly(Side.CLIENT) private AxisAlignedBB renderAABB; + @SideOnly(Side.CLIENT) @Override public AxisAlignedBB getRenderBoundingBox() @@ -206,62 +208,63 @@ public AxisAlignedBB getRenderBoundingBox() // else // renderAABB = AxisAlignedBB.getBoundingBox(xCoord,yCoord,zCoord, xCoord,yCoord,zCoord); // return renderAABB; - return new AxisAlignedBB(getPos().getX()-(facing.getAxis()==Axis.Z?2:1),getPos().getY(),getPos().getZ()-(facing.getAxis()==Axis.X?2:1), getPos().getX()+(facing.getAxis()==Axis.Z?3:2),getPos().getY()+3,getPos().getZ()+(facing.getAxis()==Axis.X?3:2)); + return new AxisAlignedBB(getPos().getX()-(facing.getAxis()==Axis.Z?2: 1), getPos().getY(), getPos().getZ()-(facing.getAxis()==Axis.X?2: 1), getPos().getX()+(facing.getAxis()==Axis.Z?3: 2), getPos().getY()+3, getPos().getZ()+(facing.getAxis()==Axis.X?3: 2)); } @Override public float[] getBlockBounds() { if(pos==1||pos==3) - return new float[]{facing==EnumFacing.EAST?.4375f:0,0,facing==EnumFacing.SOUTH?.4375f:0, facing==EnumFacing.WEST?.5625f:1,.5f,facing==EnumFacing.NORTH?.5625f:1}; - else if(pos<20 && pos!=2) - return new float[]{0,0,0,1,.5f,1}; + return new float[]{facing==EnumFacing.EAST?.4375f: 0, 0, facing==EnumFacing.SOUTH?.4375f: 0, facing==EnumFacing.WEST?.5625f: 1, .5f, facing==EnumFacing.NORTH?.5625f: 1}; + else if(pos < 20&&pos!=2) + return new float[]{0, 0, 0, 1, .5f, 1}; else if(pos==25) - return new float[]{facing==EnumFacing.WEST?.5f:0,0,facing==EnumFacing.NORTH?.5f:0, facing==EnumFacing.EAST?.5f:1,1,facing==EnumFacing.SOUTH?.5f:1}; - else if((pos>=36&&pos<=38) || (pos>=41&&pos<=43)) + return new float[]{facing==EnumFacing.WEST?.5f: 0, 0, facing==EnumFacing.NORTH?.5f: 0, facing==EnumFacing.EAST?.5f: 1, 1, facing==EnumFacing.SOUTH?.5f: 1}; + else if((pos >= 36&&pos <= 38)||(pos >= 41&&pos <= 43)) { EnumFacing fw = facing.rotateY(); if(mirrored|pos%5==3) fw = fw.getOpposite(); if(pos%5==2) - fw=null; + fw = null; float minX = fw==EnumFacing.EAST?.125f: 0; float maxX = fw==EnumFacing.WEST?.875f: 1; float minZ = fw==EnumFacing.SOUTH?.125f: 0; float maxZ = fw==EnumFacing.NORTH?.875f: 1; - if(pos<=38) + if(pos <= 38) { - minX -= facing==EnumFacing.EAST?.875f:0; - maxX += facing==EnumFacing.WEST?.875f:0; - minZ -= facing==EnumFacing.SOUTH?.875f:0; - maxZ += facing==EnumFacing.NORTH?.875f:0; + minX -= facing==EnumFacing.EAST?.875f: 0; + maxX += facing==EnumFacing.WEST?.875f: 0; + minZ -= facing==EnumFacing.SOUTH?.875f: 0; + maxZ += facing==EnumFacing.NORTH?.875f: 0; } - return new float[]{minX,.5f,minZ, maxX,1,maxZ}; + return new float[]{minX, .5f, minZ, maxX, 1, maxZ}; } else if(pos==40||pos==44) { - EnumFacing fl = pos==44?facing.getOpposite():facing; - return new float[]{fl==EnumFacing.NORTH?.125f:fl==EnumFacing.SOUTH?.625f:0,.125f,fl==EnumFacing.EAST?.125f:fl==EnumFacing.WEST?.625f:0, fl==EnumFacing.SOUTH?.875f:fl==EnumFacing.NORTH?.375f:1,.375f,fl==EnumFacing.WEST?.875f:fl==EnumFacing.EAST?.375f:1}; + EnumFacing fl = pos==44?facing.getOpposite(): facing; + return new float[]{fl==EnumFacing.NORTH?.125f: fl==EnumFacing.SOUTH?.625f: 0, .125f, fl==EnumFacing.EAST?.125f: fl==EnumFacing.WEST?.625f: 0, fl==EnumFacing.SOUTH?.875f: fl==EnumFacing.NORTH?.375f: 1, .375f, fl==EnumFacing.WEST?.875f: fl==EnumFacing.EAST?.375f: 1}; } - else if(pos>=46&&pos<=48) - return new float[]{facing==EnumFacing.WEST?.25f:0,0,facing==EnumFacing.NORTH?.25f:0, facing==EnumFacing.EAST?.75f:1,1,facing==EnumFacing.SOUTH?.75f:1}; + else if(pos >= 46&&pos <= 48) + return new float[]{facing==EnumFacing.WEST?.25f: 0, 0, facing==EnumFacing.NORTH?.25f: 0, facing==EnumFacing.EAST?.75f: 1, 1, facing==EnumFacing.SOUTH?.75f: 1}; else if(pos==97) - return new float[]{facing.getAxis()==Axis.X?.375f:0,0,facing.getAxis()==Axis.Z?.375f:0,facing.getAxis()==Axis.X?.625f:1,1,facing.getAxis()==Axis.Z?.625f:1}; + return new float[]{facing.getAxis()==Axis.X?.375f: 0, 0, facing.getAxis()==Axis.Z?.375f: 0, facing.getAxis()==Axis.X?.625f: 1, 1, facing.getAxis()==Axis.Z?.625f: 1}; else if(pos==122) - return new float[]{facing==EnumFacing.WEST?.3125f:0,0,facing==EnumFacing.NORTH?.3125f:0,facing==EnumFacing.EAST?.6875f:1,.9375f,facing==EnumFacing.SOUTH?.6875f:1}; + return new float[]{facing==EnumFacing.WEST?.3125f: 0, 0, facing==EnumFacing.NORTH?.3125f: 0, facing==EnumFacing.EAST?.6875f: 1, .9375f, facing==EnumFacing.SOUTH?.6875f: 1}; else if(pos==117) - return new float[]{0,.625f,0,1,.9375f,1}; + return new float[]{0, .625f, 0, 1, .9375f, 1}; else if(pos==112) - return new float[]{facing==EnumFacing.EAST?.125f:0,0,facing==EnumFacing.SOUTH?.125f:0,facing==EnumFacing.WEST?.875f:1,.9375f,facing==EnumFacing.NORTH?.875f:1}; - else if(pos==51||pos==53 || pos==96||pos==98||pos==121||pos==123) + return new float[]{facing==EnumFacing.EAST?.125f: 0, 0, facing==EnumFacing.SOUTH?.125f: 0, facing==EnumFacing.WEST?.875f: 1, .9375f, facing==EnumFacing.NORTH?.875f: 1}; + else if(pos==51||pos==53||pos==96||pos==98||pos==121||pos==123) { EnumFacing fw = facing.rotateY(); - if(mirrored ^ pos % 5 == 3) + if(mirrored^pos%5==3) fw = fw.getOpposite(); - return new float[]{fw==EnumFacing.EAST?.5f:0,0,fw==EnumFacing.SOUTH?.5f:0, fw==EnumFacing.WEST?.5f:1,1,fw==EnumFacing.NORTH?.5f:1}; + return new float[]{fw==EnumFacing.EAST?.5f: 0, 0, fw==EnumFacing.SOUTH?.5f: 0, fw==EnumFacing.WEST?.5f: 1, 1, fw==EnumFacing.NORTH?.5f: 1}; } - return new float[]{0,0,0,1,1,1}; + return new float[]{0, 0, 0, 1, 1, 1}; } + @Override public List getAdvancedSelectionBounds() { @@ -273,38 +276,38 @@ public List getAdvancedSelectionBounds() fw = fw.getOpposite(); if(pos==0) { - List list = Lists.newArrayList(new AxisAlignedBB(0,0,0, 1,.5f,1).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + List list = Lists.newArrayList(new AxisAlignedBB(0, 0, 0, 1, .5f, 1).offset(getPos().getX(), getPos().getY(), getPos().getZ())); float minX = fl==EnumFacing.WEST?.625f: fl==EnumFacing.EAST?.125f: .125f; float maxX = fl==EnumFacing.EAST?.375f: fl==EnumFacing.WEST?.875f: .25f; float minZ = fl==EnumFacing.NORTH?.625f: fl==EnumFacing.SOUTH?.125f: .125f; float maxZ = fl==EnumFacing.SOUTH?.375f: fl==EnumFacing.NORTH?.875f: .25f; - list.add(new AxisAlignedBB(minX,.5f,minZ, maxX,1,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); minX = fl==EnumFacing.WEST?.625f: fl==EnumFacing.EAST?.125f: .75f; maxX = fl==EnumFacing.EAST?.375f: fl==EnumFacing.WEST?.875f: .875f; minZ = fl==EnumFacing.NORTH?.625f: fl==EnumFacing.SOUTH?.125f: .75f; maxZ = fl==EnumFacing.SOUTH?.375f: fl==EnumFacing.NORTH?.875f: .875f; - list.add(new AxisAlignedBB(minX,.5f,minZ, maxX,1,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); return list; } - else if(pos>=46&&pos<=48) + else if(pos >= 46&&pos <= 48) { - float minX = fl==EnumFacing.WEST?.25f:0; - float maxX = fl==EnumFacing.EAST?.75f:1; - float minZ = fl==EnumFacing.NORTH?.25f:0; - float maxZ = fl==EnumFacing.SOUTH?.75f:1; - List list = Lists.newArrayList(new AxisAlignedBB(minX,0,minZ,maxX,1,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + float minX = fl==EnumFacing.WEST?.25f: 0; + float maxX = fl==EnumFacing.EAST?.75f: 1; + float minZ = fl==EnumFacing.NORTH?.25f: 0; + float maxZ = fl==EnumFacing.SOUTH?.75f: 1; + List list = Lists.newArrayList(new AxisAlignedBB(minX, 0, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); minX = fl==EnumFacing.WEST?0: fl==EnumFacing.EAST?.75f: .25f; maxX = fl==EnumFacing.EAST?1: fl==EnumFacing.WEST?.25f: .75f; minZ = fl==EnumFacing.NORTH?0: fl==EnumFacing.SOUTH?.75f: .25f; maxZ = fl==EnumFacing.SOUTH?1: fl==EnumFacing.NORTH?.25f: .75f; - list.add(new AxisAlignedBB(minX,.25f,minZ, maxX,.75,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, .25f, minZ, maxX, .75, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); return list; } - else if(pos%25>=10 && (pos%5==0||pos%5==4)) + else if(pos%25 >= 10&&(pos%5==0||pos%5==4)) { - List list = pos<25?Lists.newArrayList(new AxisAlignedBB(0,0,0, 1,.5f,1).offset(getPos().getX(),getPos().getY(),getPos().getZ())):new ArrayList(2); + List list = pos < 25?Lists.newArrayList(new AxisAlignedBB(0, 0, 0, 1, .5f, 1).offset(getPos().getX(), getPos().getY(), getPos().getZ())): new ArrayList(2); if(pos%5==4) fw = fw.getOpposite(); float minX = fw==EnumFacing.EAST?.5f: 0; @@ -312,51 +315,51 @@ else if(pos%25>=10 && (pos%5==0||pos%5==4)) float minZ = fw==EnumFacing.SOUTH?.5f: 0; float maxZ = fw==EnumFacing.NORTH?.5f: 1; if(pos%25/5!=3) - list.add(new AxisAlignedBB(minX,pos<25?.5:0,minZ, maxX,1,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); - if(pos<25) + list.add(new AxisAlignedBB(minX, pos < 25?.5: 0, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); + if(pos < 25) { - minX = fw==EnumFacing.EAST?.125f: fw==EnumFacing.WEST?.625f: fl==EnumFacing.EAST?.375f:-1.625f; + minX = fw==EnumFacing.EAST?.125f: fw==EnumFacing.WEST?.625f: fl==EnumFacing.EAST?.375f: -1.625f; maxX = fw==EnumFacing.EAST?.375f: fw==EnumFacing.WEST?.875f: fl==EnumFacing.WEST?.625f: 2.625f; - minZ = fw==EnumFacing.SOUTH?.125f: fw==EnumFacing.NORTH?.625f: fl==EnumFacing.SOUTH?.375f:-1.625f; + minZ = fw==EnumFacing.SOUTH?.125f: fw==EnumFacing.NORTH?.625f: fl==EnumFacing.SOUTH?.375f: -1.625f; maxZ = fw==EnumFacing.SOUTH?.375f: fw==EnumFacing.NORTH?.875f: fl==EnumFacing.NORTH?.625f: 2.625f; - AxisAlignedBB aabb = new AxisAlignedBB(minX,.6875,minZ, maxX,.9375,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ()); - aabb = aabb.offset(-fl.getFrontOffsetX()*(pos%25-10)/5,0,-fl.getFrontOffsetZ()*(pos%25-10)/5); + AxisAlignedBB aabb = new AxisAlignedBB(minX, .6875, minZ, maxX, .9375, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()); + aabb = aabb.offset(-fl.getFrontOffsetX()*(pos%25-10)/5, 0, -fl.getFrontOffsetZ()*(pos%25-10)/5); list.add(aabb); minX = fw==EnumFacing.EAST?.375f: fw==EnumFacing.WEST?.5f: fl==EnumFacing.EAST?.375f: .375f; maxX = fw==EnumFacing.EAST?.5f: fw==EnumFacing.WEST?.625f: fl==EnumFacing.WEST?.625f: .625f; minZ = fw==EnumFacing.SOUTH?.375f: fw==EnumFacing.NORTH?.5f: fl==EnumFacing.SOUTH?.375f: .375f; maxZ = fw==EnumFacing.SOUTH?.5f: fw==EnumFacing.NORTH?.625f: fl==EnumFacing.NORTH?.625f: .625f; - aabb = new AxisAlignedBB(minX,.6875,minZ, maxX,.9375,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ()); - aabb = aabb.offset(-fl.getFrontOffsetX()*(pos%25-10)/5,0,-fl.getFrontOffsetZ()*(pos%25-10)/5); + aabb = new AxisAlignedBB(minX, .6875, minZ, maxX, .9375, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()); + aabb = aabb.offset(-fl.getFrontOffsetX()*(pos%25-10)/5, 0, -fl.getFrontOffsetZ()*(pos%25-10)/5); list.add(aabb); - minX = fw==EnumFacing.EAST?.375f: fw==EnumFacing.WEST?.5f: fl==EnumFacing.EAST?2.375f:-1.625f; + minX = fw==EnumFacing.EAST?.375f: fw==EnumFacing.WEST?.5f: fl==EnumFacing.EAST?2.375f: -1.625f; maxX = fw==EnumFacing.EAST?.5f: fw==EnumFacing.WEST?.625f: fl==EnumFacing.WEST?-1.375f: 2.625f; - minZ = fw==EnumFacing.SOUTH?.375f: fw==EnumFacing.NORTH?.5f: fl==EnumFacing.SOUTH?2.375f:-1.625f; + minZ = fw==EnumFacing.SOUTH?.375f: fw==EnumFacing.NORTH?.5f: fl==EnumFacing.SOUTH?2.375f: -1.625f; maxZ = fw==EnumFacing.SOUTH?.5f: fw==EnumFacing.NORTH?.625f: fl==EnumFacing.NORTH?-1.375f: 2.625f; - aabb = new AxisAlignedBB(minX,.6875,minZ, maxX,.9375,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ()); - aabb = aabb.offset(-fl.getFrontOffsetX()*(pos%25-10)/5,0,-fl.getFrontOffsetZ()*(pos%25-10)/5); + aabb = new AxisAlignedBB(minX, .6875, minZ, maxX, .9375, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()); + aabb = aabb.offset(-fl.getFrontOffsetX()*(pos%25-10)/5, 0, -fl.getFrontOffsetZ()*(pos%25-10)/5); list.add(aabb); } - else if(pos<50) + else if(pos < 50) { - minX = fw==EnumFacing.EAST?.125f: fw==EnumFacing.WEST?.625f: fl==EnumFacing.EAST?.375f:-1.625f; + minX = fw==EnumFacing.EAST?.125f: fw==EnumFacing.WEST?.625f: fl==EnumFacing.EAST?.375f: -1.625f; maxX = fw==EnumFacing.EAST?.375f: fw==EnumFacing.WEST?.875f: fl==EnumFacing.WEST?.625f: 2.625f; - minZ = fw==EnumFacing.SOUTH?.125f: fw==EnumFacing.NORTH?.625f: fl==EnumFacing.SOUTH?.375f:-1.625f; + minZ = fw==EnumFacing.SOUTH?.125f: fw==EnumFacing.NORTH?.625f: fl==EnumFacing.SOUTH?.375f: -1.625f; maxZ = fw==EnumFacing.SOUTH?.375f: fw==EnumFacing.NORTH?.875f: fl==EnumFacing.NORTH?.625f: 2.625f; - AxisAlignedBB aabb = new AxisAlignedBB(minX,.125,minZ, maxX,.375,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ()); - aabb = aabb.offset(-fl.getFrontOffsetX()*(pos%25-10)/5,0,-fl.getFrontOffsetZ()*(pos%25-10)/5); + AxisAlignedBB aabb = new AxisAlignedBB(minX, .125, minZ, maxX, .375, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()); + aabb = aabb.offset(-fl.getFrontOffsetX()*(pos%25-10)/5, 0, -fl.getFrontOffsetZ()*(pos%25-10)/5); list.add(aabb); minX = fw==EnumFacing.EAST?.375f: fw==EnumFacing.WEST?.5f: fl==EnumFacing.EAST?.375f: .375f; maxX = fw==EnumFacing.EAST?.5f: fw==EnumFacing.WEST?.625f: fl==EnumFacing.WEST?.625f: .625f; minZ = fw==EnumFacing.SOUTH?.375f: fw==EnumFacing.NORTH?.5f: fl==EnumFacing.SOUTH?.375f: .375f; maxZ = fw==EnumFacing.SOUTH?.5f: fw==EnumFacing.NORTH?.625f: fl==EnumFacing.NORTH?.625f: .625f; - aabb = new AxisAlignedBB(minX,.125,minZ, maxX,.375,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ()); - aabb = aabb.offset(-fl.getFrontOffsetX()*(pos%25-10)/5,0,-fl.getFrontOffsetZ()*(pos%25-10)/5); + aabb = new AxisAlignedBB(minX, .125, minZ, maxX, .375, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()); + aabb = aabb.offset(-fl.getFrontOffsetX()*(pos%25-10)/5, 0, -fl.getFrontOffsetZ()*(pos%25-10)/5); if(pos%5==0) - aabb = aabb.offset(0,.6875,0); + aabb = aabb.offset(0, .6875, 0); list.add(aabb); if(pos%5==0) { @@ -364,16 +367,16 @@ else if(pos<50) maxX = fw==EnumFacing.EAST?.375f: fw==EnumFacing.WEST?.875f: fl==EnumFacing.WEST?.625f: .625f; minZ = fw==EnumFacing.SOUTH?.125f: fw==EnumFacing.NORTH?.625f: fl==EnumFacing.SOUTH?.375f: .375f; maxZ = fw==EnumFacing.SOUTH?.375f: fw==EnumFacing.NORTH?.875f: fl==EnumFacing.NORTH?.625f: .625f; - aabb = new AxisAlignedBB(minX,.375,minZ, maxX,1.0625,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ()); - aabb = aabb.offset(-fl.getFrontOffsetX()*(pos%25-10)/5,0,-fl.getFrontOffsetZ()*(pos%25-10)/5); + aabb = new AxisAlignedBB(minX, .375, minZ, maxX, 1.0625, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()); + aabb = aabb.offset(-fl.getFrontOffsetX()*(pos%25-10)/5, 0, -fl.getFrontOffsetZ()*(pos%25-10)/5); list.add(aabb); } - minX = fw==EnumFacing.EAST?.375f: fw==EnumFacing.WEST?.5f: fl==EnumFacing.EAST?2.375f:-1.625f; + minX = fw==EnumFacing.EAST?.375f: fw==EnumFacing.WEST?.5f: fl==EnumFacing.EAST?2.375f: -1.625f; maxX = fw==EnumFacing.EAST?.5f: fw==EnumFacing.WEST?.625f: fl==EnumFacing.WEST?-1.375f: 2.625f; - minZ = fw==EnumFacing.SOUTH?.375f: fw==EnumFacing.NORTH?.5f: fl==EnumFacing.SOUTH?2.375f:-1.625f; + minZ = fw==EnumFacing.SOUTH?.375f: fw==EnumFacing.NORTH?.5f: fl==EnumFacing.SOUTH?2.375f: -1.625f; maxZ = fw==EnumFacing.SOUTH?.5f: fw==EnumFacing.NORTH?.625f: fl==EnumFacing.NORTH?-1.375f: 2.625f; - aabb = new AxisAlignedBB(minX,.125,minZ, maxX,.375,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ()); - aabb = aabb.offset(-fl.getFrontOffsetX()*(pos%25-10)/5,0,-fl.getFrontOffsetZ()*(pos%25-10)/5); + aabb = new AxisAlignedBB(minX, .125, minZ, maxX, .375, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()); + aabb = aabb.offset(-fl.getFrontOffsetX()*(pos%25-10)/5, 0, -fl.getFrontOffsetZ()*(pos%25-10)/5); list.add(aabb); } else if(pos==60||pos==64) @@ -382,17 +385,19 @@ else if(pos==60||pos==64) maxX = fw==EnumFacing.EAST?.5f: fw==EnumFacing.WEST?.625f: .75f; minZ = fw==EnumFacing.SOUTH?.375f: fw==EnumFacing.NORTH?.5f: .25f; maxZ = fw==EnumFacing.SOUTH?.5f: fw==EnumFacing.NORTH?.625f: .75f; - list.add(new AxisAlignedBB(minX,.25,minZ, maxX,.75,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, .25, minZ, maxX, .75, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); } return list; } return null; } + @Override public boolean isOverrideBox(AxisAlignedBB box, EntityPlayer player, RayTraceResult mop, ArrayList list) { return false; } + @Override public List getAdvancedColisionBounds() { @@ -402,8 +407,9 @@ public List getAdvancedColisionBounds() @Override public int[] getEnergyPos() { - return new int[]{46,47,48}; + return new int[]{46, 47, 48}; } + @Override public int[] getRedstonePos() { @@ -422,7 +428,7 @@ public int getComparatorInputOverride() for(int i = 23; i < 26; i++) if(!master.inventory.get(i).isEmpty()) f += 1-(master.inventory.get(i).getItemDamage()/(float)master.inventory.get(i).getMaxDamage()); - return MathHelper.floor(Math.max(f/3f,0)*15); + return MathHelper.floor(Math.max(f/3f, 0)*15); } } return super.getComparatorInputOverride(); @@ -433,10 +439,11 @@ public boolean isInWorldProcessingMachine() { return false; } + @Override public boolean shouldRenderAsActive() { - return hasElectrodes() && super.shouldRenderAsActive(); + return hasElectrodes()&&super.shouldRenderAsActive(); } @Override @@ -444,7 +451,7 @@ public boolean additionalCanProcessCheck(MultiblockProcess pro { if(!hasElectrodes()) return false; - if(process.recipe!=null && !process.recipe.slag.isEmpty()) + if(process.recipe!=null&&!process.recipe.slag.isEmpty()) { if(this.inventory.get(22).isEmpty()) return true; @@ -452,20 +459,23 @@ public boolean additionalCanProcessCheck(MultiblockProcess pro } return true; } + @Override public void doProcessOutput(ItemStack output) { - BlockPos pos = getPos().add(0,-1,0).offset(facing,-2); + BlockPos pos = getPos().add(0, -1, 0).offset(facing, -2); TileEntity inventoryTile = this.world.getTileEntity(pos); if(inventoryTile!=null) output = Utils.insertStackIntoInventory(inventoryTile, output, facing.getOpposite()); if(!output.isEmpty()) Utils.dropStackAtPos(world, pos, output, facing); } + @Override public void doProcessFluidOutput(FluidStack output) { } + @Override public void onProcessFinish(MultiblockProcess process) { @@ -473,20 +483,23 @@ public void onProcessFinish(MultiblockProcess process) { if(this.inventory.get(22).isEmpty()) this.inventory.set(22, process.recipe.slag.copy()); - else if(ItemHandlerHelper.canItemStacksStack(this.inventory.get(22), process.recipe.slag) || inventory.get(22).getCount() + process.recipe.slag.getCount() >getSlotLimit(22)) + else if(ItemHandlerHelper.canItemStacksStack(this.inventory.get(22), process.recipe.slag)||inventory.get(22).getCount()+process.recipe.slag.getCount() > getSlotLimit(22)) this.inventory.get(22).grow(process.recipe.slag.getCount()); } } + @Override public int getMaxProcessPerTick() { return 12; } + @Override public int getProcessQueueMaxLength() { return 12; } + @Override public float getMinProcessDistance(MultiblockProcess process) { @@ -499,104 +512,115 @@ public int getComparatedSize() { return 12; } + @Override public NonNullList getInventory() { return this.inventory; } + @Override public boolean isStackValid(int slot, ItemStack stack) { return true; } + @Override public int getSlotLimit(int slot) { - return slot>22?1:64; + return slot > 22?1: 64; } - static int[] outputSlots = {16,17,18,19,20,21}; + + static int[] outputSlots = {16, 17, 18, 19, 20, 21}; + @Override public int[] getOutputSlots() { return outputSlots; } + @Override public int[] getOutputTanks() { return null; } + @Override public IFluidTank[] getInternalTanks() { return null; } + @Override protected IFluidTank[] getAccessibleFluidTanks(EnumFacing side) { return new IFluidTank[0]; } + @Override protected boolean canFillTankFrom(int iTank, EnumFacing side, FluidStack resources) { return false; } + @Override protected boolean canDrainTankFrom(int iTank, EnumFacing side) { return false; } + @Override public void doGraphicalUpdates(int slot) { } - IItemHandler inputHandler = new IEInventoryHandler(12, this, 0, true,false) + IItemHandler inputHandler = new IEInventoryHandler(12, this, 0, true, false) { //ignore the given slot and spread it out @Override public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { - if (stack.isEmpty()) + if(stack.isEmpty()) return stack; stack = stack.copy(); List possibleSlots = new ArrayList<>(12); - for (int i = 0; i < 12; i++) + for(int i = 0; i < 12; i++) { ItemStack here = inventory.get(i); - if (here.isEmpty()) + if(here.isEmpty()) { - if (!simulate) + if(!simulate) inventory.set(i, stack); return ItemStack.EMPTY; } - else if (ItemHandlerHelper.canItemStacksStack(stack, here) && here.getCount() < here.getMaxStackSize()) + else if(ItemHandlerHelper.canItemStacksStack(stack, here)&&here.getCount() < here.getMaxStackSize()) { possibleSlots.add(i); } } Collections.sort(possibleSlots, (a, b) -> Integer.compare(inventory.get(a).getCount(), inventory.get(b).getCount())); - for (int i : possibleSlots) + for(int i : possibleSlots) { ItemStack here = inventory.get(i); - int fillCount = Math.min(here.getMaxStackSize() - here.getCount(), stack.getCount()); - if (!simulate) + int fillCount = Math.min(here.getMaxStackSize()-here.getCount(), stack.getCount()); + if(!simulate) here.grow(fillCount); stack.shrink(fillCount); - if (stack.isEmpty()) + if(stack.isEmpty()) return ItemStack.EMPTY; } return stack; } }; - IItemHandler additiveHandler = new IEInventoryHandler(4, this, 12, true,false); - IItemHandler outputHandler = new IEInventoryHandler(6, this, 16, false,true); - IItemHandler slagHandler = new IEInventoryHandler(1, this, 22, false,true); + IItemHandler additiveHandler = new IEInventoryHandler(4, this, 12, true, false); + IItemHandler outputHandler = new IEInventoryHandler(6, this, 16, false, true); + IItemHandler slagHandler = new IEInventoryHandler(1, this, 22, false, true); @Override public boolean hasCapability(Capability capability, EnumFacing facing) { - if((pos == 2 || pos == 22 || pos == 86 || pos == 88) && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) + if((pos==2||pos==22||pos==86||pos==88)&&capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return master()!=null; return super.hasCapability(capability, facing); } @@ -607,15 +631,15 @@ public T getCapability(Capability capability, EnumFacing facing) if(capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { TileEntityArcFurnace master = master(); - if (master==null) + if(master==null) return null; if(pos==2) return (T)master.outputHandler; else if(pos==22) return (T)master.slagHandler; - else if(pos==(mirrored?88:86)) + else if(pos==(mirrored?88: 86)) return (T)master.inputHandler; - else if(pos==(mirrored?86:88)) + else if(pos==(mirrored?86: 88)) return (T)master.additiveHandler; } return super.getCapability(capability, facing); @@ -626,16 +650,18 @@ public ArcFurnaceRecipe findRecipeForInsertion(ItemStack inserting) { return null; } + @Override protected ArcFurnaceRecipe readRecipeFromNBT(NBTTagCompound tag) { return ArcFurnaceRecipe.loadFromNBT(tag); } + @Override protected MultiblockProcess loadProcessFromNBT(NBTTagCompound tag) { IMultiblockRecipe recipe = readRecipeFromNBT(tag); - if(recipe!=null && recipe instanceof ArcFurnaceRecipe) + if(recipe!=null&&recipe instanceof ArcFurnaceRecipe) return new MultiblockProcessArcFurnace((ArcFurnaceRecipe)recipe, tag.getIntArray("process_inputSlots")); return null; } @@ -643,13 +669,15 @@ protected MultiblockProcess loadProcessFromNBT(NBTTagCompound tag) @Override public boolean canOpenGui() { - return formed && (pos==2||pos==25|| (pos>25 && pos%5>0 && pos%5<4 && pos%25/5<4)); + return formed&&(pos==2||pos==25||(pos > 25&&pos%5 > 0&&pos%5 < 4&&pos%25/5 < 4)); } + @Override public int getGuiID() { return Lib.GUIID_ArcFurnace; } + @Override public TileEntity getGuiMaster() { @@ -674,8 +702,8 @@ protected NonNullList getRecipeItemOutputs(TileEntityMultiblockMetal { ItemStack input = multiblock.getInventory().get(this.inputSlots[0]); NonNullList additives = NonNullList.withSize(4, ItemStack.EMPTY); - for(int i=0; i<4; i++) - additives.set(i, !multiblock.getInventory().get(12+i).isEmpty()? multiblock.getInventory().get(12+i).copy():ItemStack.EMPTY); + for(int i = 0; i < 4; i++) + additives.set(i, !multiblock.getInventory().get(12+i).isEmpty()?multiblock.getInventory().get(12+i).copy(): ItemStack.EMPTY); return recipe.getOutputs(input, additives); } @@ -683,7 +711,7 @@ protected NonNullList getRecipeItemOutputs(TileEntityMultiblockMetal protected void processFinish(TileEntityMultiblockMetal te) { super.processFinish(te); - te.getWorld().addBlockEvent(te.getPos(), te.getBlockType(), 0,40); + te.getWorld().addBlockEvent(te.getPos(), te.getBlockType(), 0, 40); } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityAssembler.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityAssembler.java index 7ef8834928..01a69f7748 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityAssembler.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityAssembler.java @@ -45,18 +45,19 @@ import java.util.ArrayList; import java.util.Iterator; -public class TileEntityAssembler extends TileEntityMultiblockMetal implements IGuiTile, IConveyorAttachable// IAdvancedSelectionBounds,IAdvancedCollisionBounds +public class TileEntityAssembler extends TileEntityMultiblockMetal implements IGuiTile, IConveyorAttachable// IAdvancedSelectionBounds,IAdvancedCollisionBounds { public boolean[] computerOn = new boolean[3]; public boolean isComputerControlled = false; + public TileEntityAssembler() { - super(MultiblockAssembler.instance, new int[]{3,3,3}, 32000, true); + super(MultiblockAssembler.instance, new int[]{3, 3, 3}, 32000, true); } - public FluidTank[] tanks = {new FluidTank(8000),new FluidTank(8000),new FluidTank(8000)}; + public FluidTank[] tanks = {new FluidTank(8000), new FluidTank(8000), new FluidTank(8000)}; public NonNullList inventory = NonNullList.withSize(18+3, ItemStack.EMPTY); - public CrafterPatternInventory[] patterns = {new CrafterPatternInventory(this),new CrafterPatternInventory(this),new CrafterPatternInventory(this)}; + public CrafterPatternInventory[] patterns = {new CrafterPatternInventory(this), new CrafterPatternInventory(this), new CrafterPatternInventory(this)}; public boolean recursiveIngredients = false; @Override @@ -70,7 +71,7 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) if(!descPacket) { inventory = Utils.readInventory(nbt.getTagList("inventory", 10), 18+3); - for(int iPattern=0; iPattern= 0 && id < patterns.length) + if(id >= 0&&id < patterns.length) { CrafterPatternInventory pattern = patterns[id]; for(int i = 0; i < pattern.inv.size(); i++) @@ -128,9 +131,10 @@ public void receiveMessageFromClient(NBTTagCompound message) } else if(id==3) { - recursiveIngredients=!recursiveIngredients; + recursiveIngredients = !recursiveIngredients; } - } else if(message.hasKey("patternSync")) + } + else if(message.hasKey("patternSync")) { int r = message.getInteger("recipe"); NBTTagList list = message.getTagList("patternSync", 10); @@ -142,34 +146,35 @@ else if(id==3) } } } + @Override public void update() { super.update(); - if (isDummy() || isRSDisabled() || world.isRemote || world.getTotalWorldTime() % 16 != ((getPos().getX() ^ getPos().getZ()) & 15)) + if(isDummy()||isRSDisabled()||world.isRemote||world.getTotalWorldTime()%16!=((getPos().getX()^getPos().getZ())&15)) return; boolean update = false; NonNullList[] outputBuffer = new NonNullList[patterns.length]; - for (int p = 0; p < patterns.length; p++) + for(int p = 0; p < patterns.length; p++) { CrafterPatternInventory pattern = patterns[p]; - if (isComputerControlled && !computerOn[p]) + if(isComputerControlled&&!computerOn[p]) continue; - if (!pattern.inv.get(9).isEmpty() && canOutput(pattern.inv.get(9), p)) + if(!pattern.inv.get(9).isEmpty()&&canOutput(pattern.inv.get(9), p)) { ItemStack output = pattern.inv.get(9).copy(); ArrayList queryList = new ArrayList<>();//List of all available inputs in the inventory - for (NonNullList bufferedStacks : outputBuffer) - if (bufferedStacks != null) - for (ItemStack stack : bufferedStacks) - if (!stack.isEmpty()) + for(NonNullList bufferedStacks : outputBuffer) + if(bufferedStacks!=null) + for(ItemStack stack : bufferedStacks) + if(!stack.isEmpty()) queryList.add(stack.copy()); - for (ItemStack stack : this.inventory) - if (!stack.isEmpty()) + for(ItemStack stack : this.inventory) + if(!stack.isEmpty()) queryList.add(stack.copy()); int consumed = IEConfig.Machines.assembler_consumption; - if (this.energyStorage.extractEnergy(consumed, true) == consumed && this.hasIngredients(pattern, queryList)) + if(this.energyStorage.extractEnergy(consumed, true)==consumed&&this.hasIngredients(pattern, queryList)) { this.energyStorage.extractEnergy(consumed, false); NonNullList outputList = NonNullList.create();//List of all outputs for the current recipe. This includes discarded containers @@ -177,25 +182,25 @@ public void update() AssemblerHandler.IRecipeAdapter adapter = AssemblerHandler.findAdapter(pattern.recipe); AssemblerHandler.RecipeQuery[] queries = adapter.getQueriedInputs(pattern.recipe, pattern.inv); NonNullList gridItems = NonNullList.withSize(9, ItemStack.EMPTY); - for (int i = 0; i < queries.length; i++) - if (queries[i] != null) + for(int i = 0; i < queries.length; i++) + if(queries[i]!=null) { AssemblerHandler.RecipeQuery recipeQuery = queries[i]; Optional taken = Optional.absent(); - for (int j = 0; j < outputBuffer.length; j++) - if (outputBuffer[j] != null) + for(int j = 0; j < outputBuffer.length; j++) + if(outputBuffer[j]!=null) { taken = consumeItem(recipeQuery.query, recipeQuery.querySize, outputBuffer[j], outputList); - if (taken.isPresent()) + if(taken.isPresent()) break; } - if (!taken.isPresent()) + if(!taken.isPresent()) taken = this.consumeItem(recipeQuery.query, recipeQuery.querySize, inventory, outputList); gridItems.set(i, taken.or(ItemStack.EMPTY)); } NonNullList remainingItems = pattern.recipe.getRemainingItems(Utils.InventoryCraftingFalse.createFilledCraftingInventory(3, 3, gridItems)); - for (ItemStack rem : remainingItems) - if (!rem.isEmpty()) + for(ItemStack rem : remainingItems) + if(!rem.isEmpty()) outputList.add(rem); outputBuffer[p] = outputList; update = true; @@ -204,51 +209,52 @@ public void update() } BlockPos outputPos = getPos().offset(facing, 2); TileEntity inventoryTile = Utils.getExistingTileEntity(world, outputPos); - for (int buffer = 0; buffer < outputBuffer.length; buffer++) - if (outputBuffer[buffer] != null && outputBuffer[buffer].size() > 0) - for (int iOutput = 0; iOutput < outputBuffer[buffer].size(); iOutput++) + for(int buffer = 0; buffer < outputBuffer.length; buffer++) + if(outputBuffer[buffer]!=null&&outputBuffer[buffer].size() > 0) + for(int iOutput = 0; iOutput < outputBuffer[buffer].size(); iOutput++) { ItemStack output = outputBuffer[buffer].get(iOutput); - if (!output.isEmpty() && output.getCount() > 0) + if(!output.isEmpty()&&output.getCount() > 0) { - if (!isRecipeIngredient(output, buffer) && inventoryTile != null) + if(!isRecipeIngredient(output, buffer)&&inventoryTile!=null) { output = Utils.insertStackIntoInventory(inventoryTile, output, facing.getOpposite()); - if (output.isEmpty() || output.getCount() <= 0) + if(output.isEmpty()||output.getCount() <= 0) continue; } int free = -1; - if (iOutput == 0)//Main recipe output + if(iOutput==0)//Main recipe output { - if (this.inventory.get(18 + buffer).isEmpty() && free < 0) - free = 18 + buffer; - else if (!this.inventory.get(18 + buffer).isEmpty() && OreDictionary.itemMatches(output, this.inventory.get(18 + buffer), true) && this.inventory.get(18 + buffer).getCount() + output.getCount() <= this.inventory.get(18 + buffer).getMaxStackSize()) + if(this.inventory.get(18+buffer).isEmpty()&&free < 0) + free = 18+buffer; + else if(!this.inventory.get(18+buffer).isEmpty()&&OreDictionary.itemMatches(output, this.inventory.get(18+buffer), true)&&this.inventory.get(18+buffer).getCount()+output.getCount() <= this.inventory.get(18+buffer).getMaxStackSize()) { - this.inventory.get(18 + buffer).grow(output.getCount()); + this.inventory.get(18+buffer).grow(output.getCount()); free = -1; continue; } - } else - for (int i = 0; i < this.inventory.size(); i++) + } + else + for(int i = 0; i < this.inventory.size(); i++) { - if (this.inventory.get(i).isEmpty() && free < 0) + if(this.inventory.get(i).isEmpty()&&free < 0) free = i; - else if (!this.inventory.get(i).isEmpty() && OreDictionary.itemMatches(output, this.inventory.get(i), true) && this.inventory.get(i).getCount() + output.getCount() <= this.inventory.get(i).getMaxStackSize()) + else if(!this.inventory.get(i).isEmpty()&&OreDictionary.itemMatches(output, this.inventory.get(i), true)&&this.inventory.get(i).getCount()+output.getCount() <= this.inventory.get(i).getMaxStackSize()) { this.inventory.get(i).grow(output.getCount()); free = -1; break; } } - if (free >= 0) + if(free >= 0) this.inventory.set(free, output.copy()); } } - for (int i = 0; i < 3; i++) - if (!isRecipeIngredient(this.inventory.get(18 + i), i) && inventoryTile != null) - this.inventory.set(18 + i, Utils.insertStackIntoInventory(inventoryTile, this.inventory.get(18 + i), facing.getOpposite())); + for(int i = 0; i < 3; i++) + if(!isRecipeIngredient(this.inventory.get(18+i), i)&&inventoryTile!=null) + this.inventory.set(18+i, Utils.insertStackIntoInventory(inventoryTile, this.inventory.get(18+i), facing.getOpposite())); - if (update) + if(update) { this.markDirty(); this.markContainingBlockForUpdate(null); @@ -257,10 +263,10 @@ else if (!this.inventory.get(i).isEmpty() && OreDictionary.itemMatches(output, t public Optional consumeItem(Object query, int querySize, NonNullList inventory, NonNullList containerItems) { - FluidStack fs = query instanceof FluidStack ? (FluidStack)query : (query instanceof IngredientStack && ((IngredientStack)query).fluid != null) ? ((IngredientStack)query).fluid : null; - if(fs != null) + FluidStack fs = query instanceof FluidStack?(FluidStack)query: (query instanceof IngredientStack&&((IngredientStack)query).fluid!=null)?((IngredientStack)query).fluid: null; + if(fs!=null) for(FluidTank tank : tanks) - if(tank.getFluid() != null && tank.getFluid().containsFluid(fs)) + if(tank.getFluid()!=null&&tank.getFluid().containsFluid(fs)) { tank.drain(fs.amount, true); markDirty(); @@ -268,8 +274,8 @@ public Optional consumeItem(Object query, int querySize, NonNullList< return Optional.of(ItemStack.EMPTY); } Optional ret = Optional.absent(); - for(int i = 0; i< inventory.size(); i++) - if(!inventory.get(i).isEmpty() && Utils.stackMatchesObject(inventory.get(i), query, true)) + for(int i = 0; i < inventory.size(); i++) + if(!inventory.get(i).isEmpty()&&Utils.stackMatchesObject(inventory.get(i), query, true)) { int taken = Math.min(querySize, inventory.get(i).getCount()); boolean doTake = true; @@ -287,6 +293,7 @@ public Optional consumeItem(Object query, int querySize, NonNullList< return ret; return Optional.absent(); } + public boolean hasIngredients(CrafterPatternInventory pattern, ArrayList queryList) { boolean match = true; @@ -297,14 +304,14 @@ public boolean hasIngredients(CrafterPatternInventory pattern, ArrayList=6 && facing==EnumFacing.NORTH)) + if((pos%9 < 3&&facing==EnumFacing.SOUTH)||(pos%9 >= 6&&facing==EnumFacing.NORTH)) zMin = .25f; - else if((pos%9<3 && facing==EnumFacing.NORTH)||(pos%9>=6 && facing==EnumFacing.SOUTH)) + else if((pos%9 < 3&&facing==EnumFacing.NORTH)||(pos%9 >= 6&&facing==EnumFacing.SOUTH)) zMax = .75f; - else if((pos%9<3 && facing==EnumFacing.EAST)||(pos%9>=6 && facing==EnumFacing.WEST)) + else if((pos%9 < 3&&facing==EnumFacing.EAST)||(pos%9 >= 6&&facing==EnumFacing.WEST)) xMin = .25f; - else if((pos%9<3 && facing==EnumFacing.WEST)||(pos%9>=6 && facing==EnumFacing.EAST)) + else if((pos%9 < 3&&facing==EnumFacing.WEST)||(pos%9 >= 6&&facing==EnumFacing.EAST)) xMax = .75f; - if((pos%3==0 && facing==EnumFacing.EAST)||(pos%3==2 && facing==EnumFacing.WEST)) + if((pos%3==0&&facing==EnumFacing.EAST)||(pos%3==2&&facing==EnumFacing.WEST)) zMin = .1875f; - else if((pos%3==0 && facing==EnumFacing.WEST)||(pos%3==2 && facing==EnumFacing.EAST)) + else if((pos%3==0&&facing==EnumFacing.WEST)||(pos%3==2&&facing==EnumFacing.EAST)) zMax = .8125f; - else if((pos%3==0 && facing==EnumFacing.NORTH)||(pos%3==2 && facing==EnumFacing.SOUTH)) + else if((pos%3==0&&facing==EnumFacing.NORTH)||(pos%3==2&&facing==EnumFacing.SOUTH)) xMin = .1875f; - else if((pos%3==0 && facing==EnumFacing.SOUTH)||(pos%3==2 && facing==EnumFacing.NORTH)) + else if((pos%3==0&&facing==EnumFacing.SOUTH)||(pos%3==2&&facing==EnumFacing.NORTH)) xMax = .8125f; - return new float[]{xMin,yMin,zMin, xMax,yMax,zMax}; + return new float[]{xMin, yMin, zMin, xMax, yMax, zMax}; } @Override @@ -398,6 +407,7 @@ public int[] getEnergyPos() { return new int[]{22}; } + @Override public int[] getRedstonePos() { @@ -421,39 +431,46 @@ public boolean isInWorldProcessingMachine() { return false; } + @Override public boolean additionalCanProcessCheck(MultiblockProcess process) { return false; } + @Override public void doProcessOutput(ItemStack output) { - BlockPos pos = getPos().offset(facing,-1); + BlockPos pos = getPos().offset(facing, -1); TileEntity inventoryTile = this.world.getTileEntity(pos); if(inventoryTile!=null) output = Utils.insertStackIntoInventory(inventoryTile, output, facing.getOpposite()); if(!output.isEmpty()) Utils.dropStackAtPos(world, pos, output, facing); } + @Override public void doProcessFluidOutput(FluidStack output) { } + @Override public void onProcessFinish(MultiblockProcess process) { } + @Override public int getMaxProcessPerTick() { return 0; } + @Override public int getProcessQueueMaxLength() { return 0; } + @Override public float getMinProcessDistance(MultiblockProcess process) { @@ -466,31 +483,37 @@ public NonNullList getInventory() { return this.inventory; } + @Override public boolean isStackValid(int slot, ItemStack stack) { return true; } + @Override public int getSlotLimit(int slot) { return 64; } + @Override public int[] getOutputSlots() { return new int[0]; } + @Override public int[] getOutputTanks() { return new int[0]; } + @Override public IFluidTank[] getInternalTanks() { return this.tanks; } + @Override public void doGraphicalUpdates(int slot) { @@ -506,15 +529,17 @@ public boolean hasCapability(Capability capability, EnumFacing facing) return ((pos==10&&facing==this.facing.getOpposite())||(pos==16&&facing==this.facing))&&master()!=null; return super.hasCapability(capability, facing); } + IItemHandler insertionHandler = new IEInventoryHandler(18, this, 0, true, false); IItemHandler extractionHandler = new IEInventoryHandler(3, this, 18, false, true); + @Override public T getCapability(Capability capability, EnumFacing facing) { if((pos==10||pos==16)&&capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { TileEntityAssembler master = master(); - if (master==null) + if(master==null) return null; if(pos==10&&facing==this.facing.getOpposite()) return (T)master.insertionHandler; @@ -531,6 +556,7 @@ public IMultiblockRecipe findRecipeForInsertion(ItemStack inserting) { return null; } + @Override protected IMultiblockRecipe readRecipeFromNBT(NBTTagCompound tag) { @@ -543,11 +569,13 @@ public boolean canOpenGui() { return formed; } + @Override public int getGuiID() { return Lib.GUIID_Assembler; } + @Override public TileEntity getGuiMaster() { @@ -555,20 +583,21 @@ public TileEntity getGuiMaster() } - @Override protected IFluidTank[] getAccessibleFluidTanks(EnumFacing side) { TileEntityAssembler master = master(); - if(master!=null && pos==1&&(side==null||side==facing.getOpposite())) + if(master!=null&&pos==1&&(side==null||side==facing.getOpposite())) return master.tanks; return new FluidTank[0]; } + @Override protected boolean canFillTankFrom(int iTank, EnumFacing side, FluidStack resource) { return true; } + @Override protected boolean canDrainTankFrom(int iTank, EnumFacing side) { @@ -588,10 +617,12 @@ public static class CrafterPatternInventory implements IInventory public NonNullList inv = NonNullList.withSize(10, ItemStack.EMPTY); public IRecipe recipe; final TileEntityAssembler tile; + public CrafterPatternInventory(TileEntityAssembler tile) { this.tile = tile; } + @Override public int getSizeInventory() { @@ -599,9 +630,11 @@ public int getSizeInventory() } @Override - public boolean isEmpty() { - for (ItemStack stack : inv) { - if (!stack.isEmpty()) + public boolean isEmpty() + { + for(ItemStack stack : inv) + { + if(!stack.isEmpty()) return false; } return true; @@ -612,44 +645,48 @@ public ItemStack getStackInSlot(int slot) { return inv.get(slot); } + @Override public ItemStack decrStackSize(int slot, int amount) { ItemStack stack = getStackInSlot(slot); - if(slot<9 && !stack.isEmpty()) + if(slot < 9&&!stack.isEmpty()) if(stack.getCount() <= amount) setInventorySlotContents(slot, ItemStack.EMPTY); else { stack = stack.splitStack(amount); - if(stack.getCount() == 0) + if(stack.getCount()==0) setInventorySlotContents(slot, ItemStack.EMPTY); } return stack; } + @Override public ItemStack removeStackFromSlot(int slot) { ItemStack stack = getStackInSlot(slot); - if (!stack.isEmpty()) + if(!stack.isEmpty()) setInventorySlotContents(slot, ItemStack.EMPTY); return stack; } + @Override public void setInventorySlotContents(int slot, ItemStack stack) { - if(slot<9) + if(slot < 9) { inv.set(slot, stack); - if (!stack.isEmpty() && stack.getCount() > getInventoryStackLimit()) + if(!stack.isEmpty()&&stack.getCount() > getInventoryStackLimit()) stack.setCount(getInventoryStackLimit()); } recalculateOutput(); } + @Override public void clear() { - for(int i = 0; i< this.inv.size(); i++) + for(int i = 0; i < this.inv.size(); i++) this.inv.set(i, ItemStack.EMPTY); } @@ -657,22 +694,23 @@ public void recalculateOutput() { InventoryCrafting invC = Utils.InventoryCraftingFalse.createFilledCraftingInventory(3, 3, inv); this.recipe = Utils.findRecipe(invC, tile.getWorld()); - this.inv.set(9, recipe!=null?recipe.getCraftingResult(invC):ItemStack.EMPTY); + this.inv.set(9, recipe!=null?recipe.getCraftingResult(invC): ItemStack.EMPTY); } + public ArrayList getTotalPossibleOutputs() { ArrayList outputList = new ArrayList(); outputList.add(inv.get(9).copy()); - for(int i=0; i<9; i++) + for(int i = 0; i < 9; i++) { FluidStack fs = FluidUtil.getFluidContained(inv.get(i)); - if(fs != null) + if(fs!=null) { boolean hasFluid = false; for(FluidTank tank : tile.tanks) - if(tank.getFluid()!=null && tank.getFluid().containsFluid(fs)) + if(tank.getFluid()!=null&&tank.getFluid().containsFluid(fs)) { - hasFluid=true; + hasFluid = true; break; } if(hasFluid) @@ -688,43 +726,56 @@ public ArrayList getTotalPossibleOutputs() outputList.add(ss); return outputList; } + @Override public String getName() { return "IECrafterPattern"; } + @Override public boolean hasCustomName() { return false; } + @Override public int getInventoryStackLimit() { return 1; } + @Override public boolean isUsableByPlayer(EntityPlayer player) { return true; } + @Override - public void openInventory(EntityPlayer player){} + public void openInventory(EntityPlayer player) + { + } + @Override - public void closeInventory(EntityPlayer player){} + public void closeInventory(EntityPlayer player) + { + } + @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { return true; } + @Override public void markDirty() { this.tile.markDirty(); } + public void writeToNBT(NBTTagList list) { - for(int i = 0; i< this.inv.size(); i++) + for(int i = 0; i < this.inv.size(); i++) if(!this.inv.get(i).isEmpty()) { NBTTagCompound itemTag = new NBTTagCompound(); @@ -733,13 +784,14 @@ public void writeToNBT(NBTTagList list) list.appendTag(itemTag); } } + public void readFromNBT(NBTTagList list) { - for (int i=0; i=0 && slot= 0&&slot < getSizeInventory()) this.inv.set(slot, new ItemStack(itemTag)); } recalculateOutput(); @@ -750,15 +802,18 @@ public ITextComponent getDisplayName() { return new TextComponentString(this.getName()); } + @Override public int getField(int id) { return 0; } + @Override public void setField(int id, int value) { } + @Override public int getFieldCount() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityAutoWorkbench.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityAutoWorkbench.java index 8e5cba37e2..0f0db35041 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityAutoWorkbench.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityAutoWorkbench.java @@ -33,11 +33,11 @@ import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; -public class TileEntityAutoWorkbench extends TileEntityMultiblockMetal implements IGuiTile, IConveyorAttachable// IAdvancedSelectionBounds,IAdvancedCollisionBounds +public class TileEntityAutoWorkbench extends TileEntityMultiblockMetal implements IGuiTile, IConveyorAttachable// IAdvancedSelectionBounds,IAdvancedCollisionBounds { public TileEntityAutoWorkbench() { - super(MultiblockAutoWorkbench.instance, new int[]{2,3,3}, 32000, true); + super(MultiblockAutoWorkbench.instance, new int[]{2, 3, 3}, 32000, true); } public NonNullList inventory = NonNullList.withSize(17, ItemStack.EMPTY); @@ -53,16 +53,18 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) inventory = Utils.readInventory(nbt.getTagList("inventory", 10), 17); } } + @Override public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { super.writeCustomNBT(nbt, descPacket); - nbt.setInteger("selectedRecipe",selectedRecipe); + nbt.setInteger("selectedRecipe", selectedRecipe); // if(!descPacket) Disabled because blueprint. Have yet to see issue because of this { nbt.setTag("inventory", Utils.writeInventory(inventory)); } } + @Override public void receiveMessageFromClient(NBTTagCompound message) { @@ -71,30 +73,31 @@ public void receiveMessageFromClient(NBTTagCompound message) this.selectedRecipe = message.getInteger("recipe"); } } + @Override public void update() { super.update(); - if(isDummy() || isRSDisabled() || world.isRemote || world.getTotalWorldTime()%16!=((getPos().getX()^getPos().getZ())&15) || inventory.get(0).isEmpty()) + if(isDummy()||isRSDisabled()||world.isRemote||world.getTotalWorldTime()%16!=((getPos().getX()^getPos().getZ())&15)||inventory.get(0).isEmpty()) return; - BlueprintCraftingRecipe[] recipes = BlueprintCraftingRecipe.findRecipes(ItemNBTHelper.getString(inventory.get(0),"blueprint")); - if(recipes.length>0 && (this.selectedRecipe>=0 && this.selectedRecipe 0&&(this.selectedRecipe >= 0&&this.selectedRecipe < recipes.length)) { BlueprintCraftingRecipe recipe = recipes[this.selectedRecipe]; - if(recipe!=null && !recipe.output.isEmpty()) + if(recipe!=null&&!recipe.output.isEmpty()) { NonNullList query = NonNullList.withSize(16, ItemStack.EMPTY); - for (int i = 0;i0) + if(crafted > 0) { if(this.addProcessToQueue(new MultiblockProcessInWorld(recipe, 0.78f, NonNullList.create()), true)) { - this.addProcessToQueue(new MultiblockProcessInWorld(recipe, 0.78f, recipe.consumeInputs(query,1)), false); - for (int i = 0;i=13 && pos<=16) - return new float[]{0,0,0,1,.125f,1}; + if(pos < 10||pos==12) + return new float[]{0, 0, 0, 1, 1, 1}; + if(pos >= 13&&pos <= 16) + return new float[]{0, 0, 0, 1, .125f, 1}; float xMin = 0; float yMin = 0; float zMin = 0; @@ -169,7 +172,7 @@ else if(facing==EnumFacing.EAST) zMax = .875f; } } - return new float[]{xMin,yMin,zMin, xMax,yMax,zMax}; + return new float[]{xMin, yMin, zMin, xMax, yMax, zMax}; } @Override @@ -177,6 +180,7 @@ public int[] getEnergyPos() { return new int[]{9}; } + @Override public int[] getRedstonePos() { @@ -188,40 +192,47 @@ public boolean isInWorldProcessingMachine() { return true; } + @Override public boolean additionalCanProcessCheck(MultiblockProcess process) { return true; } + @Override public void doProcessOutput(ItemStack output) { - EnumFacing outDir = mirrored?facing.rotateYCCW():facing.rotateY(); - BlockPos pos = getPos().offset(outDir,2); + EnumFacing outDir = mirrored?facing.rotateYCCW(): facing.rotateY(); + BlockPos pos = getPos().offset(outDir, 2); TileEntity inventoryTile = this.world.getTileEntity(pos); if(inventoryTile!=null) output = Utils.insertStackIntoInventory(inventoryTile, output, outDir.getOpposite()); if(!output.isEmpty()) Utils.dropStackAtPos(world, pos, output, outDir); } + @Override public void doProcessFluidOutput(FluidStack output) { } + @Override public void onProcessFinish(MultiblockProcess process) { } + @Override public int getMaxProcessPerTick() { return 3; } + @Override public int getProcessQueueMaxLength() { return 3; } + @Override public float getMinProcessDistance(MultiblockProcess process) { @@ -234,31 +245,37 @@ public NonNullList getInventory() { return this.inventory; } + @Override public boolean isStackValid(int slot, ItemStack stack) { return true; } + @Override public int getSlotLimit(int slot) { return 64; } + @Override public int[] getOutputSlots() { return null; } + @Override public int[] getOutputTanks() { return new int[0]; } + @Override public IFluidTank[] getInternalTanks() { return null; } + @Override public void doGraphicalUpdates(int slot) { @@ -274,7 +291,9 @@ public boolean hasCapability(Capability capability, EnumFacing facing) return master()!=null; return super.hasCapability(capability, facing); } + IItemHandler insertionHandler = new IEInventoryHandler(16, this, 1, true, false); + @Override public T getCapability(Capability capability, EnumFacing facing) { @@ -294,6 +313,7 @@ public IMultiblockRecipe findRecipeForInsertion(ItemStack inserting) { return null; } + @Override protected IMultiblockRecipe readRecipeFromNBT(NBTTagCompound tag) { @@ -306,11 +326,13 @@ public boolean canOpenGui() { return formed; } + @Override public int getGuiID() { return Lib.GUIID_AutoWorkbench; } + @Override public TileEntity getGuiMaster() { @@ -323,11 +345,13 @@ protected IFluidTank[] getAccessibleFluidTanks(EnumFacing side) { return new FluidTank[0]; } + @Override protected boolean canFillTankFrom(int iTank, EnumFacing side, FluidStack resource) { return true; } + @Override protected boolean canDrainTankFrom(int iTank, EnumFacing side) { @@ -345,13 +369,13 @@ public EnumFacing[] sigOutputDirections() @Override public void replaceStructureBlock(BlockPos pos, IBlockState state, ItemStack stack, int h, int l, int w) { - if (state.getBlock()== IEContent.blockConveyor) + if(state.getBlock()==IEContent.blockConveyor) { - if ((l==2&&w==0)||l==1) + if((l==2&&w==0)||l==1) state = state.withProperty(IEProperties.FACING_ALL, facing.rotateY()); else state = state.withProperty(IEProperties.FACING_ALL, facing.getOpposite()); } - super.replaceStructureBlock(pos,state, stack, h, l, w); + super.replaceStructureBlock(pos, state, stack, h, l, w); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityBelljar.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityBelljar.java index 5d8f58769d..6e624080bf 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityBelljar.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityBelljar.java @@ -78,7 +78,7 @@ protected void onContentsChanged() TileEntityBelljar.this.sendSyncPacket(2); } }; - public FluxStorage energyStorage = new FluxStorage(16000,Math.max(256,IEConfig.Machines.belljar_consumption)); + public FluxStorage energyStorage = new FluxStorage(16000, Math.max(256, IEConfig.Machines.belljar_consumption)); private IPlantHandler curPlantHandler; public int fertilizerAmount = 0; @@ -91,18 +91,18 @@ protected void onContentsChanged() public void update() { ApiUtils.checkForNeedlessTicking(this); - if(dummy!=0 || world.isBlockIndirectlyGettingPowered(getPos())>0) + if(dummy!=0||world.isBlockIndirectlyGettingPowered(getPos()) > 0) return; ItemStack soil = inventory.get(SLOT_SOIL); ItemStack seed = inventory.get(SLOT_SEED); if(getWorld().isRemote) { - if(energyStorage.getEnergyStored()>IEConfig.Machines.belljar_consumption && fertilizerAmount>0 && renderActive) + if(energyStorage.getEnergyStored() > IEConfig.Machines.belljar_consumption&&fertilizerAmount > 0&&renderActive) { IPlantHandler handler = getCurrentPlantHandler(); - if(handler!=null&&handler.isCorrectSoil(seed, soil) && fertilizerAmount>0) + if(handler!=null&&handler.isCorrectSoil(seed, soil)&&fertilizerAmount > 0) { - if(renderGrowth<1) + if(renderGrowth < 1) { renderGrowth += handler.getGrowthStep(seed, soil, renderGrowth, this, fertilizerMod, true); fertilizerAmount--; @@ -124,7 +124,7 @@ public void update() if(!seed.isEmpty()) { IPlantHandler handler = getCurrentPlantHandler(); - if(handler!=null&&handler.isCorrectSoil(seed, soil) && fertilizerAmount>0 && energyStorage.extractEnergy(IEConfig.Machines.belljar_consumption, true)==IEConfig.Machines.belljar_consumption) + if(handler!=null&&handler.isCorrectSoil(seed, soil)&&fertilizerAmount > 0&&energyStorage.extractEnergy(IEConfig.Machines.belljar_consumption, true)==IEConfig.Machines.belljar_consumption) { boolean consume = false; if(growth >= 1) @@ -132,23 +132,23 @@ public void update() ItemStack[] outputs = handler.getOutput(seed, soil, this); int canFit = 0; boolean[] emptySlotsUsed = new boolean[4]; - for (ItemStack output : outputs) - if (!output.isEmpty()) - for (int j = 3; j < 7; j++) + for(ItemStack output : outputs) + if(!output.isEmpty()) + for(int j = 3; j < 7; j++) { ItemStack existing = inventory.get(j); - if ((existing.isEmpty() && !emptySlotsUsed[j-3]) || (ItemHandlerHelper.canItemStacksStack(existing, output) && existing.getCount()+output.getCount() <= existing.getMaxStackSize())) + if((existing.isEmpty()&&!emptySlotsUsed[j-3])||(ItemHandlerHelper.canItemStacksStack(existing, output)&&existing.getCount()+output.getCount() <= existing.getMaxStackSize())) { canFit++; - if (existing.isEmpty()) + if(existing.isEmpty()) emptySlotsUsed[j-3] = true; break; } } - if(canFit>=outputs.length) + if(canFit >= outputs.length) { for(ItemStack output : outputs) - for(int j=3;j<7;j++) + for(int j = 3; j < 7; j++) { ItemStack existing = inventory.get(j); if(existing.isEmpty()) @@ -156,7 +156,7 @@ public void update() inventory.set(j, output.copy()); break; } - else if(ItemHandlerHelper.canItemStacksStack(existing, output)&& existing.getCount()+output.getCount() <= existing.getMaxStackSize()) + else if(ItemHandlerHelper.canItemStacksStack(existing, output)&&existing.getCount()+output.getCount() <= existing.getMaxStackSize()) { existing.grow(output.getCount()); break; @@ -168,7 +168,7 @@ else if(ItemHandlerHelper.canItemStacksStack(existing, output)&& existing.getCou } else if(growth < 1) { - growth += Config.IEConfig.Machines.belljar_growth_mod * handler.getGrowthStep(seed, soil, growth, this, fertilizerMod, false); + growth += Config.IEConfig.Machines.belljar_growth_mod*handler.getGrowthStep(seed, soil, growth, this, fertilizerMod, false); consume = true; if(world.getTotalWorldTime()%32==((getPos().getX()^getPos().getZ())&31)) sendSyncPacket(0); @@ -192,7 +192,7 @@ else if(renderActive) else growth = 0; - if(fertilizerAmount<=0 && tank.getFluidAmount()>=IEConfig.Machines.belljar_fluid) + if(fertilizerAmount <= 0&&tank.getFluidAmount() >= IEConfig.Machines.belljar_fluid) { FluidFertilizerHandler fluidFert = BelljarHandler.getFluidFertilizerHandler(tank.getFluid()); if(fluidFert!=null) @@ -206,7 +206,7 @@ else if(renderActive) if(itemFert!=null) fertilizerMod *= itemFert.getGrowthMultiplier(fertilizer, seed, soil, this); fertilizer.shrink(1); - if(fertilizer.getCount()<=0) + if(fertilizer.getCount() <= 0) inventory.set(2, ItemStack.EMPTY); } fertilizerAmount = IEConfig.Machines.belljar_fertilizer; @@ -221,19 +221,19 @@ else if(renderActive) { BlockPos outputPos = getPos().up().offset(facing.getOpposite()); TileEntity outputTile = Utils.getExistingTileEntity(world, outputPos); - if (outputTile != null) - for (int j = 3; j < 7; j++) + if(outputTile!=null) + for(int j = 3; j < 7; j++) { ItemStack outStack = inventory.get(j); - if (!outStack.isEmpty()) + if(!outStack.isEmpty()) { int outCount = Math.min(outStack.getCount(), 16); ItemStack stack = Utils.copyStackWithAmount(outStack, outCount); stack = Utils.insertStackIntoInventory(outputTile, stack, facing); - if (!stack.isEmpty()) + if(!stack.isEmpty()) outCount -= stack.getCount(); outStack.shrink(outCount); - if (outStack.getCount() <= 0) + if(outStack.getCount() <= 0) this.inventory.set(j, ItemStack.EMPTY); } } @@ -244,7 +244,7 @@ else if(renderActive) public IPlantHandler getCurrentPlantHandler() { ItemStack seed = inventory.get(SLOT_SEED); - if(curPlantHandler==null || !curPlantHandler.isValid(seed)) + if(curPlantHandler==null||!curPlantHandler.isValid(seed)) curPlantHandler = BelljarHandler.getHandler(seed); return curPlantHandler; } @@ -265,8 +265,9 @@ else if(type==1) } else if(type==2) nbt.setTag("tank", tank.writeToNBT(new NBTTagCompound())); - ImmersiveEngineering.packetHandler.sendToAllAround(new MessageTileSync(this, nbt), new TargetPoint(world.provider.getDimension(),getPos().getX(), getPos().getY(), getPos().getZ(), 128)); + ImmersiveEngineering.packetHandler.sendToAllAround(new MessageTileSync(this, nbt), new TargetPoint(world.provider.getDimension(), getPos().getX(), getPos().getY(), getPos().getZ(), 128)); } + @Override public void receiveMessageFromServer(NBTTagCompound message) { @@ -289,7 +290,7 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) { facing = EnumFacing.getFront(nbt.getInteger("facing")); dummy = nbt.getInteger("dummy"); - inventory = Utils.readInventory(nbt.getTagList("inventory",10),7); + inventory = Utils.readInventory(nbt.getTagList("inventory", 10), 7); energyStorage.readFromNBT(nbt); tank.readFromNBT(nbt.getCompoundTag("tank")); fertilizerAmount = nbt.getInteger("fertilizerAmount"); @@ -317,26 +318,31 @@ public EnumFacing getFacing() { return facing; } + @Override public void setFacing(EnumFacing facing) { this.facing = facing; } + @Override public int getFacingLimitation() { return 2; } + @Override public boolean mirrorFacingOnPlacement(EntityLivingBase placer) { return false; } + @Override public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) { return true; } + @Override public boolean canRotate(EnumFacing axis) { @@ -354,20 +360,22 @@ public boolean isDummy() { return dummy!=0; } + @Override public void placeDummies(BlockPos pos, IBlockState state, EnumFacing side, float hitX, float hitY, float hitZ) { - for(int i=1; i<=2; i++) + for(int i = 1; i <= 2; i++) { world.setBlockState(pos.up(i), state); ((TileEntityBelljar)world.getTileEntity(pos.up(i))).dummy = i; ((TileEntityBelljar)world.getTileEntity(pos.up(i))).facing = facing; } } + @Override public void breakDummies(BlockPos pos, IBlockState state) { - for(int i=0; i<=2; i++) + for(int i = 0; i <= 2; i++) { BlockPos p = getPos().down(dummy).up(i); if(world.getTileEntity(p) instanceof TileEntityBelljar) @@ -380,19 +388,22 @@ public NonNullList getInventory() { return inventory; } + @Override public boolean isStackValid(int slot, ItemStack stack) { - if (slot==SLOT_FERTILIZER) - return BelljarHandler.getItemFertilizerHandler(stack) != null; + if(slot==SLOT_FERTILIZER) + return BelljarHandler.getItemFertilizerHandler(stack)!=null; else return true; } + @Override public int getSlotLimit(int slot) { - return slot<2?1:64; + return slot < 2?1: 64; } + @Override public void doGraphicalUpdates(int slot) { @@ -407,32 +418,34 @@ public void doGraphicalUpdates(int slot) @Override public boolean hasCapability(Capability capability, EnumFacing facing) { - if (getGuiMaster()!=null) + if(getGuiMaster()!=null) { - if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) - return dummy == 0 ? (facing == null || facing.getAxis() != this.facing.rotateY().getAxis()) : dummy == 1 && (facing == null || facing == this.facing.getOpposite()); - else if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) - return dummy == 0 && (facing == null || facing.getAxis() != this.facing.rotateY().getAxis()); + if(capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) + return dummy==0?(facing==null||facing.getAxis()!=this.facing.rotateY().getAxis()): dummy==1&&(facing==null||facing==this.facing.getOpposite()); + else if(capability==CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) + return dummy==0&&(facing==null||facing.getAxis()!=this.facing.rotateY().getAxis()); } return super.hasCapability(capability, facing); } - IItemHandler inputHandler = new IEInventoryHandler(1,this,2, true,false); - IItemHandler outputHandler = new IEInventoryHandler(4,this,3, false,true); + + IItemHandler inputHandler = new IEInventoryHandler(1, this, 2, true, false); + IItemHandler outputHandler = new IEInventoryHandler(4, this, 3, false, true); + @Override public T getCapability(Capability capability, EnumFacing facing) { if(capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { - if(dummy==0 && (facing==null||facing.getAxis()!=this.facing.rotateY().getAxis())) + if(dummy==0&&(facing==null||facing.getAxis()!=this.facing.rotateY().getAxis())) return (T)inputHandler; - if(dummy==1 && (facing==null||facing==this.facing.getOpposite())) + if(dummy==1&&(facing==null||facing==this.facing.getOpposite())) { TileEntityBelljar te = getGuiMaster(); if(te!=null) - return (T) te.outputHandler; + return (T)te.outputHandler; } } - else if(capability==CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && dummy==0 && (facing==null||facing.getAxis()!=this.facing.rotateY().getAxis())) + else if(capability==CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY&&dummy==0&&(facing==null||facing.getAxis()!=this.facing.rotateY().getAxis())) return (T)tank; return super.getCapability(capability, facing); } @@ -442,11 +455,13 @@ public boolean canOpenGui() { return true; } + @Override public int getGuiID() { return Lib.GUIID_Belljar; } + @Override public TileEntityBelljar getGuiMaster() { @@ -454,7 +469,7 @@ public TileEntityBelljar getGuiMaster() return this; TileEntity te = world.getTileEntity(getPos().down(dummy)); if(te instanceof TileEntityBelljar) - return (TileEntityBelljar) te; + return (TileEntityBelljar)te; return null; } @@ -463,7 +478,7 @@ public TileEntityBelljar getGuiMaster() @SideOnly(Side.CLIENT) public TextureAtlasSprite getTextureReplacement(IBlockState object, String material) { - if(!inventory.get(SLOT_SOIL).isEmpty() && "farmland".equals(material)) + if(!inventory.get(SLOT_SOIL).isEmpty()&&"farmland".equals(material)) { ResourceLocation rl = getSoilTexture(); if(rl!=null) @@ -471,18 +486,21 @@ public TextureAtlasSprite getTextureReplacement(IBlockState object, String mater } return null; } + @Override @SideOnly(Side.CLIENT) public boolean shouldRenderGroup(IBlockState object, String group) { return !"glass".equals(group); } + @Override @SideOnly(Side.CLIENT) public Optional applyTransformations(IBlockState object, String group, Optional transform) { return transform; } + @Override @SideOnly(Side.CLIENT) public String getCacheKey(IBlockState object) @@ -495,13 +513,14 @@ public String getCacheKey(IBlockState object) } return null; } + @SideOnly(Side.CLIENT) private ResourceLocation getSoilTexture() { ItemStack soil = inventory.get(SLOT_SOIL); - ResourceLocation rl = curPlantHandler!=null?curPlantHandler.getSoilTexture(inventory.get(SLOT_SEED), soil, this):null; + ResourceLocation rl = curPlantHandler!=null?curPlantHandler.getSoilTexture(inventory.get(SLOT_SEED), soil, this): null; if(rl==null) - rl=BelljarHandler.getSoilTexture(soil); + rl = BelljarHandler.getSoilTexture(soil); if(rl==null) { try @@ -509,12 +528,12 @@ private ResourceLocation getSoilTexture() IBlockState state = Utils.getStateFromItemStack(soil); if(state!=null) rl = ClientUtils.getSideTexture(state, EnumFacing.UP); - }catch(Exception e) + } catch(Exception e) { rl = ClientUtils.getSideTexture(soil, EnumFacing.UP); } } - if(rl==null && !soil.isEmpty() && Utils.isFluidRelatedItemStack(soil)) + if(rl==null&&!soil.isEmpty()&&Utils.isFluidRelatedItemStack(soil)) { FluidStack fs = FluidUtil.getFluidContained(soil); if(fs!=null) @@ -535,13 +554,16 @@ public FluxStorage getFluxStorage() } return this.energyStorage; } + @Nonnull @Override public SideConfig getEnergySideConfig(@Nullable EnumFacing facing) { - return facing==null||(dummy==0&&facing.getAxis()==this.facing.rotateY().getAxis())||(dummy==2&&facing==EnumFacing.UP)?SideConfig.INPUT:SideConfig.NONE; + return facing==null||(dummy==0&&facing.getAxis()==this.facing.rotateY().getAxis())||(dummy==2&&facing==EnumFacing.UP)?SideConfig.INPUT: SideConfig.NONE; } + IEForgeEnergyWrapper energyWrapper = new IEForgeEnergyWrapper(this, null); + @Override public IEForgeEnergyWrapper getCapabilityWrapper(EnumFacing facing) { @@ -549,11 +571,13 @@ public IEForgeEnergyWrapper getCapabilityWrapper(EnumFacing facing) return energyWrapper; return null; } + AxisAlignedBB renderBB; + @Override public AxisAlignedBB getRenderBoundingBox() { - if (renderBB==null) + if(renderBB==null) renderBB = new AxisAlignedBB(0, 0, 0, 1, 2, 1).offset(pos); return renderBB; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityBlastFurnacePreheater.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityBlastFurnacePreheater.java index 4ade48f752..7d5396c68f 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityBlastFurnacePreheater.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityBlastFurnacePreheater.java @@ -39,7 +39,7 @@ public int doSpeedup() int consumed = IEConfig.Machines.preheater_consumption; if(this.energyStorage.extractEnergy(consumed, true)==consumed) { - if (!active) + if(!active) { active = true; this.markContainingBlockForUpdate(null); @@ -58,24 +58,26 @@ else if(active) @Override public boolean isDummy() { - return dummy>0; + return dummy > 0; } + @Override public void placeDummies(BlockPos pos, IBlockState state, EnumFacing side, float hitX, float hitY, float hitZ) { - for(int i=1; i<=2; i++) + for(int i = 1; i <= 2; i++) { - world.setBlockState(pos.add(0,i,0), state); - ((TileEntityBlastFurnacePreheater)world.getTileEntity(pos.add(0,i,0))).dummy = i; - ((TileEntityBlastFurnacePreheater)world.getTileEntity(pos.add(0,i,0))).facing = this.facing; + world.setBlockState(pos.add(0, i, 0), state); + ((TileEntityBlastFurnacePreheater)world.getTileEntity(pos.add(0, i, 0))).dummy = i; + ((TileEntityBlastFurnacePreheater)world.getTileEntity(pos.add(0, i, 0))).facing = this.facing; } } + @Override public void breakDummies(BlockPos pos, IBlockState state) { - for(int i=0; i<=2; i++) - if(world.getTileEntity(getPos().add(0,-dummy,0).add(0,i,0)) instanceof TileEntityBlastFurnacePreheater) - world.setBlockToAir(getPos().add(0,-dummy,0).add(0,i,0)); + for(int i = 0; i <= 2; i++) + if(world.getTileEntity(getPos().add(0, -dummy, 0).add(0, i, 0)) instanceof TileEntityBlastFurnacePreheater) + world.setBlockToAir(getPos().add(0, -dummy, 0).add(0, i, 0)); } @Override @@ -102,21 +104,24 @@ public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) @Override public FluxStorage getFluxStorage() { - if(dummy>0) + if(dummy > 0) { - TileEntity te = world.getTileEntity(getPos().add(0,-dummy,0)); + TileEntity te = world.getTileEntity(getPos().add(0, -dummy, 0)); if(te instanceof TileEntityBlastFurnacePreheater) return ((TileEntityBlastFurnacePreheater)te).getFluxStorage(); } return energyStorage; } + @Nonnull @Override public SideConfig getEnergySideConfig(EnumFacing facing) { - return dummy==2&&facing==EnumFacing.UP?SideConfig.INPUT:SideConfig.NONE; + return dummy==2&&facing==EnumFacing.UP?SideConfig.INPUT: SideConfig.NONE; } + IEForgeEnergyWrapper wrapper = new IEForgeEnergyWrapper(this, EnumFacing.UP); + @Override public IEForgeEnergyWrapper getCapabilityWrapper(EnumFacing facing) { @@ -130,37 +135,43 @@ public EnumFacing getFacing() { return facing; } + @Override public void setFacing(EnumFacing facing) { this.facing = facing; } + @Override public int getFacingLimitation() { return 2; } + @Override public boolean mirrorFacingOnPlacement(EntityLivingBase placer) { return false; } + @Override public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) { return true; } + @Override public boolean canRotate(EnumFacing axis) { return true; } + @Override - public void afterRotation(EnumFacing oldDir, EnumFacing newDir) + public void afterRotation(EnumFacing oldDir, EnumFacing newDir) { - for(int i=0; i<=2; i++) + for(int i = 0; i <= 2; i++) { - TileEntity te = world.getTileEntity(getPos().add(0,-dummy+i,0)); + TileEntity te = world.getTileEntity(getPos().add(0, -dummy+i, 0)); if(te instanceof TileEntityBlastFurnacePreheater) { ((TileEntityBlastFurnacePreheater)te).setFacing(newDir); diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityBottlingMachine.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityBottlingMachine.java index c3f620b9e2..5618d33f40 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityBottlingMachine.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityBottlingMachine.java @@ -38,13 +38,14 @@ import java.util.Iterator; import java.util.List; -public class TileEntityBottlingMachine extends TileEntityMultiblockMetal implements IConveyorAttachable// IAdvancedSelectionBounds,IAdvancedCollisionBounds +public class TileEntityBottlingMachine extends TileEntityMultiblockMetal implements IConveyorAttachable// IAdvancedSelectionBounds,IAdvancedCollisionBounds { public FluidTank[] tanks = new FluidTank[]{new FluidTank(8000)}; public List bottlingProcessQueue = new ArrayList<>(); + public TileEntityBottlingMachine() { - super(MultiblockBottlingMachine.instance, new int[]{3,2,3}, 16000, true); + super(MultiblockBottlingMachine.instance, new int[]{3, 2, 3}, 16000, true); } @Override @@ -54,7 +55,7 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) NBTTagList processNBT = nbt.getTagList("bottlingQueue", 10); bottlingProcessQueue.clear(); - for(int i=0; i processIterator = bottlingProcessQueue.iterator(); tickedProcesses = 0; - while(processIterator.hasNext() && i++=6 && pos<=8) - return new float[]{0,0,0,1,.125f,1}; + return new float[]{0, 0, 0, 1, .5f, 1}; + if(pos < 6||pos==11) + return new float[]{0, 0, 0, 1, 1, 1}; + if(pos >= 6&&pos <= 8) + return new float[]{0, 0, 0, 1, .125f, 1}; if(pos==9) - return new float[]{.0625f,0,.0625f,.9375f,1,.9375f}; + return new float[]{.0625f, 0, .0625f, .9375f, 1, .9375f}; if(pos==10) { - EnumFacing f = mirrored?facing.rotateYCCW():facing.rotateY(); - float xMin = f==EnumFacing.EAST?-.0625f:f==EnumFacing.WEST?.25f: facing==EnumFacing.WEST?.125f:facing==EnumFacing.EAST?.25f: 0; - float zMin = facing==EnumFacing.NORTH?.125f:facing==EnumFacing.SOUTH?.25f: f==EnumFacing.SOUTH?-.0625f:f==EnumFacing.NORTH?.25f: 0; - float xMax = f==EnumFacing.EAST?.75f:f==EnumFacing.WEST?1.0625f: facing==EnumFacing.WEST?.75f:facing==EnumFacing.EAST?.875f: 1; - float zMax = facing==EnumFacing.NORTH?.75f:facing==EnumFacing.SOUTH?.875f: f==EnumFacing.SOUTH?.75f:f==EnumFacing.NORTH?1.0625f: 1; - return new float[]{xMin,.0625f,zMin, xMax,.6875f,zMax}; + EnumFacing f = mirrored?facing.rotateYCCW(): facing.rotateY(); + float xMin = f==EnumFacing.EAST?-.0625f: f==EnumFacing.WEST?.25f: facing==EnumFacing.WEST?.125f: facing==EnumFacing.EAST?.25f: 0; + float zMin = facing==EnumFacing.NORTH?.125f: facing==EnumFacing.SOUTH?.25f: f==EnumFacing.SOUTH?-.0625f: f==EnumFacing.NORTH?.25f: 0; + float xMax = f==EnumFacing.EAST?.75f: f==EnumFacing.WEST?1.0625f: facing==EnumFacing.WEST?.75f: facing==EnumFacing.EAST?.875f: 1; + float zMax = facing==EnumFacing.NORTH?.75f: facing==EnumFacing.SOUTH?.875f: f==EnumFacing.SOUTH?.75f: f==EnumFacing.NORTH?1.0625f: 1; + return new float[]{xMin, .0625f, zMin, xMax, .6875f, zMax}; } if(pos==13) { - float xMin = facing==EnumFacing.WEST?0:.21875f; - float zMin = facing==EnumFacing.NORTH?0:.21875f; - float xMax = facing==EnumFacing.EAST?1:.78125f; - float zMax = facing==EnumFacing.SOUTH?1:.78125f; - return new float[]{xMin,-.4375f,zMin, xMax,.5625f,zMax}; + float xMin = facing==EnumFacing.WEST?0: .21875f; + float zMin = facing==EnumFacing.NORTH?0: .21875f; + float xMax = facing==EnumFacing.EAST?1: .78125f; + float zMax = facing==EnumFacing.SOUTH?1: .78125f; + return new float[]{xMin, -.4375f, zMin, xMax, .5625f, zMax}; } if(pos==16) { - float xMin = facing==EnumFacing.WEST?.8125f:facing==EnumFacing.EAST?0:.125f; - float zMin = facing==EnumFacing.NORTH?.8125f:facing==EnumFacing.SOUTH?0:.125f; - float xMax = facing==EnumFacing.WEST?1:facing==EnumFacing.EAST?.1875f:.875f; - float zMax = facing==EnumFacing.NORTH?1:facing==EnumFacing.SOUTH?.1875f:.875f; - return new float[]{xMin,-1,zMin, xMax,.25f,zMax}; + float xMin = facing==EnumFacing.WEST?.8125f: facing==EnumFacing.EAST?0: .125f; + float zMin = facing==EnumFacing.NORTH?.8125f: facing==EnumFacing.SOUTH?0: .125f; + float xMax = facing==EnumFacing.WEST?1: facing==EnumFacing.EAST?.1875f: .875f; + float zMax = facing==EnumFacing.NORTH?1: facing==EnumFacing.SOUTH?.1875f: .875f; + return new float[]{xMin, -1, zMin, xMax, .25f, zMax}; } - return new float[]{0,0,0, 1,1,1}; + return new float[]{0, 0, 0, 1, 1, 1}; } @Override @@ -154,6 +158,7 @@ public int[] getEnergyPos() { return new int[]{11}; } + @Override public int[] getRedstonePos() { @@ -175,14 +180,14 @@ else if(h==1&&l==0) { TileEntity tile = world.getTileEntity(pos); if(tile instanceof TileEntityConveyorBelt) - ((TileEntityConveyorBelt)tile).setFacing(this.mirrored?this.facing.rotateYCCW():this.facing.rotateY()); + ((TileEntityConveyorBelt)tile).setFacing(this.mirrored?this.facing.rotateYCCW(): this.facing.rotateY()); } } @Override public void onEntityCollision(World world, Entity entity) { - if(pos==6 && !world.isRemote && entity!=null && !entity.isDead && entity instanceof EntityItem) + if(pos==6&&!world.isRemote&&entity!=null&&!entity.isDead&&entity instanceof EntityItem) { TileEntityBottlingMachine master = master(); if(master==null) @@ -208,7 +213,7 @@ public void onEntityCollision(World world, Entity entity) master.bottlingProcessQueue.add(p); master.markDirty(); master.markContainingBlockForUpdate(null); - stack.shrink(1); + stack.shrink(1); if(stack.getCount() <= 0) entity.setDead(); } @@ -220,40 +225,47 @@ public boolean isInWorldProcessingMachine() { return true; } + @Override public boolean additionalCanProcessCheck(MultiblockProcess process) { return true; } + @Override public void doProcessOutput(ItemStack output) { - EnumFacing outDir = mirrored?facing.rotateYCCW():facing.rotateY(); - BlockPos pos = getPos().offset(outDir,2); + EnumFacing outDir = mirrored?facing.rotateYCCW(): facing.rotateY(); + BlockPos pos = getPos().offset(outDir, 2); TileEntity inventoryTile = this.world.getTileEntity(pos); if(inventoryTile!=null) output = Utils.insertStackIntoInventory(inventoryTile, output, outDir.getOpposite()); if(!output.isEmpty()) Utils.dropStackAtPos(world, pos, output, outDir); } + @Override public void doProcessFluidOutput(FluidStack output) { } + @Override public void onProcessFinish(MultiblockProcess process) { } + @Override public int getMaxProcessPerTick() { return 2; } + @Override public int getProcessQueueMaxLength() { return 2; } + @Override public float getMinProcessDistance(MultiblockProcess process) { @@ -265,31 +277,37 @@ public NonNullList getInventory() { return null; } + @Override public boolean isStackValid(int slot, ItemStack stack) { return true; } + @Override public int getSlotLimit(int slot) { return 64; } + @Override public int[] getOutputSlots() { return null; } + @Override public int[] getOutputTanks() { return new int[0]; } + @Override public IFluidTank[] getInternalTanks() { return tanks; } + @Override public void doGraphicalUpdates(int slot) { @@ -303,6 +321,7 @@ public IMultiblockRecipe findRecipeForInsertion(ItemStack inserting) { return null; } + @Override protected IMultiblockRecipe readRecipeFromNBT(NBTTagCompound tag) { @@ -315,13 +334,15 @@ public boolean hasCapability(Capability capability, EnumFacing facing) if(capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { TileEntityBottlingMachine master = master(); - if(master == null) + if(master==null) return false; - return pos==6 && facing==(mirrored?this.facing.rotateY():this.facing.rotateYCCW()); + return pos==6&&facing==(mirrored?this.facing.rotateY(): this.facing.rotateYCCW()); } return super.hasCapability(capability, facing); } + IItemHandler insertionHandler = new BottlingMachineInventoryHandler(this); + @Override public T getCapability(Capability capability, EnumFacing facing) { @@ -330,7 +351,7 @@ public T getCapability(Capability capability, EnumFacing facing) TileEntityBottlingMachine master = master(); if(master==null) return null; - if(pos==6 && facing==(mirrored?this.facing.rotateY():this.facing.rotateYCCW())) + if(pos==6&&facing==(mirrored?this.facing.rotateY(): this.facing.rotateYCCW())) return (T)master.insertionHandler; return null; } @@ -343,21 +364,23 @@ protected IFluidTank[] getAccessibleFluidTanks(EnumFacing side) TileEntityBottlingMachine master = this.master(); if(master!=null) { - if(pos==3 && (side==null||side.getAxis()!=Axis.Y)) + if(pos==3&&(side==null||side.getAxis()!=Axis.Y)) return master.tanks; } return new FluidTank[0]; } + @Override protected boolean canFillTankFrom(int iTank, EnumFacing side, FluidStack resource) { - if(pos==3 && (side== null||side.getAxis()!=Axis.Y)) + if(pos==3&&(side==null||side.getAxis()!=Axis.Y)) { TileEntityBottlingMachine master = this.master(); return !(master==null||master.tanks[iTank].getFluidAmount() >= master.tanks[iTank].getCapacity()); } return false; } + @Override protected boolean canDrainTankFrom(int iTank, EnumFacing side) { @@ -368,7 +391,7 @@ protected boolean canDrainTankFrom(int iTank, EnumFacing side) public EnumFacing[] sigOutputDirections() { if(pos==8) - return new EnumFacing[]{mirrored?facing.rotateYCCW():facing.rotateY()}; + return new EnumFacing[]{mirrored?facing.rotateYCCW(): facing.rotateY()}; return new EnumFacing[0]; } @@ -388,7 +411,7 @@ public BottlingProcess(ItemStack input) public boolean processStep(TileEntityBottlingMachine tile) { int energyExtracted = (int)(8*Config.IEConfig.Machines.bottlingMachine_energyModifier); - if(tile.energyStorage.extractEnergy(energyExtracted, true)>=energyExtracted) + if(tile.energyStorage.extractEnergy(energyExtracted, true) >= energyExtracted) { tile.energyStorage.extractEnergy(energyExtracted, false); if(++processTick==(int)(maxProcessTick*.4375)) @@ -399,7 +422,7 @@ public boolean processStep(TileEntityBottlingMachine tile) BottlingMachineRecipe recipe = BottlingMachineRecipe.findRecipe(items.get(0), fs); if(recipe!=null) { - if (tile.tanks[0].drainInternal(recipe.fluidInput, false).amount==recipe.fluidInput.amount) + if(tile.tanks[0].drainInternal(recipe.fluidInput, false).amount==recipe.fluidInput.amount) { items.set(1, recipe.getActualItemOutputs(tile).get(0)); tile.tanks[0].drainInternal(recipe.fluidInput, true); @@ -415,7 +438,7 @@ public boolean processStep(TileEntityBottlingMachine tile) items.set(1, items.get(0)); } } - if(processTick>=maxProcessTick) + if(processTick >= maxProcessTick) processFinished = true; return true; } @@ -432,6 +455,7 @@ public NBTTagCompound writeToNBT() nbt.setInteger("processTick", processTick); return nbt; } + public static BottlingProcess readFromNBT(NBTTagCompound nbt) { ItemStack input = new ItemStack(nbt.getCompoundTag("input")); @@ -446,6 +470,7 @@ public static BottlingProcess readFromNBT(NBTTagCompound nbt) public static class BottlingMachineInventoryHandler implements IItemHandlerModifiable { TileEntityBottlingMachine multiblock; + public BottlingMachineInventoryHandler(TileEntityBottlingMachine multiblock) { this.multiblock = multiblock; @@ -456,6 +481,7 @@ public int getSlots() { return 1; } + @Override public ItemStack getStackInSlot(int slot) { @@ -470,13 +496,13 @@ public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) stack = stack.copy(); float dist = 1; BottlingProcess p = null; - if(multiblock.bottlingProcessQueue.size()>0) + if(multiblock.bottlingProcessQueue.size() > 0) { p = multiblock.bottlingProcessQueue.get(multiblock.bottlingProcessQueue.size()-1); - if(p != null) + if(p!=null) dist = p.processTick/(float)p.maxProcessTick; } - if(p!=null && dist { - public int rotation=0; - public EnumFacing facing=EnumFacing.NORTH; + public int rotation = 0; + public EnumFacing facing = EnumFacing.NORTH; public int wires = 0; - public boolean active=false; - public boolean inverted=false; + public boolean active = false; + public boolean inverted = false; public BlockPos endOfLeftConnection = null; @Override @@ -57,11 +56,13 @@ protected boolean canTakeLV() { return true; } + @Override protected boolean canTakeMV() { return true; } + @Override protected boolean canTakeHV() { @@ -81,10 +82,11 @@ public boolean canConnectCable(WireType cableType, TargetingInfo target, Vec3i o return false; if(HV_CATEGORY.equals(cableType.getCategory())&&!canTakeHV()) return false; - if(wires>=2) + if(wires >= 2) return false; - return limitType==null || WireApi.canMix(cableType, limitType); + return limitType==null||WireApi.canMix(cableType, limitType); } + @Override public void connectCable(WireType cableType, TargetingInfo target, IImmersiveConnectable other) { @@ -93,21 +95,23 @@ public void connectCable(WireType cableType, TargetingInfo target, IImmersiveCon wires++; onConnectionChange(); } + @Override public WireType getCableLimiter(TargetingInfo target) { return limitType; } + @Override public void removeCable(Connection connection) { - WireType type = connection!=null?connection.cableType:null; + WireType type = connection!=null?connection.cableType: null; if(type==null) wires = 0; else wires--; - if(wires<=0) - limitType=null; + if(wires <= 0) + limitType = null; onConnectionChange(); } @@ -121,6 +125,7 @@ public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) nbt.setBoolean("active", active); nbt.setBoolean("inverted", inverted); } + @Override public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) { @@ -138,40 +143,40 @@ public Vec3d getConnectionOffset(Connection con) { Matrix4 mat = new Matrix4(facing); mat.translate(.5, .5, 0).rotate(Math.PI/2*rotation, 0, 0, 1).translate(-.5, -.5, 0); - if (endOfLeftConnection==null) + if(endOfLeftConnection==null) calculateLeftConn(mat); boolean isLeft = con.end.equals(endOfLeftConnection)||con.start.equals(endOfLeftConnection); - Vec3d ret = mat.apply(new Vec3d(isLeft?.25:.75, .5, .125)); + Vec3d ret = mat.apply(new Vec3d(isLeft?.25: .75, .5, .125)); return ret; } protected void calculateLeftConn(Matrix4 transform) { Vec3d leftVec = transform.apply(new Vec3d(-1, .5, .5)).subtract(0, .5, .5); - EnumFacing dir = EnumFacing.getFacingFromVector((float) leftVec.x, (float) leftVec.y, (float) leftVec.z); + EnumFacing dir = EnumFacing.getFacingFromVector((float)leftVec.x, (float)leftVec.y, (float)leftVec.z); int maxDiff = Integer.MIN_VALUE; Set conns = ImmersiveNetHandler.INSTANCE.getConnections(world, pos); - if (conns!=null) - for (Connection c:conns) + if(conns!=null) + for(Connection c : conns) { - Vec3i diff = pos.equals(c.start)?c.end.subtract(pos):c.start.subtract(pos); + Vec3i diff = pos.equals(c.start)?c.end.subtract(pos): c.start.subtract(pos); int val = 0; - switch (dir.getAxis()) + switch(dir.getAxis()) { - case X: - val = diff.getX(); - break; - case Y: - val = diff.getY(); - break; - case Z: - val = diff.getZ(); + case X: + val = diff.getX(); + break; + case Y: + val = diff.getY(); + break; + case Z: + val = diff.getZ(); } val *= dir.getAxisDirection().getOffset(); - if (val>maxDiff) + if(val > maxDiff) { maxDiff = val; - endOfLeftConnection = pos==c.end?c.start:c.end; + endOfLeftConnection = pos==c.end?c.start: c.end; } } } @@ -179,11 +184,11 @@ protected void calculateLeftConn(Matrix4 transform) @Override public boolean hammerUseSide(EnumFacing side, EntityPlayer player, float hitX, float hitY, float hitZ) { - if (player.isSneaking()) + if(player.isSneaking()) { inverted = !inverted; - ChatUtils.sendServerNoSpamMessages(player, new TextComponentTranslation(Lib.CHAT_INFO+"rsSignal."+(inverted?"invertedOn":"invertedOff"))); - if (wires>1) + ChatUtils.sendServerNoSpamMessages(player, new TextComponentTranslation(Lib.CHAT_INFO+"rsSignal."+(inverted?"invertedOn": "invertedOff"))); + if(wires > 1) ImmersiveNetHandler.INSTANCE.resetCachedIndirectConnections(world, pos); notifyNeighbours(); } @@ -194,20 +199,22 @@ public boolean hammerUseSide(EnumFacing side, EntityPlayer player, float hitX, f } return true; } + @Override public boolean interact(EnumFacing side, EntityPlayer player, EnumHand hand, ItemStack heldItem, float hitX, float hitY, float hitZ) { - if (!Utils.isHammer(heldItem)) + if(!Utils.isHammer(heldItem)) { active = !active; - world.playSound(null, getPos(), IESounds.direSwitch, SoundCategory.BLOCKS, 2.5F,1); - if (wires>1) + world.playSound(null, getPos(), IESounds.direSwitch, SoundCategory.BLOCKS, 2.5F, 1); + if(wires > 1) ImmersiveNetHandler.INSTANCE.resetCachedIndirectConnections(world, pos); - world.addBlockEvent(getPos(), getBlockType(), active?1:0, 0); + world.addBlockEvent(getPos(), getBlockType(), active?1: 0, 0); notifyNeighbours(); } return true; } + public void notifyNeighbours() { markDirty(); @@ -225,41 +232,49 @@ public boolean receiveClientEvent(int id, int arg) this.markContainingBlockForUpdate(null); return true; } + @Override public PropertyBoolInverted getBoolProperty(Class inf) { return IEProperties.BOOLEANS[0]; } + @Override public boolean getIsActive() { return active; } + @Override public EnumFacing getFacing() { return facing; } + @Override public void setFacing(EnumFacing facing) { this.facing = facing; } + @Override public int getFacingLimitation() { return 0; } + @Override public boolean mirrorFacingOnPlacement(EntityLivingBase placer) { return true; } + @Override public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) { return false; } + @Override public boolean canRotate(EnumFacing axis) { @@ -269,36 +284,39 @@ public boolean canRotate(EnumFacing axis) @Override public float[] getBlockBounds() { - Vec3d start = new Vec3d(.25,.1875,0); - Vec3d end = new Vec3d(.75,.8125,.5); + Vec3d start = new Vec3d(.25, .1875, 0); + Vec3d end = new Vec3d(.75, .8125, .5); Matrix4 mat = new Matrix4(facing); mat.translate(.5, .5, 0).rotate(Math.PI/2*rotation, 0, 0, 1).translate(-.5, -.5, 0); start = mat.apply(start); end = mat.apply(end); - return new float[]{(float) start.x, (float) start.y, (float) start.z, - (float) end.x, (float) end.y, (float) end.z}; + return new float[]{(float)start.x, (float)start.y, (float)start.z, + (float)end.x, (float)end.y, (float)end.z}; } @Override public int getWeakRSOutput(IBlockState state, EnumFacing side) { - return (active^inverted)?15:0; + return (active^inverted)?15: 0; } + @Override public int getStrongRSOutput(IBlockState state, EnumFacing side) { - return side.getOpposite()==facing && (active^inverted)?15:0; + return side.getOpposite()==facing&&(active^inverted)?15: 0; } + @Override public boolean canConnectRedstone(IBlockState state, EnumFacing side) { return true; } + @Override public Optional applyTransformations(IBlockState object, String group, Optional transform) { - Matrix4 mat = transform.isPresent()?new Matrix4(transform.get().getMatrix()):new Matrix4(); - mat = mat.translate(.5,0,.5).rotate(Math.PI/2*rotation,0,1,0).translate(-.5,0,-.5); + Matrix4 mat = transform.isPresent()?new Matrix4(transform.get().getMatrix()): new Matrix4(); + mat = mat.translate(.5, 0, .5).rotate(Math.PI/2*rotation, 0, 1, 0).translate(-.5, 0, -.5); transform = Optional.of(new TRSRTransformation(mat.toMatrix4f())); return transform; } @@ -308,45 +326,47 @@ public String getCacheKey(IBlockState object) { return rotation+","+facing.getIndex()+","+active; } + @Override public void onDirectionalPlacement(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase placer) { EnumFacing f = EnumFacing.SOUTH; - if(side.getAxis() == Axis.Y) + if(side.getAxis()==Axis.Y) { - float xFromMid = hitX - .5f; - float zFromMid = hitZ - .5f; + float xFromMid = hitX-.5f; + float zFromMid = hitZ-.5f; float max = Math.max(Math.abs(xFromMid), Math.abs(zFromMid)); - if(max == Math.abs(xFromMid)) - f = xFromMid < 0 ? EnumFacing.WEST : EnumFacing.EAST; + if(max==Math.abs(xFromMid)) + f = xFromMid < 0?EnumFacing.WEST: EnumFacing.EAST; else - f = zFromMid < 0 ? EnumFacing.NORTH : EnumFacing.SOUTH; - if ((side==EnumFacing.UP&&f.getAxis()==Axis.Z)||side==EnumFacing.DOWN) + f = zFromMid < 0?EnumFacing.NORTH: EnumFacing.SOUTH; + if((side==EnumFacing.UP&&f.getAxis()==Axis.Z)||side==EnumFacing.DOWN) f = f.getOpposite(); } rotation = f.getHorizontalIndex(); } + protected void onConnectionChange() { - if (world!=null&&world.isRemote) + if(world!=null&&world.isRemote) { endOfLeftConnection = null; ImmersiveEngineering.proxy.clearConnectionModelCache(); // reset cached connection vertices Set conns = ImmersiveNetHandler.INSTANCE.getConnections(world, pos); - if (conns!=null) - for (Connection c:conns) + if(conns!=null) + for(Connection c : conns) { c.catenaryVertices = null; world.markBlockRangeForRenderUpdate(c.end, c.end); Set connsThere = ImmersiveNetHandler.INSTANCE.getConnections(world, c.end); - if (connsThere!=null) - for (Connection c2:connsThere) - if (c2.end.equals(pos)) + if(connsThere!=null) + for(Connection c2 : connsThere) + if(c2.end.equals(pos)) c2.catenaryVertices = null; } } - if (world!=null) + if(world!=null) markContainingBlockForUpdate(null); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityBucketWheel.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityBucketWheel.java index 862eadbb0e..ba47b6321e 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityBucketWheel.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityBucketWheel.java @@ -44,16 +44,18 @@ public class TileEntityBucketWheel extends TileEntityMultiblockPart5*IEConfig.Machines.excavator_speed)?nbtRot:rotation; // avoid stuttering due to packet delays + rotation = (Math.abs(nbtRot-rotation) > 5*IEConfig.Machines.excavator_speed)?nbtRot: rotation; // avoid stuttering due to packet delays digStacks = Utils.readInventory(nbt.getTagList("digStacks", 10), 8); active = nbt.getBoolean("active"); - particleStack = nbt.hasKey("particleStack")?new ItemStack(nbt.getCompoundTag("particleStack")):ItemStack.EMPTY; + particleStack = nbt.hasKey("particleStack")?new ItemStack(nbt.getCompoundTag("particleStack")): ItemStack.EMPTY; } + @Override public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { @@ -83,11 +86,13 @@ protected IFluidTank[] getAccessibleFluidTanks(EnumFacing side) { return new IFluidTank[0]; } + @Override protected boolean canFillTankFrom(int iTank, EnumFacing side, FluidStack resources) { return false; } + @Override protected boolean canDrainTankFrom(int iTank, EnumFacing side) { @@ -98,13 +103,13 @@ protected boolean canDrainTankFrom(int iTank, EnumFacing side) public void update() { ApiUtils.checkForNeedlessTicking(this); - if(!formed || pos!=24) + if(!formed||pos!=24) return; if(active) { - rotation+=IEConfig.Machines.excavator_speed; - rotation%=360; + rotation += IEConfig.Machines.excavator_speed; + rotation %= 360; } if(world.isRemote) @@ -115,7 +120,7 @@ public void update() particleStack = ItemStack.EMPTY; } } - else if (active&&world.getTotalWorldTime()%20==0) + else if(active&&world.getTotalWorldTime()%20==0) { NBTTagCompound nbt = new NBTTagCompound(); nbt.setFloat("rotation", rotation); @@ -127,24 +132,26 @@ else if (active&&world.getTotalWorldTime()%20==0) @Override @SideOnly(Side.CLIENT) - public HashMap getTextureReplacements() + public HashMap getTextureReplacements() { - synchronized (digStacks) + synchronized(digStacks) { - HashMap texMap = new HashMap(); - for(int i = 0; i< this.digStacks.size(); i++) + HashMap texMap = new HashMap(); + for(int i = 0; i < this.digStacks.size(); i++) if(!this.digStacks.get(i).isEmpty()) { Block b = Block.getBlockFromItem(this.digStacks.get(i).getItem()); IBlockState state = b!=null?b.getStateFromMeta(this.digStacks.get(i).getMetadata()): Blocks.STONE.getDefaultState(); IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(state); - if(model!=null && model.getParticleTexture()!=null) + if(model!=null&&model.getParticleTexture()!=null) texMap.put("dig"+i, model.getParticleTexture().getIconName()); } return texMap; } } + static ArrayList emptyDisplayList = new ArrayList<>(); + @Override public ArrayList compileDisplayList() { @@ -154,16 +161,16 @@ public ArrayList compileDisplayList() @Override public void receiveMessageFromServer(NBTTagCompound message) { - synchronized (digStacks) + synchronized(digStacks) { - if (message.hasKey("fill")) + if(message.hasKey("fill")) this.digStacks.set(message.getInteger("fill"), new ItemStack(message.getCompoundTag("fillStack"))); - if (message.hasKey("empty")) + if(message.hasKey("empty")) this.digStacks.set(message.getInteger("empty"), ItemStack.EMPTY); - if (message.hasKey("rotation")) + if(message.hasKey("rotation")) { int packetRotation = message.getInteger("rotation"); - if (Math.abs(packetRotation-rotation)>5*IEConfig.Machines.excavator_speed) + if(Math.abs(packetRotation-rotation) > 5*IEConfig.Machines.excavator_speed) rotation = packetRotation; } } @@ -179,13 +186,14 @@ public boolean receiveClientEvent(int id, int arg) @SideOnly(Side.CLIENT) private AxisAlignedBB renderAABB; + @Override @SideOnly(Side.CLIENT) public AxisAlignedBB getRenderBoundingBox() { if(renderAABB==null) // if(pos==24) - renderAABB = new AxisAlignedBB(getPos().add(-(facing.getAxis() == Axis.Z ? 3 : 0), -3, -(facing.getAxis() == Axis.X ? 3 : 0)), getPos().add((facing.getAxis() == Axis.Z ? 4 : 1), 4, (facing.getAxis() == Axis.X ? 4 : 1))); + renderAABB = new AxisAlignedBB(getPos().add(-(facing.getAxis()==Axis.Z?3: 0), -3, -(facing.getAxis()==Axis.X?3: 0)), getPos().add((facing.getAxis()==Axis.Z?4: 1), 4, (facing.getAxis()==Axis.X?4: 1))); // else // renderAABB = new AxisAlignedBB(getPos(), getPos()); return renderAABB; @@ -195,17 +203,17 @@ public AxisAlignedBB getRenderBoundingBox() public float[] getBlockBounds() { if(pos==3||pos==9||pos==11) - return new float[]{0,.25f,0, 1,1,1}; + return new float[]{0, .25f, 0, 1, 1, 1}; else if(pos==45||pos==37||pos==39) - return new float[]{0,0,0, 1,.75f,1}; + return new float[]{0, 0, 0, 1, .75f, 1}; else if(pos==21) - return new float[]{facing==EnumFacing.NORTH?.25f:0,0,facing==EnumFacing.WEST?.25f:0, facing==EnumFacing.SOUTH?.75f:1,1,facing==EnumFacing.EAST?.75f:1}; + return new float[]{facing==EnumFacing.NORTH?.25f: 0, 0, facing==EnumFacing.WEST?.25f: 0, facing==EnumFacing.SOUTH?.75f: 1, 1, facing==EnumFacing.EAST?.75f: 1}; else if(pos==27) - return new float[]{facing==EnumFacing.SOUTH?.25f:0,0,facing==EnumFacing.EAST?.25f:0, facing==EnumFacing.NORTH?.75f:1,1,facing==EnumFacing.WEST?.75f:1}; + return new float[]{facing==EnumFacing.SOUTH?.25f: 0, 0, facing==EnumFacing.EAST?.25f: 0, facing==EnumFacing.NORTH?.75f: 1, 1, facing==EnumFacing.WEST?.75f: 1}; else if(pos==15||pos==29) - return new float[]{facing==EnumFacing.NORTH?.25f:0,0,facing==EnumFacing.WEST?.25f:0, facing==EnumFacing.SOUTH?.75f:1,1,facing==EnumFacing.EAST?.75f:1}; + return new float[]{facing==EnumFacing.NORTH?.25f: 0, 0, facing==EnumFacing.WEST?.25f: 0, facing==EnumFacing.SOUTH?.75f: 1, 1, facing==EnumFacing.EAST?.75f: 1}; else if(pos==19||pos==33) - return new float[]{facing==EnumFacing.SOUTH?.25f:0,0,facing==EnumFacing.EAST?.25f:0, facing==EnumFacing.NORTH?.75f:1,1,facing==EnumFacing.WEST?.75f:1}; - return new float[]{0,0,0,1,1,1}; + return new float[]{facing==EnumFacing.SOUTH?.25f: 0, 0, facing==EnumFacing.EAST?.25f: 0, facing==EnumFacing.NORTH?.75f: 1, 1, facing==EnumFacing.WEST?.75f: 1}; + return new float[]{0, 0, 0, 1, 1, 1}; } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityCapacitorCreative.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityCapacitorCreative.java index 4a17f1efa6..4e03105668 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityCapacitorCreative.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityCapacitorCreative.java @@ -19,14 +19,14 @@ public class TileEntityCapacitorCreative extends TileEntityCapacitorLV public TileEntityCapacitorCreative() { super(); - for(int i=0; i=sideConfig.length || sideConfig[from.ordinal()]!=SideConfig.INPUT) + if(world.isRemote||from.ordinal() >= sideConfig.length||sideConfig[from.ordinal()]!=SideConfig.INPUT) return 0; return maxReceive; } @@ -34,7 +34,7 @@ public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate) @Override public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate) { - if(world.isRemote || from.ordinal()>=sideConfig.length || sideConfig[from.ordinal()]!=SideConfig.OUTPUT) + if(world.isRemote||from.ordinal() >= sideConfig.length||sideConfig[from.ordinal()]!=SideConfig.OUTPUT) return 0; return maxExtract; } @@ -50,10 +50,11 @@ public int getMaxEnergyStored(EnumFacing from) { return Integer.MAX_VALUE; } + @Override protected void transferEnergy(int side) { - if (sideConfig[side] != SideConfig.OUTPUT) + if(sideConfig[side]!=SideConfig.OUTPUT) return; EnumFacing to = EnumFacing.getFront(side); TileEntity te = Utils.getExistingTileEntity(world, pos.offset(to)); diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityCapacitorHV.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityCapacitorHV.java index a54543327e..b8e0fb9d46 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityCapacitorHV.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityCapacitorHV.java @@ -17,11 +17,13 @@ public int getMaxStorage() { return IEConfig.Machines.capacitorHV_storage; } + @Override public int getMaxInput() { return IEConfig.Machines.capacitorHV_input; } + @Override public int getMaxOutput() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityCapacitorLV.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityCapacitorLV.java index e417db5629..98b47af2a0 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityCapacitorLV.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityCapacitorLV.java @@ -39,17 +39,17 @@ public class TileEntityCapacitorLV extends TileEntityIEBase implements ITickable, IIEInternalFluxHandler, IBlockOverlayText, IConfigurableSides, IComparatorOverride, ITileDrop { - public SideConfig[] sideConfig={SideConfig.NONE,SideConfig.INPUT,SideConfig.NONE,SideConfig.NONE,SideConfig.NONE,SideConfig.NONE}; - FluxStorage energyStorage = new FluxStorage(getMaxStorage(),getMaxInput(),getMaxOutput()); + public SideConfig[] sideConfig = {SideConfig.NONE, SideConfig.INPUT, SideConfig.NONE, SideConfig.NONE, SideConfig.NONE, SideConfig.NONE}; + FluxStorage energyStorage = new FluxStorage(getMaxStorage(), getMaxInput(), getMaxOutput()); - public int comparatorOutput=0; + public int comparatorOutput = 0; @Override public void update() { if(!world.isRemote) { - for(int i=0; i<6; i++) + for(int i = 0; i < 6; i++) this.transferEnergy(i); if(world.getTotalWorldTime()%32==((getPos().getX()^getPos().getZ())&31)) @@ -57,12 +57,13 @@ public void update() int i = scaleStoredEnergyTo(15); if(i!=this.comparatorOutput) { - this.comparatorOutput=i; + this.comparatorOutput = i; world.updateComparatorOutputLevel(getPos(), getBlockType()); } } } } + public int scaleStoredEnergyTo(int scale) { return (int)(scale*(energyStorage.getEnergyStored()/(float)energyStorage.getMaxEnergyStored())); @@ -70,7 +71,7 @@ public int scaleStoredEnergyTo(int scale) protected void transferEnergy(int side) { - if(this.sideConfig[side] != SideConfig.OUTPUT) + if(this.sideConfig[side]!=SideConfig.OUTPUT) return; EnumFacing fd = EnumFacing.getFront(side); BlockPos outPos = getPos().offset(fd); @@ -78,11 +79,13 @@ protected void transferEnergy(int side) int out = Math.min(getMaxOutput(), this.energyStorage.getEnergyStored()); this.energyStorage.modifyEnergyStored(-EnergyHelper.insertFlux(tileEntity, fd.getOpposite(), out, false)); } + @Override public IEEnums.SideConfig getSideConfig(int side) { return this.sideConfig[side]; } + @Override public boolean toggleSide(int side, EntityPlayer player) { @@ -92,6 +95,7 @@ public boolean toggleSide(int side, EntityPlayer player) world.addBlockEvent(getPos(), this.getBlockType(), 0, 0); return true; } + @Override public boolean receiveClientEvent(int id, int arg) { @@ -107,10 +111,12 @@ public int getMaxStorage() { return IEConfig.Machines.capacitorLV_storage; } + public int getMaxInput() { return IEConfig.Machines.capacitorLV_input; } + public int getMaxOutput() { return IEConfig.Machines.capacitorLV_output; @@ -119,33 +125,36 @@ public int getMaxOutput() @Override public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { - for(int i=0; i<6; i++) + for(int i = 0; i < 6; i++) nbt.setInteger("sideConfig_"+i, sideConfig[i].ordinal()); energyStorage.writeToNBT(nbt); } + @Override public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) { if(nbt.hasKey("sideConfig"))//old NBT style { int[] old = nbt.getIntArray("sideConfig"); - for(int i=0; i0) + if(energyStorage.getEnergyStored() > 0) ItemNBTHelper.setInt(stack, "energyStorage", energyStorage.getEnergyStored()); - for(int i=0; i<6; i++) + for(int i = 0; i < 6; i++) ItemNBTHelper.setInt(stack, "sideConfig_"+i, sideConfig[i].ordinal()); return stack; } + @Override public void readOnPlacement(EntityLivingBase placer, ItemStack stack) { if(ItemNBTHelper.hasKey(stack, "energyStorage")) energyStorage.setEnergy(ItemNBTHelper.getInt(stack, "energyStorage")); - for(int i=0; i<6; i++) + for(int i = 0; i < 6; i++) if(ItemNBTHelper.hasKey(stack, "sideConfig_"+i)) sideConfig[i] = SideConfig.values()[ItemNBTHelper.getInt(stack, "sideConfig_"+i)]; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityCapacitorMV.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityCapacitorMV.java index 7337fca89a..a29c37ad3b 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityCapacitorMV.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityCapacitorMV.java @@ -17,11 +17,13 @@ public int getMaxStorage() { return IEConfig.Machines.capacitorMV_storage; } + @Override public int getMaxInput() { return IEConfig.Machines.capacitorMV_input; } + @Override public int getMaxOutput() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityChargingStation.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityChargingStation.java index 4b3d144574..26ab4bcc9e 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityChargingStation.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityChargingStation.java @@ -44,7 +44,7 @@ public class TileEntityChargingStation extends TileEntityIEBase implements ITick public EnumFacing facing = EnumFacing.NORTH; public NonNullList inventory = NonNullList.withSize(1, ItemStack.EMPTY); private boolean charging = true; - public int comparatorOutput=0; + public int comparatorOutput = 0; @Override public void update() @@ -55,25 +55,25 @@ public void update() { float charge = 0; float max = EnergyHelper.getMaxEnergyStored(inventory.get(0)); - if(max>0) + if(max > 0) charge = EnergyHelper.getEnergyStored(inventory.get(0))/max; - for(int i=0; i<3; i++) + for(int i = 0; i < 3; i++) { long time = world.getTotalWorldTime(); - if(charge>=1 || (time%12>=i*4&&time%12<=i*4+2)) + if(charge >= 1||(time%12 >= i*4&&time%12 <= i*4+2)) { int shift = i-1; - double x = getPos().getX()+.5+(facing==EnumFacing.WEST?-.46875:facing==EnumFacing.EAST?.46875: facing==EnumFacing.NORTH?(-.1875*shift): (.1875*shift)); + double x = getPos().getX()+.5+(facing==EnumFacing.WEST?-.46875: facing==EnumFacing.EAST?.46875: facing==EnumFacing.NORTH?(-.1875*shift): (.1875*shift)); double y = getPos().getY()+.25; - double z = getPos().getZ()+.5+(facing==EnumFacing.NORTH?-.46875:facing==EnumFacing.SOUTH?.46875: facing==EnumFacing.EAST?(-.1875*shift): (.1875*shift)); - ImmersiveEngineering.proxy.spawnRedstoneFX(world, x,y,z, .25,.25,.25, .5f, 1-charge,charge,0); + double z = getPos().getZ()+.5+(facing==EnumFacing.NORTH?-.46875: facing==EnumFacing.SOUTH?.46875: facing==EnumFacing.EAST?(-.1875*shift): (.1875*shift)); + ImmersiveEngineering.proxy.spawnRedstoneFX(world, x, y, z, .25, .25, .25, .5f, 1-charge, charge, 0); } } } - else if (charging) + else if(charging) { - if (energyStorage.getEnergyStored()==0) + if(energyStorage.getEnergyStored()==0) { charging = false; this.markContainingBlockForUpdate(null); @@ -83,13 +83,13 @@ else if (charging) { int stored = EnergyHelper.getEnergyStored(inventory.get(0)); int max = EnergyHelper.getMaxEnergyStored(inventory.get(0)); - int space = max - stored; - if(space>0) + int space = max-stored; + if(space > 0) { int energyDec = (10*stored)/max; int insert = Math.min(space, Math.max(energyStorage.getAverageInsertion(), IEConfig.Machines.charger_consumption)); int accepted = Math.min(EnergyHelper.insertFlux(inventory.get(0), insert, true), this.energyStorage.extractEnergy(insert, true)); - if((accepted=this.energyStorage.extractEnergy(accepted, false))>0) + if((accepted = this.energyStorage.extractEnergy(accepted, false)) > 0) stored += EnergyHelper.insertFlux(inventory.get(0), accepted, false); int energyDecNew = (10*stored)/max; if(energyDec!=energyDecNew) @@ -97,7 +97,7 @@ else if (charging) } } } - else if (energyStorage.getEnergyStored()>=energyStorage.getMaxEnergyStored()*.95) + else if(energyStorage.getEnergyStored() >= energyStorage.getMaxEnergyStored()*.95) { charging = true; this.markContainingBlockForUpdate(null); @@ -105,13 +105,13 @@ else if (energyStorage.getEnergyStored()>=energyStorage.getMaxEnergyStored()*.95 } - if(!world.isRemote && world.getTotalWorldTime()%32==((getPos().getX()^getPos().getZ())&31)) + if(!world.isRemote&&world.getTotalWorldTime()%32==((getPos().getX()^getPos().getZ())&31)) { float charge = 0; if(EnergyHelper.isFluxItem(inventory.get(0))) { float max = EnergyHelper.getMaxEnergyStored(inventory.get(0)); - if(max>0) + if(max > 0) charge = EnergyHelper.getEnergyStored(inventory.get(0))/max; } // else @@ -119,7 +119,7 @@ else if (energyStorage.getEnergyStored()>=energyStorage.getMaxEnergyStored()*.95 int i = (int)(15*charge); if(i!=this.comparatorOutput) { - this.comparatorOutput=i; + this.comparatorOutput = i; world.notifyNeighborsOfStateChange(getPos(), getBlockType(), true); } } @@ -133,6 +133,7 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) inventory.set(0, new ItemStack(nbt.getCompoundTag("inventory"))); charging = nbt.getBoolean("charging"); } + @Override public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { @@ -160,14 +161,17 @@ public FluxStorage getFluxStorage() { return energyStorage; } + @Nonnull @Override public SideConfig getEnergySideConfig(EnumFacing facing) { - return facing==EnumFacing.DOWN||facing==this.facing.getOpposite()?SideConfig.INPUT:SideConfig.NONE; + return facing==EnumFacing.DOWN||facing==this.facing.getOpposite()?SideConfig.INPUT: SideConfig.NONE; } + IEForgeEnergyWrapper wrapperDown = new IEForgeEnergyWrapper(this, EnumFacing.DOWN); IEForgeEnergyWrapper wrapperDir = new IEForgeEnergyWrapper(this, facing.getOpposite()); + @Override public IEForgeEnergyWrapper getCapabilityWrapper(EnumFacing facing) { @@ -205,16 +209,19 @@ public int getFacingLimitation() { return 2; } + @Override public boolean mirrorFacingOnPlacement(EntityLivingBase placer) { return true; } + @Override public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) { return true; } + @Override public boolean canRotate(EnumFacing axis) { @@ -224,7 +231,7 @@ public boolean canRotate(EnumFacing axis) @Override public float[] getBlockBounds() { - return new float[]{facing.getAxis()==Axis.X?0:.125f,0,facing.getAxis()==Axis.Z?0:.125f, facing.getAxis()==Axis.X?1:.875f,1,facing.getAxis()==Axis.Z?1:.875f}; + return new float[]{facing.getAxis()==Axis.X?0: .125f, 0, facing.getAxis()==Axis.Z?0: .125f, facing.getAxis()==Axis.X?1: .875f, 1, facing.getAxis()==Axis.Z?1: .875f}; } @Override @@ -232,16 +239,19 @@ public NonNullList getInventory() { return inventory; } + @Override public boolean isStackValid(int slot, ItemStack stack) { return EnergyHelper.isFluxItem(stack); } + @Override public int getSlotLimit(int slot) { return 1; } + @Override public void doGraphicalUpdates(int slot) { @@ -256,7 +266,9 @@ public boolean hasCapability(Capability capability, EnumFacing facing) return true; return super.hasCapability(capability, facing); } - IItemHandler insertionHandler = new IEInventoryHandler(1,this); + + IItemHandler insertionHandler = new IEInventoryHandler(1, this); + @Override public T getCapability(Capability capability, EnumFacing facing) { @@ -270,7 +282,7 @@ public boolean interact(EnumFacing side, EntityPlayer player, EnumHand hand, Ite { if(EnergyHelper.isFluxItem(heldItem)) { - ItemStack stored = !inventory.get(0).isEmpty()? inventory.get(0).copy():ItemStack.EMPTY; + ItemStack stored = !inventory.get(0).isEmpty()?inventory.get(0).copy(): ItemStack.EMPTY; inventory.set(0, heldItem.copy()); player.setHeldItem(hand, stored); markDirty(); diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConnectorHV.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConnectorHV.java index 7ab96077a7..0c5dcb1915 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConnectorHV.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConnectorHV.java @@ -20,6 +20,7 @@ protected boolean canTakeHV() { return true; } + @Override protected boolean canTakeMV() { @@ -51,6 +52,7 @@ public int getMaxInput() { return connectorInputValues[2]; } + @Override public int getMaxOutput() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConnectorLV.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConnectorLV.java index fd0d9c77b7..82a7a0ad99 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConnectorLV.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConnectorLV.java @@ -47,12 +47,12 @@ //@Optional.Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2") public class TileEntityConnectorLV extends TileEntityImmersiveConnectable implements ITickable, IDirectionalTile, IIEInternalFluxHandler, IBlockBounds//, ic2.api.energy.tile.IEnergySink { - boolean inICNet=false; + boolean inICNet = false; public EnumFacing facing = EnumFacing.DOWN; private long lastTransfer = -1; - public int currentTickAccepted=0; + public int currentTickAccepted = 0; public static int[] connectorInputValues = Config.IEConfig.Machines.wireConnectorInput; - private FluxStorage energyStorage = new FluxStorage(getMaxInput(),getMaxInput(),0); + private FluxStorage energyStorage = new FluxStorage(getMaxInput(), getMaxInput(), 0); boolean firstTick = true; @@ -66,10 +66,10 @@ public void update() // IC2Helper.loadIC2Tile(this); // this.inICNet = true; // } - if(energyStorage.getEnergyStored()>0) + if(energyStorage.getEnergyStored() > 0) { int temp = this.transferEnergy(energyStorage.getEnergyStored(), true, 0); - if(temp>0) + if(temp > 0) { energyStorage.modifyEnergyStored(-this.transferEnergy(temp, false, 0)); markDirty(); @@ -79,12 +79,12 @@ public void update() } currentTickAccepted = 0; } - else if (firstTick) + else if(firstTick) { Set conns = ImmersiveNetHandler.INSTANCE.getConnections(world, pos); - if (conns!=null) - for (Connection conn:conns) - if (pos.compareTo(conn.end)<0&&world.isBlockLoaded(conn.end)) + if(conns!=null) + for(Connection conn : conns) + if(pos.compareTo(conn.end) < 0&&world.isBlockLoaded(conn.end)) this.markContainingBlockForUpdate(null); firstTick = false; } @@ -115,26 +115,31 @@ public EnumFacing getFacing() { return this.facing; } + @Override public void setFacing(EnumFacing facing) { this.facing = facing; } + @Override public int getFacingLimitation() { return 0; } + @Override public boolean mirrorFacingOnPlacement(EntityLivingBase placer) { return true; } + @Override public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) { return false; } + @Override public boolean canRotate(EnumFacing axis) { @@ -156,13 +161,14 @@ public boolean isEnergyOutput() TileEntity tile = Utils.getExistingTileEntity(world, outPos); return EnergyHelper.isFluxReceiver(tile, facing.getOpposite()); } + @Override public int outputEnergy(int amount, boolean simulate, int energyType) { if(isRelay()) return 0; int acceptanceLeft = getMaxOutput()-currentTickAccepted; - if(acceptanceLeft<=0) + if(acceptanceLeft <= 0) return 0; int toAccept = Math.min(acceptanceLeft, amount); @@ -189,7 +195,7 @@ public int outputEnergy(int amount, boolean simulate, int energyType) // ret = reConv; // } if(!simulate) - currentTickAccepted+=ret; + currentTickAccepted += ret; return ret; } @@ -201,6 +207,7 @@ public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) nbt.setLong("lastTransfer", lastTransfer); energyStorage.writeToNBT(nbt); } + @Override public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) { @@ -220,6 +227,7 @@ public Vec3d getConnectionOffset(Connection con) @SideOnly(Side.CLIENT) private AxisAlignedBB renderAABB; + @SideOnly(Side.CLIENT) @Override public AxisAlignedBB getRenderBoundingBox() @@ -229,7 +237,7 @@ public AxisAlignedBB getRenderBoundingBox() // if(Config.getBoolean("increasedRenderboxes")) // { int inc = getRenderRadiusIncrease(); - return new AxisAlignedBB(this.pos.getX()-inc,this.pos.getY()-inc,this.pos.getZ()-inc, this.pos.getX()+inc+1,this.pos.getY()+inc+1,this.pos.getZ()+inc+1); + return new AxisAlignedBB(this.pos.getX()-inc, this.pos.getY()-inc, this.pos.getZ()-inc, this.pos.getX()+inc+1, this.pos.getY()+inc+1, this.pos.getZ()+inc+1); // renderAABB = new AxisAlignedBB(this.pos.getX()-inc,this.pos.getY()-inc,this.pos.getZ()-inc, this.pos.getX()+inc+1,this.pos.getY()+inc+1,this.pos.getZ()+inc+1); // } // else @@ -237,18 +245,20 @@ public AxisAlignedBB getRenderBoundingBox() // } // return renderAABB; } + int getRenderRadiusIncrease() { return WireType.COPPER.getMaxLength(); } IEForgeEnergyWrapper energyWrapper; + @Override public IEForgeEnergyWrapper getCapabilityWrapper(EnumFacing facing) { - if(facing!=this.facing || isRelay()) + if(facing!=this.facing||isRelay()) return null; - if(energyWrapper==null || energyWrapper.side!=this.facing) + if(energyWrapper==null||energyWrapper.side!=this.facing) energyWrapper = new IEForgeEnergyWrapper(this, this.facing); return energyWrapper; } @@ -258,10 +268,11 @@ public FluxStorage getFluxStorage() { return energyStorage; } + @Override public SideConfig getEnergySideConfig(EnumFacing facing) { - return (!isRelay()&&facing==this.facing)?SideConfig.INPUT:SideConfig.NONE; + return (!isRelay()&&facing==this.facing)?SideConfig.INPUT: SideConfig.NONE; } @Override @@ -271,17 +282,18 @@ public boolean canConnectEnergy(EnumFacing from) return false; return from==facing; } + @Override public int receiveEnergy(EnumFacing from, int energy, boolean simulate) { - if(world.isRemote || isRelay()) + if(world.isRemote||isRelay()) return 0; if(world.getTotalWorldTime()==lastTransfer) return 0; - int accepted = Math.min(Math.min(getMaxOutput(),getMaxInput()), energy); + int accepted = Math.min(Math.min(getMaxOutput(), getMaxInput()), energy); accepted = Math.min(getMaxOutput()-energyStorage.getEnergyStored(), accepted); - if(accepted<=0) + if(accepted <= 0) return 0; if(!simulate) @@ -302,6 +314,7 @@ public int getEnergyStored(EnumFacing from) return 0; return energyStorage.getEnergyStored(); } + @Override public int getMaxEnergyStored(EnumFacing from) { @@ -309,6 +322,7 @@ public int getMaxEnergyStored(EnumFacing from) return 0; return getMaxInput(); } + @Override public int extractEnergy(EnumFacing from, int energy, boolean simulate) { @@ -322,23 +336,23 @@ public int transferEnergy(int energy, boolean simulate, final int energyType) { Set outputs = ImmersiveNetHandler.INSTANCE.getIndirectEnergyConnections(Utils.toCC(this), world, true); - int powerLeft = Math.min(Math.min(getMaxOutput(),getMaxInput()), energy); + int powerLeft = Math.min(Math.min(getMaxOutput(), getMaxInput()), energy); final int powerForSort = powerLeft; - if(outputs.size()<1) + if(outputs.size() < 1) return 0; int sum = 0; - HashMap powerSorting = new HashMap<>(); + HashMap powerSorting = new HashMap<>(); for(AbstractConnection con : outputs) - if (con.isEnergyOutput) + if(con.isEnergyOutput) { IImmersiveConnectable end = ApiUtils.toIIC(con.end, world); - if(con.cableType!=null && end!=null) + if(con.cableType!=null&&end!=null) { int atmOut = Math.min(powerForSort, con.cableType.getTransferRate()); int tempR = end.outputEnergy(atmOut, true, energyType); - if (tempR > 0) + if(tempR > 0) { powerSorting.put(con, tempR); sum += tempR; @@ -346,11 +360,11 @@ public int transferEnergy(int energy, boolean simulate, final int energyType) } } - if(sum>0) + if(sum > 0) for(AbstractConnection con : powerSorting.keySet()) { IImmersiveConnectable end = ApiUtils.toIIC(con.end, world); - if(con.cableType!=null && end!=null) + if(con.cableType!=null&&end!=null) { float prio = powerSorting.get(con)/(float)sum; int output = (int)(powerForSort*prio); @@ -358,7 +372,7 @@ public int transferEnergy(int energy, boolean simulate, final int energyType) int tempR = end.outputEnergy(Math.min(output, con.cableType.getTransferRate()), true, energyType); int r = tempR; int maxInput = getMaxInput(); - tempR -= (int) Math.max(0, Math.floor(tempR*con.getPreciseLossRate(tempR,maxInput))); + tempR -= (int)Math.max(0, Math.floor(tempR*con.getPreciseLossRate(tempR, maxInput))); end.outputEnergy(tempR, simulate, energyType); HashSet passedConnectors = new HashSet(); float intermediaryLoss = 0; @@ -367,24 +381,24 @@ public int transferEnergy(int energy, boolean simulate, final int energyType) float length = sub.length/(float)sub.cableType.getMaxLength(); float baseLoss = (float)sub.cableType.getLossRatio(); float mod = (((maxInput-tempR)/(float)maxInput)/.25f)*.1f; - intermediaryLoss = MathHelper.clamp(intermediaryLoss+length*(baseLoss+baseLoss*mod), 0,1); + intermediaryLoss = MathHelper.clamp(intermediaryLoss+length*(baseLoss+baseLoss*mod), 0, 1); int transferredPerCon = ImmersiveNetHandler.INSTANCE.getTransferedRates(world.provider.getDimension()).getOrDefault(sub, 0); transferredPerCon += r; if(!simulate) { - ImmersiveNetHandler.INSTANCE.getTransferedRates(world.provider.getDimension()).put(sub,transferredPerCon); - IImmersiveConnectable subStart = ApiUtils.toIIC(sub.start,world); - IImmersiveConnectable subEnd = ApiUtils.toIIC(sub.end,world); - if(subStart!=null && passedConnectors.add(subStart)) + ImmersiveNetHandler.INSTANCE.getTransferedRates(world.provider.getDimension()).put(sub, transferredPerCon); + IImmersiveConnectable subStart = ApiUtils.toIIC(sub.start, world); + IImmersiveConnectable subEnd = ApiUtils.toIIC(sub.end, world); + if(subStart!=null&&passedConnectors.add(subStart)) subStart.onEnergyPassthrough(r-r*intermediaryLoss); - if(subEnd!=null && passedConnectors.add(subEnd)) + if(subEnd!=null&&passedConnectors.add(subEnd)) subEnd.onEnergyPassthrough(r-r*intermediaryLoss); } } received += r; powerLeft -= r; - if(powerLeft<=0) + if(powerLeft <= 0) break; } } @@ -394,12 +408,12 @@ public int transferEnergy(int energy, boolean simulate, final int energyType) private void notifyAvailableEnergy(int energyStored, @Nullable Set outputs) { - if (outputs==null) + if(outputs==null) outputs = ImmersiveNetHandler.INSTANCE.getIndirectEnergyConnections(pos, world, true); for(AbstractConnection con : outputs) { IImmersiveConnectable end = ApiUtils.toIIC(con.end, world); - if(con.cableType!=null && end!=null && end.allowEnergyToPass(null)) + if(con.cableType!=null&&end!=null&&end.allowEnergyToPass(null)) { Pair> e = getEnergyForConnection(con); end.addAvailableEnergy(e.getKey(), e.getValue()); @@ -409,10 +423,10 @@ private void notifyAvailableEnergy(int energyStored, @Nullable Set> getEnergyForConnection(@Nullable AbstractConnection c) { - float loss = c!=null?c.getAverageLossRate():0; + float loss = c!=null?c.getAverageLossRate(): 0; float max = (1-loss)*energyStorage.getEnergyStored(); - Consumer extract = (energy)->{ - energyStorage.modifyEnergyStored((int) (-energy/(1-loss))); + Consumer extract = (energy) -> { + energyStorage.modifyEnergyStored((int)(-energy/(1-loss))); }; return new ImmutablePair<>(max, extract); } @@ -422,6 +436,7 @@ public int getMaxInput() { return connectorInputValues[0]; } + public int getMaxOutput() { return connectorInputValues[0]; @@ -438,24 +453,24 @@ protected Pair> getOwnEnergy() public float[] getBlockBounds() { float length = this instanceof TileEntityRelayHV?.875f: this instanceof TileEntityConnectorHV?.75f: this instanceof TileEntityConnectorMV?.5625f: .5f; - float wMin = this instanceof TileEntityConnectorStructural?.25f:.3125f; - float wMax = this instanceof TileEntityConnectorStructural?.75f:.6875f; - switch(facing.getOpposite() ) + float wMin = this instanceof TileEntityConnectorStructural?.25f: .3125f; + float wMax = this instanceof TileEntityConnectorStructural?.75f: .6875f; + switch(facing.getOpposite()) { case UP: - return new float[]{wMin,0,wMin, wMax,length,wMax}; + return new float[]{wMin, 0, wMin, wMax, length, wMax}; case DOWN: - return new float[]{wMin,1-length,wMin, wMax,1,wMax}; + return new float[]{wMin, 1-length, wMin, wMax, 1, wMax}; case SOUTH: - return new float[]{wMin,wMin,0, wMax,wMax,length}; + return new float[]{wMin, wMin, 0, wMax, wMax, length}; case NORTH: - return new float[]{wMin,wMin,1-length, wMax,wMax,1}; + return new float[]{wMin, wMin, 1-length, wMax, wMax, 1}; case EAST: - return new float[]{0,wMin,wMin, length,wMax,wMax}; + return new float[]{0, wMin, wMin, length, wMax, wMax}; case WEST: - return new float[]{1-length,wMin,wMin, 1,wMax,wMax}; + return new float[]{1-length, wMin, wMin, 1, wMax, wMax}; } - return new float[]{0,0,0,1,1,1}; + return new float[]{0, 0, 0, 1, 1, 1}; } // @Optional.Method(modid = "IC2") diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConnectorMV.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConnectorMV.java index c2b6ca11e5..7325520cb7 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConnectorMV.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConnectorMV.java @@ -20,6 +20,7 @@ protected boolean canTakeMV() { return true; } + @Override protected boolean canTakeLV() { @@ -39,12 +40,13 @@ int getRenderRadiusIncrease() { return WireType.ELECTRUM.getMaxLength(); } - + @Override public int getMaxInput() { return connectorInputValues[1]; } + @Override public int getMaxOutput() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConnectorProbe.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConnectorProbe.java index 3b98c16cef..5c73fbeb29 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConnectorProbe.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConnectorProbe.java @@ -38,7 +38,7 @@ public class TileEntityConnectorProbe extends TileEntityConnectorRedstone @Override public void update() { - if(!world.isRemote && world.getTotalWorldTime() % 8 != ((getPos().getX() ^ getPos().getZ()) & 8)) + if(!world.isRemote&&world.getTotalWorldTime()%8!=((getPos().getX()^getPos().getZ())&8)) { int out = getComparatorSignal(); if(out!=lastOutput) @@ -74,25 +74,26 @@ else if(state.isNormalCube()) state = world.getBlockState(pos); if(state.hasComparatorInputOverride()) return state.getComparatorInputOverride(world, pos); - else if(state.getMaterial() == Material.AIR) + else if(state.getMaterial()==Material.AIR) { EntityItemFrame entityitemframe = this.findItemFrame(world, facing, pos); - if(entityitemframe != null) + if(entityitemframe!=null) return entityitemframe.getAnalogOutput(); } } return 0; } + private EntityItemFrame findItemFrame(World world, final EnumFacing facing, BlockPos pos) { - List list = world.getEntitiesWithinAABB(EntityItemFrame.class, new AxisAlignedBB(pos), entity -> entity!=null && entity.getHorizontalFacing()==facing); - return list.size()==1 ? list.get(0) : null; + List list = world.getEntitiesWithinAABB(EntityItemFrame.class, new AxisAlignedBB(pos), entity -> entity!=null&&entity.getHorizontalFacing()==facing); + return list.size()==1?list.get(0): null; } @Override public void updateInput(byte[] signals) { - signals[redstoneChannelSending] = (byte) Math.max(lastOutput, signals[redstoneChannelSending]); + signals[redstoneChannelSending] = (byte)Math.max(lastOutput, signals[redstoneChannelSending]); rsDirty = false; } @@ -100,9 +101,9 @@ public void updateInput(byte[] signals) public boolean hammerUseSide(EnumFacing side, EntityPlayer player, float hitX, float hitY, float hitZ) { if(player.isSneaking()) - redstoneChannel = (redstoneChannel + 1) % 16; + redstoneChannel = (redstoneChannel+1)%16; else - redstoneChannelSending = (redstoneChannelSending + 1) % 16; + redstoneChannelSending = (redstoneChannelSending+1)%16; markDirty(); wireNetwork.updateValues(); onChange(); @@ -129,8 +130,8 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) public Vec3d getConnectionOffset(Connection con) { EnumFacing side = facing.getOpposite(); - double conRadius = con.cableType.getRenderDiameter() / 2; - return new Vec3d(.5 + side.getFrontOffsetX()*(.375-conRadius), .5 + side.getFrontOffsetY()*(.375-conRadius), .5 + side.getFrontOffsetZ()*(.375-conRadius)); + double conRadius = con.cableType.getRenderDiameter()/2; + return new Vec3d(.5+side.getFrontOffsetX()*(.375-conRadius), .5+side.getFrontOffsetY()*(.375-conRadius), .5+side.getFrontOffsetZ()*(.375-conRadius)); } @Override @@ -157,11 +158,11 @@ public float[] getBlockBounds() @Override public boolean shouldRenderGroup(IBlockState object, String group) { - if(MinecraftForgeClient.getRenderLayer()== BlockRenderLayer.SOLID) + if(MinecraftForgeClient.getRenderLayer()==BlockRenderLayer.SOLID) return false; if("glass".equals(group)) - return MinecraftForgeClient.getRenderLayer()== BlockRenderLayer.TRANSLUCENT; - return MinecraftForgeClient.getRenderLayer()== BlockRenderLayer.CUTOUT; + return MinecraftForgeClient.getRenderLayer()==BlockRenderLayer.TRANSLUCENT; + return MinecraftForgeClient.getRenderLayer()==BlockRenderLayer.CUTOUT; } @SideOnly(Side.CLIENT) @@ -187,8 +188,8 @@ public String[] getOverlayText(EntityPlayer player, RayTraceResult mop, boolean if(!hammer) return null; return new String[]{ - I18n.format(Lib.DESC_INFO + "redstoneChannel.rec", I18n.format("item.fireworksCharge." + EnumDyeColor.byMetadata(redstoneChannel).getUnlocalizedName())), - I18n.format(Lib.DESC_INFO + "redstoneChannel.send", I18n.format("item.fireworksCharge." + EnumDyeColor.byMetadata(redstoneChannelSending).getUnlocalizedName())) + I18n.format(Lib.DESC_INFO+"redstoneChannel.rec", I18n.format("item.fireworksCharge."+EnumDyeColor.byMetadata(redstoneChannel).getUnlocalizedName())), + I18n.format(Lib.DESC_INFO+"redstoneChannel.send", I18n.format("item.fireworksCharge."+EnumDyeColor.byMetadata(redstoneChannelSending).getUnlocalizedName())) }; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConnectorRedstone.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConnectorRedstone.java index c43a2b854f..02ad19232c 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConnectorRedstone.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConnectorRedstone.java @@ -53,33 +53,33 @@ public class TileEntityConnectorRedstone extends TileEntityImmersiveConnectable @Override public void update() { - if (hasWorld() && !world.isRemote && !refreshWireNetwork) + if(hasWorld()&&!world.isRemote&&!refreshWireNetwork) { refreshWireNetwork = true; wireNetwork.removeFromNetwork(null); } - if (hasWorld() && !world.isRemote && rsDirty) + if(hasWorld()&&!world.isRemote&&rsDirty) wireNetwork.updateValues(); } @Override public int getStrongRSOutput(IBlockState state, EnumFacing side) { - if (!isRSOutput() || side != this.facing.getOpposite()) + if(!isRSOutput()||side!=this.facing.getOpposite()) return 0; - if (world.isRemote) + if(world.isRemote) return outputClient; - return wireNetwork != null ? wireNetwork.getPowerOutput(redstoneChannel) : 0; + return wireNetwork!=null?wireNetwork.getPowerOutput(redstoneChannel): 0; } @Override public int getWeakRSOutput(IBlockState state, EnumFacing side) { - if (!isRSOutput()) + if(!isRSOutput()) return 0; - if (world.isRemote) + if(world.isRemote) return outputClient; - return wireNetwork != null ? wireNetwork.getPowerOutput(redstoneChannel) : 0; + return wireNetwork!=null?wireNetwork.getPowerOutput(redstoneChannel): 0; } @Override @@ -103,7 +103,7 @@ public RedstoneWireNetwork getNetwork() @Override public void onChange() { - if (!isInvalid() && isRSOutput()) + if(!isInvalid()&&isRSOutput()) { markDirty(); markContainingBlockForUpdate(null); @@ -119,26 +119,26 @@ public World getConnectorWorld() public boolean isRSInput() { - return ioMode == 0; + return ioMode==0; } @Override public void updateInput(byte[] signals) { - if (isRSInput()) - signals[redstoneChannel] = (byte) Math.max(getLocalRS(), signals[redstoneChannel]); + if(isRSInput()) + signals[redstoneChannel] = (byte)Math.max(getLocalRS(), signals[redstoneChannel]); rsDirty = false; } protected int getLocalRS() { int val = world.isBlockIndirectlyGettingPowered(pos); - if (val == 0) + if(val==0) { - for (EnumFacing f : EnumFacing.HORIZONTALS) + for(EnumFacing f : EnumFacing.HORIZONTALS) { IBlockState state = world.getBlockState(pos.offset(f)); - if (state.getBlock() == Blocks.REDSTONE_WIRE && state.getValue(BlockRedstoneWire.POWER) > val) + if(state.getBlock()==Blocks.REDSTONE_WIRE&&state.getValue(BlockRedstoneWire.POWER) > val) val = state.getValue(BlockRedstoneWire.POWER); } } @@ -147,17 +147,17 @@ protected int getLocalRS() public boolean isRSOutput() { - return ioMode == 1; + return ioMode==1; } @Override public boolean hammerUseSide(EnumFacing side, EntityPlayer player, float hitX, float hitY, float hitZ) { //Sneaking iterates through colours, normal hammerign toggles in and out - if (player.isSneaking()) - redstoneChannel = (redstoneChannel + 1) % 16; + if(player.isSneaking()) + redstoneChannel = (redstoneChannel+1)%16; else - ioMode = ioMode == 0 ? 1 : 0; + ioMode = ioMode==0?1: 0; markDirty(); wireNetwork.updateValues(); onChange(); @@ -169,9 +169,9 @@ public boolean hammerUseSide(EnumFacing side, EntityPlayer player, float hitX, f @Override public boolean canConnectCable(WireType cableType, TargetingInfo target, Vec3i offset) { - if (!REDSTONE_CATEGORY.equals(cableType.getCategory())) + if(!REDSTONE_CATEGORY.equals(cableType.getCategory())) return false; - return limitType == null || limitType == cableType; + return limitType==null||limitType==cableType; } @Override @@ -232,7 +232,7 @@ public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) nbt.setInteger("facing", facing.ordinal()); nbt.setInteger("ioMode", ioMode); nbt.setInteger("redstoneChannel", redstoneChannel); - nbt.setInteger("output", wireNetwork != null ? wireNetwork.getPowerOutput(redstoneChannel) : 0); + nbt.setInteger("output", wireNetwork!=null?wireNetwork.getPowerOutput(redstoneChannel): 0); } @Override @@ -249,8 +249,8 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) public Vec3d getConnectionOffset(Connection con) { EnumFacing side = facing.getOpposite(); - double conRadius = con.cableType.getRenderDiameter() / 2; - return new Vec3d(.5 - conRadius * side.getFrontOffsetX(), .5 - conRadius * side.getFrontOffsetY(), .5 - conRadius * side.getFrontOffsetZ()); + double conRadius = con.cableType.getRenderDiameter()/2; + return new Vec3d(.5-conRadius*side.getFrontOffsetX(), .5-conRadius*side.getFrontOffsetY(), .5-conRadius*side.getFrontOffsetZ()); } @Override @@ -267,7 +267,7 @@ public void onConnectivityUpdate(BlockPos pos, int dimension) public AxisAlignedBB getRenderBoundingBox() { int inc = getRenderRadiusIncrease(); - return new AxisAlignedBB(this.pos.getX() - inc, this.pos.getY() - inc, this.pos.getZ() - inc, this.pos.getX() + inc + 1, this.pos.getY() + inc + 1, this.pos.getZ() + inc + 1); + return new AxisAlignedBB(this.pos.getX()-inc, this.pos.getY()-inc, this.pos.getZ()-inc, this.pos.getX()+inc+1, this.pos.getY()+inc+1, this.pos.getZ()+inc+1); } int getRenderRadiusIncrease() @@ -281,20 +281,20 @@ public float[] getBlockBounds() float length = .625f; float wMin = .3125f; float wMax = .6875f; - switch (facing.getOpposite()) + switch(facing.getOpposite()) { case UP: return new float[]{wMin, 0, wMin, wMax, length, wMax}; case DOWN: - return new float[]{wMin, 1 - length, wMin, wMax, 1, wMax}; + return new float[]{wMin, 1-length, wMin, wMax, 1, wMax}; case SOUTH: return new float[]{wMin, wMin, 0, wMax, wMax, length}; case NORTH: - return new float[]{wMin, wMin, 1 - length, wMax, wMax, 1}; + return new float[]{wMin, wMin, 1-length, wMax, wMax, 1}; case EAST: return new float[]{0, wMin, wMin, length, wMax, wMax}; case WEST: - return new float[]{1 - length, wMin, wMin, 1, wMax, wMax}; + return new float[]{1-length, wMin, wMin, 1, wMax, wMax}; } return new float[]{0, 0, 0, 1, 1, 1}; } @@ -303,10 +303,10 @@ public float[] getBlockBounds() @Override public boolean shouldRenderGroup(IBlockState object, String group) { - if ("io_out".equals(group)) - return this.ioMode == 1; - else if ("io_in".equals(group)) - return this.ioMode == 0; + if("io_out".equals(group)) + return this.ioMode==1; + else if("io_in".equals(group)) + return this.ioMode==0; return true; } @@ -314,25 +314,25 @@ else if ("io_in".equals(group)) @Override public int getRenderColour(IBlockState object, String group) { - if ("coloured".equals(group)) - return 0xff000000 | EnumDyeColor.byMetadata(this.redstoneChannel).getColorValue(); + if("coloured".equals(group)) + return 0xff000000|EnumDyeColor.byMetadata(this.redstoneChannel).getColorValue(); return 0xffffffff; } @Override public String getCacheKey(IBlockState object) { - return redstoneChannel + ";" + ioMode; + return redstoneChannel+";"+ioMode; } @Override public String[] getOverlayText(EntityPlayer player, RayTraceResult mop, boolean hammer) { - if (!hammer) + if(!hammer) return null; return new String[]{ - I18n.format(Lib.DESC_INFO + "redstoneChannel", I18n.format("item.fireworksCharge." + EnumDyeColor.byMetadata(redstoneChannel).getUnlocalizedName())), - I18n.format(Lib.DESC_INFO + "blockSide.io." + this.ioMode) + I18n.format(Lib.DESC_INFO+"redstoneChannel", I18n.format("item.fireworksCharge."+EnumDyeColor.byMetadata(redstoneChannel).getUnlocalizedName())), + I18n.format(Lib.DESC_INFO+"blockSide.io."+this.ioMode) }; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConnectorStructural.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConnectorStructural.java index b30ef5746a..8fabf35d48 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConnectorStructural.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConnectorStructural.java @@ -37,6 +37,7 @@ protected boolean canTakeMV() { return false; } + @Override protected boolean canTakeLV() { @@ -51,7 +52,7 @@ protected boolean canTakeLV() @Override public boolean hammerUseSide(EnumFacing side, EntityPlayer player, float hitX, float hitY, float hitZ) { - rotation += player.isSneaking()?-22.5f:22.5f; + rotation += player.isSneaking()?-22.5f: 22.5f; rotation %= 360; markDirty(); world.addBlockEvent(getPos(), this.getBlockType(), 254, 0); @@ -64,12 +65,13 @@ public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) super.writeCustomNBT(nbt, descPacket); nbt.setFloat("rotation", rotation); } + @Override public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) { super.readCustomNBT(nbt, descPacket); rotation = nbt.getFloat("rotation"); - if(FMLCommonHandler.instance().getEffectiveSide()==Side.CLIENT && world!=null) + if(FMLCommonHandler.instance().getEffectiveSide()==Side.CLIENT&&world!=null) this.markContainingBlockForUpdate(null); } @@ -92,6 +94,7 @@ public int getMaxInput() { return 0; } + @Override public int getMaxOutput() { @@ -105,6 +108,7 @@ public boolean canConnectCable(WireType cableType, TargetingInfo target, Vec3i o return false; return limitType==null||limitType==cableType; } + @Override public boolean isEnergyOutput() { @@ -114,9 +118,9 @@ public boolean isEnergyOutput() @Override public Optional applyTransformations(IBlockState object, String group, Optional transform) { - Matrix4 mat = transform.isPresent()?new Matrix4(transform.get().getMatrix()):new Matrix4(); - mat = mat.translate(.5,0,.5).rotate(Math.toRadians(rotation),0,1,0).translate(-.5,0,-.5); - transform = Optional.of( new TRSRTransformation(mat.toMatrix4f())); + Matrix4 mat = transform.isPresent()?new Matrix4(transform.get().getMatrix()): new Matrix4(); + mat = mat.translate(.5, 0, .5).rotate(Math.toRadians(rotation), 0, 1, 0).translate(-.5, 0, -.5); + transform = Optional.of(new TRSRTransformation(mat.toMatrix4f())); return transform; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConveyorBelt.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConveyorBelt.java index 672b7befad..afeea359ed 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConveyorBelt.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConveyorBelt.java @@ -60,7 +60,7 @@ public void setConveyorSubtype(IConveyorBelt conveyor) @Override public void onEntityCollision(World world, Entity entity) { - if(this.conveyorBeltSubtype != null) + if(this.conveyorBeltSubtype!=null) this.conveyorBeltSubtype.onEntityCollision(this, entity, facing); } @@ -74,7 +74,7 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) conveyorBeltSubtype.readConveyorNBT(nbt.getCompoundTag("conveyorBeltSubtypeNBT")); } - if(descPacket && world!=null) + if(descPacket&&world!=null) this.markContainingBlockForUpdate(null); } @@ -82,7 +82,7 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { nbt.setInteger("facing", facing.ordinal()); - if(conveyorBeltSubtype != null) + if(conveyorBeltSubtype!=null) { nbt.setString("conveyorBeltSubtype", ConveyorHandler.reverseClassRegistry.get(conveyorBeltSubtype.getClass()).toString()); nbt.setTag("conveyorBeltSubtypeNBT", conveyorBeltSubtype.writeConveyorNBT()); @@ -94,35 +94,41 @@ public EnumFacing getFacing() { return this.facing; } + @Override public void setFacing(EnumFacing facing) { this.facing = facing; } + @Override public int getFacingLimitation() { return 5; } + @Override public boolean mirrorFacingOnPlacement(EntityLivingBase placer) { return false; } + @Override public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) { return !entity.isSneaking(); } + @Override public boolean canRotate(EnumFacing axis) { return true; } + @Override public void afterRotation(EnumFacing oldDir, EnumFacing newDir) { - if(this.conveyorBeltSubtype != null) + if(this.conveyorBeltSubtype!=null) this.conveyorBeltSubtype.afterRotation(oldDir, newDir); } @@ -143,7 +149,7 @@ public void update() @Override public boolean hammerUseSide(EnumFacing side, EntityPlayer player, float hitX, float hitY, float hitZ) { - if(player.isSneaking() && conveyorBeltSubtype != null && conveyorBeltSubtype.changeConveyorDirection()) + if(player.isSneaking()&&conveyorBeltSubtype!=null&&conveyorBeltSubtype.changeConveyorDirection()) { // if(transportUp) // { @@ -169,13 +175,13 @@ public boolean interact(EnumFacing side, EntityPlayer player, EnumHand hand, Ite if(conveyorBeltSubtype!=null) { boolean update; - if(conveyorBeltSubtype.canBeDyed() && Utils.isDye(heldItem)) + if(conveyorBeltSubtype.canBeDyed()&&Utils.isDye(heldItem)) { EnumDyeColor dye = EnumDyeColor.byDyeDamage(Utils.getDye(heldItem)); update = dye!=null&&conveyorBeltSubtype.setDyeColour(dye.getColorValue()); } else - update = conveyorBeltSubtype.playerInteraction(this, player, hand, heldItem, hitX,hitY,hitZ, side); + update = conveyorBeltSubtype.playerInteraction(this, player, hand, heldItem, hitX, hitY, hitZ, side); if(update) { this.markDirty(); @@ -199,10 +205,11 @@ public float[] getBlockBounds() } static AxisAlignedBB COLISIONBB = new AxisAlignedBB(0, 0, 0, 1, .125F, 1); + @Override public List getAdvancedColisionBounds() { - if(conveyorBeltSubtype != null) + if(conveyorBeltSubtype!=null) { List boxes = new ArrayList(); for(AxisAlignedBB aabb : conveyorBeltSubtype.getColisionBoxes(this, facing)) @@ -215,7 +222,7 @@ public List getAdvancedColisionBounds() @Override public List getAdvancedSelectionBounds() { - if(conveyorBeltSubtype != null) + if(conveyorBeltSubtype!=null) { List boxes = new ArrayList(); for(AxisAlignedBB aabb : conveyorBeltSubtype.getSelectionBoxes(this, facing)) @@ -238,7 +245,9 @@ public boolean hasCapability(Capability capability, EnumFacing facing) return true; return super.hasCapability(capability, facing); } + IItemHandler insertionHandler = new ConveyorInventoryHandler(this); + @Override public T getCapability(Capability capability, EnumFacing facing) { @@ -251,7 +260,7 @@ public T getCapability(Capability capability, EnumFacing facing) public ItemStack getTileDrop(EntityPlayer player, IBlockState state) { ItemStack stack = new ItemStack(state.getBlock()); - if(conveyorBeltSubtype != null) + if(conveyorBeltSubtype!=null) ItemNBTHelper.setString(stack, "conveyorType", ConveyorHandler.reverseClassRegistry.get(this.conveyorBeltSubtype.getClass()).toString()); return stack; } @@ -267,6 +276,7 @@ public void readOnPlacement(EntityLivingBase placer, ItemStack stack) public static class ConveyorInventoryHandler implements IItemHandlerModifiable { TileEntityConveyorBelt conveyor; + public ConveyorInventoryHandler(TileEntityConveyorBelt conveyor) { this.conveyor = conveyor; @@ -277,6 +287,7 @@ public int getSlots() { return 1; } + @Override public ItemStack getStackInSlot(int slot) { @@ -288,7 +299,7 @@ public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { if(!simulate) { - EntityItem entity = new EntityItem(conveyor.getWorld(), conveyor.getPos().getX() + .5, conveyor.getPos().getY() + .1875, conveyor.getPos().getZ() + .5, stack.copy()); + EntityItem entity = new EntityItem(conveyor.getWorld(), conveyor.getPos().getX()+.5, conveyor.getPos().getY()+.1875, conveyor.getPos().getZ()+.5, stack.copy()); entity.motionX = 0; entity.motionY = 0; entity.motionZ = 0; @@ -306,7 +317,8 @@ public ItemStack extractItem(int slot, int amount, boolean simulate) } @Override - public int getSlotLimit(int slot) { + public int getSlotLimit(int slot) + { return 64; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConveyorVertical.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConveyorVertical.java index dafd5b2725..a7a6b104ba 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConveyorVertical.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityConveyorVertical.java @@ -26,49 +26,49 @@ public class TileEntityConveyorVertical extends TileEntityConveyorBelt @Override public void onEntityCollision(World world, Entity entity) { - if(entity!=null && !entity.isDead) + if(entity!=null&&!entity.isDead) { - if(world.isBlockIndirectlyGettingPowered(pos)>0) + if(world.isBlockIndirectlyGettingPowered(pos) > 0) return; - double vBase = entity instanceof EntityLivingBase?1.5:1.15; - double distY = Math.abs(getPos().add(0,1,0).getY()+.5-entity.posY); + double vBase = entity instanceof EntityLivingBase?1.5: 1.15; + double distY = Math.abs(getPos().add(0, 1, 0).getY()+.5-entity.posY); double treshold = .9; - boolean contact = distY getPos().getZ()+0.65D) - vZ = -0.1D * vBase; + vZ = -0.1D*vBase; else if(entity.posZ < getPos().getZ()+0.35D) - vZ = 0.1D * vBase; + vZ = 0.1D*vBase; } - else if(facing==EnumFacing.NORTH || facing==EnumFacing.SOUTH) + else if(facing==EnumFacing.NORTH||facing==EnumFacing.SOUTH) { if(entity.posX > getPos().getX()+0.65D) - vX = -0.1D * vBase; + vX = -0.1D*vBase; else if(entity.posX < getPos().getX()+0.35D) - vX = 0.1D * vBase; + vX = 0.1D*vBase; } } //Little boost at the top of a conveyor to help players and minecarts to get off - if(contact && !(world.getTileEntity(getPos().add(0,1,0)) instanceof TileEntityConveyorVertical)) + if(contact&&!(world.getTileEntity(getPos().add(0, 1, 0)) instanceof TileEntityConveyorVertical)) vY *= 2.25; entity.onGround = false; - if (entity.fallDistance<3) + if(entity.fallDistance < 3) entity.fallDistance = 0; else - entity.fallDistance*=.9; + entity.fallDistance *= .9; entity.motionX = vX; entity.motionY = vY; entity.motionZ = vZ; @@ -76,10 +76,10 @@ else if(entity.posX < getPos().getX()+0.35D) { ((EntityItem)entity).setNoDespawn(); TileEntity inventoryTile; - inventoryTile = world.getTileEntity(getPos().add(0,1,0)); + inventoryTile = world.getTileEntity(getPos().add(0, 1, 0)); if(!world.isRemote) { - if(contact && inventoryTile!=null && !(inventoryTile instanceof TileEntityConveyorBelt)) + if(contact&&inventoryTile!=null&&!(inventoryTile instanceof TileEntityConveyorBelt)) { ItemStack stack = ((EntityItem)entity).getItem(); if(!stack.isEmpty()) @@ -87,7 +87,7 @@ else if(entity.posX < getPos().getX()+0.35D) ItemStack ret = Utils.insertStackIntoInventory(inventoryTile, stack, EnumFacing.DOWN); if(ret.isEmpty()) entity.setDead(); - else if(ret.getCount() getAdvancedColisionBounds() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityCrusher.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityCrusher.java index dc665eaac7..e18f8679e7 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityCrusher.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityCrusher.java @@ -10,7 +10,6 @@ import blusunrize.immersiveengineering.ImmersiveEngineering; import blusunrize.immersiveengineering.api.crafting.CrusherRecipe; -import blusunrize.immersiveengineering.common.Config.IEConfig; import blusunrize.immersiveengineering.common.EventHandler; import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IAdvancedCollisionBounds; import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IAdvancedSelectionBounds; @@ -47,12 +46,12 @@ import java.util.ArrayList; import java.util.List; -public class TileEntityCrusher extends TileEntityMultiblockMetal implements ISoundTile, IAdvancedSelectionBounds,IAdvancedCollisionBounds +public class TileEntityCrusher extends TileEntityMultiblockMetal implements ISoundTile, IAdvancedSelectionBounds, IAdvancedCollisionBounds { public List inputs = new ArrayList<>(); public int process = 0; - public float animation_barrelRotation=0; + public float animation_barrelRotation = 0; // public boolean active = false; // public boolean hasPower = false; // public boolean mobGrinding = false; @@ -62,7 +61,7 @@ public class TileEntityCrusher extends TileEntityMultiblockMetal15 && pos%5>0&&pos%5<4) + if(pos > 15&&pos%5 > 0&&pos%5 < 4) { float minX = 0; float maxX = 1; @@ -167,13 +168,14 @@ else if(pos%5==3) maxZ = .8125f; } - return new float[]{minX,0,minZ, maxX,1,maxZ}; + return new float[]{minX, 0, minZ, maxX, 1, maxZ}; } if(pos==19) - return new float[]{facing==EnumFacing.WEST?.5f:0,0,facing==EnumFacing.NORTH?.5f:0, facing==EnumFacing.EAST?.5f:1,1,facing==EnumFacing.SOUTH?.5f:1}; + return new float[]{facing==EnumFacing.WEST?.5f: 0, 0, facing==EnumFacing.NORTH?.5f: 0, facing==EnumFacing.EAST?.5f: 1, 1, facing==EnumFacing.SOUTH?.5f: 1}; - return new float[]{0,0,0,1,1,1}; + return new float[]{0, 0, 0, 1, 1, 1}; } + @Override public List getAdvancedSelectionBounds() { @@ -185,21 +187,21 @@ public List getAdvancedSelectionBounds() fw = fw.getOpposite(); if(pos==4) { - List list = Lists.newArrayList(new AxisAlignedBB(0,0,0, 1,.5f,1).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + List list = Lists.newArrayList(new AxisAlignedBB(0, 0, 0, 1, .5f, 1).offset(getPos().getX(), getPos().getY(), getPos().getZ())); float minX = fl==EnumFacing.WEST?.625f: fl==EnumFacing.EAST?.125f: .125f; float maxX = fl==EnumFacing.EAST?.375f: fl==EnumFacing.WEST?.875f: .25f; float minZ = fl==EnumFacing.NORTH?.625f: fl==EnumFacing.SOUTH?.125f: .125f; float maxZ = fl==EnumFacing.SOUTH?.375f: fl==EnumFacing.NORTH?.875f: .25f; - list.add(new AxisAlignedBB(minX,.5f,minZ, maxX,1,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); minX = fl==EnumFacing.WEST?.625f: fl==EnumFacing.EAST?.125f: .75f; maxX = fl==EnumFacing.EAST?.375f: fl==EnumFacing.WEST?.875f: .875f; minZ = fl==EnumFacing.NORTH?.625f: fl==EnumFacing.SOUTH?.125f: .75f; maxZ = fl==EnumFacing.SOUTH?.375f: fl==EnumFacing.NORTH?.875f: .875f; - list.add(new AxisAlignedBB(minX,.5f,minZ, maxX,1,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); return list; } - if((pos>20 && pos<24)||(pos>35 && pos<39)) + if((pos > 20&&pos < 24)||(pos > 35&&pos < 39)) { List list = new ArrayList(3); float minY = .5f; @@ -207,21 +209,21 @@ public List getAdvancedSelectionBounds() float maxX = (pos%5==1&&fw==EnumFacing.WEST)||(pos%5==3&&fw==EnumFacing.EAST)?.5625f: 1; float minZ = (pos%5==1&&fw==EnumFacing.SOUTH)||(pos%5==3&&fw==EnumFacing.NORTH)?.4375f: 0; float maxZ = (pos%5==1&&fw==EnumFacing.NORTH)||(pos%5==3&&fw==EnumFacing.SOUTH)?.5625f: 1; - if(pos>20 && pos<24) - list.add(new AxisAlignedBB(minX,.5f,minZ, maxX,.75f,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + if(pos > 20&&pos < 24) + list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, .75f, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); else minY = 0; minX = (pos%5==1&&fw==EnumFacing.EAST)||(pos%5==3&&fw==EnumFacing.WEST)?.1875f: (pos%5==1&&fw==EnumFacing.WEST)||(pos%5==3&&fw==EnumFacing.EAST)?.5625f: 0; maxX = (pos%5==1&&fw==EnumFacing.WEST)||(pos%5==3&&fw==EnumFacing.EAST)?.8125f: (pos%5==1&&fw==EnumFacing.EAST)||(pos%5==3&&fw==EnumFacing.WEST)?.4375f: 1; minZ = (pos%5==1&&fw==EnumFacing.SOUTH)||(pos%5==3&&fw==EnumFacing.NORTH)?.1875f: (pos%5==1&&fw==EnumFacing.NORTH)||(pos%5==3&&fw==EnumFacing.SOUTH)?.5625f: 0; - maxZ = (pos%5==1&&fw==EnumFacing.NORTH)||(pos%5==3&&fw==EnumFacing.SOUTH)?.8125f: (pos%5==1&&fw==EnumFacing.SOUTH)||(pos%5==3&&fw==EnumFacing.NORTH)?.4375f :1; - list.add(new AxisAlignedBB(minX,minY,minZ, maxX,1,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + maxZ = (pos%5==1&&fw==EnumFacing.NORTH)||(pos%5==3&&fw==EnumFacing.SOUTH)?.8125f: (pos%5==1&&fw==EnumFacing.SOUTH)||(pos%5==3&&fw==EnumFacing.NORTH)?.4375f: 1; + list.add(new AxisAlignedBB(minX, minY, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); return list; } - if((pos>15 && pos<19)||(pos>30 && pos<34)||(pos>25 && pos<29)||(pos>40 && pos<44)) + if((pos > 15&&pos < 19)||(pos > 30&&pos < 34)||(pos > 25&&pos < 29)||(pos > 40&&pos < 44)) { - if(pos%15>9) + if(pos%15 > 9) fl = fl.getOpposite(); List list = new ArrayList(3); float minY = .5f; @@ -229,44 +231,44 @@ public List getAdvancedSelectionBounds() float maxX = (pos%5==1&&fw==EnumFacing.WEST)||(pos%5==3&&fw==EnumFacing.EAST)?.5625f: fl==EnumFacing.WEST?.5625f: 1; float minZ = (pos%5==1&&fw==EnumFacing.SOUTH)||(pos%5==3&&fw==EnumFacing.NORTH)?.4375f: fl==EnumFacing.SOUTH?.4375f: 0; float maxZ = (pos%5==1&&fw==EnumFacing.NORTH)||(pos%5==3&&fw==EnumFacing.SOUTH)?.5625f: fl==EnumFacing.NORTH?.5625f: 1; - if((pos>15 && pos<19) || (pos>25 && pos<29)) - list.add(new AxisAlignedBB(minX,.5f,minZ, maxX,.75f,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + if((pos > 15&&pos < 19)||(pos > 25&&pos < 29)) + list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, .75f, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); else minY = 0; - if(pos/15>9) + if(pos/15 > 9) fl = fl.getOpposite(); minX = (pos%5==1&&fw==EnumFacing.EAST)||(pos%5==3&&fw==EnumFacing.WEST)?.1875f: fl==EnumFacing.EAST?.1875f: fl==EnumFacing.WEST?.5625f: 0; maxX = (pos%5==1&&fw==EnumFacing.WEST)||(pos%5==3&&fw==EnumFacing.EAST)?.8125f: fl==EnumFacing.WEST?.8125f: fl==EnumFacing.EAST?.4375f: 1; minZ = (pos%5==1&&fw==EnumFacing.SOUTH)||(pos%5==3&&fw==EnumFacing.NORTH)?.1875f: fl==EnumFacing.SOUTH?.1875f: fl==EnumFacing.NORTH?.5625f: 0; maxZ = (pos%5==1&&fw==EnumFacing.NORTH)||(pos%5==3&&fw==EnumFacing.SOUTH)?.8125f: fl==EnumFacing.NORTH?.8125f: fl==EnumFacing.SOUTH?.4375f: 1; - list.add(new AxisAlignedBB(minX,minY,minZ, maxX,1,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); - if(pos!=17&&pos!=32 && pos!=27&&pos!=42) + list.add(new AxisAlignedBB(minX, minY, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); + if(pos!=17&&pos!=32&&pos!=27&&pos!=42) { minX = (pos%5==1&&fw==EnumFacing.EAST)||(pos%5==3&&fw==EnumFacing.WEST)?.1875f: fl==EnumFacing.EAST?.4375f: fl==EnumFacing.WEST?0: .5625f; maxX = (pos%5==1&&fw==EnumFacing.WEST)||(pos%5==3&&fw==EnumFacing.EAST)?.8125f: fl==EnumFacing.WEST?.5625f: fl==EnumFacing.EAST?1: .4375f; minZ = (pos%5==1&&fw==EnumFacing.SOUTH)||(pos%5==3&&fw==EnumFacing.NORTH)?.1875f: fl==EnumFacing.SOUTH?.4375f: fl==EnumFacing.NORTH?0: .5625f; maxZ = (pos%5==1&&fw==EnumFacing.NORTH)||(pos%5==3&&fw==EnumFacing.SOUTH)?.8125f: fl==EnumFacing.NORTH?.5625f: fl==EnumFacing.SOUTH?1: .4375f; - list.add(new AxisAlignedBB(minX,minY,minZ, maxX,1,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, minY, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); if(pos%15%10==1) fw = fw.getOpposite(); - if((pos>15 && pos<19) || (pos>25 && pos<29)) + if((pos > 15&&pos < 19)||(pos > 25&&pos < 29)) { minX = fl==EnumFacing.WEST?.5f: fl==EnumFacing.EAST?.25f: fw==EnumFacing.EAST?.5f: .25f; maxX = fl==EnumFacing.EAST?.5f: fl==EnumFacing.WEST?.75f: fw==EnumFacing.EAST?.75f: .5f; minZ = fl==EnumFacing.NORTH?.5f: fl==EnumFacing.SOUTH?.25f: fw==EnumFacing.SOUTH?.5f: .25f; maxZ = fl==EnumFacing.SOUTH?.5f: fl==EnumFacing.NORTH?.75f: fw==EnumFacing.SOUTH?.75f: .5f; - list.add(new AxisAlignedBB(minX,0,minZ, maxX,.5f,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, 0, minZ, maxX, .5f, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); } } return list; } if(pos==1||pos==3||pos==11||pos==13) { - List list = Lists.newArrayList(new AxisAlignedBB(0,0,0, 1,.5f,1).offset(getPos().getX(),getPos().getY(),getPos().getZ())); - if(pos%15>9) + List list = Lists.newArrayList(new AxisAlignedBB(0, 0, 0, 1, .5f, 1).offset(getPos().getX(), getPos().getY(), getPos().getZ())); + if(pos%15 > 9) fl = fl.getOpposite(); if(pos%15%10==1) fw = fw.getOpposite(); @@ -274,18 +276,20 @@ public List getAdvancedSelectionBounds() float maxX = fl==EnumFacing.EAST?.5f: fl==EnumFacing.WEST?.75f: fw==EnumFacing.EAST?.75f: .5f; float minZ = fl==EnumFacing.NORTH?.5f: fl==EnumFacing.SOUTH?.25f: fw==EnumFacing.SOUTH?.5f: .25f; float maxZ = fl==EnumFacing.SOUTH?.5f: fl==EnumFacing.NORTH?.75f: fw==EnumFacing.SOUTH?.75f: .5f; - list.add(new AxisAlignedBB(minX,.5f,minZ, maxX,1,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); return list; } return null; } + @Override public boolean isOverrideBox(AxisAlignedBB box, EntityPlayer player, RayTraceResult mop, ArrayList list) { return false; } + @Override public List getAdvancedColisionBounds() { @@ -296,16 +300,16 @@ public List getAdvancedColisionBounds() public void onEntityCollision(World world, Entity entity) { boolean bpos = pos==16||pos==17||pos==18||pos==21||pos==22||pos==23||pos==26||pos==27||pos==28; - if(bpos && !world.isRemote && entity!=null && !entity.isDead&&!isRSDisabled()) + if(bpos&&!world.isRemote&&entity!=null&&!entity.isDead&&!isRSDisabled()) { TileEntityCrusher master = master(); if(master==null) return; - Vec3d center = new Vec3d(master.getPos()).addVector(.5,.75,.5); - AxisAlignedBB crusherInternal = new AxisAlignedBB(center.x-1.0625,center.y,center.z-1.0625, center.x+1.0625,center.y+1.25,center.z+1.0625); + Vec3d center = new Vec3d(master.getPos()).addVector(.5, .75, .5); + AxisAlignedBB crusherInternal = new AxisAlignedBB(center.x-1.0625, center.y, center.z-1.0625, center.x+1.0625, center.y+1.25, center.z+1.0625); if(!entity.getEntityBoundingBox().intersects(crusherInternal)) return; - if(entity instanceof EntityItem && !((EntityItem)entity).getItem().isEmpty()) + if(entity instanceof EntityItem&&!((EntityItem)entity).getItem().isEmpty()) { ItemStack stack = ((EntityItem)entity).getItem(); if(stack.isEmpty()) @@ -319,14 +323,14 @@ public void onEntityCollision(World world, Entity entity) { master.addProcessToQueue(process, false, true); stack.shrink(displayStack.getCount()); - if(stack.getCount()<=0) + if(stack.getCount() <= 0) entity.setDead(); } } - else if(entity instanceof EntityLivingBase && ( !(entity instanceof EntityPlayer) || !((EntityPlayer)entity).capabilities.disableDamage) ) + else if(entity instanceof EntityLivingBase&&(!(entity instanceof EntityPlayer)||!((EntityPlayer)entity).capabilities.disableDamage)) { int consumed = master.energyStorage.extractEnergy(80, true); - if(consumed>0) + if(consumed > 0) { master.energyStorage.extractEnergy(consumed, false); EventHandler.crusherMap.put(entity.getUniqueID(), master); @@ -341,6 +345,7 @@ public int[] getEnergyPos() { return new int[]{20}; } + @Override public int[] getRedstonePos() { @@ -352,39 +357,46 @@ public boolean isInWorldProcessingMachine() { return true; } + @Override public boolean additionalCanProcessCheck(MultiblockProcess process) { return true; } + @Override public void doProcessOutput(ItemStack output) { - BlockPos pos = getPos().add(0,-1,0).offset(facing,-2); + BlockPos pos = getPos().add(0, -1, 0).offset(facing, -2); TileEntity inventoryTile = this.world.getTileEntity(pos); if(inventoryTile!=null) output = Utils.insertStackIntoInventory(inventoryTile, output, facing); if(!output.isEmpty()) Utils.dropStackAtPos(world, pos, output, facing.getOpposite()); } + @Override public void doProcessFluidOutput(FluidStack output) { } + @Override public void onProcessFinish(MultiblockProcess process) { } + @Override public int getMaxProcessPerTick() { return 1; } + @Override public int getProcessQueueMaxLength() { return 2048; } + @Override public float getMinProcessDistance(MultiblockProcess process) { @@ -395,21 +407,22 @@ public float getMinProcessDistance(MultiblockProcess process) public int[] getCurrentProcessesStep() { TileEntityCrusher master = master(); - if(master!=this && master!=null) + if(master!=this&&master!=null) return master.getCurrentProcessesStep(); - int[] ia = new int[processQueue.size()>0?1:0]; - for(int i=0; i 0?1: 0]; + for(int i = 0; i < ia.length; i++) ia[i] = processQueue.get(i).processTick; return ia; } + @Override public int[] getCurrentProcessesMax() { TileEntityCrusher master = master(); - if(master!=this && master!=null) + if(master!=this&&master!=null) return master.getCurrentProcessesMax(); - int[] ia = new int[processQueue.size()>0?1:0]; - for(int i=0; i 0?1: 0]; + for(int i = 0; i < ia.length; i++) ia[i] = processQueue.get(i).maxTicks; return ia; } @@ -419,46 +432,55 @@ public NonNullList getInventory() { return null; } + @Override public boolean isStackValid(int slot, ItemStack stack) { return false; } + @Override public int getSlotLimit(int slot) { return 0; } + @Override public int[] getOutputSlots() { return null; } + @Override public int[] getOutputTanks() { return null; } + @Override public IFluidTank[] getInternalTanks() { return null; } + @Override protected IFluidTank[] getAccessibleFluidTanks(EnumFacing side) { return new IFluidTank[0]; } + @Override protected boolean canFillTankFrom(int iTank, EnumFacing side, FluidStack resources) { return false; } + @Override protected boolean canDrainTankFrom(int iTank, EnumFacing side) { return false; } + @Override public void doGraphicalUpdates(int slot) { @@ -468,15 +490,17 @@ public void doGraphicalUpdates(int slot) @Override public boolean hasCapability(Capability capability, EnumFacing facing) { - if(pos>30&&pos<44 && pos%5>0&&pos%5<4 && capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) + if(pos > 30&&pos < 44&&pos%5 > 0&&pos%5 < 4&&capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return master()!=null; return super.hasCapability(capability, facing); } + IItemHandler insertionHandler = new MultiblockInventoryHandler_DirectProcessing(this).setProcessStacking(true); + @Override public T getCapability(Capability capability, EnumFacing facing) { - if(pos>30&&pos<44 && pos%5>0&&pos%5<4 && capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) + if(pos > 30&&pos < 44&&pos%5 > 0&&pos%5 < 4&&capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { TileEntityCrusher master = master(); if(master!=null) @@ -491,6 +515,7 @@ public CrusherRecipe findRecipeForInsertion(ItemStack inserting) { return CrusherRecipe.findRecipe(inserting); } + @Override protected CrusherRecipe readRecipeFromNBT(NBTTagCompound tag) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityDieselGenerator.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityDieselGenerator.java index 7567c6541f..dd8dada05c 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityDieselGenerator.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityDieselGenerator.java @@ -38,21 +38,21 @@ import java.util.ArrayList; import java.util.List; -public class TileEntityDieselGenerator extends TileEntityMultiblockMetal - implements IAdvancedSelectionBounds,IAdvancedCollisionBounds, IGuiTile, ISoundTile, IFaceShape +public class TileEntityDieselGenerator extends TileEntityMultiblockMetal + implements IAdvancedSelectionBounds, IAdvancedCollisionBounds, IGuiTile, ISoundTile, IFaceShape { public TileEntityDieselGenerator() { - super(MultiblockDieselGenerator.instance, new int[]{3,5,3}, 0, true); + super(MultiblockDieselGenerator.instance, new int[]{3, 5, 3}, 0, true); } public FluidTank[] tanks = new FluidTank[]{new FluidTank(24000)}; public boolean active = false; - public float animation_fanRotationStep=0; - public float animation_fanRotation=0; - public int animation_fanFadeIn=0; - public int animation_fanFadeOut=0; + public float animation_fanRotationStep = 0; + public float animation_fanRotation = 0; + public int animation_fanFadeIn = 0; + public int animation_fanFadeOut = 0; @Override public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) @@ -64,6 +64,7 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) animation_fanFadeIn = nbt.getInteger("animation_fanFadeIn"); animation_fanFadeOut = nbt.getInteger("animation_fanFadeOut"); } + @Override public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { @@ -82,16 +83,16 @@ public void update() if(isDummy()) return; - if(active || animation_fanFadeIn>0 || animation_fanFadeOut>0) + if(active||animation_fanFadeIn > 0||animation_fanFadeOut > 0) { float base = 18f; - float step = active?base:0; - if(animation_fanFadeIn>0) + float step = active?base: 0; + if(animation_fanFadeIn > 0) { step -= (animation_fanFadeIn/80f)*base; animation_fanFadeIn--; } - if(animation_fanFadeOut>0) + if(animation_fanFadeOut > 0) { step += (animation_fanFadeOut/80f)*base; animation_fanFadeOut--; @@ -103,40 +104,40 @@ public void update() if(world.isRemote) { - ImmersiveEngineering.proxy.handleTileSound(IESounds.dieselGenerator, this, active, .5f,1); - if(active && world.getTotalWorldTime()%4==0) + ImmersiveEngineering.proxy.handleTileSound(IESounds.dieselGenerator, this, active, .5f, 1); + if(active&&world.getTotalWorldTime()%4==0) { BlockPos exhaust = this.getBlockPosForPos(38); EnumFacing fl = facing; EnumFacing fw = facing.rotateY(); if(mirrored) fw = fw.getOpposite(); - world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, exhaust.getX()+.5+(fl.getFrontOffsetX()*.3125f)+(-fw.getFrontOffsetX()*.3125f), exhaust.getY()+1.25, exhaust.getZ()+.5+(fl.getFrontOffsetZ()*.3125f)+(-fw.getFrontOffsetZ()*.3125f), 0,0,0); + world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, exhaust.getX()+.5+(fl.getFrontOffsetX()*.3125f)+(-fw.getFrontOffsetX()*.3125f), exhaust.getY()+1.25, exhaust.getZ()+.5+(fl.getFrontOffsetZ()*.3125f)+(-fw.getFrontOffsetZ()*.3125f), 0, 0, 0); } } else { boolean prevActive = active; - if(!isRSDisabled() && tanks[0].getFluid()!=null && tanks[0].getFluid().getFluid()!=null) + if(!isRSDisabled()&&tanks[0].getFluid()!=null&&tanks[0].getFluid().getFluid()!=null) { int burnTime = DieselHandler.getBurnTime(tanks[0].getFluid().getFluid()); if(burnTime > 0) { - int fluidConsumed = 1000 / burnTime; + int fluidConsumed = 1000/burnTime; int output = IEConfig.Machines.dieselGen_output; int connected = 0; TileEntity[] receivers = new TileEntity[3]; for(int i = 0; i < 3; i++) { - receivers[i] = getEnergyOutput(i == 1 ? -1 : i == 2 ? 1 : 0); - if(receivers[i] != null) + receivers[i] = getEnergyOutput(i==1?-1: i==2?1: 0); + if(receivers[i]!=null) { - if(EnergyHelper.insertFlux(receivers[i], EnumFacing.DOWN, 4096, true)>0) + if(EnergyHelper.insertFlux(receivers[i], EnumFacing.DOWN, 4096, true) > 0) connected++; } } - if(connected > 0 && tanks[0].getFluidAmount() >= fluidConsumed) + if(connected > 0&&tanks[0].getFluidAmount() >= fluidConsumed) { if(!active) { @@ -144,12 +145,13 @@ public void update() animation_fanFadeIn = 80; } tanks[0].drain(fluidConsumed, true); - int splitOutput = output / connected; - int leftover = output % connected; + int splitOutput = output/connected; + int leftover = output%connected; for(int i = 0; i < 3; i++) - if(receivers[i] != null) - EnergyHelper.insertFlux(receivers[i], EnumFacing.DOWN, splitOutput + (leftover-- > 0 ? 1 : 0), false); - } else if(active) + if(receivers[i]!=null) + EnergyHelper.insertFlux(receivers[i], EnumFacing.DOWN, splitOutput+(leftover-- > 0?1: 0), false); + } + else if(active) { active = false; animation_fanFadeOut = 80; @@ -158,23 +160,24 @@ public void update() } else if(active) { - active=false; - animation_fanFadeOut=80; + active = false; + animation_fanFadeOut = 80; } - if(prevActive != active) + if(prevActive!=active) { this.markDirty(); this.markContainingBlockForUpdate(null); } } } + @Nullable TileEntity getEnergyOutput(int w) { - BlockPos outPos = this.getBlockPosForPos(16 + w).add(0, 1, 0); + BlockPos outPos = this.getBlockPosForPos(16+w).add(0, 1, 0); TileEntity eTile = Utils.getExistingTileEntity(world, outPos); - if (EnergyHelper.isFluxReceiver(eTile, EnumFacing.DOWN)) + if(EnergyHelper.isFluxReceiver(eTile, EnumFacing.DOWN)) return eTile; return null; } @@ -188,43 +191,44 @@ public float[] getBlockBounds() fw = fw.getOpposite(); if(pos==1) - return new float[]{fl==EnumFacing.WEST?-.625f:0,.5f,fl==EnumFacing.NORTH?-.625f:0, fl==EnumFacing.EAST?1.375f:1,1.5f,fl==EnumFacing.SOUTH?1.375f:1}; + return new float[]{fl==EnumFacing.WEST?-.625f: 0, .5f, fl==EnumFacing.NORTH?-.625f: 0, fl==EnumFacing.EAST?1.375f: 1, 1.5f, fl==EnumFacing.SOUTH?1.375f: 1}; if(pos==0||pos==29||pos==44) - return new float[]{fw==EnumFacing.WEST?.5f:(pos%15>11&&fl==EnumFacing.EAST)?-.125f:0,0,fw==EnumFacing.NORTH?.5f:(pos%15>11&&fl==EnumFacing.SOUTH)?-.125f:0, fw==EnumFacing.EAST?.5f:(pos%15>11&&fl==EnumFacing.WEST)?1.125f:1,pos>30?.8125f:1,fw==EnumFacing.SOUTH?.5f:(pos%15>11&&fl==EnumFacing.NORTH)?1.125f:1}; + return new float[]{fw==EnumFacing.WEST?.5f: (pos%15 > 11&&fl==EnumFacing.EAST)?-.125f: 0, 0, fw==EnumFacing.NORTH?.5f: (pos%15 > 11&&fl==EnumFacing.SOUTH)?-.125f: 0, fw==EnumFacing.EAST?.5f: (pos%15 > 11&&fl==EnumFacing.WEST)?1.125f: 1, pos > 30?.8125f: 1, fw==EnumFacing.SOUTH?.5f: (pos%15 > 11&&fl==EnumFacing.NORTH)?1.125f: 1}; if(pos==2||pos==27||pos==42) - return new float[]{fw==EnumFacing.EAST?.5f:(pos%15>11&&fl==EnumFacing.EAST)?-.125f:0,0,fw==EnumFacing.SOUTH?.5f:(pos%15>11&&fl==EnumFacing.SOUTH)?-.125f:0, fw==EnumFacing.WEST?.5f:(pos%15>11&&fl==EnumFacing.WEST)?1.125f:1,pos>30?.8125f:1,fw==EnumFacing.NORTH?.5f:(pos%15>11&&fl==EnumFacing.NORTH)?1.125f:1}; + return new float[]{fw==EnumFacing.EAST?.5f: (pos%15 > 11&&fl==EnumFacing.EAST)?-.125f: 0, 0, fw==EnumFacing.SOUTH?.5f: (pos%15 > 11&&fl==EnumFacing.SOUTH)?-.125f: 0, fw==EnumFacing.WEST?.5f: (pos%15 > 11&&fl==EnumFacing.WEST)?1.125f: 1, pos > 30?.8125f: 1, fw==EnumFacing.NORTH?.5f: (pos%15 > 11&&fl==EnumFacing.NORTH)?1.125f: 1}; if(pos==43) - return new float[]{pos%15>11&&fl==EnumFacing.EAST?.375f:0,0,pos%15>11&&fl==EnumFacing.SOUTH?.375f:0, pos%15>11&&fl==EnumFacing.WEST?.625f:1,pos>30?.8125f:1,pos%15>11&&fl==EnumFacing.NORTH?.625f:1}; + return new float[]{pos%15 > 11&&fl==EnumFacing.EAST?.375f: 0, 0, pos%15 > 11&&fl==EnumFacing.SOUTH?.375f: 0, pos%15 > 11&&fl==EnumFacing.WEST?.625f: 1, pos > 30?.8125f: 1, pos%15 > 11&&fl==EnumFacing.NORTH?.625f: 1}; - if(pos>=15&&pos<=17) - return new float[]{0,.5f,0, 1,1,1}; + if(pos >= 15&&pos <= 17) + return new float[]{0, .5f, 0, 1, 1, 1}; if(pos==19||pos==34) - return new float[]{fl==EnumFacing.EAST?.375f:fl.getAxis()==Axis.Z?.0625f:0,0,fl==EnumFacing.SOUTH?.375f:fl.getAxis()==Axis.X?.0625f:0, fl==EnumFacing.WEST?.625f:fl.getAxis()==Axis.Z?.9375f:1,pos>30?.3125f:1,fl==EnumFacing.NORTH?.625f:fl.getAxis()==Axis.X?.9375f:1}; + return new float[]{fl==EnumFacing.EAST?.375f: fl.getAxis()==Axis.Z?.0625f: 0, 0, fl==EnumFacing.SOUTH?.375f: fl.getAxis()==Axis.X?.0625f: 0, fl==EnumFacing.WEST?.625f: fl.getAxis()==Axis.Z?.9375f: 1, pos > 30?.3125f: 1, fl==EnumFacing.NORTH?.625f: fl.getAxis()==Axis.X?.9375f: 1}; if(pos==37||pos==40) - return new float[]{fl.getAxis()==Axis.Z?.0625f:0,0,fl.getAxis()==Axis.X?.0625f:0, fl.getAxis()==Axis.Z?.9375f:1,.3125f,fl.getAxis()==Axis.X?.9375f:1}; + return new float[]{fl.getAxis()==Axis.Z?.0625f: 0, 0, fl.getAxis()==Axis.X?.0625f: 0, fl.getAxis()==Axis.Z?.9375f: 1, .3125f, fl.getAxis()==Axis.X?.9375f: 1}; - if(pos<15&&pos%3!=1) - return new float[]{0,0,0, 1,.5f,1}; + if(pos < 15&&pos%3!=1) + return new float[]{0, 0, 0, 1, .5f, 1}; - if(pos<30&&pos%3==0) - return new float[]{fw==EnumFacing.EAST?.9375f:(pos<21&&fl==EnumFacing.EAST)?.375f:0,-.5f,fw==EnumFacing.SOUTH?.9375f:(pos<21&&fl==EnumFacing.SOUTH)?.375f:0, fw==EnumFacing.WEST?.0625f:(pos<21&&fl==EnumFacing.WEST)?.625f:1,.625f,fw==EnumFacing.NORTH?.0625f:(pos<21&&fl==EnumFacing.NORTH)?.625f:1}; - if(pos<30&&pos%3==2) - return new float[]{fw==EnumFacing.WEST?.9375f:(pos<21&&fl==EnumFacing.EAST)?.375f:0,-.5f,fw==EnumFacing.NORTH?.9375f:(pos<21&&fl==EnumFacing.SOUTH)?.375f:0, fw==EnumFacing.EAST?.0625f:(pos<21&&fl==EnumFacing.WEST)?.625f:1,.625f,fw==EnumFacing.SOUTH?.0625f:(pos<21&&fl==EnumFacing.NORTH)?.625f:1}; + if(pos < 30&&pos%3==0) + return new float[]{fw==EnumFacing.EAST?.9375f: (pos < 21&&fl==EnumFacing.EAST)?.375f: 0, -.5f, fw==EnumFacing.SOUTH?.9375f: (pos < 21&&fl==EnumFacing.SOUTH)?.375f: 0, fw==EnumFacing.WEST?.0625f: (pos < 21&&fl==EnumFacing.WEST)?.625f: 1, .625f, fw==EnumFacing.NORTH?.0625f: (pos < 21&&fl==EnumFacing.NORTH)?.625f: 1}; + if(pos < 30&&pos%3==2) + return new float[]{fw==EnumFacing.WEST?.9375f: (pos < 21&&fl==EnumFacing.EAST)?.375f: 0, -.5f, fw==EnumFacing.NORTH?.9375f: (pos < 21&&fl==EnumFacing.SOUTH)?.375f: 0, fw==EnumFacing.EAST?.0625f: (pos < 21&&fl==EnumFacing.WEST)?.625f: 1, .625f, fw==EnumFacing.SOUTH?.0625f: (pos < 21&&fl==EnumFacing.NORTH)?.625f: 1}; - if(pos==36 || pos==38) + if(pos==36||pos==38) { if(pos==38) fw = fw.getOpposite(); - float minX = fl==EnumFacing.WEST?-.0625f:fl==EnumFacing.EAST?.5625f: fw==EnumFacing.WEST?-.0625f: .5625f; - float maxX = fl==EnumFacing.WEST?.4375f:fl==EnumFacing.EAST?1.0625f: fw==EnumFacing.WEST?.4375f: 1.0625f; - float minZ = fl==EnumFacing.NORTH?-.0625f:fl==EnumFacing.SOUTH?.5625f: fw==EnumFacing.NORTH?-.0625f: .5625f; - float maxZ = fl==EnumFacing.NORTH?.4375f:fl==EnumFacing.SOUTH?1.0625f: fw==EnumFacing.NORTH?.4375f: 1.0625f; - return new float[]{minX,0,minZ, maxX,pos==38?1.125f:.75f,maxZ}; + float minX = fl==EnumFacing.WEST?-.0625f: fl==EnumFacing.EAST?.5625f: fw==EnumFacing.WEST?-.0625f: .5625f; + float maxX = fl==EnumFacing.WEST?.4375f: fl==EnumFacing.EAST?1.0625f: fw==EnumFacing.WEST?.4375f: 1.0625f; + float minZ = fl==EnumFacing.NORTH?-.0625f: fl==EnumFacing.SOUTH?.5625f: fw==EnumFacing.NORTH?-.0625f: .5625f; + float maxZ = fl==EnumFacing.NORTH?.4375f: fl==EnumFacing.SOUTH?1.0625f: fw==EnumFacing.NORTH?.4375f: 1.0625f; + return new float[]{minX, 0, minZ, maxX, pos==38?1.125f: .75f, maxZ}; } - return new float[]{0,0,0, 1,1,1}; + return new float[]{0, 0, 0, 1, 1, 1}; } + @Override public List getAdvancedSelectionBounds() { @@ -235,16 +239,16 @@ public List getAdvancedSelectionBounds() if(pos==16) { - return Lists.newArrayList(new AxisAlignedBB(0,.5f,0, 1,1,1).offset(getPos().getX(),getPos().getY(),getPos().getZ()), - new AxisAlignedBB(fl==EnumFacing.WEST?-.625f:0,-.5f,fl==EnumFacing.NORTH?-.625f:0, fl==EnumFacing.EAST?1.375f:1,.5f,fl==EnumFacing.SOUTH?1.375f:1).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + return Lists.newArrayList(new AxisAlignedBB(0, .5f, 0, 1, 1, 1).offset(getPos().getX(), getPos().getY(), getPos().getZ()), + new AxisAlignedBB(fl==EnumFacing.WEST?-.625f: 0, -.5f, fl==EnumFacing.NORTH?-.625f: 0, fl==EnumFacing.EAST?1.375f: 1, .5f, fl==EnumFacing.SOUTH?1.375f: 1).offset(getPos().getX(), getPos().getY(), getPos().getZ())); } if(pos==15||pos==17) { - List list = Lists.newArrayList(new AxisAlignedBB(0,.5f,0, 1,1,1).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + List list = Lists.newArrayList(new AxisAlignedBB(0, .5f, 0, 1, 1, 1).offset(getPos().getX(), getPos().getY(), getPos().getZ())); if(pos==17) fw = fw.getOpposite(); - list.add(new AxisAlignedBB(fw==EnumFacing.EAST?.125f:fw==EnumFacing.WEST?.625f:.125f,0,fw==EnumFacing.SOUTH?.125f:fw==EnumFacing.NORTH?.625f:.125f, fw==EnumFacing.EAST?.375f:fw==EnumFacing.WEST?.875f:.375f,.5f,fw==EnumFacing.SOUTH?.375f:fw==EnumFacing.NORTH?.875f:.375f).offset(getPos().getX(),getPos().getY(),getPos().getZ())); - list.add(new AxisAlignedBB(fw==EnumFacing.EAST?.125f:fw==EnumFacing.WEST?.625f:.625f,0,fw==EnumFacing.SOUTH?.125f:fw==EnumFacing.NORTH?.625f:.625f, fw==EnumFacing.EAST?.375f:fw==EnumFacing.WEST?.875f:.875f,.5f,fw==EnumFacing.SOUTH?.375f:fw==EnumFacing.NORTH?.875f:.875f).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(fw==EnumFacing.EAST?.125f: fw==EnumFacing.WEST?.625f: .125f, 0, fw==EnumFacing.SOUTH?.125f: fw==EnumFacing.NORTH?.625f: .125f, fw==EnumFacing.EAST?.375f: fw==EnumFacing.WEST?.875f: .375f, .5f, fw==EnumFacing.SOUTH?.375f: fw==EnumFacing.NORTH?.875f: .375f).offset(getPos().getX(), getPos().getY(), getPos().getZ())); + list.add(new AxisAlignedBB(fw==EnumFacing.EAST?.125f: fw==EnumFacing.WEST?.625f: .625f, 0, fw==EnumFacing.SOUTH?.125f: fw==EnumFacing.NORTH?.625f: .625f, fw==EnumFacing.EAST?.375f: fw==EnumFacing.WEST?.875f: .875f, .5f, fw==EnumFacing.SOUTH?.375f: fw==EnumFacing.NORTH?.875f: .875f).offset(getPos().getX(), getPos().getY(), getPos().getZ())); return list; } @@ -252,68 +256,70 @@ public List getAdvancedSelectionBounds() if(pos==23) { float[] defaultBounds = this.getBlockBounds(); - List list = Lists.newArrayList(new AxisAlignedBB(defaultBounds[0],defaultBounds[1],defaultBounds[2],defaultBounds[3],defaultBounds[4],defaultBounds[5]).offset(getPos().getX(),getPos().getY(),getPos().getZ())); - list.add(new AxisAlignedBB(fw==EnumFacing.EAST?.5f:fw==EnumFacing.WEST?0:.3125f,.25f,fw==EnumFacing.SOUTH?.5f:fw==EnumFacing.NORTH?0:.3125f, fw==EnumFacing.EAST?1:fw==EnumFacing.WEST?.5f:.6875f,.75f,fw==EnumFacing.SOUTH?1:fw==EnumFacing.NORTH?.5f:.6875f).offset(getPos().getX(),getPos().getY(),getPos().getZ())); - list.add(new AxisAlignedBB(fw==EnumFacing.EAST?.6875f:fw==EnumFacing.WEST?.1875f:.4375f,-.5f,fw==EnumFacing.SOUTH?.6875f:fw==EnumFacing.NORTH?.1875f:.4375f, fw==EnumFacing.EAST?.8125f:fw==EnumFacing.WEST?.3125f:.5625f,.25f,fw==EnumFacing.SOUTH?.8125f:fw==EnumFacing.NORTH?.3125f:.5625f).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + List list = Lists.newArrayList(new AxisAlignedBB(defaultBounds[0], defaultBounds[1], defaultBounds[2], defaultBounds[3], defaultBounds[4], defaultBounds[5]).offset(getPos().getX(), getPos().getY(), getPos().getZ())); + list.add(new AxisAlignedBB(fw==EnumFacing.EAST?.5f: fw==EnumFacing.WEST?0: .3125f, .25f, fw==EnumFacing.SOUTH?.5f: fw==EnumFacing.NORTH?0: .3125f, fw==EnumFacing.EAST?1: fw==EnumFacing.WEST?.5f: .6875f, .75f, fw==EnumFacing.SOUTH?1: fw==EnumFacing.NORTH?.5f: .6875f).offset(getPos().getX(), getPos().getY(), getPos().getZ())); + list.add(new AxisAlignedBB(fw==EnumFacing.EAST?.6875f: fw==EnumFacing.WEST?.1875f: .4375f, -.5f, fw==EnumFacing.SOUTH?.6875f: fw==EnumFacing.NORTH?.1875f: .4375f, fw==EnumFacing.EAST?.8125f: fw==EnumFacing.WEST?.3125f: .5625f, .25f, fw==EnumFacing.SOUTH?.8125f: fw==EnumFacing.NORTH?.3125f: .5625f).offset(getPos().getX(), getPos().getY(), getPos().getZ())); return list; } - if(pos>2&&pos<15&&pos%3!=1) + if(pos > 2&&pos < 15&&pos%3!=1) { float[] defaultBounds = this.getBlockBounds(); - List list = Lists.newArrayList(new AxisAlignedBB(defaultBounds[0],defaultBounds[1],defaultBounds[2],defaultBounds[3],defaultBounds[4],defaultBounds[5]).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + List list = Lists.newArrayList(new AxisAlignedBB(defaultBounds[0], defaultBounds[1], defaultBounds[2], defaultBounds[3], defaultBounds[4], defaultBounds[5]).offset(getPos().getX(), getPos().getY(), getPos().getZ())); if(pos%3==2) fw = fw.getOpposite(); - if(pos<6) + if(pos < 6) { - float minX = fw==EnumFacing.WEST?0:fw==EnumFacing.EAST?.125f: fl==EnumFacing.WEST?.25f: .5f; - float maxX = fw==EnumFacing.WEST?.875f:fw==EnumFacing.EAST?1: fl==EnumFacing.EAST?.75f: .5f; + float minX = fw==EnumFacing.WEST?0: fw==EnumFacing.EAST?.125f: fl==EnumFacing.WEST?.25f: .5f; + float maxX = fw==EnumFacing.WEST?.875f: fw==EnumFacing.EAST?1: fl==EnumFacing.EAST?.75f: .5f; float minZ = fw==EnumFacing.NORTH?0: fw==EnumFacing.SOUTH?.125f: fl==EnumFacing.NORTH?.25f: .5f; float maxZ = fw==EnumFacing.NORTH?.875f: fw==EnumFacing.SOUTH?1: fl==EnumFacing.SOUTH?.75f: .5f; - list.add(new AxisAlignedBB(minX,.5625f,minZ, maxX,.8125f,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, .5625f, minZ, maxX, .8125f, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); - minX = fw==EnumFacing.WEST?.625f:fw==EnumFacing.EAST?.125f: fl==EnumFacing.EAST?0: .5f; - maxX = fw==EnumFacing.WEST?.875f:fw==EnumFacing.EAST?.375f: fl==EnumFacing.WEST?1: .5f; + minX = fw==EnumFacing.WEST?.625f: fw==EnumFacing.EAST?.125f: fl==EnumFacing.EAST?0: .5f; + maxX = fw==EnumFacing.WEST?.875f: fw==EnumFacing.EAST?.375f: fl==EnumFacing.WEST?1: .5f; minZ = fw==EnumFacing.NORTH?.625f: fw==EnumFacing.SOUTH?.125f: fl==EnumFacing.SOUTH?0: .5f; maxZ = fw==EnumFacing.NORTH?.875f: fw==EnumFacing.SOUTH?.375f: fl==EnumFacing.NORTH?1: .5f; - list.add(new AxisAlignedBB(minX,.5625f,minZ, maxX,.8125f,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, .5625f, minZ, maxX, .8125f, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); } - else if(pos<12) + else if(pos < 12) { - float minX = (fw==EnumFacing.WEST?0:fw==EnumFacing.EAST?.4375f: fl==EnumFacing.EAST?.25f: -.5625f) +(pos<=8?0: fl==EnumFacing.WEST?1: fl==EnumFacing.EAST?-1: 0); - float maxX = (fw==EnumFacing.WEST?.5626f:fw==EnumFacing.EAST?1: fl==EnumFacing.WEST?.75f: 1.4375f) +(pos<=8?0: fl==EnumFacing.WEST?1: fl==EnumFacing.EAST?-1: 0); - float minZ = (fw==EnumFacing.NORTH?0: fw==EnumFacing.SOUTH?.4375f: fl==EnumFacing.SOUTH?.25f: -.5625f) +(pos<=8?0: fl==EnumFacing.NORTH?1: fl==EnumFacing.SOUTH?-1: 0); - float maxZ = (fw==EnumFacing.NORTH?.5625f: fw==EnumFacing.SOUTH?1: fl==EnumFacing.NORTH?.75f: 1.4375f) +(pos<=8?0: fl==EnumFacing.NORTH?1: fl==EnumFacing.SOUTH?-1: 0); - list.add(new AxisAlignedBB(minX,.5f,minZ, maxX,1,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + float minX = (fw==EnumFacing.WEST?0: fw==EnumFacing.EAST?.4375f: fl==EnumFacing.EAST?.25f: -.5625f)+(pos <= 8?0: fl==EnumFacing.WEST?1: fl==EnumFacing.EAST?-1: 0); + float maxX = (fw==EnumFacing.WEST?.5626f: fw==EnumFacing.EAST?1: fl==EnumFacing.WEST?.75f: 1.4375f)+(pos <= 8?0: fl==EnumFacing.WEST?1: fl==EnumFacing.EAST?-1: 0); + float minZ = (fw==EnumFacing.NORTH?0: fw==EnumFacing.SOUTH?.4375f: fl==EnumFacing.SOUTH?.25f: -.5625f)+(pos <= 8?0: fl==EnumFacing.NORTH?1: fl==EnumFacing.SOUTH?-1: 0); + float maxZ = (fw==EnumFacing.NORTH?.5625f: fw==EnumFacing.SOUTH?1: fl==EnumFacing.NORTH?.75f: 1.4375f)+(pos <= 8?0: fl==EnumFacing.NORTH?1: fl==EnumFacing.SOUTH?-1: 0); + list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); } - if(pos>8) + if(pos > 8) { - float minX = (fw==EnumFacing.WEST?.5625f:fw==EnumFacing.EAST?.375f: fl==EnumFacing.WEST?.5625f: .1875f) +(pos<=11?0:fl==EnumFacing.WEST?1: fl==EnumFacing.EAST?-1: 0); - float maxX = (fw==EnumFacing.WEST?.625f:fw==EnumFacing.EAST?.4375f: fl==EnumFacing.EAST?.4375f: .8125f) +(pos<=11?0:fl==EnumFacing.WEST?1: fl==EnumFacing.EAST?-1: 0); - float minZ = (fw==EnumFacing.NORTH?.5625f: fw==EnumFacing.SOUTH?.375f: fl==EnumFacing.NORTH?.5625f: .1875f) +(pos<=11?0:fl==EnumFacing.NORTH?1: fl==EnumFacing.SOUTH?-1: 0); - float maxZ = (fw==EnumFacing.NORTH?.625f: fw==EnumFacing.SOUTH?.4375f: fl==EnumFacing.SOUTH?.4375f: .8125f) +(pos<=11?0:fl==EnumFacing.NORTH?1: fl==EnumFacing.SOUTH?-1: 0); - list.add(new AxisAlignedBB(minX,.5625f,minZ, maxX,.8125f,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); - minX = (fw==EnumFacing.WEST?.5f:fw==EnumFacing.EAST?.375f: fl==EnumFacing.WEST?-.875f: 1.625f) +(pos<=11?0:fl==EnumFacing.WEST?1: fl==EnumFacing.EAST?-1: 0); - maxX = (fw==EnumFacing.WEST?.625f:fw==EnumFacing.EAST?.5f: fl==EnumFacing.EAST?1.875f: -.625f) +(pos<=11?0:fl==EnumFacing.WEST?1: fl==EnumFacing.EAST?-1: 0); - minZ = (fw==EnumFacing.NORTH?.5f: fw==EnumFacing.SOUTH?.375f: fl==EnumFacing.NORTH?-.875f: 1.625f) +(pos<=11?0:fl==EnumFacing.NORTH?1: fl==EnumFacing.SOUTH?-1: 0); - maxZ = (fw==EnumFacing.NORTH?.625f: fw==EnumFacing.SOUTH?.5f: fl==EnumFacing.SOUTH?1.875f: -.625f) +(pos<=11?0:fl==EnumFacing.NORTH?1: fl==EnumFacing.SOUTH?-1: 0); - list.add(new AxisAlignedBB(minX,.5625f,minZ, maxX,.8125f,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); - minX = (fw==EnumFacing.WEST?.625f:fw==EnumFacing.EAST?.125f: fl==EnumFacing.EAST?.1875f: -.875f) +(pos<=11?0:fl==EnumFacing.WEST?1: fl==EnumFacing.EAST?-1: 0); - maxX = (fw==EnumFacing.WEST?.875f:fw==EnumFacing.EAST?.375f: fl==EnumFacing.WEST?.8125f: 1.875f) +(pos<=11?0:fl==EnumFacing.WEST?1: fl==EnumFacing.EAST?-1: 0); - minZ = (fw==EnumFacing.NORTH?.625f: fw==EnumFacing.SOUTH?.125f: fl==EnumFacing.SOUTH?.1875f: -.875f) +(pos<=11?0:fl==EnumFacing.NORTH?1: fl==EnumFacing.SOUTH?-1: 0); - maxZ = (fw==EnumFacing.NORTH?.875f: fw==EnumFacing.SOUTH?.375f: fl==EnumFacing.NORTH?.8125f: 1.875f) +(pos<=11?0:fl==EnumFacing.NORTH?1: fl==EnumFacing.SOUTH?-1: 0); - list.add(new AxisAlignedBB(minX,.5625f,minZ, maxX,.8125f,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + float minX = (fw==EnumFacing.WEST?.5625f: fw==EnumFacing.EAST?.375f: fl==EnumFacing.WEST?.5625f: .1875f)+(pos <= 11?0: fl==EnumFacing.WEST?1: fl==EnumFacing.EAST?-1: 0); + float maxX = (fw==EnumFacing.WEST?.625f: fw==EnumFacing.EAST?.4375f: fl==EnumFacing.EAST?.4375f: .8125f)+(pos <= 11?0: fl==EnumFacing.WEST?1: fl==EnumFacing.EAST?-1: 0); + float minZ = (fw==EnumFacing.NORTH?.5625f: fw==EnumFacing.SOUTH?.375f: fl==EnumFacing.NORTH?.5625f: .1875f)+(pos <= 11?0: fl==EnumFacing.NORTH?1: fl==EnumFacing.SOUTH?-1: 0); + float maxZ = (fw==EnumFacing.NORTH?.625f: fw==EnumFacing.SOUTH?.4375f: fl==EnumFacing.SOUTH?.4375f: .8125f)+(pos <= 11?0: fl==EnumFacing.NORTH?1: fl==EnumFacing.SOUTH?-1: 0); + list.add(new AxisAlignedBB(minX, .5625f, minZ, maxX, .8125f, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); + minX = (fw==EnumFacing.WEST?.5f: fw==EnumFacing.EAST?.375f: fl==EnumFacing.WEST?-.875f: 1.625f)+(pos <= 11?0: fl==EnumFacing.WEST?1: fl==EnumFacing.EAST?-1: 0); + maxX = (fw==EnumFacing.WEST?.625f: fw==EnumFacing.EAST?.5f: fl==EnumFacing.EAST?1.875f: -.625f)+(pos <= 11?0: fl==EnumFacing.WEST?1: fl==EnumFacing.EAST?-1: 0); + minZ = (fw==EnumFacing.NORTH?.5f: fw==EnumFacing.SOUTH?.375f: fl==EnumFacing.NORTH?-.875f: 1.625f)+(pos <= 11?0: fl==EnumFacing.NORTH?1: fl==EnumFacing.SOUTH?-1: 0); + maxZ = (fw==EnumFacing.NORTH?.625f: fw==EnumFacing.SOUTH?.5f: fl==EnumFacing.SOUTH?1.875f: -.625f)+(pos <= 11?0: fl==EnumFacing.NORTH?1: fl==EnumFacing.SOUTH?-1: 0); + list.add(new AxisAlignedBB(minX, .5625f, minZ, maxX, .8125f, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); + minX = (fw==EnumFacing.WEST?.625f: fw==EnumFacing.EAST?.125f: fl==EnumFacing.EAST?.1875f: -.875f)+(pos <= 11?0: fl==EnumFacing.WEST?1: fl==EnumFacing.EAST?-1: 0); + maxX = (fw==EnumFacing.WEST?.875f: fw==EnumFacing.EAST?.375f: fl==EnumFacing.WEST?.8125f: 1.875f)+(pos <= 11?0: fl==EnumFacing.WEST?1: fl==EnumFacing.EAST?-1: 0); + minZ = (fw==EnumFacing.NORTH?.625f: fw==EnumFacing.SOUTH?.125f: fl==EnumFacing.SOUTH?.1875f: -.875f)+(pos <= 11?0: fl==EnumFacing.NORTH?1: fl==EnumFacing.SOUTH?-1: 0); + maxZ = (fw==EnumFacing.NORTH?.875f: fw==EnumFacing.SOUTH?.375f: fl==EnumFacing.NORTH?.8125f: 1.875f)+(pos <= 11?0: fl==EnumFacing.NORTH?1: fl==EnumFacing.SOUTH?-1: 0); + list.add(new AxisAlignedBB(minX, .5625f, minZ, maxX, .8125f, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); } return list; } return null; } + @Override public boolean isOverrideBox(AxisAlignedBB box, EntityPlayer player, RayTraceResult mop, ArrayList list) { return false; } + @Override public List getAdvancedColisionBounds() { @@ -323,8 +329,9 @@ public List getAdvancedColisionBounds() @Override public int[] getEnergyPos() { - return new int[]{15,16,17}; + return new int[]{15, 16, 17}; } + @Override public int[] getRedstonePos() { @@ -336,33 +343,40 @@ public boolean isInWorldProcessingMachine() { return false; } + @Override public boolean additionalCanProcessCheck(MultiblockProcess process) { return false; } + @Override public void doProcessOutput(ItemStack output) { } + @Override public void doProcessFluidOutput(FluidStack output) { } + @Override public void onProcessFinish(MultiblockProcess process) { } + @Override public int getMaxProcessPerTick() { return 0; } + @Override public int getProcessQueueMaxLength() { return 0; } + @Override public float getMinProcessDistance(MultiblockProcess process) { @@ -375,51 +389,60 @@ public NonNullList getInventory() { return null; } + @Override public boolean isStackValid(int slot, ItemStack stack) { return false; } + @Override public int getSlotLimit(int slot) { return 0; } + @Override public int[] getOutputSlots() { return new int[0]; } + @Override public int[] getOutputTanks() { return new int[0]; } + @Override public IFluidTank[] getInternalTanks() { return tanks; } + @Override protected IFluidTank[] getAccessibleFluidTanks(EnumFacing side) { TileEntityDieselGenerator master = master(); - if(master != null && (pos == 0 || pos == 2) && (side == null || side.getAxis() == facing.rotateYCCW().getAxis())) + if(master!=null&&(pos==0||pos==2)&&(side==null||side.getAxis()==facing.rotateYCCW().getAxis())) return master.tanks; return new FluidTank[0]; } + @Override protected boolean canFillTankFrom(int iTank, EnumFacing side, FluidStack resources) { - if(resources == null) + if(resources==null) return false; return DieselHandler.isValidFuel(resources.getFluid()); } + @Override protected boolean canDrainTankFrom(int iTank, EnumFacing side) { return false; } + @Override public void doGraphicalUpdates(int slot) { @@ -433,21 +456,25 @@ public IMultiblockRecipe findRecipeForInsertion(ItemStack inserting) { return null; } + @Override protected IMultiblockRecipe readRecipeFromNBT(NBTTagCompound tag) { return null; } + @Override public boolean canOpenGui() { return false; } + @Override public int getGuiID() { return -1; } + @Override public TileEntity getGuiMaster() { @@ -464,11 +491,11 @@ public boolean shoudlPlaySound(String sound) public BlockFaceShape getFaceShape(EnumFacing side) { if(pos==0||pos==2) - return side.getAxis()==facing.rotateY().getAxis()?BlockFaceShape.SOLID:BlockFaceShape.UNDEFINED; - else if(pos>=15&&pos<=17) - return side == EnumFacing.UP?BlockFaceShape.SOLID:BlockFaceShape.UNDEFINED; + return side.getAxis()==facing.rotateY().getAxis()?BlockFaceShape.SOLID: BlockFaceShape.UNDEFINED; + else if(pos >= 15&&pos <= 17) + return side==EnumFacing.UP?BlockFaceShape.SOLID: BlockFaceShape.UNDEFINED; else if(pos==23) - return side.getAxis()==facing.rotateY().getAxis()?BlockFaceShape.SOLID:BlockFaceShape.UNDEFINED; + return side.getAxis()==facing.rotateY().getAxis()?BlockFaceShape.SOLID: BlockFaceShape.UNDEFINED; return BlockFaceShape.UNDEFINED; } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityDynamo.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityDynamo.java index 3c86d4ab8c..9d2b39d181 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityDynamo.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityDynamo.java @@ -29,13 +29,13 @@ public class TileEntityDynamo extends TileEntityIEBase implements IIEInternalFluxConnector, IDirectionalTile, IRotationAcceptor { public EnumFacing facing = EnumFacing.NORTH; - + @Override public void inputRotation(double rotation, @Nonnull EnumFacing side) { if(side!=this.facing.getOpposite()) return; - int output = (int) (IEConfig.Machines.dynamo_output * rotation); + int output = (int)(IEConfig.Machines.dynamo_output*rotation); for(EnumFacing fd : EnumFacing.VALUES) { BlockPos outputPos = getPos().offset(fd); @@ -55,21 +55,25 @@ public void setFacing(EnumFacing facing) { this.facing = facing; } + @Override public int getFacingLimitation() { return 2; } + @Override public boolean mirrorFacingOnPlacement(EntityLivingBase placer) { return true; } + @Override public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) { return true; } + @Override public boolean canRotate(EnumFacing axis) { @@ -83,6 +87,7 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) // if(descPacket && world!=null) // world.markBlockForUpdate(getPos()); } + @Override public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { @@ -95,12 +100,15 @@ public SideConfig getEnergySideConfig(@Nullable EnumFacing facing) { return SideConfig.OUTPUT; } + @Override public boolean canConnectEnergy(EnumFacing from) { return true; } - IEForgeEnergyWrapper wrapper = new IEForgeEnergyWrapper(this,null); + + IEForgeEnergyWrapper wrapper = new IEForgeEnergyWrapper(this, null); + @Override public IEForgeEnergyWrapper getCapabilityWrapper(EnumFacing facing) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityElectricLantern.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityElectricLantern.java index ced81cfe37..3cc71a733e 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityElectricLantern.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityElectricLantern.java @@ -23,13 +23,13 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.EnumSkyBlock; -public class TileEntityElectricLantern extends TileEntityImmersiveConnectable implements ISpawnInterdiction, ITickable, IDirectionalTile,IHammerInteraction, IBlockBounds, IActiveState, ILightValue +public class TileEntityElectricLantern extends TileEntityImmersiveConnectable implements ISpawnInterdiction, ITickable, IDirectionalTile, IHammerInteraction, IBlockBounds, IActiveState, ILightValue { public int energyStorage = 0; private int energyDraw = IEConfig.Machines.lantern_energyDraw; private int maximumStorage = IEConfig.Machines.lantern_maximumStorage; public boolean active = false; - private boolean interdictionList=false; + private boolean interdictionList = false; private boolean flipped = false; @Override @@ -37,23 +37,24 @@ public void update() { if(world.isRemote) return; - if(!interdictionList && IEConfig.Machines.lantern_spawnPrevent) + if(!interdictionList&&IEConfig.Machines.lantern_spawnPrevent) { - synchronized (EventHandler.interdictionTiles) { - if (!EventHandler.interdictionTiles.contains(this)) + synchronized(EventHandler.interdictionTiles) + { + if(!EventHandler.interdictionTiles.contains(this)) EventHandler.interdictionTiles.add(this); } - interdictionList=true; + interdictionList = true; } boolean b = active; if(energyStorage >= energyDraw) { energyStorage -= energyDraw; if(!active) - active=true; + active = true; } else if(active) - active=false; + active = false; if(active!=b) { @@ -66,21 +67,24 @@ else if(active) @Override public double getInterdictionRangeSquared() { - return active?1024:0; + return active?1024: 0; } @Override public void invalidate() { - synchronized (EventHandler.interdictionTiles) { + synchronized(EventHandler.interdictionTiles) + { EventHandler.interdictionTiles.remove(this); } super.invalidate(); } @Override - public void onChunkUnload(){ - synchronized (EventHandler.interdictionTiles) { + public void onChunkUnload() + { + synchronized(EventHandler.interdictionTiles) + { EventHandler.interdictionTiles.remove(this); } super.onChunkUnload(); @@ -99,9 +103,9 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { super.writeCustomNBT(nbt, descPacket); - nbt.setBoolean("active",active); - nbt.setInteger("energyStorage",energyStorage); - nbt.setBoolean("flipped",flipped); + nbt.setBoolean("active", active); + nbt.setInteger("energyStorage", energyStorage); + nbt.setBoolean("flipped", flipped); } @Override @@ -109,31 +113,35 @@ protected boolean canTakeLV() { return true; } + @Override public boolean isEnergyOutput() { return true; } + @Override protected boolean isRelay() { return true; } + @Override public int outputEnergy(int amount, boolean simulate, int energyType) { - if(amount > 0 && energyStorage < maximumStorage) + if(amount > 0&&energyStorage < maximumStorage) { if(!simulate) { - int rec = Math.min(maximumStorage - energyStorage, energyDraw); - energyStorage+=rec; + int rec = Math.min(maximumStorage-energyStorage, energyDraw); + energyStorage += rec; return rec; } - return Math.min(maximumStorage - energyStorage, energyDraw); + return Math.min(maximumStorage-energyStorage, energyDraw); } return 0; } + @Override public boolean receiveClientEvent(int id, int arg) { @@ -149,17 +157,17 @@ public boolean receiveClientEvent(int id, int arg) @Override public Vec3d getConnectionOffset(Connection con) { - int xDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(getPos())&&con.end!=null)? con.end.getX()-getPos().getX(): (con.end.equals(getPos())&& con.start!=null)?con.start.getX()-getPos().getX(): 0; - int zDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(getPos())&&con.end!=null)? con.end.getZ()-getPos().getZ(): (con.end.equals(getPos())&& con.start!=null)?con.start.getZ()-getPos().getZ(): 0; - if(Math.abs(xDif)>=Math.abs(zDif)) - return new Vec3d(xDif<0?.25:xDif>0?.75:.5, flipped?.9375:.0625, .5); - return new Vec3d(.5, flipped?.9375:.0625, zDif<0?.25:zDif>0?.75:.5); + int xDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(getPos())&&con.end!=null)?con.end.getX()-getPos().getX(): (con.end.equals(getPos())&&con.start!=null)?con.start.getX()-getPos().getX(): 0; + int zDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(getPos())&&con.end!=null)?con.end.getZ()-getPos().getZ(): (con.end.equals(getPos())&&con.start!=null)?con.start.getZ()-getPos().getZ(): 0; + if(Math.abs(xDif) >= Math.abs(zDif)) + return new Vec3d(xDif < 0?.25: xDif > 0?.75: .5, flipped?.9375: .0625, .5); + return new Vec3d(.5, flipped?.9375: .0625, zDif < 0?.25: zDif > 0?.75: .5); } @Override public float[] getBlockBounds() { - return new float[]{.1875f,0,.1875f, .8125f,1,.8125f}; + return new float[]{.1875f, 0, .1875f, .8125f, 1, .8125f}; } @Override @@ -167,6 +175,7 @@ public PropertyBoolInverted getBoolProperty(Class lastPackets = new ArrayList<>(25); - public boolean lower=true; + public boolean lower = true; private int compVal = -1; @Override @@ -47,11 +47,13 @@ protected boolean canTakeLV() { return true; } + @Override protected boolean canTakeMV() { return true; } + @Override protected boolean canTakeHV() { @@ -67,20 +69,20 @@ protected boolean isRelay() @Override public boolean interact(EnumFacing side, EntityPlayer player, EnumHand hand, ItemStack heldItem, float hitX, float hitY, float hitZ) { - if (!heldItem.isEmpty()&&heldItem.getItem() instanceof IWireCoil) + if(!heldItem.isEmpty()&&heldItem.getItem() instanceof IWireCoil) return false; int transfer = getAveragePower(); int packets = lastPackets.size(); if(lower) { - TileEntity above = world.getTileEntity(getPos().add(0,1,0)); + TileEntity above = world.getTileEntity(getPos().add(0, 1, 0)); if(above instanceof TileEntityEnergyMeter) packets = ((TileEntityEnergyMeter)above).lastPackets.size(); } String transferred = "0"; - if(transfer>0) + if(transfer > 0) transferred = Utils.formatDouble(transfer, "0.###"); - ChatUtils.sendServerNoSpamMessages(player, new TextComponentTranslation(Lib.CHAT_INFO+"energyTransfered",packets,transferred)); + ChatUtils.sendServerNoSpamMessages(player, new TextComponentTranslation(Lib.CHAT_INFO+"energyTransfered", packets, transferred)); return true; } @@ -88,13 +90,13 @@ public boolean interact(EnumFacing side, EntityPlayer player, EnumHand hand, Ite public void update() { ApiUtils.checkForNeedlessTicking(this); - if(lower || world.isRemote) + if(lower||world.isRemote) return; - if (((world.getTotalWorldTime()&31)==(pos.toLong()&31)||compVal<0)) + if(((world.getTotalWorldTime()&31)==(pos.toLong()&31)||compVal < 0)) updateComparatorValues(); //Yes, this might tick in between different connectors sending power, but since this is a block for statistical evaluation over a tick, that is irrelevant. lastPackets.add(lastEnergyPassed); - if(lastPackets.size()>20) + if(lastPackets.size() > 20) lastPackets.remove(0); lastEnergyPassed = 0; } @@ -116,21 +118,22 @@ public boolean canConnectCable(WireType cableType, TargetingInfo target, Vec3i o { if(lower) { - TileEntity above = world.getTileEntity(getPos().add(0,1,0)); + TileEntity above = world.getTileEntity(getPos().add(0, 1, 0)); if(above instanceof TileEntityEnergyMeter) return ((TileEntityEnergyMeter)above).canConnectCable(cableType, target, offset); return false; } return super.canConnectCable(cableType, target, offset); } + @Override public void connectCable(WireType cableType, TargetingInfo target, IImmersiveConnectable other) { if(lower) { - TileEntity above = world.getTileEntity(getPos().add(0,1,0)); + TileEntity above = world.getTileEntity(getPos().add(0, 1, 0)); if(above instanceof TileEntityEnergyMeter) - ((TileEntityEnergyMeter) above).connectCable(cableType, target, other); + ((TileEntityEnergyMeter)above).connectCable(cableType, target, other); } else super.connectCable(cableType, target, other); @@ -139,7 +142,7 @@ public void connectCable(WireType cableType, TargetingInfo target, IImmersiveCon @Override public BlockPos getConnectionMaster(WireType cableType, TargetingInfo target) { - if (lower) + if(lower) return pos.up(); else return pos; @@ -152,6 +155,7 @@ public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) nbt.setInteger("facing", facing.ordinal()); nbt.setBoolean("dummy", lower); } + @Override public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) { @@ -163,12 +167,12 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) @Override public Vec3d getConnectionOffset(Connection con) { - int xDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(Utils.toCC(this))&&con.end!=null)? con.end.getX()-getPos().getX(): (con.end.equals(Utils.toCC(this))&& con.start!=null)?con.start.getX()-getPos().getX(): 0; - int zDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(Utils.toCC(this))&&con.end!=null)? con.end.getZ()-getPos().getZ(): (con.end.equals(Utils.toCC(this))&& con.start!=null)?con.start.getZ()-getPos().getZ(): 0; + int xDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(Utils.toCC(this))&&con.end!=null)?con.end.getX()-getPos().getX(): (con.end.equals(Utils.toCC(this))&&con.start!=null)?con.start.getX()-getPos().getX(): 0; + int zDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(Utils.toCC(this))&&con.end!=null)?con.end.getZ()-getPos().getZ(): (con.end.equals(Utils.toCC(this))&&con.start!=null)?con.start.getZ()-getPos().getZ(): 0; if(facing.getAxis()==Axis.X) - return new Vec3d(.5,.4375,zDif>0?.8125:.1875); + return new Vec3d(.5, .4375, zDif > 0?.8125: .1875); else - return new Vec3d(xDif>0?.8125:.1875,.4375,.5); + return new Vec3d(xDif > 0?.8125: .1875, .4375, .5); } @Override @@ -186,16 +190,17 @@ public boolean isLogicDummy() @Override public void placeDummies(BlockPos pos, IBlockState state, EnumFacing side, float hitX, float hitY, float hitZ) { - world.setBlockState(pos.add(0,1,0), state); - ((TileEntityEnergyMeter)world.getTileEntity(pos.add(0,1,0))).lower = false; - ((TileEntityEnergyMeter)world.getTileEntity(pos.add(0,1,0))).facing = this.facing; + world.setBlockState(pos.add(0, 1, 0), state); + ((TileEntityEnergyMeter)world.getTileEntity(pos.add(0, 1, 0))).lower = false; + ((TileEntityEnergyMeter)world.getTileEntity(pos.add(0, 1, 0))).facing = this.facing; } + @Override public void breakDummies(BlockPos pos, IBlockState state) { - for(int i=0; i<=1; i++) - if(world.getTileEntity(getPos().add(0,!lower?-1:0,0).add(0,i,0)) instanceof TileEntityEnergyMeter) - world.setBlockToAir(getPos().add(0,!lower?-1:0,0).add(0,i,0)); + for(int i = 0; i <= 1; i++) + if(world.getTileEntity(getPos().add(0, !lower?-1: 0, 0).add(0, i, 0)) instanceof TileEntityEnergyMeter) + world.setBlockToAir(getPos().add(0, !lower?-1: 0, 0).add(0, i, 0)); } public int getAveragePower() @@ -203,20 +208,20 @@ public int getAveragePower() TileEntityEnergyMeter te = this; if(te.lower) { - TileEntity tmp = world.getTileEntity(getPos().add(0,1,0)); + TileEntity tmp = world.getTileEntity(getPos().add(0, 1, 0)); if(!(tmp instanceof TileEntityEnergyMeter)) return -1; - te = (TileEntityEnergyMeter) tmp; + te = (TileEntityEnergyMeter)tmp; } if(te.lastPackets.size()==0) return 0; double sum = 0; - synchronized (te.lastPackets) + synchronized(te.lastPackets) { - for(double transfer: te.lastPackets) + for(double transfer : te.lastPackets) sum += transfer; } - return (int) Math.round(sum/te.lastPackets.size()); + return (int)Math.round(sum/te.lastPackets.size()); } @Override @@ -225,22 +230,25 @@ public float[] getBlockBounds() // return new float[]{0,0,0,1,1,1}; return null; } + @Override public List getAdvancedSelectionBounds() { - List list = Lists.newArrayList(new AxisAlignedBB(.1875f,-.625f,.1875f, .8125f,.8125f,.8125f).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + List list = Lists.newArrayList(new AxisAlignedBB(.1875f, -.625f, .1875f, .8125f, .8125f, .8125f).offset(getPos().getX(), getPos().getY(), getPos().getZ())); if(lower) { - list.set(0, list.get(0).offset(0,1,0)); - list.add(new AxisAlignedBB(0,0,0, 1,.375f,1).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.set(0, list.get(0).offset(0, 1, 0)); + list.add(new AxisAlignedBB(0, 0, 0, 1, .375f, 1).offset(getPos().getX(), getPos().getY(), getPos().getZ())); } return list; } + @Override public boolean isOverrideBox(AxisAlignedBB box, EntityPlayer player, RayTraceResult mop, ArrayList list) { return false; } + @Override public List getAdvancedColisionBounds() { @@ -252,55 +260,62 @@ public EnumFacing getFacing() { return facing; } + @Override public void setFacing(EnumFacing facing) { this.facing = facing; } + @Override public int getFacingLimitation() { return 2; } + @Override public boolean mirrorFacingOnPlacement(EntityLivingBase placer) { return false; } + @Override public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) { return false; } + @Override public boolean canRotate(EnumFacing axis) { return false; } + private void updateComparatorValues() { int oldVal = compVal; int maxTrans = 0; Set conns = ImmersiveNetHandler.INSTANCE.getConnections(world, pos); - if (conns==null) + if(conns==null) compVal = 0; else { - for (Connection c : conns) + for(Connection c : conns) maxTrans += c.cableType.getTransferRate(); maxTrans /= 2; - double val = getAveragePower() / (double) maxTrans; - compVal = (int) Math.ceil(15 * val); + double val = getAveragePower()/(double)maxTrans; + compVal = (int)Math.ceil(15*val); TileEntity te = world.getTileEntity(pos.down()); - if (te instanceof TileEntityEnergyMeter) - ((TileEntityEnergyMeter) te).compVal = compVal; + if(te instanceof TileEntityEnergyMeter) + ((TileEntityEnergyMeter)te).compVal = compVal; } - if (oldVal!=compVal) + if(oldVal!=compVal) { world.updateComparatorOutputLevel(pos, getBlockType()); world.updateComparatorOutputLevel(pos.down(), getBlockType()); } } + @Override public int getComparatorInputOverride() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityExcavator.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityExcavator.java index 43c204a9a1..00157e5639 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityExcavator.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityExcavator.java @@ -45,11 +45,11 @@ import java.util.ArrayList; import java.util.List; -public class TileEntityExcavator extends TileEntityMultiblockMetal implements IAdvancedSelectionBounds,IAdvancedCollisionBounds +public class TileEntityExcavator extends TileEntityMultiblockMetal implements IAdvancedSelectionBounds, IAdvancedCollisionBounds { public TileEntityExcavator() { - super(MultiblockExcavator.instance, new int[]{3,6,3}, 64000, true); + super(MultiblockExcavator.instance, new int[]{3, 6, 3}, 64000, true); } public boolean active = false; @@ -60,6 +60,7 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) { super.readCustomNBT(nbt, descPacket); } + @Override public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { @@ -72,13 +73,13 @@ public int getComparatorInputOverride() if(!this.isRedstonePos()) return 0; BlockPos wheelPos = this.getBlockPosForPos(31); - if(world.isBlockLoaded(wheelPos) && world.getTileEntity(wheelPos) instanceof TileEntityBucketWheel) + if(world.isBlockLoaded(wheelPos)&&world.getTileEntity(wheelPos) instanceof TileEntityBucketWheel) { - MineralWorldInfo info = ExcavatorHandler.getMineralWorldInfo(world, wheelPos.getX()>>4, wheelPos.getZ()>>4); - if (info==null) + MineralWorldInfo info = ExcavatorHandler.getMineralWorldInfo(world, wheelPos.getX() >> 4, wheelPos.getZ() >> 4); + if(info==null) return 0; float remain = (ExcavatorHandler.mineralVeinCapacity-info.depletion)/(float)ExcavatorHandler.mineralVeinCapacity; - return MathHelper.floor(Math.max(remain,0)*15); + return MathHelper.floor(Math.max(remain, 0)*15); } return 0; } @@ -90,7 +91,7 @@ public void update() if(isDummy()) return; BlockPos wheelPos = this.getBlockPosForPos(31); - if(!world.isRemote && world.isBlockLoaded(wheelPos)) + if(!world.isRemote&&world.isBlockLoaded(wheelPos)) { TileEntity center = world.getTileEntity(wheelPos); @@ -98,18 +99,18 @@ public void update() { float rot = 0; int target = -1; - TileEntityBucketWheel wheel = ((TileEntityBucketWheel) center); + TileEntityBucketWheel wheel = ((TileEntityBucketWheel)center); EnumFacing fRot = this.facing.rotateYCCW(); if(wheel.facing==fRot) { if(active!=wheel.active) - world.addBlockEvent(wheel.getPos(), wheel.getBlockType(), 0, active? 1: 0); + world.addBlockEvent(wheel.getPos(), wheel.getBlockType(), 0, active?1: 0); rot = wheel.rotation; - if(rot%45>40) + if(rot%45 > 40) target = Math.round(rot/360f*8)%8; } - if(wheel.facing!=fRot || wheel.mirrored!=this.mirrored) + if(wheel.facing!=fRot||wheel.mirrored!=this.mirrored) { for(int h = -3; h <= 3; h++) for(int w = -3; w <= 3; w++) @@ -124,49 +125,50 @@ public void update() world.addBlockEvent(te.getPos(), te.getBlockType(), 255, 0); } } - } + } if(!isRSDisabled()) { - ExcavatorHandler.MineralMix mineral = ExcavatorHandler.getRandomMineral(world, wheelPos.getX()>>4, wheelPos.getZ()>>4); + ExcavatorHandler.MineralMix mineral = ExcavatorHandler.getRandomMineral(world, wheelPos.getX() >> 4, wheelPos.getZ() >> 4); int consumed = IEConfig.Machines.excavator_consumption; int extracted = energyStorage.extractEnergy(consumed, true); - if(extracted>=consumed) + if(extracted >= consumed) { energyStorage.extractEnergy(consumed, false); active = true; if(target >= 0) { - int targetDown = (target + 4) % 8; + int targetDown = (target+4)%8; NBTTagCompound packet = new NBTTagCompound(); if(wheel.digStacks.get(targetDown).isEmpty()) { ItemStack blocking = this.digBlocksInTheWay(wheel); - BlockPos lowGroundPos = wheelPos.add(0,-5,0); + BlockPos lowGroundPos = wheelPos.add(0, -5, 0); if(!blocking.isEmpty()) { wheel.digStacks.set(targetDown, blocking); wheel.markDirty(); this.markContainingBlockForUpdate(null); - } else if(mineral != null - && !world.isAirBlock(lowGroundPos.offset(facing, -2)) - && !world.isAirBlock(lowGroundPos.offset(facing, 2)) - && !world.isAirBlock(lowGroundPos.offset(facing, -1)) - && !world.isAirBlock(lowGroundPos.offset(facing, 1)) - && !world.isAirBlock(lowGroundPos)) + } + else if(mineral!=null + &&!world.isAirBlock(lowGroundPos.offset(facing, -2)) + &&!world.isAirBlock(lowGroundPos.offset(facing, 2)) + &&!world.isAirBlock(lowGroundPos.offset(facing, -1)) + &&!world.isAirBlock(lowGroundPos.offset(facing, 1)) + &&!world.isAirBlock(lowGroundPos)) { ItemStack ore = mineral.getRandomOre(Utils.RAND); float configChance = Utils.RAND.nextFloat(); float failChance = Utils.RAND.nextFloat(); - if(!ore.isEmpty() && configChance> IEConfig.Machines.excavator_fail_chance && failChance>mineral.failChance) + if(!ore.isEmpty()&&configChance > IEConfig.Machines.excavator_fail_chance&&failChance > mineral.failChance) { wheel.digStacks.set(targetDown, ore); wheel.markDirty(); this.markContainingBlockForUpdate(null); } - ExcavatorHandler.depleteMinerals(world, wheelPos.getX()>>4, wheelPos.getZ()>>4); + ExcavatorHandler.depleteMinerals(world, wheelPos.getX() >> 4, wheelPos.getZ() >> 4); } if(!wheel.digStacks.get(targetDown).isEmpty()) { @@ -190,11 +192,11 @@ public void update() } } else if(active) - active=false; + active = false; } else if(active) { - active=false; + active = false; // update = true; } // if(update) @@ -208,32 +210,32 @@ else if(active) ItemStack digBlocksInTheWay(TileEntityBucketWheel wheel) { - BlockPos pos = wheel.getPos().add(0,-4,0); + BlockPos pos = wheel.getPos().add(0, -4, 0); ItemStack s = digBlock(pos); if(!s.isEmpty()) return s; //Backward 1 - s = digBlock(pos.offset(facing,-1)); + s = digBlock(pos.offset(facing, -1)); if(!s.isEmpty()) return s; //Backward 2 - s = digBlock(pos.offset(facing,-2)); + s = digBlock(pos.offset(facing, -2)); if(!s.isEmpty()) return s; //Forward 1 - s = digBlock(pos.offset(facing,1)); + s = digBlock(pos.offset(facing, 1)); if(!s.isEmpty()) return s; //Forward 2 - s = digBlock(pos.offset(facing,2)); + s = digBlock(pos.offset(facing, 2)); if(!s.isEmpty()) return s; //Backward+Sides - s = digBlock(pos.offset(facing,-1).offset(facing.rotateY())); + s = digBlock(pos.offset(facing, -1).offset(facing.rotateY())); if(!s.isEmpty()) return s; - s = digBlock(pos.offset(facing,-1).offset(facing.rotateYCCW())); + s = digBlock(pos.offset(facing, -1).offset(facing.rotateYCCW())); if(!s.isEmpty()) return s; //Center Sides @@ -244,10 +246,10 @@ ItemStack digBlocksInTheWay(TileEntityBucketWheel wheel) if(!s.isEmpty()) return s; //Forward+Sides - s = digBlock(pos.offset(facing,1).offset(facing.rotateY())); + s = digBlock(pos.offset(facing, 1).offset(facing.rotateY())); if(!s.isEmpty()) return s; - s = digBlock(pos.offset(facing,1).offset(facing.rotateYCCW())); + s = digBlock(pos.offset(facing, 1).offset(facing.rotateYCCW())); if(!s.isEmpty()) return s; return ItemStack.EMPTY; @@ -258,37 +260,37 @@ ItemStack digBlock(BlockPos pos) { if(!(world instanceof WorldServer)) return ItemStack.EMPTY; - FakePlayer fakePlayer = FakePlayerUtil.getFakePlayer((WorldServer) world); + FakePlayer fakePlayer = FakePlayerUtil.getFakePlayer((WorldServer)world); IBlockState blockstate = world.getBlockState(pos); Block block = blockstate.getBlock(); - if(block!=null && !world.isAirBlock(pos) && blockstate.getPlayerRelativeBlockHardness(fakePlayer, world, pos)!=0) + if(block!=null&&!world.isAirBlock(pos)&&blockstate.getPlayerRelativeBlockHardness(fakePlayer, world, pos)!=0) { if(!block.canHarvestBlock(world, pos, fakePlayer)) return ItemStack.EMPTY; block.onBlockHarvested(world, pos, blockstate, fakePlayer); if(block.removedByPlayer(blockstate, world, pos, fakePlayer, true)) { - block.onBlockDestroyedByPlayer( world, pos, blockstate); + block.onBlockDestroyedByPlayer(world, pos, blockstate); if(block.canSilkHarvest(world, pos, blockstate, fakePlayer)) { ArrayList items = new ArrayList(); Item bitem = Item.getItemFromBlock(block); - if(bitem== Items.AIR) + if(bitem==Items.AIR) return ItemStack.EMPTY; ItemStack itemstack = new ItemStack(bitem, 1, block.getMetaFromState(blockstate)); - if (!itemstack.isEmpty()) + if(!itemstack.isEmpty()) items.add(itemstack); ForgeEventFactory.fireBlockHarvesting(items, world, pos, blockstate, 0, 1.0f, true, fakePlayer); - for(int i=0; i0) + if(items.size() > 0) return items.get(0); } else @@ -310,31 +312,30 @@ public float[] getBlockBounds() fw = fw.getOpposite(); if(pos==45) - return new float[]{fl==EnumFacing.EAST?.5f:0,0,fl==EnumFacing.SOUTH?.5f:0, fl==EnumFacing.WEST?.5f:1,.5f,fl==EnumFacing.NORTH?.5f:1}; + return new float[]{fl==EnumFacing.EAST?.5f: 0, 0, fl==EnumFacing.SOUTH?.5f: 0, fl==EnumFacing.WEST?.5f: 1, .5f, fl==EnumFacing.NORTH?.5f: 1}; if(pos==48) - return new float[]{0,0,0, 1,.5f,1}; + return new float[]{0, 0, 0, 1, .5f, 1}; if(pos==51) - return new float[]{fl==EnumFacing.WEST?.5f:0,0,fl==EnumFacing.NORTH?.5f:0, fl==EnumFacing.EAST?.5f:1,.5f,fl==EnumFacing.SOUTH?.5f:1}; + return new float[]{fl==EnumFacing.WEST?.5f: 0, 0, fl==EnumFacing.NORTH?.5f: 0, fl==EnumFacing.EAST?.5f: 1, .5f, fl==EnumFacing.SOUTH?.5f: 1}; if(pos==47) - return new float[]{fl==EnumFacing.EAST?.5f:fl==EnumFacing.WEST?.375f:0,0,fl==EnumFacing.SOUTH?.5f:fl==EnumFacing.NORTH?.375f:0, fl==EnumFacing.WEST?.5f:fl==EnumFacing.EAST?.625f:1,1,fl==EnumFacing.NORTH?.5f:fl==EnumFacing.SOUTH?.625f:1}; + return new float[]{fl==EnumFacing.EAST?.5f: fl==EnumFacing.WEST?.375f: 0, 0, fl==EnumFacing.SOUTH?.5f: fl==EnumFacing.NORTH?.375f: 0, fl==EnumFacing.WEST?.5f: fl==EnumFacing.EAST?.625f: 1, 1, fl==EnumFacing.NORTH?.5f: fl==EnumFacing.SOUTH?.625f: 1}; if(pos==50) - return new float[]{fw==EnumFacing.EAST?.875f:0,0,fw==EnumFacing.SOUTH?.875f:0, fw==EnumFacing.WEST?.125f:1,1,fw==EnumFacing.NORTH?.125f:1}; + return new float[]{fw==EnumFacing.EAST?.875f: 0, 0, fw==EnumFacing.SOUTH?.875f: 0, fw==EnumFacing.WEST?.125f: 1, 1, fw==EnumFacing.NORTH?.125f: 1}; if(pos==53) - return new float[]{fl==EnumFacing.WEST?.5f:fl==EnumFacing.EAST?.375f:0,0,fl==EnumFacing.NORTH?.5f:fl==EnumFacing.SOUTH?.375f:0, fl==EnumFacing.EAST?.5f:fl==EnumFacing.WEST?.625f:1,1,fl==EnumFacing.SOUTH?.5f:fl==EnumFacing.NORTH?.625f:1}; + return new float[]{fl==EnumFacing.WEST?.5f: fl==EnumFacing.EAST?.375f: 0, 0, fl==EnumFacing.NORTH?.5f: fl==EnumFacing.SOUTH?.375f: 0, fl==EnumFacing.EAST?.5f: fl==EnumFacing.WEST?.625f: 1, 1, fl==EnumFacing.SOUTH?.5f: fl==EnumFacing.NORTH?.625f: 1}; if(pos==5||pos==23||pos==41) - return new float[]{fw==EnumFacing.WEST?.5f:0,0,fw==EnumFacing.NORTH?.5f:0, fw==EnumFacing.EAST?.5f:1,1,fw==EnumFacing.SOUTH?.5f:1}; + return new float[]{fw==EnumFacing.WEST?.5f: 0, 0, fw==EnumFacing.NORTH?.5f: 0, fw==EnumFacing.EAST?.5f: 1, 1, fw==EnumFacing.SOUTH?.5f: 1}; if(pos==9||pos==12||pos==15) - return new float[]{fw==EnumFacing.EAST?.5f:0,0,fw==EnumFacing.SOUTH?.5f:0, fw==EnumFacing.WEST?.5f:1,1,fw==EnumFacing.NORTH?.5f:1}; + return new float[]{fw==EnumFacing.EAST?.5f: 0, 0, fw==EnumFacing.SOUTH?.5f: 0, fw==EnumFacing.WEST?.5f: 1, 1, fw==EnumFacing.NORTH?.5f: 1}; if(pos==11||pos==14||pos==17) - return new float[]{fw==EnumFacing.WEST?.5f:0,0,fw==EnumFacing.NORTH?.5f:0, fw==EnumFacing.EAST?.5f:1,1,fw==EnumFacing.SOUTH?.5f:1}; + return new float[]{fw==EnumFacing.WEST?.5f: 0, 0, fw==EnumFacing.NORTH?.5f: 0, fw==EnumFacing.EAST?.5f: 1, 1, fw==EnumFacing.SOUTH?.5f: 1}; - - - return new float[]{0,0,0, 1,1,1}; + return new float[]{0, 0, 0, 1, 1, 1}; } + @Override public List getAdvancedSelectionBounds() { @@ -345,40 +346,42 @@ public List getAdvancedSelectionBounds() if(pos==5||pos==23||pos==41) { - List list = Lists.newArrayList(new AxisAlignedBB(fw==EnumFacing.WEST?.5f:0,0,fw==EnumFacing.NORTH?.5f:0, fw==EnumFacing.EAST?.5f:1,1,fw==EnumFacing.SOUTH?.5f:1).offset(getPos().getX(),getPos().getY(),getPos().getZ())); - list.add(new AxisAlignedBB(fw==EnumFacing.EAST?.5f:fw==EnumFacing.WEST?0:.25f,.25f,fw==EnumFacing.SOUTH?.5f:fw==EnumFacing.NORTH?0:.25f, fw==EnumFacing.WEST?.5f:fw==EnumFacing.EAST?1:.75f,.75f,fw==EnumFacing.NORTH?.5f:fw==EnumFacing.SOUTH?1:.75f).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + List list = Lists.newArrayList(new AxisAlignedBB(fw==EnumFacing.WEST?.5f: 0, 0, fw==EnumFacing.NORTH?.5f: 0, fw==EnumFacing.EAST?.5f: 1, 1, fw==EnumFacing.SOUTH?.5f: 1).offset(getPos().getX(), getPos().getY(), getPos().getZ())); + list.add(new AxisAlignedBB(fw==EnumFacing.EAST?.5f: fw==EnumFacing.WEST?0: .25f, .25f, fw==EnumFacing.SOUTH?.5f: fw==EnumFacing.NORTH?0: .25f, fw==EnumFacing.WEST?.5f: fw==EnumFacing.EAST?1: .75f, .75f, fw==EnumFacing.NORTH?.5f: fw==EnumFacing.SOUTH?1: .75f).offset(getPos().getX(), getPos().getY(), getPos().getZ())); return list; } else if(pos==9||pos==12||pos==15) { - List list = Lists.newArrayList(new AxisAlignedBB(fw==EnumFacing.EAST?.5f:0,0,fw==EnumFacing.SOUTH?.5f:0, fw==EnumFacing.WEST?.5f:1,1,fw==EnumFacing.NORTH?.5f:1).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + List list = Lists.newArrayList(new AxisAlignedBB(fw==EnumFacing.EAST?.5f: 0, 0, fw==EnumFacing.SOUTH?.5f: 0, fw==EnumFacing.WEST?.5f: 1, 1, fw==EnumFacing.NORTH?.5f: 1).offset(getPos().getX(), getPos().getY(), getPos().getZ())); if(pos==9) - list.add(new AxisAlignedBB(fw==EnumFacing.WEST||fl==EnumFacing.EAST?.5f:0,.5f,fw==EnumFacing.NORTH||fl==EnumFacing.SOUTH?.5f:0, fw==EnumFacing.EAST||fl==EnumFacing.WEST?.5f:1,1,fw==EnumFacing.SOUTH||fl==EnumFacing.NORTH?.5f:1).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(fw==EnumFacing.WEST||fl==EnumFacing.EAST?.5f: 0, .5f, fw==EnumFacing.NORTH||fl==EnumFacing.SOUTH?.5f: 0, fw==EnumFacing.EAST||fl==EnumFacing.WEST?.5f: 1, 1, fw==EnumFacing.SOUTH||fl==EnumFacing.NORTH?.5f: 1).offset(getPos().getX(), getPos().getY(), getPos().getZ())); else if(pos==12) - list.add(new AxisAlignedBB(fw==EnumFacing.WEST?.5f:0,.5f,fw==EnumFacing.NORTH?.5f:0, fw==EnumFacing.EAST?.5f:1,1,fw==EnumFacing.SOUTH?.5f:1).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(fw==EnumFacing.WEST?.5f: 0, .5f, fw==EnumFacing.NORTH?.5f: 0, fw==EnumFacing.EAST?.5f: 1, 1, fw==EnumFacing.SOUTH?.5f: 1).offset(getPos().getX(), getPos().getY(), getPos().getZ())); else - list.add(new AxisAlignedBB(fw==EnumFacing.WEST||fl==EnumFacing.WEST?.5f:0,.5f,fw==EnumFacing.NORTH||fl==EnumFacing.NORTH?.5f:0, fw==EnumFacing.EAST||fl==EnumFacing.EAST?.5f:1,1,fw==EnumFacing.SOUTH||fl==EnumFacing.SOUTH?.5f:1).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(fw==EnumFacing.WEST||fl==EnumFacing.WEST?.5f: 0, .5f, fw==EnumFacing.NORTH||fl==EnumFacing.NORTH?.5f: 0, fw==EnumFacing.EAST||fl==EnumFacing.EAST?.5f: 1, 1, fw==EnumFacing.SOUTH||fl==EnumFacing.SOUTH?.5f: 1).offset(getPos().getX(), getPos().getY(), getPos().getZ())); return list; } else if(pos==47) { - List list = Lists.newArrayList(new AxisAlignedBB(fl==EnumFacing.EAST?.5f:fl==EnumFacing.WEST?.375f:0,0,fl==EnumFacing.SOUTH?.5f:fl==EnumFacing.NORTH?.375f:0, fl==EnumFacing.WEST?.5f:fl==EnumFacing.EAST?.625f:1,1,fl==EnumFacing.NORTH?.5f:fl==EnumFacing.SOUTH?.625f:1).offset(getPos().getX(),getPos().getY(),getPos().getZ())); - list.add(new AxisAlignedBB(fl==EnumFacing.EAST?.625f:fw==EnumFacing.EAST?.875f:0,0,fl==EnumFacing.SOUTH?.625f:fw==EnumFacing.SOUTH?.875f:0, fl==EnumFacing.WEST?.375f:fw==EnumFacing.WEST?.125f:1,1,fl==EnumFacing.NORTH?.375f:fw==EnumFacing.NORTH?.125f:1).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + List list = Lists.newArrayList(new AxisAlignedBB(fl==EnumFacing.EAST?.5f: fl==EnumFacing.WEST?.375f: 0, 0, fl==EnumFacing.SOUTH?.5f: fl==EnumFacing.NORTH?.375f: 0, fl==EnumFacing.WEST?.5f: fl==EnumFacing.EAST?.625f: 1, 1, fl==EnumFacing.NORTH?.5f: fl==EnumFacing.SOUTH?.625f: 1).offset(getPos().getX(), getPos().getY(), getPos().getZ())); + list.add(new AxisAlignedBB(fl==EnumFacing.EAST?.625f: fw==EnumFacing.EAST?.875f: 0, 0, fl==EnumFacing.SOUTH?.625f: fw==EnumFacing.SOUTH?.875f: 0, fl==EnumFacing.WEST?.375f: fw==EnumFacing.WEST?.125f: 1, 1, fl==EnumFacing.NORTH?.375f: fw==EnumFacing.NORTH?.125f: 1).offset(getPos().getX(), getPos().getY(), getPos().getZ())); return list; } else if(pos==53) { - List list = Lists.newArrayList(new AxisAlignedBB(fl==EnumFacing.WEST?.5f:fl==EnumFacing.EAST?.375f:0,0,fl==EnumFacing.NORTH?.5f:fl==EnumFacing.SOUTH?.375f:0, fl==EnumFacing.EAST?.5f:fl==EnumFacing.WEST?.625f:1,1,fl==EnumFacing.SOUTH?.5f:fl==EnumFacing.NORTH?.625f:1).offset(getPos().getX(),getPos().getY(),getPos().getZ())); - list.add(new AxisAlignedBB(fl==EnumFacing.WEST?.625f:fw==EnumFacing.EAST?.875f:0,0,fl==EnumFacing.NORTH?.625f:fw==EnumFacing.SOUTH?.875f:0, fl==EnumFacing.EAST?.375f:fw==EnumFacing.WEST?.125f:1,1,fl==EnumFacing.SOUTH?.375f:fw==EnumFacing.NORTH?.125f:1).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + List list = Lists.newArrayList(new AxisAlignedBB(fl==EnumFacing.WEST?.5f: fl==EnumFacing.EAST?.375f: 0, 0, fl==EnumFacing.NORTH?.5f: fl==EnumFacing.SOUTH?.375f: 0, fl==EnumFacing.EAST?.5f: fl==EnumFacing.WEST?.625f: 1, 1, fl==EnumFacing.SOUTH?.5f: fl==EnumFacing.NORTH?.625f: 1).offset(getPos().getX(), getPos().getY(), getPos().getZ())); + list.add(new AxisAlignedBB(fl==EnumFacing.WEST?.625f: fw==EnumFacing.EAST?.875f: 0, 0, fl==EnumFacing.NORTH?.625f: fw==EnumFacing.SOUTH?.875f: 0, fl==EnumFacing.EAST?.375f: fw==EnumFacing.WEST?.125f: 1, 1, fl==EnumFacing.SOUTH?.375f: fw==EnumFacing.NORTH?.125f: 1).offset(getPos().getX(), getPos().getY(), getPos().getZ())); return list; } return null; } + @Override public boolean isOverrideBox(AxisAlignedBB box, EntityPlayer player, RayTraceResult mop, ArrayList list) { return false; } + @Override public List getAdvancedColisionBounds() { @@ -388,8 +391,9 @@ public List getAdvancedColisionBounds() @Override public int[] getEnergyPos() { - return new int[]{5,23,41}; + return new int[]{5, 23, 41}; } + @Override public int[] getRedstonePos() { @@ -401,39 +405,46 @@ public boolean isInWorldProcessingMachine() { return false; } + @Override public boolean additionalCanProcessCheck(MultiblockProcess process) { return false; } + @Override public void doProcessOutput(ItemStack output) { - BlockPos pos = getPos().offset(facing,-1); + BlockPos pos = getPos().offset(facing, -1); TileEntity inventoryTile = this.world.getTileEntity(pos); if(inventoryTile!=null) output = Utils.insertStackIntoInventory(inventoryTile, output, facing.getOpposite()); if(!output.isEmpty()) Utils.dropStackAtPos(world, pos, output, facing); } + @Override public void doProcessFluidOutput(FluidStack output) { } + @Override public void onProcessFinish(MultiblockProcess process) { } + @Override public int getMaxProcessPerTick() { return 0; } + @Override public int getProcessQueueMaxLength() { return 0; } + @Override public float getMinProcessDistance(MultiblockProcess process) { @@ -446,46 +457,55 @@ public NonNullList getInventory() { return null; } + @Override public boolean isStackValid(int slot, ItemStack stack) { return false; } + @Override public int getSlotLimit(int slot) { return 0; } + @Override public int[] getOutputSlots() { return new int[0]; } + @Override public int[] getOutputTanks() { return new int[0]; } + @Override public IFluidTank[] getInternalTanks() { return null; } + @Override protected IFluidTank[] getAccessibleFluidTanks(EnumFacing side) { return new IFluidTank[0]; } + @Override protected boolean canFillTankFrom(int iTank, EnumFacing side, FluidStack resources) { return false; } + @Override protected boolean canDrainTankFrom(int iTank, EnumFacing side) { return false; } + @Override public void doGraphicalUpdates(int slot) { @@ -499,17 +519,20 @@ public IMultiblockRecipe findRecipeForInsertion(ItemStack inserting) { return null; } + @Override protected IMultiblockRecipe readRecipeFromNBT(NBTTagCompound tag) { return null; } + @Override - public void disassemble() { + public void disassemble() + { super.disassemble(); BlockPos wheelPos = this.getBlockPosForPos(31); TileEntity center = world.getTileEntity(wheelPos); - if (center instanceof TileEntityBucketWheel) + if(center instanceof TileEntityBucketWheel) world.addBlockEvent(center.getPos(), center.getBlockType(), 0, 0); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFeedthrough.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFeedthrough.java index a167968ec5..b8b4a8ebab 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFeedthrough.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFeedthrough.java @@ -59,7 +59,7 @@ public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { super.writeCustomNBT(nbt, descPacket); nbt.setString(WIRE, reference.getUniqueName()); - if (connPositive!=null) + if(connPositive!=null) { nbt.setInteger(POSITIVE_CON_X, connPositive.getX()); nbt.setInteger(POSITIVE_CON_Y, connPositive.getY()); @@ -78,7 +78,7 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) { super.readCustomNBT(nbt, descPacket); reference = WireType.getValue(nbt.getString(WIRE)); - if (nbt.hasKey(POSITIVE_CON_X)) + if(nbt.hasKey(POSITIVE_CON_X)) connPositive = new BlockPos( nbt.getInteger(POSITIVE_CON_X), nbt.getInteger(POSITIVE_CON_Y), @@ -99,7 +99,7 @@ private boolean isPositive(Vec3i offset) { return offset.getX()*facing.getFrontOffsetX()+ offset.getY()*facing.getFrontOffsetY()+ - offset.getZ()*facing.getFrontOffsetZ()>0; + offset.getZ()*facing.getFrontOffsetZ() > 0; } @Override @@ -111,7 +111,7 @@ public Vec3d getConnectionOffset(ImmersiveNetHandler.Connection con, TargetingIn private Vec3d getOffset(boolean positive) { double l = INFOS.get(reference).connOffset; - int factor = positive?1:-1; + int factor = positive?1: -1; return new Vec3d(.5+(.5+l)*facing.getFrontOffsetX()*factor, .5+(.5+l)*facing.getFrontOffsetY()*factor, .5+(.5+l)*facing.getFrontOffsetZ()*factor); } @@ -119,10 +119,10 @@ private Vec3d getOffset(boolean positive) @Override public boolean canConnectCable(WireType cableType, TargetingInfo target, Vec3i offset) { - if (!WireApi.canMix(reference, cableType)) + if(!WireApi.canMix(reference, cableType)) return false; boolean positive = isPositive(offset); - if (positive) + if(positive) return connPositive==null; else return !hasNegative; @@ -131,9 +131,9 @@ public boolean canConnectCable(WireType cableType, TargetingInfo target, Vec3i o @Override public void connectCable(WireType cableType, TargetingInfo target, IImmersiveConnectable other, @Nullable Vec3i offset) { - if (offset!=null) + if(offset!=null) { - if (isPositive(offset)) + if(isPositive(offset)) connPositive = ApiUtils.toBlockPos(other); else hasNegative = true; @@ -143,14 +143,14 @@ public void connectCable(WireType cableType, TargetingInfo target, IImmersiveCon @Override public void removeCable(ImmersiveNetHandler.Connection connection) { - if (connection==null) + if(connection==null) { connPositive = null; hasNegative = false; } else { - if (connection.end.equals(connPositive)||connection.start.equals(connPositive)) + if(connection.end.equals(connPositive)||connection.start.equals(connPositive)) connPositive = null; else hasNegative = false; @@ -179,9 +179,9 @@ public BlockPos getConnectionMaster(WireType cableType, TargetingInfo target) public NonNullList getTileDrops(@Nullable EntityPlayer player, IBlockState state) { WireApi.FeedthroughModelInfo info = INFOS.get(reference); - if (info.canReplace()) + if(info.canReplace()) { - if (offset==0) + if(offset==0) return Utils.getDrops(stateForMiddle); else { @@ -205,16 +205,16 @@ public NonNullList getTileDrops(@Nullable EntityPlayer player, IBlock public ItemStack getPickBlock(@Nullable EntityPlayer player, IBlockState state, RayTraceResult rayRes) { WireApi.FeedthroughModelInfo info = INFOS.get(reference); - if (info.canReplace() && offset==0) + if(info.canReplace()&&offset==0) { //getPickBlock needs a proper World, not an IBlockAccess, which is hard to emulate quickly. // "world, pos" won't have anything remotely like the state this expects, I hope it won't notice. try { return stateForMiddle.getBlock().getPickBlock(stateForMiddle, rayRes, world, pos, player); - } - catch (Exception x)// We can't predict what is going to happen with weird inputs. The block is mostly inert, so it shouldn't be too bad. - {} // No output as WAILA etc call this every tick (every frame?) + } catch(Exception x)// We can't predict what is going to happen with weird inputs. The block is mostly inert, so it shouldn't be too bad. + { + } // No output as WAILA etc call this every tick (every frame?) } return getTileDrop(player, state); } @@ -266,17 +266,17 @@ public boolean canRotate(EnumFacing axis) @Override public void placeDummies(BlockPos pos, IBlockState state, EnumFacing side, float hitX, float hitY, float hitZ) { - for (int i = -1;i<=1;i+=2) + for(int i = -1; i <= 1; i += 2) { BlockPos tmp = pos.offset(facing, i); world.setBlockState(tmp, state); TileEntity te = world.getTileEntity(tmp); - if (te instanceof TileEntityFeedthrough) + if(te instanceof TileEntityFeedthrough) { - ((TileEntityFeedthrough) te).facing = facing; - ((TileEntityFeedthrough) te).offset = i; - ((TileEntityFeedthrough) te).reference = reference; - ((TileEntityFeedthrough) te).stateForMiddle = stateForMiddle; + ((TileEntityFeedthrough)te).facing = facing; + ((TileEntityFeedthrough)te).offset = i; + ((TileEntityFeedthrough)te).reference = reference; + ((TileEntityFeedthrough)te).stateForMiddle = stateForMiddle; world.checkLight(tmp); } } @@ -285,22 +285,22 @@ public void placeDummies(BlockPos pos, IBlockState state, EnumFacing side, float @Override public void breakDummies(BlockPos pos, IBlockState state) { - if (!formed) + if(!formed) return; WireApi.FeedthroughModelInfo info = INFOS.get(reference); - for (int i = -1;i<=1;i++) + for(int i = -1; i <= 1; i++) { int offsetLocal = i-offset; BlockPos replacePos = pos.offset(facing, offsetLocal); - if (!info.canReplace()) + if(!info.canReplace()) world.setBlockToAir(replacePos); - else if (i!=offset) + else if(i!=offset) { TileEntity te = world.getTileEntity(replacePos); - if (te instanceof TileEntityFeedthrough) + if(te instanceof TileEntityFeedthrough) ((TileEntityFeedthrough)te).formed = false; IBlockState newState = Blocks.AIR.getDefaultState(); - switch (i) + switch(i) { case -1: newState = info.conn.withProperty(IEProperties.FACING_ALL, facing); @@ -325,18 +325,19 @@ public boolean isDummy() private static float[] FULL_BLOCK = {0, 0, 0, 1, 1, 1}; private float[] aabb; + @Override public float[] getBlockBounds() { - if (offset==0) + if(offset==0) return FULL_BLOCK; - if (aabb==null) + if(aabb==null) { float[] tmp = { 5F/16, 0, 5F/16, - 11F/16, (float) INFOS.get(reference).connLength, 11F/16 + 11F/16, (float)INFOS.get(reference).connLength, 11F/16 }; - aabb = Utils.rotateToFacing(tmp, offset>0?facing:facing.getOpposite()); + aabb = Utils.rotateToFacing(tmp, offset > 0?facing: facing.getOpposite()); } return aabb; } @@ -344,7 +345,7 @@ public float[] getBlockBounds() @Override public Object[] getCacheData() { - return new Object[] { + return new Object[]{ stateForMiddle, reference, facing }; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFloodlight.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFloodlight.java index 18bd147aa3..548f60b62a 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFloodlight.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFloodlight.java @@ -55,8 +55,8 @@ public class TileEntityFloodlight extends TileEntityImmersiveConnectable impleme public boolean redstoneControlInverted = false; public EnumFacing facing = EnumFacing.NORTH; public EnumFacing side = EnumFacing.UP; - public float rotY=0; - public float rotX=0; + public float rotY = 0; + public float rotX = 0; public List fakeLights = new ArrayList<>(); public List lightsToBePlaced = new ArrayList<>(); public List lightsToBeRemoved = new ArrayList<>(); @@ -89,24 +89,24 @@ public void update() shouldUpdate = false; } - enabled = (controllingComputers > 0 && computerOn) || (world.isBlockIndirectlyGettingPowered(getPos())>0^redstoneControlInverted); - if(energyStorage >= (!active ? energyDraw*10 : energyDraw) && enabled && switchCooldown <= 0) + enabled = (controllingComputers > 0&&computerOn)||(world.isBlockIndirectlyGettingPowered(getPos()) > 0^redstoneControlInverted); + if(energyStorage >= (!active?energyDraw*10: energyDraw)&&enabled&&switchCooldown <= 0) { energyStorage -= energyDraw; if(!active) - active=true; + active = true; } else if(active) { - active=false; + active = false; switchCooldown = timeBetweenSwitches; } switchCooldown--; - if(active != b || world.getTotalWorldTime() % 512 == ((getPos().getX() ^ getPos().getZ()) & 511)) + if(active!=b||world.getTotalWorldTime()%512==((getPos().getX()^getPos().getZ())&511)) { this.markContainingBlockForUpdate(null); - updateFakeLights(true,active); + updateFakeLights(true, active); world.checkLightFor(EnumSkyBlock.BLOCK, getPos()); } if(!active) @@ -114,23 +114,23 @@ else if(active) if(!lightsToBePlaced.isEmpty()) lightsToBePlaced.clear(); } - if((!lightsToBePlaced.isEmpty()||!lightsToBeRemoved.isEmpty()) && world.getTotalWorldTime()%8==((getPos().getX()^getPos().getZ())&7)) + if((!lightsToBePlaced.isEmpty()||!lightsToBeRemoved.isEmpty())&&world.getTotalWorldTime()%8==((getPos().getX()^getPos().getZ())&7)) { Iterator it = lightsToBePlaced.iterator(); int timeout = 0; - while(it.hasNext() && timeout++ checklist) { - Vec3d light = new Vec3d(getPos()).addVector(.5,.75,.5); + Vec3d light = new Vec3d(getPos()).addVector(.5, .75, .5); int range = 32; HashSet ignore = new HashSet(); ignore.add(getPos()); - BlockPos hit = Utils.rayTraceForFirst(Utils.addVectors(vec,light), light.addVector(vec.x*range,vec.y*range,vec.z*range), world, ignore); - double maxDistance = hit!=null?new Vec3d(hit).addVector(.5,.75,.5).squareDistanceTo(light):range*range; - for(int i=1+offset; i<=range; i++) + BlockPos hit = Utils.rayTraceForFirst(Utils.addVectors(vec, light), light.addVector(vec.x*range, vec.y*range, vec.z*range), world, ignore); + double maxDistance = hit!=null?new Vec3d(hit).addVector(.5, .75, .5).squareDistanceTo(light): range*range; + for(int i = 1+offset; i <= range; i++) { BlockPos target = getPos().add(Math.round(vec.x*i), Math.round(vec.y*i), Math.round(vec.z*i)); double dist = (vec.x*i*vec.x*i)+(vec.y*i*vec.y*i)+(vec.z*i*vec.z*i); - if(dist>maxDistance) + if(dist > maxDistance) break; - if(target.getY()>255||target.getY()<0) + if(target.getY() > 255||target.getY() < 0) continue; //&&world.getBlockLightValue(xx,yy,zz)<12 using this makes it not work in daylight .-. @@ -252,7 +253,7 @@ public void placeLightAlongVector(Vec3d vec, int offset, ArrayList che { if(!checklist.remove(target)) lightsToBePlaced.add(target); - i+=2; + i += 2; } } } @@ -261,21 +262,24 @@ public void placeLightAlongVector(Vec3d vec, int offset, ArrayList che @Override public double getInterdictionRangeSquared() { - return active?1024:0; + return active?1024: 0; } @Override public void invalidate() { - synchronized (EventHandler.interdictionTiles) { + synchronized(EventHandler.interdictionTiles) + { EventHandler.interdictionTiles.remove(this); } super.invalidate(); } @Override - public void onChunkUnload(){ - synchronized (EventHandler.interdictionTiles) { + public void onChunkUnload() + { + synchronized(EventHandler.interdictionTiles) + { EventHandler.interdictionTiles.remove(this); } super.onChunkUnload(); @@ -295,19 +299,20 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) rotX = nbt.getFloat("rotX"); int lightAmount = nbt.getInteger("lightAmount"); fakeLights.clear(); - for(int i=0; i 0 && energyStorage < maximumStorage) + if(amount > 0&&energyStorage < maximumStorage) { if(!simulate) { - int rec = Math.min(maximumStorage - energyStorage, amount); - energyStorage+=rec; + int rec = Math.min(maximumStorage-energyStorage, amount); + energyStorage += rec; return rec; } - return Math.min(maximumStorage - energyStorage, amount); + return Math.min(maximumStorage-energyStorage, amount); } return 0; } + @Override public boolean receiveClientEvent(int id, int arg) { @@ -381,45 +390,45 @@ public boolean receiveClientEvent(int id, int arg) @Override public Vec3d getConnectionOffset(Connection con) { - int xDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(Utils.toCC(this))&&con.end!=null)? con.end.getX()-getPos().getX(): (con.end.equals(Utils.toCC(this))&& con.start!=null)?con.start.getX()-getPos().getX(): 0; - int yDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(Utils.toCC(this))&&con.end!=null)? con.end.getY()-getPos().getY(): (con.end.equals(Utils.toCC(this))&& con.start!=null)?con.start.getY()-getPos().getY(): 0; - int zDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(Utils.toCC(this))&&con.end!=null)? con.end.getZ()-getPos().getZ(): (con.end.equals(Utils.toCC(this))&& con.start!=null)?con.start.getZ()-getPos().getZ(): 0; + int xDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(Utils.toCC(this))&&con.end!=null)?con.end.getX()-getPos().getX(): (con.end.equals(Utils.toCC(this))&&con.start!=null)?con.start.getX()-getPos().getX(): 0; + int yDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(Utils.toCC(this))&&con.end!=null)?con.end.getY()-getPos().getY(): (con.end.equals(Utils.toCC(this))&&con.start!=null)?con.start.getY()-getPos().getY(): 0; + int zDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(Utils.toCC(this))&&con.end!=null)?con.end.getZ()-getPos().getZ(): (con.end.equals(Utils.toCC(this))&&con.start!=null)?con.start.getZ()-getPos().getZ(): 0; double x, y, z; switch(side) { case DOWN: case UP: - x = (Math.abs(xDif) >= Math.abs(zDif)) ? (xDif >= 0) ? .9375 : .0625 : .5; - y = (side == EnumFacing.DOWN) ? .9375 : .0625; - z = (Math.abs(zDif) > Math.abs(xDif)) ? (zDif >= 0) ? .9375 : .0625 : .5; + x = (Math.abs(xDif) >= Math.abs(zDif))?(xDif >= 0)?.9375: .0625: .5; + y = (side==EnumFacing.DOWN)?.9375: .0625; + z = (Math.abs(zDif) > Math.abs(xDif))?(zDif >= 0)?.9375: .0625: .5; break; case NORTH: case SOUTH: - x = (Math.abs(xDif) >= Math.abs(yDif)) ? (xDif >= 0) ? .9375 : .0625 : .5; - y = (Math.abs(yDif) > Math.abs(xDif)) ? (yDif >= 0) ? .9375 : .0625 : .5; - z = (side == EnumFacing.NORTH) ? .9375 : .0625; + x = (Math.abs(xDif) >= Math.abs(yDif))?(xDif >= 0)?.9375: .0625: .5; + y = (Math.abs(yDif) > Math.abs(xDif))?(yDif >= 0)?.9375: .0625: .5; + z = (side==EnumFacing.NORTH)?.9375: .0625; break; case WEST: case EAST: default: - x = (side == EnumFacing.WEST) ? .9375 : .0625; - y = (Math.abs(yDif) >= Math.abs(zDif)) ? (yDif >= 0) ? .9375 : .0625 : .5; - z = (Math.abs(zDif) > Math.abs(yDif)) ? (zDif >= 0) ? .9375 : .0625 : .5; + x = (side==EnumFacing.WEST)?.9375: .0625; + y = (Math.abs(yDif) >= Math.abs(zDif))?(yDif >= 0)?.9375: .0625: .5; + z = (Math.abs(zDif) > Math.abs(yDif))?(zDif >= 0)?.9375: .0625: .5; break; } - return new Vec3d(x,y,z); + return new Vec3d(x, y, z); } @Override public float[] getBlockBounds() { - return new float[] { - side.getAxis()==Axis.X?0:.0625f, - side.getAxis() == Axis.Y ? 0 : .0625f, - side.getAxis() == Axis.Z ? 0 : .0625f, - side.getAxis() == Axis.X ? 1 : .9375f, - side.getAxis() == Axis.Y ? 1 : .9375f, - side.getAxis() == Axis.Z ? 1 : .9375f + return new float[]{ + side.getAxis()==Axis.X?0: .0625f, + side.getAxis()==Axis.Y?0: .0625f, + side.getAxis()==Axis.Z?0: .0625f, + side.getAxis()==Axis.X?1: .9375f, + side.getAxis()==Axis.Y?1: .9375f, + side.getAxis()==Axis.Z?1: .9375f }; } @@ -428,6 +437,7 @@ public PropertyBoolInverted getBoolProperty(Class=.8125: this.side==EnumFacing.UP?hitY<=.1875: this.side==EnumFacing.NORTH?hitZ>=.8125: this.side==EnumFacing.UP?hitZ<=.1875: this.side==EnumFacing.WEST?hitX>=.8125: hitX<=.1875; + boolean base = this.side==EnumFacing.DOWN?hitY >= .8125: this.side==EnumFacing.UP?hitY <= .1875: this.side==EnumFacing.NORTH?hitZ >= .8125: this.side==EnumFacing.UP?hitZ <= .1875: this.side==EnumFacing.WEST?hitX >= .8125: hitX <= .1875; if(base) { redstoneControlInverted = !redstoneControlInverted; - ChatUtils.sendServerNoSpamMessages(player, new TextComponentTranslation(Lib.CHAT_INFO+"rsControl."+(redstoneControlInverted?"invertedOn":"invertedOff"))); + ChatUtils.sendServerNoSpamMessages(player, new TextComponentTranslation(Lib.CHAT_INFO+"rsControl."+(redstoneControlInverted?"invertedOn": "invertedOff"))); markDirty(); this.markContainingBlockForUpdate(null); return true; @@ -467,37 +477,43 @@ public EnumFacing getFacing() { return side; } + @Override public void setFacing(EnumFacing facing) { - this.side=facing; + this.side = facing; } + @Override public int getFacingLimitation() { return 0; } + @Override public boolean mirrorFacingOnPlacement(EntityLivingBase placer) { return false; } + @Override public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) { return false; } + @Override public boolean canRotate(EnumFacing axis) { return false; } + @Override public void onDirectionalPlacement(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase placer) { EnumFacing f = EnumFacing.fromAngle(placer.rotationYaw); if(f==side.getOpposite()) - f = placer.rotationPitch>0?EnumFacing.DOWN:EnumFacing.UP; + f = placer.rotationPitch > 0?EnumFacing.DOWN: EnumFacing.UP; facing = f; } @@ -506,10 +522,11 @@ public void onDirectionalPlacement(EnumFacing side, float hitX, float hitY, floa public boolean shouldRenderGroup(IBlockState object, String group) { if("glass".equals(group)) - return MinecraftForgeClient.getRenderLayer()== BlockRenderLayer.TRANSLUCENT; + return MinecraftForgeClient.getRenderLayer()==BlockRenderLayer.TRANSLUCENT; else - return MinecraftForgeClient.getRenderLayer()== BlockRenderLayer.SOLID; + return MinecraftForgeClient.getRenderLayer()==BlockRenderLayer.SOLID; } + @SideOnly(Side.CLIENT) @Override public Optional applyTransformations(IBlockState object, String group, Optional transform) @@ -517,7 +534,7 @@ public Optional applyTransformations(IBlockState object, Str if(!transform.isPresent()) transform = Optional.of(new TRSRTransformation((Matrix4f)null)); Matrix4f mat = transform.get().getMatrix(); - Vector3f transl = new Vector3f(.5f,.5f,.5f); + Vector3f transl = new Vector3f(.5f, .5f, .5f); double yaw = 0; double pitch = 0; @@ -526,7 +543,7 @@ public Optional applyTransformations(IBlockState object, Str // pitch, yaw, roll if(side.getAxis()==Axis.Y) { - yaw = facing==EnumFacing.SOUTH?180:facing==EnumFacing.WEST?90:facing==EnumFacing.EAST?-90:0; + yaw = facing==EnumFacing.SOUTH?180: facing==EnumFacing.WEST?90: facing==EnumFacing.EAST?-90: 0; if(side==EnumFacing.DOWN) roll = 180; } @@ -552,13 +569,13 @@ public Optional applyTransformations(IBlockState object, Str if(facing==EnumFacing.DOWN) roll += 180; - else if(side.getAxis()==Axis.X && facing.getAxis()==Axis.Z) + else if(side.getAxis()==Axis.X&&facing.getAxis()==Axis.Z) roll += 90*facing.getAxisDirection().getOffset()*side.getAxisDirection().getOffset(); - else if(side.getAxis()==Axis.Z && facing.getAxis()==Axis.X) + else if(side.getAxis()==Axis.Z&&facing.getAxis()==Axis.X) roll += -90*facing.getAxisDirection().getOffset()*side.getAxisDirection().getOffset(); } - transl.add(new Vector3f(side.getFrontOffsetX()*.125f,side.getFrontOffsetY()*.125f,side.getFrontOffsetZ()*.125f)); + transl.add(new Vector3f(side.getFrontOffsetX()*.125f, side.getFrontOffsetY()*.125f, side.getFrontOffsetZ()*.125f)); if("axis".equals(group)||"light".equals(group)||"off".equals(group)||"glass".equals(group)) { if(side.getAxis()==Axis.Y) @@ -575,14 +592,15 @@ else if(side.getAxis()==Axis.Z && facing.getAxis()==Axis.X) @SideOnly(Side.CLIENT) @Override - public String getCacheKey(IBlockState object) { + public String getCacheKey(IBlockState object) + { return side+":"+facing+":"+rotX+":"+rotY+":"+active; } //computer stuff public boolean canComputerTurn() { - return turnCooldown <= 0 || !active; + return turnCooldown <= 0||!active; } public void turnX(boolean dir, boolean throwException) @@ -594,7 +612,7 @@ public void turnX(boolean dir, boolean throwException) else return; } - this.rotX = Math.min(191.25f, Math.max(-11.25f, rotX + (dir ? -11.25f : 11.25f))); + this.rotX = Math.min(191.25f, Math.max(-11.25f, rotX+(dir?-11.25f: 11.25f))); world.addBlockEvent(getPos(), getBlockType(), 255, 0); turnCooldown = 20; shouldUpdate = true; @@ -609,7 +627,7 @@ public void turnY(boolean dir, boolean throwException) else return; } - this.rotY += dir ? -11.25 : 11.25; + this.rotY += dir?-11.25: 11.25; this.rotY %= 360; world.addBlockEvent(getPos(), getBlockType(), 255, 0); turnCooldown = 20; diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFluidPipe.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFluidPipe.java index fcbf52fdf0..1db4475443 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFluidPipe.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFluidPipe.java @@ -66,7 +66,9 @@ public class TileEntityFluidPipe extends TileEntityIEBase implements IFluidPipe, static ConcurrentHashMap> indirectConnections = new ConcurrentHashMap>(); public static ArrayList> validPipeCovers = new ArrayList<>(); public static ArrayList> climbablePipeCovers = new ArrayList<>(); - public static void initCovers() { + + public static void initCovers() + { final ArrayList scaffolds = Lists.newArrayList( new ItemStack(IEContent.blockWoodenDecoration, 1, BlockTypes_WoodenDecoration.SCAFFOLDING.getMeta()), new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()), @@ -105,7 +107,7 @@ public Boolean apply(ItemStack input) }); } - public int[] sideConfig = new int[] {0,0,0,0,0,0}; + public int[] sideConfig = new int[]{0, 0, 0, 0, 0, 0}; public ItemStack pipeCover = ItemStack.EMPTY; private byte connections = 0; @@ -118,16 +120,16 @@ public static Set getConnectedFluidHandlers(BlockPos nod ArrayList closedList = new ArrayList<>(); Set fluidHandlers = Collections.newSetFromMap(new ConcurrentHashMap<>()); openList.add(node); - while(!openList.isEmpty() && closedList.size()<1024) + while(!openList.isEmpty()&&closedList.size() < 1024) { BlockPos next = openList.get(0); TileEntity pipeTile = Utils.getExistingTileEntity(world, next); - if(!closedList.contains(next) && (pipeTile instanceof IFluidPipe)) + if(!closedList.contains(next)&&(pipeTile instanceof IFluidPipe)) { if(pipeTile instanceof TileEntityFluidPipe) closedList.add(next); IFluidTankProperties[] tankInfo; - for(int i=0; i<6; i++) + for(int i = 0; i < 6; i++) { // boolean b = (te instanceof TileEntityFluidPipe)? (((TileEntityFluidPipe) te).sideConfig[i]==0): (((TileEntityFluidPump) te).sideConfig[i]==1); EnumFacing fd = EnumFacing.getFront(i); @@ -141,7 +143,7 @@ public static Set getConnectedFluidHandlers(BlockPos nod else if(adjacentTile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, fd.getOpposite())) { IFluidHandler handler = adjacentTile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, fd.getOpposite()); - if(handler != null) + if(handler!=null) { tankInfo = handler.getTankProperties(); if(tankInfo!=null&&tankInfo.length > 0) @@ -153,7 +155,7 @@ else if(adjacentTile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILI } openList.remove(0); } - if(FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) + if(FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER) { if(!indirectConnections.containsKey(node)) { @@ -168,13 +170,13 @@ else if(adjacentTile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILI public void validate() { super.validate(); - if (!world.isRemote) + if(!world.isRemote) ApiUtils.addFutureServerTask(world, () -> { boolean changed = false; - for (EnumFacing f : EnumFacing.VALUES) + for(EnumFacing f : EnumFacing.VALUES) changed |= updateConnectionByte(f); - if (changed) + if(changed) { world.notifyNeighborsOfStateChange(pos, getBlockType(), false); markContainingBlockForUpdate(null); @@ -186,7 +188,7 @@ public void validate() public void invalidate() { super.invalidate(); - if (!world.isRemote) + if(!world.isRemote) indirectConnections.clear(); } @@ -194,13 +196,13 @@ public void invalidate() @Override public void onEntityCollision(World world, Entity entity) { - if(!(entity instanceof EntityLivingBase) || ((EntityLivingBase)entity).isOnLadder() || pipeCover.isEmpty()) + if(!(entity instanceof EntityLivingBase)||((EntityLivingBase)entity).isOnLadder()||pipeCover.isEmpty()) return; else { boolean climb = false; - for(Function f : climbablePipeCovers) - if(f!=null && f.apply(pipeCover)==Boolean.TRUE) + for(Function f : climbablePipeCovers) + if(f!=null&&f.apply(pipeCover)==Boolean.TRUE) { climb = true; break; @@ -208,26 +210,26 @@ public void onEntityCollision(World world, Entity entity) if(!climb) return; float f5 = 0.15F; - if(entity.motionX<-f5) - entity.motionX=-f5; - if(entity.motionX>f5) - entity.motionX=f5; - if(entity.motionZ<-f5) - entity.motionZ=-f5; - if(entity.motionZ>f5) - entity.motionZ=f5; - - entity.fallDistance=0f; - if(entity.motionY<-.15) + if(entity.motionX < -f5) + entity.motionX = -f5; + if(entity.motionX > f5) + entity.motionX = f5; + if(entity.motionZ < -f5) + entity.motionZ = -f5; + if(entity.motionZ > f5) + entity.motionZ = f5; + + entity.fallDistance = 0f; + if(entity.motionY < -.15) entity.motionY = -0.15D; - if(entity.motionY<0 && entity instanceof EntityPlayer && entity.isSneaking()) + if(entity.motionY < 0&&entity instanceof EntityPlayer&&entity.isSneaking()) { - entity.motionY=.05; + entity.motionY = .05; return; } if(entity.collidedHorizontally) - entity.motionY=.2; + entity.motionY = .2; } } @@ -235,12 +237,12 @@ public void onEntityCollision(World world, Entity entity) public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) { sideConfig = nbt.getIntArray("sideConfig"); - if (sideConfig == null || sideConfig.length != 6) + if(sideConfig==null||sideConfig.length!=6) sideConfig = new int[]{0, 0, 0, 0, 0, 0}; pipeCover = new ItemStack(nbt.getCompoundTag("pipeCover")); byte oldConns = connections; connections = nbt.getByte("connections"); - if (world != null && world.isRemote && connections != oldConns) + if(world!=null&&world.isRemote&&connections!=oldConns) { IBlockState state = world.getBlockState(pos); world.notifyBlockUpdate(pos, state, state, 3); @@ -264,18 +266,20 @@ boolean canOutputPressurized(TileEntity output, boolean consumePower) return false; } - PipeFluidHandler[] sidedHandlers = {new PipeFluidHandler(this, EnumFacing.DOWN),new PipeFluidHandler(this, EnumFacing.UP),new PipeFluidHandler(this, EnumFacing.NORTH),new PipeFluidHandler(this, EnumFacing.SOUTH),new PipeFluidHandler(this, EnumFacing.WEST),new PipeFluidHandler(this, EnumFacing.EAST)}; + PipeFluidHandler[] sidedHandlers = {new PipeFluidHandler(this, EnumFacing.DOWN), new PipeFluidHandler(this, EnumFacing.UP), new PipeFluidHandler(this, EnumFacing.NORTH), new PipeFluidHandler(this, EnumFacing.SOUTH), new PipeFluidHandler(this, EnumFacing.WEST), new PipeFluidHandler(this, EnumFacing.EAST)}; + @Override public boolean hasCapability(Capability capability, @Nullable EnumFacing facing) { - if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && facing!=null&&sideConfig[facing.ordinal()]==0) + if(capability==CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY&&facing!=null&&sideConfig[facing.ordinal()]==0) return true; return super.hasCapability(capability, facing); } + @Override public T getCapability(Capability capability, @Nullable EnumFacing facing) { - if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && facing!=null&&sideConfig[facing.ordinal()]==0) + if(capability==CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY&&facing!=null&&sideConfig[facing.ordinal()]==0) return (T)sidedHandlers[facing.ordinal()]; return super.getCapability(capability, facing); } @@ -287,10 +291,10 @@ public List modifyQuads(IBlockState object, List quads) if(!pipeCover.isEmpty()) { Block b = Block.getBlockFromItem(pipeCover.getItem()); - IBlockState state = b != null ? b.getStateFromMeta(pipeCover.getMetadata()) : Blocks.STONE.getDefaultState(); + IBlockState state = b!=null?b.getStateFromMeta(pipeCover.getMetadata()): Blocks.STONE.getDefaultState(); IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(state); BlockRenderLayer curL = MinecraftForgeClient.getRenderLayer(); - if(model != null) + if(model!=null) for(BlockRenderLayer layer : BlockRenderLayer.values()) { ForgeHooksClient.setRenderLayer(layer); @@ -330,7 +334,7 @@ public void onNeighborBlockChange(BlockPos otherPos) { EnumFacing dir = EnumFacing.getFacingFromVector(otherPos.getX()-pos.getX(), otherPos.getY()-pos.getY(), otherPos.getZ()-pos.getZ()); - if (updateConnectionByte(dir)) + if(updateConnectionByte(dir)) { world.notifyNeighborsOfStateExcept(pos, getBlockType(), dir); markContainingBlockForUpdate(null); @@ -353,12 +357,13 @@ public IFluidTankProperties[] getTankProperties() { return new IFluidTankProperties[]{new FluidTankProperties(null, 1000, true, false)}; } + @Override public int fill(FluidStack resource, boolean doFill) { // if(resource==null || from==null || sideConfig[from.ordinal()]!=0 || world.isRemote) // return 0; - if(resource == null) + if(resource==null) return 0; int canAccept = resource.amount; if(canAccept <= 0) @@ -374,7 +379,7 @@ public int fill(FluidStack resource, boolean doFill) for(DirectionalFluidOutput output : outputList) { BlockPos cc = Utils.toCC(output.containingTile); - if(!cc.equals(ccFrom) && pipe.world.isBlockLoaded(cc) && !pipe.equals(output.containingTile)) + if(!cc.equals(ccFrom)&&pipe.world.isBlockLoaded(cc)&&!pipe.equals(output.containingTile)) { int limit = getTranferrableAmount(resource, output); int tileSpecificAcceptedFluid = Math.min(limit, canAccept); @@ -392,12 +397,12 @@ public int fill(FluidStack resource, boolean doFill) for(DirectionalFluidOutput output : sorting.keySet()) { int amount = sorting.get(output); - if (sum>resource.amount) + if(sum > resource.amount) { int limit = getTranferrableAmount(resource, output); int tileSpecificAcceptedFluid = Math.min(limit, canAccept); - float prio = amount / (float) sum; - amount = (int) Math.ceil(MathHelper.clamp(amount, 1, + float prio = amount/(float)sum; + amount = (int)Math.ceil(MathHelper.clamp(amount, 1, Math.min(resource.amount*prio, tileSpecificAcceptedFluid))); amount = Math.min(amount, canAccept); } @@ -414,10 +419,11 @@ public int fill(FluidStack resource, boolean doFill) return 0; } - private int getTranferrableAmount(FluidStack resource, DirectionalFluidOutput output) { - return (resource.tag != null && resource.tag.hasKey("pressurized")) || + private int getTranferrableAmount(FluidStack resource, DirectionalFluidOutput output) + { + return (resource.tag!=null&&resource.tag.hasKey("pressurized"))|| pipe.canOutputPressurized(output.containingTile, false) - ? 1000 : 50; + ?1000: 50; } @Nullable @@ -426,6 +432,7 @@ public FluidStack drain(FluidStack resource, boolean doDrain) { return null; } + @Nullable @Override public FluidStack drain(int maxDrain, boolean doDrain) @@ -433,11 +440,13 @@ public FluidStack drain(int maxDrain, boolean doDrain) return null; } } + public static class DirectionalFluidOutput { IFluidHandler output; EnumFacing direction; TileEntity containingTile; + public DirectionalFluidOutput(IFluidHandler output, TileEntity containingTile, EnumFacing direction) { this.output = output; @@ -454,10 +463,10 @@ public boolean updateConnectionByte(EnumFacing dir) int mask = 1< 0) @@ -471,16 +480,16 @@ public byte getAvailableConnectionByte() { byte connections = 0; IFluidTankProperties[] tankInfo; - for(int i=5; i>=0; i--) + for(int i = 5; i >= 0; i--) { // TileEntity con = world.getTileEntity(xCoord+(i==4?-1: i==5?1: 0),yCoord+(i==0?-1: i==1?1: 0),zCoord+(i==2?-1: i==3?1: 0)); EnumFacing dir = EnumFacing.getFront(i); TileEntity con = Utils.getExistingTileEntity(world, getPos().offset(dir)); connections <<= 1; - if (con != null && con.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, dir.getOpposite())) + if(con!=null&&con.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, dir.getOpposite())) { IFluidHandler handler = con.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, dir.getOpposite()); - if(handler != null) + if(handler!=null) { tankInfo = handler.getTankProperties(); if(tankInfo!=null&&tankInfo.length > 0) @@ -490,6 +499,7 @@ public byte getAvailableConnectionByte() } return connections; } + public int getConnectionStyle(int connection) { if(sideConfig[connection]==-1) @@ -513,7 +523,7 @@ public int getConnectionStyle(int connection) public void toggleSide(int side) { sideConfig[side]++; - if(sideConfig[side]>0) + if(sideConfig[side] > 0) sideConfig[side] = -1; markDirty(); @@ -523,10 +533,11 @@ public void toggleSide(int side) { ((TileEntityFluidPipe)connected).sideConfig[fd.getOpposite().ordinal()] = sideConfig[side]; connected.markDirty(); - world.addBlockEvent(getPos().offset(fd), getBlockType(), 0,0); + world.addBlockEvent(getPos().offset(fd), getBlockType(), 0, 0); } - world.addBlockEvent(getPos(), getBlockType(), 0,0); + world.addBlockEvent(getPos(), getBlockType(), 0, 0); } + @Override public boolean receiveClientEvent(int id, int arg) { @@ -543,6 +554,7 @@ public float[] getBlockBounds() { return null; } + @Override public List getAdvancedColisionBounds() { @@ -555,56 +567,57 @@ public List getAdvancedColisionBounds() if(/*connections==16||connections==32||*/connections==48) { list.add(new AxisAlignedBB(0, .25f, .25f, 1, .75f, .75f).offset(getPos())); - if((connections&16) == 0) + if((connections&16)==0) list.add(new AxisAlignedBB(0, .125f, .125f, .125f, .875f, .875f).offset(getPos())); - if((connections&32) == 0) + if((connections&32)==0) list.add(new AxisAlignedBB(.875f, .125f, .125f, 1, .875f, .875f).offset(getPos())); } else if(/*connections==4||connections==8||*/connections==12) { list.add(new AxisAlignedBB(.25f, .25f, 0, .75f, .75f, 1).offset(getPos())); - if((connections&4) == 0) + if((connections&4)==0) list.add(new AxisAlignedBB(.125f, .125f, 0, .875f, .875f, .125f).offset(getPos())); - if((connections&8) == 0) + if((connections&8)==0) list.add(new AxisAlignedBB(.125f, .125f, .875f, .875f, .875f, 1).offset(getPos())); } else if(/*connections==1||connections==2||*/connections==3) { list.add(new AxisAlignedBB(.25f, 0, .25f, .75f, 1, .75f).offset(getPos())); - if((connections&1) == 0) + if((connections&1)==0) list.add(new AxisAlignedBB(.125f, 0, .125f, .875f, .125f, .875f).offset(getPos())); - if((connections&2) == 0) + if((connections&2)==0) list.add(new AxisAlignedBB(.125f, .875f, .125f, .875f, 1, .875f).offset(getPos())); } else { list.add(new AxisAlignedBB(.25f, .25f, .25f, .75f, .75f, .75f).offset(getPos())); - for(int i=0; i<6; i++) + for(int i = 0; i < 6; i++) { - if((connections & (1< getAdvancedSelectionBounds() { List list = Lists.newArrayList(); byte availableConnections = getAvailableConnectionByte(); - double[] baseAABB = !pipeCover.isEmpty() ? new double[]{.002, .998, .002, .998, .002, .998} : new double[]{.25, .75, .25, .75, .25, .75}; - for(int i=0; i<6; i++) + double[] baseAABB = !pipeCover.isEmpty()?new double[]{.002, .998, .002, .998, .002, .998}: new double[]{.25, .75, .25, .75, .25, .75}; + for(int i = 0; i < 6; i++) { - double depth = getConnectionStyle(i)==0?.25:.125; - double size = getConnectionStyle(i)==0?.25:.125; + double depth = getConnectionStyle(i)==0?.25: .125; + double size = getConnectionStyle(i)==0?.25: .125; // if(pipeCover!=null) // size = 0; - if((availableConnections & 0x1)==1) - list.add(new AdvancedAABB(new AxisAlignedBB(i == 4 ? 0 : i == 5 ? 1 - depth : size, i == 0 ? 0 : i == 1 ? 1 - depth : size, i == 2 ? 0 : i == 3 ? 1 - depth : size, i == 4 ? depth : i == 5 ? 1 : 1 - size, i == 0 ? depth : i == 1 ? 1 : 1 - size, i == 2 ? depth : i == 3 ? 1 : 1 - size).offset(getPos()), EnumFacing.getFront(i))); - if((connections & (1<>1); + availableConnections = (byte)(availableConnections >> 1); } list.add(new AdvancedAABB(new AxisAlignedBB(baseAABB[4], baseAABB[0], baseAABB[2], baseAABB[5], baseAABB[1], baseAABB[3]).offset(getPos()), null)); return list; @@ -617,7 +630,7 @@ public boolean isOverrideBox(AxisAlignedBB box, EntityPlayer player, RayTraceRes { if(box.grow(.002).contains(mop.hitVec)) { - AxisAlignedBB changedBox = ((AdvancedAABB)box).fd!=null?box.grow(((AdvancedAABB)box).fd.getFrontOffsetX()!=0?0:.03125, ((AdvancedAABB)box).fd.getFrontOffsetY()!=0?0:.03125, ((AdvancedAABB)box).fd.getFrontOffsetZ()!=0?0:.03125): box; + AxisAlignedBB changedBox = ((AdvancedAABB)box).fd!=null?box.grow(((AdvancedAABB)box).fd.getFrontOffsetX()!=0?0: .03125, ((AdvancedAABB)box).fd.getFrontOffsetY()!=0?0: .03125, ((AdvancedAABB)box).fd.getFrontOffsetZ()!=0?0: .03125): box; list.add(changedBox); return true; } @@ -633,10 +646,10 @@ public boolean isOverrideBox(AxisAlignedBB box, EntityPlayer player, RayTraceRes String getRenderCacheKey() { StringBuilder key = new StringBuilder(); - for(int i=0; i<6; i++) + for(int i = 0; i < 6; i++) { if((connections&(1<>(dir+8)); + return 1&(conns >> (dir+8)); } @Override @@ -720,15 +733,15 @@ public static OBJState getStateFromKey(String key) //default: y- if((connections&2)!=0)//y+ - rotationMatrix.rotate(Math.PI, 0,0,1); + rotationMatrix.rotate(Math.PI, 0, 0, 1); else if((connections&4)!=0)//z- - rotationMatrix.rotate(Math.PI/2, 1,0,0); + rotationMatrix.rotate(Math.PI/2, 1, 0, 0); else if((connections&8)!=0)//z+ - rotationMatrix.rotate(-Math.PI/2, 1,0,0); + rotationMatrix.rotate(-Math.PI/2, 1, 0, 0); else if((connections&16)!=0)//x- - rotationMatrix.rotate(-Math.PI/2, 0,0,1); + rotationMatrix.rotate(-Math.PI/2, 0, 0, 1); else if((connections&32)!=0)//x+ - rotationMatrix.rotate(Math.PI/2, 0,0,1); + rotationMatrix.rotate(Math.PI/2, 0, 0, 1); parts.add("con_yMin"); break; case 2://straight or curve @@ -765,25 +778,25 @@ else if(straightX) if((connections&3)!=0)//curve to top or bottom { if(connectTo==16)//x- - rotationMatrix.rotate(Math.PI/2, 0,1,0); + rotationMatrix.rotate(Math.PI/2, 0, 1, 0); else if(connectTo==32)//x+ - rotationMatrix.rotate(-Math.PI/2, 0,1,0); + rotationMatrix.rotate(-Math.PI/2, 0, 1, 0); else if(connectTo==8)//z+ - rotationMatrix.rotate(Math.PI, 0,1,0); + rotationMatrix.rotate(Math.PI, 0, 1, 0); if((connections&2)!=0)//flip to top - rotationMatrix.rotate(Math.PI, 0,0,1); + rotationMatrix.rotate(Math.PI, 0, 0, 1); //default: Curve to z- } else//curve to horizontal { - rotationMatrix.rotate(-Math.PI/2, 0,0,1); + rotationMatrix.rotate(-Math.PI/2, 0, 0, 1); if(connectTo==40)//z+ to x+ - rotationMatrix.rotate(Math.PI, 1,0,0); + rotationMatrix.rotate(Math.PI, 1, 0, 0); else if(connectTo==24)//z+ to x- - rotationMatrix.rotate(-Math.PI/2, 1,0,0); + rotationMatrix.rotate(-Math.PI/2, 1, 0, 0); else if(connectTo==36)//z- to x+ - rotationMatrix.rotate(Math.PI/2, 1,0,0); + rotationMatrix.rotate(Math.PI/2, 1, 0, 0); //default: z- to x- } } @@ -797,34 +810,34 @@ else if(connectTo==36)//z- to x+ parts.add("con_zMax"); if(straightX) { - rotationMatrix.rotate(Math.PI/2, 0,1,0); + rotationMatrix.rotate(Math.PI/2, 0, 1, 0); if((connections&4)!=0)//z- - rotationMatrix.rotate(Math.PI/2, 0,0,1); + rotationMatrix.rotate(Math.PI/2, 0, 0, 1); else if((connections&8)!=0)//z+ - rotationMatrix.rotate(-Math.PI/2, 0,0,1); + rotationMatrix.rotate(-Math.PI/2, 0, 0, 1); else if((connections&2)!=0)//y+ - rotationMatrix.rotate(Math.PI, 0,0,1); + rotationMatrix.rotate(Math.PI, 0, 0, 1); //default: Curve to y- } else if(straightY) { - rotationMatrix.rotate(Math.PI/2, 1,0,0); + rotationMatrix.rotate(Math.PI/2, 1, 0, 0); if((connections&16)!=0)//x- - rotationMatrix.rotate(-Math.PI/2, 0,0,1); + rotationMatrix.rotate(-Math.PI/2, 0, 0, 1); else if((connections&32)!=0)//x+ - rotationMatrix.rotate(Math.PI/2, 0,0,1); + rotationMatrix.rotate(Math.PI/2, 0, 0, 1); else if((connections&8)!=0)//z+ - rotationMatrix.rotate(Math.PI, 0,0,1); + rotationMatrix.rotate(Math.PI, 0, 0, 1); //default: Curve to z- } else //default:z straight { if((connections&16)!=0)//x- - rotationMatrix.rotate(-Math.PI/2, 0,0,1); + rotationMatrix.rotate(-Math.PI/2, 0, 0, 1); else if((connections&32)!=0)//x+ - rotationMatrix.rotate(Math.PI/2, 0,0,1); + rotationMatrix.rotate(Math.PI/2, 0, 0, 1); else if((connections&2)!=0)//y+ - rotationMatrix.rotate(Math.PI, 0,0,1); + rotationMatrix.rotate(Math.PI, 0, 0, 1); //default: Curve to y- } } @@ -838,17 +851,17 @@ else if((connections&2)!=0)//y+ if((connections&8)!=0)//z+ { if((connections&16)!=0)//x- - rotationMatrix.rotate(Math.PI, 0,1,0); + rotationMatrix.rotate(Math.PI, 0, 1, 0); else - rotationMatrix.rotate(-Math.PI/2, 0,1,0); + rotationMatrix.rotate(-Math.PI/2, 0, 1, 0); } else//z- { if((connections&16)!=0)//x- - rotationMatrix.rotate(Math.PI/2, 0,1,0); + rotationMatrix.rotate(Math.PI/2, 0, 1, 0); } if((connections&2)!=0)//y+ - rotationMatrix.rotate(Math.PI/2, 0,0,1); + rotationMatrix.rotate(Math.PI/2, 0, 0, 1); } break; case 4://cross or complex tcross @@ -861,9 +874,9 @@ else if((connections&2)!=0)//y+ parts.add("con_zMin"); parts.add("con_zMax"); if(!straightY)//x and z - rotationMatrix.rotate(Math.PI/2, 0,0,1); + rotationMatrix.rotate(Math.PI/2, 0, 0, 1); else if(straightX)//x and y - rotationMatrix.rotate(Math.PI/2, 0,1,0); + rotationMatrix.rotate(Math.PI/2, 0, 1, 0); } else { @@ -876,31 +889,31 @@ else if(straightX)//x and y { //default y- z+- x+ if((connections&16)!=0)//x- - rotationMatrix.rotate(Math.PI, 0,1,0); + rotationMatrix.rotate(Math.PI, 0, 1, 0); if((connections&2)!=0)//y+ - rotationMatrix.rotate(Math.PI/2, 0,0,1); + rotationMatrix.rotate(Math.PI/2, 0, 0, 1); } else if(straightY) { - rotationMatrix.rotate(Math.PI / 2, 1, 0, 0); + rotationMatrix.rotate(Math.PI/2, 1, 0, 0); //default y+- z- x+ if((connections&8)!=0)//z+ { - rotationMatrix.rotate(Math.PI/2, 0,0,1); + rotationMatrix.rotate(Math.PI/2, 0, 0, 1); if((connections&16)!=0)//x- - rotationMatrix.rotate(Math.PI/2, 0,0,1); + rotationMatrix.rotate(Math.PI/2, 0, 0, 1); } else if((connections&16)!=0)//x- - rotationMatrix.rotate(-Math.PI/2, 0,0,1); + rotationMatrix.rotate(-Math.PI/2, 0, 0, 1); } else { - rotationMatrix.rotate(Math.PI/2, 0,1,0); + rotationMatrix.rotate(Math.PI/2, 0, 1, 0); //default y- z- x+- if((connections&8)!=0)//z+ - rotationMatrix.rotate(Math.PI, 0,1,0); + rotationMatrix.rotate(Math.PI, 0, 1, 0); if((connections&2)!=0)//y+ - rotationMatrix.rotate(Math.PI/2, 0,0,1); + rotationMatrix.rotate(Math.PI/2, 0, 0, 1); } } break; @@ -917,16 +930,16 @@ else if((connections&16)!=0)//x- if(straightY) { if((connections&16)!=0)//x- - rotationMatrix.rotate(Math.PI, 0,1,0); + rotationMatrix.rotate(Math.PI, 0, 1, 0); } else if(straightX) - rotationMatrix.rotate(((connections&2)!=0)?(Math.PI/2):(-Math.PI/2), 0,0,1); + rotationMatrix.rotate(((connections&2)!=0)?(Math.PI/2): (-Math.PI/2), 0, 0, 1); } else if(straightX) { - rotationMatrix.rotate(Math.PI/2, 0,1,0); + rotationMatrix.rotate(Math.PI/2, 0, 1, 0); if((connections&8)!=0)//z+ - rotationMatrix.rotate(Math.PI, 0,1,0); + rotationMatrix.rotate(Math.PI, 0, 1, 0); } break; case 6://Full Crossing @@ -965,28 +978,29 @@ public int getRenderColour(int tintIndex) @Override public boolean interact(EnumFacing side, EntityPlayer player, EnumHand hand, ItemStack heldItem, float hitX, float hitY, float hitZ) { - if(heldItem.isEmpty() && player.isSneaking() && !pipeCover.isEmpty()) + if(heldItem.isEmpty()&&player.isSneaking()&&!pipeCover.isEmpty()) { - if(!world.isRemote && world.getGameRules().getBoolean("doTileDrops")) + if(!world.isRemote&&world.getGameRules().getBoolean("doTileDrops")) { EntityItem entityitem = player.dropItem(pipeCover.copy(), false); - if(entityitem != null) + if(entityitem!=null) entityitem.setNoPickupDelay(); } pipeCover = ItemStack.EMPTY; this.markContainingBlockForUpdate(null); world.addBlockEvent(getPos(), getBlockType(), 255, 0); return true; - } else if(!heldItem.isEmpty() && !player.isSneaking()) + } + else if(!heldItem.isEmpty()&&!player.isSneaking()) for(Function func : validPipeCovers) - if(func.apply(heldItem) == Boolean.TRUE) + if(func.apply(heldItem)==Boolean.TRUE) { if(!OreDictionary.itemMatches(pipeCover, heldItem, true)) { - if(!world.isRemote && !pipeCover.isEmpty() && world.getGameRules().getBoolean("doTileDrops")) + if(!world.isRemote&&!pipeCover.isEmpty()&&world.getGameRules().getBoolean("doTileDrops")) { EntityItem entityitem = player.dropItem(pipeCover.copy(), false); - if(entityitem != null) + if(entityitem!=null) entityitem.setNoPickupDelay(); } pipeCover = Utils.copyStackWithAmount(heldItem, 1); @@ -998,6 +1012,7 @@ public boolean interact(EnumFacing side, EntityPlayer player, EnumHand hand, Ite } return false; } + @Override public boolean hammerUseSide(EnumFacing side, EntityPlayer player, float hitX, float hitY, float hitZ) { @@ -1009,7 +1024,7 @@ public boolean hammerUseSide(EnumFacing side, EntityPlayer player, float hitX, f if(box instanceof AdvancedAABB) { if(box.grow(.002).contains(new Vec3d(getPos().getX()+hitX, getPos().getY()+hitY, getPos().getZ()+hitZ))) - if(box instanceof AdvancedAABB && ((AdvancedAABB)box).fd != null) + if(box instanceof AdvancedAABB&&((AdvancedAABB)box).fd!=null) fd = ((AdvancedAABB)box).fd; } if(fd!=null) @@ -1027,9 +1042,10 @@ public boolean canOutputPressurized(boolean consumePower) { return false; } + @Override public boolean hasOutputConnection(EnumFacing side) { - return side != null && sideConfig[side.ordinal()] == 0; + return side!=null&&sideConfig[side.ordinal()]==0; } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFluidPlacer.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFluidPlacer.java index d1d6f4aec5..8ac14da8d9 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFluidPlacer.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFluidPlacer.java @@ -36,7 +36,7 @@ public class TileEntityFluidPlacer extends TileEntityIEBase implements ITickable, IConfigurableSides, IBlockOverlayText { - public int[] sideConfig = new int[] {1,0,1,1,1,1}; + public int[] sideConfig = new int[]{1, 0, 1, 1, 1, 1}; public FluidTank tank = new FluidTank(4000); private int tickCount = 0; @@ -48,29 +48,29 @@ public class TileEntityFluidPlacer extends TileEntityIEBase implements ITickable @Override public void update() { - if(getWorld().isRemote || getWorld().isBlockIndirectlyGettingPowered(getPos())!=0) + if(getWorld().isRemote||getWorld().isBlockIndirectlyGettingPowered(getPos())!=0) return; if(tickCount%16==0) { if(tickCount%512==0)//Initial placement prepareAreaCheck(); - if(tank.getFluidAmount()>=Fluid.BUCKET_VOLUME && tank.getFluid().getFluid().getBlock()!=null && !layeredPlacementQueue.isEmpty()) + if(tank.getFluidAmount() >= Fluid.BUCKET_VOLUME&&tank.getFluid().getFluid().getBlock()!=null&&!layeredPlacementQueue.isEmpty()) { Queue lowestLayer = layeredPlacementQueue.firstEntry().getValue(); - if(lowestLayer==null || lowestLayer.isEmpty()) + if(lowestLayer==null||lowestLayer.isEmpty()) layeredPlacementQueue.pollFirstEntry(); else { BlockPos targetPos = lowestLayer.poll(); IBlockState state = getWorld().getBlockState(targetPos); - if((state.getBlock().isAir(state,getWorld(),targetPos) || !state.getMaterial().isSolid()) && !isFullFluidBlock(targetPos, state)) - if(tryPlaceFluid(null, getWorld(), tank.getFluid(), targetPos)) - { - tank.drain(Fluid.BUCKET_VOLUME, true); - addConnectedSpaces(targetPos); - handleTempFluids(); - } + if((state.getBlock().isAir(state, getWorld(), targetPos)||!state.getMaterial().isSolid())&&!isFullFluidBlock(targetPos, state)) + if(tryPlaceFluid(null, getWorld(), tank.getFluid(), targetPos)) + { + tank.drain(Fluid.BUCKET_VOLUME, true); + addConnectedSpaces(targetPos); + handleTempFluids(); + } } } } @@ -82,13 +82,13 @@ public void update() //Mezz reported he was doing further work in this space for us, we should be able to remove this soon. public static boolean tryPlaceFluid(@Nullable EntityPlayer player, World worldIn, FluidStack fluidStack, BlockPos pos) { - if (worldIn == null || fluidStack == null || pos == null) + if(worldIn==null||fluidStack==null||pos==null) { return false; } Fluid fluid = fluidStack.getFluid(); - if (fluid == null || !fluid.canBePlacedInWorld()) + if(fluid==null||!fluid.canBePlacedInWorld()) { return false; } @@ -98,18 +98,18 @@ public static boolean tryPlaceFluid(@Nullable EntityPlayer player, World worldIn Material destMaterial = destBlockState.getMaterial(); boolean isDestNonSolid = !destMaterial.isSolid(); boolean isDestReplaceable = destBlockState.getBlock().isReplaceable(worldIn, pos); - if (!worldIn.isAirBlock(pos) && !isDestNonSolid && !isDestReplaceable) + if(!worldIn.isAirBlock(pos)&&!isDestNonSolid&&!isDestReplaceable) { return false; // Non-air, solid, unreplacable block. We can't put fluid here. } - if (worldIn.provider.doesWaterVaporize() && fluid.doesVaporize(fluidStack)) + if(worldIn.provider.doesWaterVaporize()&&fluid.doesVaporize(fluidStack)) { fluid.vaporize(player, worldIn, pos, fluidStack); } else { - if (!worldIn.isRemote && (isDestNonSolid || isDestReplaceable) && !destMaterial.isLiquid()) + if(!worldIn.isRemote&&(isDestNonSolid||isDestReplaceable)&&!destMaterial.isLiquid()) { worldIn.destroyBlock(pos, true); } @@ -147,21 +147,21 @@ private Queue getQueueForYLevel(int yLevel) private void addConnectedSpaces(BlockPos pos) { for(EnumFacing facing : EnumFacing.values()) - if(facing!=EnumFacing.UP && (pos!=getPos()||sideConfig[facing.ordinal()]==1)) + if(facing!=EnumFacing.UP&&(pos!=getPos()||sideConfig[facing.ordinal()]==1)) addToQueue(pos.offset(facing)); } private void addToQueue(BlockPos pos) { - if(pos.getY()>=0 && pos.getY()<=255)//Within world borders + if(pos.getY() >= 0&&pos.getY() <= 255)//Within world borders if(checkedPositions.add(pos))//Don't add checked positions - if(pos.distanceSq(getPos())<64*64)//Within max range + if(pos.distanceSq(getPos()) < 64*64)//Within max range if(getWorld().isBlockLoaded(pos)) { IBlockState state = getWorld().getBlockState(pos); - if(tank.getFluid()!=null && tank.getFluid().getFluid()==FluidRegistry.lookupFluidForBlock(state.getBlock())) + if(tank.getFluid()!=null&&tank.getFluid().getFluid()==FluidRegistry.lookupFluidForBlock(state.getBlock())) tempFluids.add(pos); - if((state.getBlock().isAir(state,getWorld(),pos) || !state.getMaterial().isSolid()) && !isFullFluidBlock(pos, state)) + if((state.getBlock().isAir(state, getWorld(), pos)||!state.getMaterial().isSolid())&&!isFullFluidBlock(pos, state)) getQueueForYLevel(pos.getY()).add(pos); } } @@ -177,7 +177,7 @@ private void handleTempFluids() private boolean isFullFluidBlock(BlockPos pos, IBlockState state) { if(state.getBlock() instanceof IFluidBlock) - return Math.abs(((IFluidBlock)state.getBlock()).getFilledPercentage(getWorld(),pos))==1; + return Math.abs(((IFluidBlock)state.getBlock()).getFilledPercentage(getWorld(), pos))==1; else if(state.getBlock() instanceof BlockLiquid) return state.getBlock().getMetaFromState(state)==0; return false; @@ -187,8 +187,8 @@ else if(state.getBlock() instanceof BlockLiquid) public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) { sideConfig = nbt.getIntArray("sideConfig"); - if(sideConfig==null || sideConfig.length!=6) - sideConfig = new int[]{1,0,1,1,1,1}; + if(sideConfig==null||sideConfig.length!=6) + sideConfig = new int[]{1, 0, 1, 1, 1, 1}; tank.readFromNBT(nbt.getCompoundTag("tank")); if(descPacket) this.markContainingBlockForUpdate(null); @@ -204,14 +204,15 @@ public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) @Override public SideConfig getSideConfig(int side) { - return (side>=0&&side<6)?SideConfig.values()[this.sideConfig[side]+1]: SideConfig.NONE; + return (side >= 0&&side < 6)?SideConfig.values()[this.sideConfig[side]+1]: SideConfig.NONE; } + @Override public boolean toggleSide(int side, EntityPlayer p) { sideConfig[side]++; - if(sideConfig[side]>1) - sideConfig[side]=-1; + if(sideConfig[side] > 1) + sideConfig[side] = -1; prepareAreaCheck(); this.markDirty(); this.markContainingBlockForUpdate(null); @@ -222,14 +223,15 @@ public boolean toggleSide(int side, EntityPlayer p) @Override public boolean hasCapability(Capability capability, @Nullable EnumFacing facing) { - if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && (facing==null||sideConfig[facing.ordinal()]==0) ) + if(capability==CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY&&(facing==null||sideConfig[facing.ordinal()]==0)) return true; return super.hasCapability(capability, facing); } + @Override public T getCapability(Capability capability, @Nullable EnumFacing facing) { - if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && (facing==null||sideConfig[facing.ordinal()]==0) ) + if(capability==CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY&&(facing==null||sideConfig[facing.ordinal()]==0)) return (T)tank; return super.getCapability(capability, facing); } @@ -237,19 +239,20 @@ public T getCapability(Capability capability, @Nullable EnumFacing facing @Override public String[] getOverlayText(EntityPlayer player, RayTraceResult mop, boolean hammer) { - if(hammer && IEConfig.colourblindSupport) + if(hammer&&IEConfig.colourblindSupport) { int i = sideConfig[Math.min(sideConfig.length-1, mop.sideHit.ordinal())]; int j = sideConfig[Math.min(sideConfig.length-1, mop.sideHit.getOpposite().ordinal())]; return new String[]{ I18n.format(Lib.DESC_INFO+"blockSide.facing") - +": "+ I18n.format(Lib.DESC_INFO+"blockSide.connectFluid."+i), + +": "+I18n.format(Lib.DESC_INFO+"blockSide.connectFluid."+i), I18n.format(Lib.DESC_INFO+"blockSide.opposite") - +": "+ I18n.format(Lib.DESC_INFO+"blockSide.connectFluid."+j) + +": "+I18n.format(Lib.DESC_INFO+"blockSide.connectFluid."+j) }; } return null; } + @Override public boolean useNixieFont(EntityPlayer player, RayTraceResult mop) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFluidPump.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFluidPump.java index 684a650f5e..3b40ad1c9c 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFluidPump.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFluidPump.java @@ -52,7 +52,7 @@ public class TileEntityFluidPump extends TileEntityIEBase implements ITickable, IBlockBounds, IHasDummyBlocks, IConfigurableSides, IFluidPipe, IIEInternalFluxHandler, IBlockOverlayText { - public int[] sideConfig = new int[] {0,-1,-1,-1,-1,-1}; + public int[] sideConfig = new int[]{0, -1, -1, -1, -1, -1}; public boolean dummy = false; public FluidTank tank = new FluidTank(4000); public FluxStorage energyStorage = new FluxStorage(8000); @@ -68,39 +68,40 @@ public class TileEntityFluidPump extends TileEntityIEBase implements ITickable, public void update() { ApiUtils.checkForNeedlessTicking(this); - if(dummy || world.isRemote) + if(dummy||world.isRemote) return; - if(tank.getFluidAmount()>0) + if(tank.getFluidAmount() > 0) { int i = outputFluid(tank.getFluid(), false); tank.drain(i, true); } - if(world.isBlockIndirectlyGettingPowered(getPos())>0||world.isBlockIndirectlyGettingPowered(getPos().add(0,1,0))>0) + if(world.isBlockIndirectlyGettingPowered(getPos()) > 0||world.isBlockIndirectlyGettingPowered(getPos().add(0, 1, 0)) > 0) { for(EnumFacing f : EnumFacing.values()) if(sideConfig[f.ordinal()]==0) { BlockPos output = getPos().offset(f); TileEntity tile = Utils.getExistingTileEntity(world, output); - if (tile != null && tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, f.getOpposite())) + if(tile!=null&&tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, f.getOpposite())) { IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, f.getOpposite()); FluidStack drain = handler.drain(500, false); - if (drain == null || drain.amount <= 0) + if(drain==null||drain.amount <= 0) continue; int out = this.outputFluid(drain, false); handler.drain(out, true); - } else if (world.getTotalWorldTime() % 20 == ((getPos().getX() ^ getPos().getZ()) & 19) && world.getBlockState(getPos().offset(f)).getBlock() == Blocks.WATER && IEConfig.Machines.pump_infiniteWater && tank.fill(new FluidStack(FluidRegistry.WATER, 1000), false) == 1000 && this.energyStorage.extractEnergy(IEConfig.Machines.pump_consumption, true) >= IEConfig.Machines.pump_consumption) + } + else if(world.getTotalWorldTime()%20==((getPos().getX()^getPos().getZ())&19)&&world.getBlockState(getPos().offset(f)).getBlock()==Blocks.WATER&&IEConfig.Machines.pump_infiniteWater&&tank.fill(new FluidStack(FluidRegistry.WATER, 1000), false)==1000&&this.energyStorage.extractEnergy(IEConfig.Machines.pump_consumption, true) >= IEConfig.Machines.pump_consumption) { int connectedSources = 0; - for (EnumFacing f2 : EnumFacing.HORIZONTALS) + for(EnumFacing f2 : EnumFacing.HORIZONTALS) { IBlockState waterState = world.getBlockState(getPos().offset(f).offset(f2)); - if (waterState.getBlock() == Blocks.WATER && Blocks.WATER.getMetaFromState(waterState) == 0) + if(waterState.getBlock()==Blocks.WATER&&Blocks.WATER.getMetaFromState(waterState)==0) connectedSources++; } - if (connectedSources > 1) + if(connectedSources > 1) { this.energyStorage.extractEnergy(IEConfig.Machines.pump_consumption, false); this.tank.fill(new FluidStack(FluidRegistry.WATER, 1000), true); @@ -118,7 +119,7 @@ public void update() FluidStack fs = Utils.drainFluidBlock(world, pos, false); if(fs==null) closedList.remove(target); - else if(tank.fill(fs, false)==fs.amount && this.energyStorage.extractEnergy(IEConfig.Machines.pump_consumption, true)>= IEConfig.Machines.pump_consumption) + else if(tank.fill(fs, false)==fs.amount&&this.energyStorage.extractEnergy(IEConfig.Machines.pump_consumption, true) >= IEConfig.Machines.pump_consumption) { this.energyStorage.extractEnergy(IEConfig.Machines.pump_consumption, false); fs = Utils.drainFluidBlock(world, pos, true); @@ -128,7 +129,7 @@ else if(tank.fill(fs, false)==fs.amount && this.energyStorage.extractEnergy(IECo // if(rainbow>9) // rainbow++; // world.setBlock( cc.posX,cc.posY,cc.posZ, Blocks.stained_glass,rainbow, 0x3); - if(IEConfig.Machines.pump_placeCobble && placeCobble) + if(IEConfig.Machines.pump_placeCobble&&placeCobble) world.setBlockState(pos, Blocks.COBBLESTONE.getDefaultState()); this.tank.fill(fs, true); closedList.remove(target); @@ -153,30 +154,31 @@ public void prepareAreaCheck() checkingArea = true; } } + public void checkAreaTick() { BlockPos next = null; final int closedListMax = 2048; int timeout = 0; - while(timeout<64 && closedList.size()=closedListMax || openList.isEmpty()) + if(closedList.size() >= closedListMax||openList.isEmpty()) checkingArea = false; } @@ -194,22 +196,22 @@ public int outputFluid(FluidStack fs, boolean simulate) return 0; int canAccept = fs.amount; - if(canAccept<=0) + if(canAccept <= 0) return 0; int accelPower = IEConfig.Machines.pump_consumption_accelerate; final int fluidForSort = canAccept; int sum = 0; - HashMap sorting = new HashMap(); + HashMap sorting = new HashMap(); for(EnumFacing f : EnumFacing.values()) if(sideConfig[f.ordinal()]==1) { TileEntity tile = Utils.getExistingTileEntity(world, getPos().offset(f)); - if(tile!=null && tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, f.getOpposite())) + if(tile!=null&&tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, f.getOpposite())) { IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, f.getOpposite()); FluidStack insertResource = Utils.copyFluidStackWithAmount(fs, fs.amount, true); - if(tile instanceof TileEntityFluidPipe && this.energyStorage.extractEnergy(accelPower, true) >= accelPower) + if(tile instanceof TileEntityFluidPipe&&this.energyStorage.extractEnergy(accelPower, true) >= accelPower) { insertResource.tag = new NBTTagCompound(); insertResource.tag.setBoolean("pressurized", true); @@ -222,27 +224,27 @@ public int outputFluid(FluidStack fs, boolean simulate) } } } - if(sum>0) + if(sum > 0) { int f = 0; - int i=0; + int i = 0; for(DirectionalFluidOutput output : sorting.keySet()) { float prio = sorting.get(output)/(float)sum; int amount = (int)(fluidForSort*prio); - if(i++ == sorting.size()-1) + if(i++==sorting.size()-1) amount = canAccept; FluidStack insertResource = Utils.copyFluidStackWithAmount(fs, amount, true); - if(output.containingTile instanceof TileEntityFluidPipe && this.energyStorage.extractEnergy(accelPower,true)>=accelPower) + if(output.containingTile instanceof TileEntityFluidPipe&&this.energyStorage.extractEnergy(accelPower, true) >= accelPower) { - this.energyStorage.extractEnergy(accelPower,false); + this.energyStorage.extractEnergy(accelPower, false); insertResource.tag = new NBTTagCompound(); insertResource.tag.setBoolean("pressurized", true); } int r = output.output.fill(insertResource, !simulate); f += r; canAccept -= r; - if(canAccept<=0) + if(canAccept <= 0) break; } return f; @@ -255,8 +257,8 @@ public int outputFluid(FluidStack fs, boolean simulate) public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) { sideConfig = nbt.getIntArray("sideConfig"); - if(sideConfig==null || sideConfig.length!=6) - sideConfig = new int[]{0,-1,-1,-1,-1,-1}; + if(sideConfig==null||sideConfig.length!=6) + sideConfig = new int[]{0, -1, -1, -1, -1, -1}; dummy = nbt.getBoolean("dummy"); if(nbt.hasKey("placeCobble")) placeCobble = nbt.getBoolean("placeCobble"); @@ -279,29 +281,30 @@ public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) @Override public SideConfig getSideConfig(int side) { - return (side>=0&&side<6)?SideConfig.values()[this.sideConfig[side]+1]: SideConfig.NONE; + return (side >= 0&&side < 6)?SideConfig.values()[this.sideConfig[side]+1]: SideConfig.NONE; } + @Override public boolean toggleSide(int side, EntityPlayer p) { - if(side!=1 && !dummy) + if(side!=1&&!dummy) { sideConfig[side]++; - if(sideConfig[side]>1) - sideConfig[side]=-1; + if(sideConfig[side] > 1) + sideConfig[side] = -1; this.markDirty(); this.markContainingBlockForUpdate(null); world.addBlockEvent(getPos(), this.getBlockType(), 0, 0); return true; } - else if (p.isSneaking()) + else if(p.isSneaking()) { TileEntityFluidPump master = this; - if (dummy) + if(dummy) { TileEntity tmp = world.getTileEntity(pos.down()); - if (tmp instanceof TileEntityFluidPump) - master = (TileEntityFluidPump) tmp; + if(tmp instanceof TileEntityFluidPump) + master = (TileEntityFluidPump)tmp; } master.placeCobble = !master.placeCobble; ChatUtils.sendServerNoSpamMessages(p, new TextComponentTranslation(Lib.CHAT_INFO+"pump.placeCobble."+master.placeCobble)); @@ -311,17 +314,19 @@ else if (p.isSneaking()) } SidedFluidHandler[] sidedFluidHandler = new SidedFluidHandler[6]; + @Override public boolean hasCapability(Capability capability, @Nullable EnumFacing facing) { - if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && facing!=null && !dummy) + if(capability==CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY&&facing!=null&&!dummy) return true; return super.hasCapability(capability, facing); } + @Override public T getCapability(Capability capability, @Nullable EnumFacing facing) { - if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && facing!=null && !dummy) + if(capability==CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY&&facing!=null&&!dummy) { if(sidedFluidHandler[facing.ordinal()]==null) sidedFluidHandler[facing.ordinal()] = new SidedFluidHandler(this, facing); @@ -333,19 +338,20 @@ public T getCapability(Capability capability, @Nullable EnumFacing facing @Override public String[] getOverlayText(EntityPlayer player, RayTraceResult mop, boolean hammer) { - if(hammer && IEConfig.colourblindSupport && !dummy) + if(hammer&&IEConfig.colourblindSupport&&!dummy) { int i = sideConfig[Math.min(sideConfig.length-1, mop.sideHit.ordinal())]; int j = sideConfig[Math.min(sideConfig.length-1, mop.sideHit.getOpposite().ordinal())]; return new String[]{ I18n.format(Lib.DESC_INFO+"blockSide.facing") - +": "+ I18n.format(Lib.DESC_INFO+"blockSide.connectFluid."+i), + +": "+I18n.format(Lib.DESC_INFO+"blockSide.connectFluid."+i), I18n.format(Lib.DESC_INFO+"blockSide.opposite") - +": "+ I18n.format(Lib.DESC_INFO+"blockSide.connectFluid."+j) + +": "+I18n.format(Lib.DESC_INFO+"blockSide.connectFluid."+j) }; } return null; } + @Override public boolean useNixieFont(EntityPlayer player, RayTraceResult mop) { @@ -356,6 +362,7 @@ static class SidedFluidHandler implements IFluidHandler { TileEntityFluidPump pump; EnumFacing facing; + SidedFluidHandler(TileEntityFluidPump pump, EnumFacing facing) { this.pump = pump; @@ -365,24 +372,27 @@ static class SidedFluidHandler implements IFluidHandler @Override public int fill(FluidStack resource, boolean doFill) { - if (resource == null || pump.sideConfig[facing.ordinal()]!=0) + if(resource==null||pump.sideConfig[facing.ordinal()]!=0) return 0; return pump.tank.fill(resource, doFill); } + @Override public FluidStack drain(FluidStack resource, boolean doDrain) { - if (resource == null) + if(resource==null) return null; return this.drain(resource.amount, doDrain); } + @Override public FluidStack drain(int maxDrain, boolean doDrain) { - if (pump.sideConfig[facing.ordinal()]!=1) + if(pump.sideConfig[facing.ordinal()]!=1) return null; return pump.tank.drain(maxDrain, doDrain); } + @Override public IFluidTankProperties[] getTankProperties() { @@ -396,19 +406,22 @@ public FluxStorage getFluxStorage() { if(dummy) { - TileEntity te = world.getTileEntity(getPos().add(0,-1,0)); + TileEntity te = world.getTileEntity(getPos().add(0, -1, 0)); if(te instanceof TileEntityFluidPump) return ((TileEntityFluidPump)te).getFluxStorage(); } return energyStorage; } + @Nonnull @Override public SideConfig getEnergySideConfig(EnumFacing facing) { - return dummy&&facing==EnumFacing.UP?SideConfig.INPUT:SideConfig.NONE; + return dummy&&facing==EnumFacing.UP?SideConfig.INPUT: SideConfig.NONE; } + IEForgeEnergyWrapper wrapper = new IEForgeEnergyWrapper(this, EnumFacing.UP); + @Override public IEForgeEnergyWrapper getCapabilityWrapper(EnumFacing facing) { @@ -422,18 +435,20 @@ public boolean isDummy() { return dummy; } + @Override public void placeDummies(BlockPos pos, IBlockState state, EnumFacing side, float hitX, float hitY, float hitZ) { - world.setBlockState(pos.add(0,1,0), state); - ((TileEntityFluidPump)world.getTileEntity(pos.add(0,1,0))).dummy = true; + world.setBlockState(pos.add(0, 1, 0), state); + ((TileEntityFluidPump)world.getTileEntity(pos.add(0, 1, 0))).dummy = true; } + @Override public void breakDummies(BlockPos pos, IBlockState state) { - for(int i=0; i<=1; i++) - if(Utils.isBlockAt(world, getPos().add(0, dummy ? -1 : 0, 0).add(0, i, 0), IEContent.blockMetalDevice0, BlockTypes_MetalDevice0.FLUID_PUMP.getMeta())) - world.setBlockToAir(getPos().add(0, dummy ? -1 : 0, 0).add(0, i, 0)); + for(int i = 0; i <= 1; i++) + if(Utils.isBlockAt(world, getPos().add(0, dummy?-1: 0, 0).add(0, i, 0), IEContent.blockMetalDevice0, BlockTypes_MetalDevice0.FLUID_PUMP.getMeta())) + world.setBlockToAir(getPos().add(0, dummy?-1: 0, 0).add(0, i, 0)); } @Override @@ -441,14 +456,14 @@ public float[] getBlockBounds() { if(!dummy) return null; - return new float[]{.1875f,0,.1875f, .8125f,1,.8125f}; + return new float[]{.1875f, 0, .1875f, .8125f, 1, .8125f}; } @Override public boolean canOutputPressurized(boolean consumePower) { int accelPower = IEConfig.Machines.pump_consumption_accelerate; - if(energyStorage.extractEnergy(accelPower, true)>=accelPower) + if(energyStorage.extractEnergy(accelPower, true) >= accelPower) { if(consumePower) energyStorage.extractEnergy(accelPower, false); @@ -456,6 +471,7 @@ public boolean canOutputPressurized(boolean consumePower) } return false; } + @Override public boolean hasOutputConnection(EnumFacing side) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFurnaceHeater.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFurnaceHeater.java index 2f03086854..e25bd39c5b 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFurnaceHeater.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFurnaceHeater.java @@ -32,7 +32,7 @@ public class TileEntityFurnaceHeater extends TileEntityIEBase implements ITickable, IIEInternalFluxHandler, IActiveState, IDirectionalTile { - public FluxStorage energyStorage = new FluxStorage(32000,Math.max(256, Math.max(IEConfig.Machines.heater_consumption, IEConfig.Machines.heater_speedupConsumption))); + public FluxStorage energyStorage = new FluxStorage(32000, Math.max(256, Math.max(IEConfig.Machines.heater_consumption, IEConfig.Machines.heater_speedupConsumption))); //public int[] sockets = new int[6]; public boolean active = false; public EnumFacing facing = EnumFacing.NORTH; @@ -43,35 +43,35 @@ public void update() if(!world.isRemote) { boolean a = active; - boolean redstonePower = world.isBlockIndirectlyGettingPowered(getPos())>0; - if(active && !redstonePower) - active=false; - if(energyStorage.getEnergyStored()>3200||a) + boolean redstonePower = world.isBlockIndirectlyGettingPowered(getPos()) > 0; + if(active&&!redstonePower) + active = false; + if(energyStorage.getEnergyStored() > 3200||a) for(EnumFacing fd : EnumFacing.VALUES) - { - TileEntity tileEntity = Utils.getExistingTileEntity(world, getPos().offset(fd)); - int consumed = 0; - if(tileEntity!=null) - if(tileEntity instanceof IExternalHeatable) - consumed = ((IExternalHeatable)tileEntity).doHeatTick(energyStorage.getEnergyStored(), redstonePower); - else - { - ExternalHeaterHandler.HeatableAdapter adapter = ExternalHeaterHandler.getHeatableAdapter(tileEntity.getClass()); - if(adapter!=null) - consumed = adapter.doHeatTick(tileEntity, energyStorage.getEnergyStored(), redstonePower); - } - if(consumed>0) + { + TileEntity tileEntity = Utils.getExistingTileEntity(world, getPos().offset(fd)); + int consumed = 0; + if(tileEntity!=null) + if(tileEntity instanceof IExternalHeatable) + consumed = ((IExternalHeatable)tileEntity).doHeatTick(energyStorage.getEnergyStored(), redstonePower); + else { - this.energyStorage.extractEnergy(consumed, false); - if(!active) - active = true; + ExternalHeaterHandler.HeatableAdapter adapter = ExternalHeaterHandler.getHeatableAdapter(tileEntity.getClass()); + if(adapter!=null) + consumed = adapter.doHeatTick(tileEntity, energyStorage.getEnergyStored(), redstonePower); } + if(consumed > 0) + { + this.energyStorage.extractEnergy(consumed, false); + if(!active) + active = true; } + } if(active!=a) { this.markDirty(); this.markContainingBlockForUpdate(null); - world.addBlockEvent(getPos(), this.getBlockType(), 1,active?1:0); + world.addBlockEvent(getPos(), this.getBlockType(), 1, active?1: 0); } } } @@ -96,13 +96,15 @@ public void update() @Override public PropertyBoolInverted getBoolProperty(Class inf) { - return inf==IActiveState.class?IEProperties.BOOLEANS[0]:null; + return inf==IActiveState.class?IEProperties.BOOLEANS[0]: null; } + @Override public boolean getIsActive() { - return active || world.isBlockIndirectlyGettingPowered(getPos())>0; + return active||world.isBlockIndirectlyGettingPowered(getPos()) > 0; } + // @Override // public SideConfig getEnergySideConfig(int side) // { @@ -135,6 +137,7 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) // sockets = new int[0]; active = nbt.getBoolean("active"); } + @Override public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { @@ -150,13 +153,16 @@ public FluxStorage getFluxStorage() { return energyStorage; } + @Nonnull @Override public SideConfig getEnergySideConfig(EnumFacing facing) { - return facing==this.facing?SideConfig.INPUT:SideConfig.NONE; + return facing==this.facing?SideConfig.INPUT: SideConfig.NONE; } + IEForgeEnergyWrapper wrapper = new IEForgeEnergyWrapper(this, facing); + @Override public IEForgeEnergyWrapper getCapabilityWrapper(EnumFacing facing) { @@ -180,21 +186,25 @@ public void setFacing(EnumFacing facing) { this.facing = facing; } + @Override public int getFacingLimitation() { return 1; } + @Override public boolean mirrorFacingOnPlacement(EntityLivingBase placer) { return placer.isSneaking(); } + @Override public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) { return true; } + @Override public boolean canRotate(EnumFacing axis) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityLadder.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityLadder.java index 6db7d7fda8..b9757b115f 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityLadder.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityLadder.java @@ -31,7 +31,7 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) @Override public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { - nbt.setInteger("facing",facing.ordinal()); + nbt.setInteger("facing", facing.ordinal()); } @Override @@ -44,7 +44,7 @@ public EnumFacing getFacingForPlacement(EntityLivingBase placer, BlockPos pos, E BlockMetalLadder ladder = (BlockMetalLadder)state.getBlock(); if(side.getAxis().isHorizontal()&&ladder.canAttachTo(world, pos.offset(side.getOpposite()), facing)) return side; - else if(ladder.getMetaFromState(state)>0) + else if(ladder.getMetaFromState(state) > 0) return placer.getAdjustedHorizontalFacing().getOpposite(); else { @@ -61,26 +61,31 @@ public EnumFacing getFacing() { return facing; } + @Override public void setFacing(EnumFacing facing) { this.facing = facing; } + @Override public int getFacingLimitation() { return -1; } + @Override public boolean mirrorFacingOnPlacement(EntityLivingBase placer) { return false; } + @Override public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) { return true; } + @Override public boolean canRotate(EnumFacing axis) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityLantern.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityLantern.java index 1bc8767a70..b78560513a 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityLantern.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityLantern.java @@ -33,7 +33,7 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) @Override public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { - nbt.setInteger("facing",facing.ordinal()); + nbt.setInteger("facing", facing.ordinal()); } @Override @@ -41,26 +41,31 @@ public EnumFacing getFacing() { return facing; } + @Override public void setFacing(EnumFacing facing) { this.facing = facing; } + @Override public int getFacingLimitation() { return 0; } + @Override public boolean mirrorFacingOnPlacement(EntityLivingBase placer) { return false; } + @Override public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) { return true; } + @Override public boolean canRotate(EnumFacing axis) { @@ -70,24 +75,25 @@ public boolean canRotate(EnumFacing axis) @Override public float[] getBlockBounds() { - return new float[]{facing==EnumFacing.EAST?0:.25f,facing==EnumFacing.UP?0:facing==EnumFacing.DOWN?.125f:.0625f,facing==EnumFacing.SOUTH?0:.25f, facing==EnumFacing.WEST?1:.75f,facing==EnumFacing.DOWN?1:.875f,facing==EnumFacing.NORTH?1:.75f}; + return new float[]{facing==EnumFacing.EAST?0: .25f, facing==EnumFacing.UP?0: facing==EnumFacing.DOWN?.125f: .0625f, facing==EnumFacing.SOUTH?0: .25f, facing==EnumFacing.WEST?1: .75f, facing==EnumFacing.DOWN?1: .875f, facing==EnumFacing.NORTH?1: .75f}; } static ArrayList[] displayList = { - Lists.newArrayList("base","attach_t"), - Lists.newArrayList("base","attach_b"), - Lists.newArrayList("base","attach_n"), - Lists.newArrayList("base","attach_s"), - Lists.newArrayList("base","attach_w"), - Lists.newArrayList("base","attach_e")}; + Lists.newArrayList("base", "attach_t"), + Lists.newArrayList("base", "attach_b"), + Lists.newArrayList("base", "attach_n"), + Lists.newArrayList("base", "attach_s"), + Lists.newArrayList("base", "attach_w"), + Lists.newArrayList("base", "attach_e")}; + @Override public ArrayList compileDisplayList() { if(facing==EnumFacing.UP) return displayList[1]; else if(facing==EnumFacing.DOWN) - return displayList[0]; - + return displayList[0]; + return displayList[3]; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityLightningrod.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityLightningrod.java index eb130bac70..7c4adde112 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityLightningrod.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityLightningrod.java @@ -40,43 +40,46 @@ public class TileEntityLightningrod extends TileEntityMultiblockPart fenceNet = null; int height; private static final int[] size = {3, 3, 3}; - public TileEntityLightningrod() { + + public TileEntityLightningrod() + { super(size); } + @Override public void update() { ApiUtils.checkForNeedlessTicking(this); - if(!world.isRemote && formed && pos==13) + if(!world.isRemote&&formed&&pos==13) { - if(energyStorage.getEnergyStored()>0) + if(energyStorage.getEnergyStored() > 0) { TileEntity tileEntity; for(EnumFacing f : EnumFacing.HORIZONTALS) - { - tileEntity = Utils.getExistingTileEntity(world, getPos().offset(f,2)); - if(tileEntity instanceof IFluxReceiver) - { - IFluxReceiver ifr = (IFluxReceiver) tileEntity; - int accepted = ifr.receiveEnergy(f.getOpposite(), energyStorage.getEnergyStored(), true); - int extracted = energyStorage.extractEnergy(accepted, false); - ifr.receiveEnergy(f.getOpposite(), extracted, false); - } - } + { + tileEntity = Utils.getExistingTileEntity(world, getPos().offset(f, 2)); + if(tileEntity instanceof IFluxReceiver) + { + IFluxReceiver ifr = (IFluxReceiver)tileEntity; + int accepted = ifr.receiveEnergy(f.getOpposite(), energyStorage.getEnergyStored(), true); + int extracted = energyStorage.extractEnergy(accepted, false); + ifr.receiveEnergy(f.getOpposite(), extracted, false); + } + } } if(world.getTotalWorldTime()%256==((getPos().getX()^getPos().getZ())&255)) fenceNet = null; if(fenceNet==null) fenceNet = this.getFenceNet(); - if(fenceNet!=null && world.getTotalWorldTime()%128==((getPos().getX()^getPos().getZ())&127) && ( world.isThundering() || (world.isRaining()&&Utils.RAND.nextInt(10)==0) )) + if(fenceNet!=null&&world.getTotalWorldTime()%128==((getPos().getX()^getPos().getZ())&127)&&(world.isThundering()||(world.isRaining()&&Utils.RAND.nextInt(10)==0))) { - int i = this.height + this.fenceNet.size(); - if(Utils.RAND.nextInt(4096*world.getHeight()) getFenceNet() { this.height = 0; boolean broken = false; - for(int i=getPos().getY()+2; i openList = new ArrayList(); ArrayList closedList = new ArrayList(); - openList.add(getPos().add(0,height,0)); - while(!openList.isEmpty() && closedList.size()<256) + openList.add(getPos().add(0, height, 0)); + while(!openList.isEmpty()&&closedList.size() < 256) { BlockPos next = openList.get(0); - if(!closedList.contains(next) && isFence(next)) + if(!closedList.contains(next)&&isFence(next)) { closedList.add(next); openList.add(next.offset(EnumFacing.WEST)); @@ -121,6 +124,7 @@ else if(!world.isAirBlock(pos)) } return closedList; } + boolean isFence(BlockPos pos) { return Utils.isBlockAt(world, pos, IEContent.blockMetalDecoration1, BlockTypes_MetalDecoration1.STEEL_FENCE.getMeta()); @@ -144,10 +148,10 @@ public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) public float[] getBlockBounds() { if(pos==22) - return new float[]{-.125f,0,-.125f,1.125f,1,1.125f}; - if(pos%9==4 || (pos<18&&pos%9%2==1)) - return new float[]{0,0,0,1,1,1}; - if(pos<9) + return new float[]{-.125f, 0, -.125f, 1.125f, 1, 1.125f}; + if(pos%9==4||(pos < 18&&pos%9%2==1)) + return new float[]{0, 0, 0, 1, 1, 1}; + if(pos < 9) return new float[]{0, 0, 0, 1, .5f, 1}; float xMin = 0; float xMax = 1; @@ -161,29 +165,29 @@ public float[] getBlockBounds() { yMin = -.5f; yMax = 1.25f; - xMin = (facing.getAxis() == Axis.X ? (pos%9 > 2 ^ facing == EnumFacing.EAST) : (pos % 3 == 2 ^ facing == EnumFacing.NORTH)) ? .8125f : .4375f; - xMax = (facing.getAxis() == Axis.X ? (pos%9 < 3 ^ facing == EnumFacing.EAST) : (pos % 3 == 0 ^ facing == EnumFacing.NORTH)) ? .1875f : .5625f; - zMin = (facing.getAxis() == Axis.X ? (pos % 3 == 2 ^ facing == EnumFacing.EAST) : (pos%9 < 3 ^ facing == EnumFacing.NORTH)) ? .8125f : .4375f; - zMax = (facing.getAxis() == Axis.X ? (pos % 3 == 0 ^ facing == EnumFacing.EAST) : (pos%9 > 2 ^ facing == EnumFacing.NORTH)) ? .1875f : .5625f; + xMin = (facing.getAxis()==Axis.X?(pos%9 > 2^facing==EnumFacing.EAST): (pos%3==2^facing==EnumFacing.NORTH))?.8125f: .4375f; + xMax = (facing.getAxis()==Axis.X?(pos%9 < 3^facing==EnumFacing.EAST): (pos%3==0^facing==EnumFacing.NORTH))?.1875f: .5625f; + zMin = (facing.getAxis()==Axis.X?(pos%3==2^facing==EnumFacing.EAST): (pos%9 < 3^facing==EnumFacing.NORTH))?.8125f: .4375f; + zMax = (facing.getAxis()==Axis.X?(pos%3==0^facing==EnumFacing.EAST): (pos%9 > 2^facing==EnumFacing.NORTH))?.1875f: .5625f; } else { yMin = .25f; yMax = .75f; - xMin = (facing.getAxis() == Axis.X ? (pos%9 > 2 ^ facing == EnumFacing.EAST) : (pos % 3 == 2 ^ facing == EnumFacing.NORTH)) ? 1 : .625f; - xMax = (facing.getAxis() == Axis.X ? (pos%9 < 3 ^ facing == EnumFacing.EAST) : (pos % 3 == 0 ^ facing == EnumFacing.NORTH)) ? 0 : .375f; - zMin = (facing.getAxis() == Axis.X ? (pos % 3 == 2 ^ facing == EnumFacing.EAST) : (pos%9 < 3 ^ facing == EnumFacing.NORTH)) ? 1 : .625f; - zMax = (facing.getAxis() == Axis.X ? (pos % 3 == 0 ^ facing == EnumFacing.EAST) : (pos%9 > 2 ^ facing == EnumFacing.NORTH)) ? 0 : .375f; + xMin = (facing.getAxis()==Axis.X?(pos%9 > 2^facing==EnumFacing.EAST): (pos%3==2^facing==EnumFacing.NORTH))?1: .625f; + xMax = (facing.getAxis()==Axis.X?(pos%9 < 3^facing==EnumFacing.EAST): (pos%3==0^facing==EnumFacing.NORTH))?0: .375f; + zMin = (facing.getAxis()==Axis.X?(pos%3==2^facing==EnumFacing.EAST): (pos%9 < 3^facing==EnumFacing.NORTH))?1: .625f; + zMax = (facing.getAxis()==Axis.X?(pos%3==0^facing==EnumFacing.EAST): (pos%9 > 2^facing==EnumFacing.NORTH))?0: .375f; } } - else if(pos>17) + else if(pos > 17) { yMin = .25f; yMax = .75f; - xMin = offset[0]<0?.375f:0; - xMax = offset[0]>0?.625f:1; - zMin = offset[2]<0?.375f:0; - zMax = offset[2]>0?.625f:1; + xMin = offset[0] < 0?.375f: 0; + xMax = offset[0] > 0?.625f: 1; + zMin = offset[2] < 0?.375f: 0; + zMax = offset[2] > 0?.625f: 1; } return new float[]{xMin, yMin, zMin, xMax, yMax, zMax}; } @@ -191,12 +195,16 @@ else if(pos>17) @Override public ItemStack getOriginalBlock() { - if(pos<0) + if(pos < 0) return ItemStack.EMPTY; ItemStack s = ItemStack.EMPTY; - try{ + try + { s = MultiblockLightningrod.instance.getStructureManual()[pos/9][pos%9/3][pos%3]; - }catch(Exception e){e.printStackTrace();} + } catch(Exception e) + { + e.printStackTrace(); + } return s.copy(); } @@ -205,11 +213,13 @@ protected IFluidTank[] getAccessibleFluidTanks(EnumFacing side) { return new IFluidTank[0]; } + @Override protected boolean canFillTankFrom(int iTank, EnumFacing side, FluidStack resource) { return false; } + @Override protected boolean canDrainTankFrom(int iTank, EnumFacing side) { @@ -218,15 +228,16 @@ protected boolean canDrainTankFrom(int iTank, EnumFacing side) @SideOnly(Side.CLIENT) private AxisAlignedBB renderAABB; + @Override @SideOnly(Side.CLIENT) public AxisAlignedBB getRenderBoundingBox() { if(renderAABB==null) if(pos==4) - renderAABB = new AxisAlignedBB(getPos().add(-1,0,-1), getPos().add(2,5,2)); + renderAABB = new AxisAlignedBB(getPos().add(-1, 0, -1), getPos().add(2, 5, 2)); else - renderAABB = new AxisAlignedBB(getPos(),getPos()); + renderAABB = new AxisAlignedBB(getPos(), getPos()); return renderAABB; } @@ -236,20 +247,23 @@ public int extractEnergy(@Nullable EnumFacing from, int energy, boolean simulate if(pos!=10&&pos!=12&&pos!=14&pos!=16) return 0; TileEntityLightningrod master = master(); - return master==null?0:master.energyStorage.extractEnergy(energy, simulate); + return master==null?0: master.energyStorage.extractEnergy(energy, simulate); } + @Override public int getEnergyStored(@Nullable EnumFacing from) { TileEntityLightningrod master = master(); - return master==null?0:master.energyStorage.getEnergyStored(); + return master==null?0: master.energyStorage.getEnergyStored(); } + @Override public int getMaxEnergyStored(@Nullable EnumFacing from) { TileEntityLightningrod master = master(); - return master==null?0:master.energyStorage.getMaxEnergyStored(); + return master==null?0: master.energyStorage.getMaxEnergyStored(); } + @Override public boolean canConnectEnergy(@Nullable EnumFacing from) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityMetalBarrel.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityMetalBarrel.java index 3d68b5ff70..11a78c73c5 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityMetalBarrel.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityMetalBarrel.java @@ -13,14 +13,16 @@ public class TileEntityMetalBarrel extends TileEntityWoodenBarrel { - @Override - public void update() { - if (world.isRemote || world.isBlockIndirectlyGettingPowered(getPos())>0) return; - else super.update(); - } + @Override + public void update() + { + if(world.isRemote||world.isBlockIndirectlyGettingPowered(getPos()) > 0) return; + else super.update(); + } + @Override public boolean isFluidValid(FluidStack fluid) { - return fluid!=null && fluid.getFluid()!=null; + return fluid!=null&&fluid.getFluid()!=null; } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityMetalPress.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityMetalPress.java index 632890a663..cec82587ff 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityMetalPress.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityMetalPress.java @@ -35,12 +35,13 @@ import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; -public class TileEntityMetalPress extends TileEntityMultiblockMetal implements IPlayerInteraction, IConveyorAttachable +public class TileEntityMetalPress extends TileEntityMultiblockMetal implements IPlayerInteraction, IConveyorAttachable { public TileEntityMetalPress() { - super(MultiblockMetalPress.instance, new int[]{3,3,1}, 16000, true); + super(MultiblockMetalPress.instance, new int[]{3, 3, 1}, 16000, true); } + // public ItemStack[] inventory = new ItemStack[3]; // public MetalPressRecipe[] curRecipes = new MetalPressRecipe[3]; // public int[] process = new int[3]; @@ -59,7 +60,7 @@ public TileEntityMetalPress() public void update() { super.update(); - if(isDummy() || isRSDisabled() || world.isRemote) + if(isDummy()||isRSDisabled()||world.isRemote) return; for(MultiblockProcess process : processQueue) { @@ -67,12 +68,12 @@ public void update() float transportTime = 52.5f/120f; float pressTime = 3.75f/120f; float fProcess = process.processTick*tick; - if(fProcess>=transportTime && fProcess=(transportTime+pressTime) && fProcess<(transportTime+pressTime+tick)) - world.playSound(null, getPos(), IESounds.metalpress_smash, SoundCategory.BLOCKS, .3F,1); - if(fProcess>=(1-transportTime) && fProcess<(1-transportTime+tick)) - world.playSound(null, getPos(), IESounds.metalpress_piston, SoundCategory.BLOCKS, .3F,1); + if(fProcess >= transportTime&&fProcess < transportTime+tick) + world.playSound(null, getPos(), IESounds.metalpress_piston, SoundCategory.BLOCKS, .3F, 1); + if(fProcess >= (transportTime+pressTime)&&fProcess < (transportTime+pressTime+tick)) + world.playSound(null, getPos(), IESounds.metalpress_smash, SoundCategory.BLOCKS, .3F, 1); + if(fProcess >= (1-transportTime)&&fProcess < (1-transportTime+tick)) + world.playSound(null, getPos(), IESounds.metalpress_piston, SoundCategory.BLOCKS, .3F, 1); } } @@ -82,6 +83,7 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) super.readCustomNBT(nbt, descPacket); mold = new ItemStack(nbt.getCompoundTag("mold")); } + @Override public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { @@ -95,20 +97,20 @@ public boolean interact(EnumFacing side, EntityPlayer player, EnumHand hand, Ite { TileEntityMetalPress master = master(); if(master!=null) - if(player.isSneaking() && !master.mold.isEmpty()) + if(player.isSneaking()&&!master.mold.isEmpty()) { if(heldItem.isEmpty()) player.setHeldItem(hand, master.mold.copy()); else if(!world.isRemote) - player.entityDropItem(master.mold.copy(),0); - master.mold= ItemStack.EMPTY; + player.entityDropItem(master.mold.copy(), 0); + master.mold = ItemStack.EMPTY; this.updateMasterBlock(null, true); return true; } else if(MetalPressRecipe.isValidMold(heldItem)) { - ItemStack tempMold = !master.mold.isEmpty()?master.mold.copy():ItemStack.EMPTY; - master.mold = Utils.copyStackWithAmount(heldItem,1); + ItemStack tempMold = !master.mold.isEmpty()?master.mold.copy(): ItemStack.EMPTY; + master.mold = Utils.copyStackWithAmount(heldItem, 1); heldItem.shrink(1); if(heldItem.getCount() <= 0) heldItem = ItemStack.EMPTY; @@ -118,7 +120,7 @@ else if(MetalPressRecipe.isValidMold(heldItem)) if(heldItem.isEmpty()) player.setHeldItem(hand, tempMold); else if(!world.isRemote) - player.entityDropItem(tempMold,0); + player.entityDropItem(tempMold, 0); this.updateMasterBlock(null, true); return true; } @@ -130,8 +132,8 @@ else if(!world.isRemote) public float[] getBlockBounds() { if(pos==3||pos==5) - return new float[]{0,0,0, 1,.125f,1}; - return new float[]{0,0,0, 1,1,1}; + return new float[]{0, 0, 0, 1, .125f, 1}; + return new float[]{0, 0, 0, 1, 1, 1}; } @Override @@ -149,7 +151,7 @@ public void replaceStructureBlock(BlockPos pos, IBlockState state, ItemStack sta @Override public void onEntityCollision(World world, Entity entity) { - if(pos==3 && !world.isRemote && entity!=null && !entity.isDead && entity instanceof EntityItem && !((EntityItem)entity).getItem().isEmpty()) + if(pos==3&&!world.isRemote&&entity!=null&&!entity.isDead&&entity instanceof EntityItem&&!((EntityItem)entity).getItem().isEmpty()) { TileEntityMetalPress master = master(); if(master==null) @@ -167,7 +169,7 @@ public void onEntityCollision(World world, Entity entity) { master.addProcessToQueue(process, false); stack.shrink(displayStack.getCount()); - if(stack.getCount()<=0) + if(stack.getCount() <= 0) entity.setDead(); } } @@ -178,6 +180,7 @@ public int[] getEnergyPos() { return new int[]{7}; } + @Override public int[] getRedstonePos() { @@ -189,39 +192,46 @@ public boolean isInWorldProcessingMachine() { return true; } + @Override public boolean additionalCanProcessCheck(MultiblockProcess process) { return true; } + @Override public void doProcessOutput(ItemStack output) { - BlockPos pos = getPos().offset(facing,2); + BlockPos pos = getPos().offset(facing, 2); TileEntity inventoryTile = this.world.getTileEntity(pos); if(inventoryTile!=null) output = Utils.insertStackIntoInventory(inventoryTile, output, facing.getOpposite()); if(!output.isEmpty()) Utils.dropStackAtPos(world, pos, output, facing); } + @Override public void doProcessFluidOutput(FluidStack output) { } + @Override public void onProcessFinish(MultiblockProcess process) { } + @Override public int getMaxProcessPerTick() { return 3; } + @Override public int getProcessQueueMaxLength() { return 3; } + @Override public float getMinProcessDistance(MultiblockProcess process) { @@ -234,51 +244,61 @@ public NonNullList getInventory() { return null; } + @Override public NonNullList getDroppedItems() { return ListUtils.fromItem(mold); } + @Override public boolean isStackValid(int slot, ItemStack stack) { return false; } + @Override public int getSlotLimit(int slot) { return 0; } + @Override public int[] getOutputSlots() { return null; } + @Override public int[] getOutputTanks() { return null; } + @Override public IFluidTank[] getInternalTanks() { return null; } + @Override protected IFluidTank[] getAccessibleFluidTanks(EnumFacing side) { return new IFluidTank[0]; } + @Override protected boolean canFillTankFrom(int iTank, EnumFacing side, FluidStack resources) { return false; } + @Override protected boolean canDrainTankFrom(int iTank, EnumFacing side) { return false; } + @Override public void doGraphicalUpdates(int slot) { @@ -293,13 +313,15 @@ public boolean hasCapability(Capability capability, EnumFacing facing) if(capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { TileEntityMetalPress master = master(); - if(master == null) + if(master==null) return false; - return pos == 3 && facing == this.facing.getOpposite(); + return pos==3&&facing==this.facing.getOpposite(); } return super.hasCapability(capability, facing); } + IItemHandler insertionHandler = new MultiblockInventoryHandler_DirectProcessing(this); + @Override public T getCapability(Capability capability, EnumFacing facing) { @@ -308,7 +330,7 @@ public T getCapability(Capability capability, EnumFacing facing) TileEntityMetalPress master = master(); if(master==null) return null; - if(pos==3 && facing==this.facing.getOpposite()) + if(pos==3&&facing==this.facing.getOpposite()) return (T)master.insertionHandler; return null; } @@ -320,6 +342,7 @@ public MetalPressRecipe findRecipeForInsertion(ItemStack inserting) { return MetalPressRecipe.findRecipe(mold, inserting); } + @Override protected MetalPressRecipe readRecipeFromNBT(NBTTagCompound tag) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityMixer.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityMixer.java index 3a56a87c0e..bc2638375a 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityMixer.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityMixer.java @@ -43,12 +43,13 @@ import java.util.*; -public class TileEntityMixer extends TileEntityMultiblockMetal implements IAdvancedSelectionBounds,IAdvancedCollisionBounds, IGuiTile +public class TileEntityMixer extends TileEntityMultiblockMetal implements IAdvancedSelectionBounds, IAdvancedCollisionBounds, IGuiTile { public TileEntityMixer() { - super(MultiblockMixer.instance, new int[]{3,3,3}, 16000, true); + super(MultiblockMixer.instance, new int[]{3, 3, 3}, 16000, true); } + public MultiFluidTank tank = new MultiFluidTank(8000); public NonNullList inventory = NonNullList.withSize(8, ItemStack.EMPTY); public float animation_agitator = 0; @@ -63,6 +64,7 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) inventory = Utils.readInventory(nbt.getTagList("inventory", 10), 8); outputAll = nbt.getBoolean("outputAll"); } + @Override public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { @@ -86,7 +88,7 @@ public void receiveMessageFromClient(NBTTagCompound message) public void update() { super.update(); - if(isDummy() || isRSDisabled()) + if(isDummy()||isRSDisabled()) return; if(world.isRemote) @@ -95,18 +97,18 @@ public void update() { if(Utils.RAND.nextInt(8)==0) { - FluidStack fs = !tank.fluids.isEmpty()?tank.fluids.get(0):null; + FluidStack fs = !tank.fluids.isEmpty()?tank.fluids.get(0): null; if(fs!=null) { float amount = tank.getFluidAmount()/(float)tank.getCapacity()*1.125f; - Vec3d partPos = new Vec3d(getPos().getX()+.5f+facing.getFrontOffsetX()*.5f+(mirrored?facing.rotateYCCW():facing.rotateY()).getFrontOffsetX()*.5f, getPos().getY()-.0625f+amount, getPos().getZ()+.5f+facing.getFrontOffsetZ()*.5f+(mirrored?facing.rotateYCCW():facing.rotateY()).getFrontOffsetZ()*.5f); + Vec3d partPos = new Vec3d(getPos().getX()+.5f+facing.getFrontOffsetX()*.5f+(mirrored?facing.rotateYCCW(): facing.rotateY()).getFrontOffsetX()*.5f, getPos().getY()-.0625f+amount, getPos().getZ()+.5f+facing.getFrontOffsetZ()*.5f+(mirrored?facing.rotateYCCW(): facing.rotateY()).getFrontOffsetZ()*.5f); float r = Utils.RAND.nextFloat()*.8125f; float angleRad = (float)Math.toRadians(animation_agitator); - partPos = partPos.addVector(r*Math.cos(angleRad),0,r*Math.sin(angleRad)); + partPos = partPos.addVector(r*Math.cos(angleRad), 0, r*Math.sin(angleRad)); if(Utils.RAND.nextBoolean()) - ImmersiveEngineering.proxy.spawnBubbleFX(world, fs, partPos.x,partPos.y,partPos.z, 0,0,0); + ImmersiveEngineering.proxy.spawnBubbleFX(world, fs, partPos.x, partPos.y, partPos.z, 0, 0, 0); else - ImmersiveEngineering.proxy.spawnFluidSplashFX(world, fs, partPos.x,partPos.y,partPos.z, 0,0,0); + ImmersiveEngineering.proxy.spawnFluidSplashFX(world, fs, partPos.x, partPos.y, partPos.z, 0, 0, 0); } } animation_agitator = (animation_agitator+9)%360; @@ -116,10 +118,10 @@ public void update() { boolean update = false; boolean foundRecipe = false; - if(energyStorage.getEnergyStored()>0 && processQueue.size() 0&&processQueue.size() < this.getProcessQueueMaxLength()) { int tankAmount = tank.getFluidAmount(); - if(tankAmount>0) + if(tankAmount > 0) { Set usedInvSlots = new HashSet(); for(MultiblockProcess process : processQueue) @@ -127,7 +129,7 @@ public void update() for(int i : ((MultiblockProcessInMachine)process).inputSlots) usedInvSlots.add(i); NonNullList components = NonNullList.withSize(this.inventory.size(), ItemStack.EMPTY); - for(int i=0; i1 || !foundRecipe || outputAll) + if(this.tank.getFluidTypes() > 1||!foundRecipe||outputAll) { BlockPos outputPos = this.getPos().down().offset(facing.getOpposite(), 2); IFluidHandler output = FluidUtil.getFluidHandler(world, outputPos, facing); @@ -173,7 +175,7 @@ public void update() { int totalOut = 0; Iterator it = this.tank.fluids.iterator(); - while (it.hasNext()) + while(it.hasNext()) { FluidStack fs = it.next(); if(fs!=null) @@ -187,7 +189,7 @@ public void update() totalOut += drained; update = true; } - if(totalOut>=80) + if(totalOut >= 80) break; } } @@ -205,12 +207,13 @@ public void update() @Override public float[] getBlockBounds() { - if(pos>1&&pos<9 && pos!=3) - return new float[]{0,0,0, 1,.5f,1}; + if(pos > 1&&pos < 9&&pos!=3) + return new float[]{0, 0, 0, 1, .5f, 1}; if(pos==11) - return new float[]{facing==EnumFacing.WEST?.5f:0,0,facing==EnumFacing.NORTH?.5f:0, facing==EnumFacing.EAST?.5f:1,1,facing==EnumFacing.SOUTH?.5f:1}; - return new float[]{0,0,0, 1,1,1}; + return new float[]{facing==EnumFacing.WEST?.5f: 0, 0, facing==EnumFacing.NORTH?.5f: 0, facing==EnumFacing.EAST?.5f: 1, 1, facing==EnumFacing.SOUTH?.5f: 1}; + return new float[]{0, 0, 0, 1, 1, 1}; } + @Override public List getAdvancedSelectionBounds() { @@ -220,24 +223,24 @@ public List getAdvancedSelectionBounds() fw = fw.getOpposite(); if(pos==2) { - List list = Lists.newArrayList(new AxisAlignedBB(0,0,0, 1,.5f,1).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + List list = Lists.newArrayList(new AxisAlignedBB(0, 0, 0, 1, .5f, 1).offset(getPos().getX(), getPos().getY(), getPos().getZ())); float minX = fl==EnumFacing.WEST?.625f: fl==EnumFacing.EAST?.125f: .125f; float maxX = fl==EnumFacing.EAST?.375f: fl==EnumFacing.WEST?.875f: .25f; float minZ = fl==EnumFacing.NORTH?.625f: fl==EnumFacing.SOUTH?.125f: .125f; float maxZ = fl==EnumFacing.SOUTH?.375f: fl==EnumFacing.NORTH?.875f: .25f; - list.add(new AxisAlignedBB(minX,.5f,minZ, maxX,1,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); minX = fl==EnumFacing.WEST?.625f: fl==EnumFacing.EAST?.125f: .75f; maxX = fl==EnumFacing.EAST?.375f: fl==EnumFacing.WEST?.875f: .875f; minZ = fl==EnumFacing.NORTH?.625f: fl==EnumFacing.SOUTH?.125f: .75f; maxZ = fl==EnumFacing.SOUTH?.375f: fl==EnumFacing.NORTH?.875f: .875f; - list.add(new AxisAlignedBB(minX,.5f,minZ, maxX,1,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); return list; } else if(pos==4||pos==5||pos==7||pos==8) { - List list = Lists.newArrayList(new AxisAlignedBB(0,0,0, 1,.5f,1).offset(getPos().getX(),getPos().getY(),getPos().getZ())); - if(pos>5) + List list = Lists.newArrayList(new AxisAlignedBB(0, 0, 0, 1, .5f, 1).offset(getPos().getX(), getPos().getY(), getPos().getZ())); + if(pos > 5) fl = fl.getOpposite(); if(pos%3==2) fw = fw.getOpposite(); @@ -245,7 +248,7 @@ else if(pos==4||pos==5||pos==7||pos==8) float maxX = fl==EnumFacing.EAST?.3125f: fl==EnumFacing.WEST?.9375f: fw==EnumFacing.EAST?.3125f: .9375f; float minZ = fl==EnumFacing.NORTH?.6875f: fl==EnumFacing.SOUTH?.0625f: fw==EnumFacing.SOUTH?.0625f: .6875f; float maxZ = fl==EnumFacing.SOUTH?.3125f: fl==EnumFacing.NORTH?.9375f: fw==EnumFacing.SOUTH?.3125f: .9375f; - list.add(new AxisAlignedBB(minX,.5f,minZ, maxX,1,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); if(pos==4) { @@ -253,19 +256,19 @@ else if(pos==4||pos==5||pos==7||pos==8) maxX = fl==EnumFacing.EAST?.375f: fl==EnumFacing.WEST?.625f: fw==EnumFacing.EAST?1.125f: 1; minZ = fl==EnumFacing.NORTH?.375f: fl==EnumFacing.SOUTH?.625f: fw==EnumFacing.NORTH?-.125f: 0; maxZ = fl==EnumFacing.SOUTH?.375f: fl==EnumFacing.NORTH?.625f: fw==EnumFacing.SOUTH?1.125f: 1; - list.add(new AxisAlignedBB(minX,.5f,minZ, maxX,.75f,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, .75f, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); minX = fl==EnumFacing.WEST?-.125f: fl==EnumFacing.EAST?.625f: fw==EnumFacing.WEST?-.125f: .875f; maxX = fl==EnumFacing.EAST?1.125f: fl==EnumFacing.WEST?.375f: fw==EnumFacing.EAST?1.125f: .125f; minZ = fl==EnumFacing.NORTH?-.125f: fl==EnumFacing.SOUTH?.625f: fw==EnumFacing.NORTH?-.125f: .875f; maxZ = fl==EnumFacing.SOUTH?1.25f: fl==EnumFacing.NORTH?.375f: fw==EnumFacing.SOUTH?1.125f: .125f; - list.add(new AxisAlignedBB(minX,.5f,minZ, maxX,.75f,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, .75f, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); minX = fl==EnumFacing.WEST?-.125f: fl==EnumFacing.EAST?.875f: fw==EnumFacing.WEST?-.125f: .875f; maxX = fl==EnumFacing.EAST?1.125f: fl==EnumFacing.WEST?.125f: fw==EnumFacing.EAST?1.125f: .125f; minZ = fl==EnumFacing.NORTH?-.125f: fl==EnumFacing.SOUTH?.875f: fw==EnumFacing.NORTH?-.125f: .875f; maxZ = fl==EnumFacing.SOUTH?1.25f: fl==EnumFacing.NORTH?.125f: fw==EnumFacing.SOUTH?1.125f: .125f; - list.add(new AxisAlignedBB(minX,.75f,minZ, maxX,1,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, .75f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); } return list; @@ -273,7 +276,7 @@ else if(pos==4||pos==5||pos==7||pos==8) else if((pos==13||pos==14||pos==16||pos==17)) { List list = new ArrayList(3); - if(pos%9>5) + if(pos%9 > 5) fl = fl.getOpposite(); if(pos%3==2) fw = fw.getOpposite(); @@ -281,19 +284,19 @@ else if((pos==13||pos==14||pos==16||pos==17)) float maxX = fl==EnumFacing.EAST?1f: fl==EnumFacing.WEST?.8125f: fw==EnumFacing.EAST?1f: .8125f; float minZ = fl==EnumFacing.NORTH?0f: fl==EnumFacing.SOUTH?.1875f: fw==EnumFacing.SOUTH?.1875f: 0f; float maxZ = fl==EnumFacing.SOUTH?1f: fl==EnumFacing.NORTH?.8125f: fw==EnumFacing.SOUTH?1f: .8125f; - list.add(new AxisAlignedBB(minX,-.25,minZ, maxX,0,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, -.25, minZ, maxX, 0, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); minX = fl==EnumFacing.WEST?0f: fl==EnumFacing.EAST?.0625f: fw==EnumFacing.EAST?.0625f: .8125f; maxX = fl==EnumFacing.EAST?1f: fl==EnumFacing.WEST?.9375f: fw==EnumFacing.EAST?.1875f: .9375f; minZ = fl==EnumFacing.NORTH?0f: fl==EnumFacing.SOUTH?.0625f: fw==EnumFacing.SOUTH?.0625f: .8125f; maxZ = fl==EnumFacing.SOUTH?1f: fl==EnumFacing.NORTH?.9375f: fw==EnumFacing.SOUTH?.1875f: .9375f; - list.add(new AxisAlignedBB(minX,0,minZ, maxX,1,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, 0, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); minX = fl==EnumFacing.WEST?.8125f: fl==EnumFacing.EAST?.0625f: fw==EnumFacing.EAST?.1875f: 0f; maxX = fl==EnumFacing.EAST?.1875f: fl==EnumFacing.WEST?.9375f: fw==EnumFacing.EAST?1f: .8125f; minZ = fl==EnumFacing.NORTH?.8125f: fl==EnumFacing.SOUTH?.0625f: fw==EnumFacing.SOUTH?.1875f: 0f; maxZ = fl==EnumFacing.SOUTH?.1875f: fl==EnumFacing.NORTH?.9375f: fw==EnumFacing.SOUTH?1f: .8125f; - list.add(new AxisAlignedBB(minX,0,minZ, maxX,1,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, 0, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); return list; } @@ -304,7 +307,7 @@ else if(pos==21) float maxX = fl==EnumFacing.EAST?.8125f: fl==EnumFacing.WEST?.6875f: fw==EnumFacing.EAST?1f: .8125f; float minZ = fl==EnumFacing.NORTH?.1875f: fl==EnumFacing.SOUTH?.3125f: fw==EnumFacing.SOUTH?.1875f: 0f; float maxZ = fl==EnumFacing.SOUTH?.8125f: fl==EnumFacing.NORTH?.6875f: fw==EnumFacing.SOUTH?1f: .8125f; - list.add(new AxisAlignedBB(minX,0,minZ, maxX,.625f,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, 0, minZ, maxX, .625f, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); return list; } else if(pos==22) @@ -314,23 +317,25 @@ else if(pos==22) float maxX = fl==EnumFacing.EAST?1.4375f: fl==EnumFacing.WEST?.4375f: fw==EnumFacing.EAST?1.4375f: .4375f; float minZ = fl==EnumFacing.NORTH?-.4375f: fl==EnumFacing.SOUTH?.5625f: fw==EnumFacing.SOUTH?.5625f: -.4375f; float maxZ = fl==EnumFacing.SOUTH?1.4375f: fl==EnumFacing.NORTH?.4375f: fw==EnumFacing.SOUTH?1.4375f: .4375f; - list.add(new AxisAlignedBB(minX,.1875,minZ, maxX,1,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, .1875, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); minX = fl==EnumFacing.WEST?0f: fl==EnumFacing.EAST?.5f: fw==EnumFacing.EAST?0f: .4375f; maxX = fl==EnumFacing.EAST?1f: fl==EnumFacing.WEST?.5f: fw==EnumFacing.EAST?.5625f: 1f; minZ = fl==EnumFacing.NORTH?0f: fl==EnumFacing.SOUTH?.5f: fw==EnumFacing.SOUTH?0f: .4375f; maxZ = fl==EnumFacing.SOUTH?1f: fl==EnumFacing.NORTH?.5f: fw==EnumFacing.SOUTH?.5625f: 1f; - list.add(new AxisAlignedBB(minX,0,minZ, maxX,.875,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, 0, minZ, maxX, .875, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); return list; } return null; } + @Override public boolean isOverrideBox(AxisAlignedBB box, EntityPlayer player, RayTraceResult mop, ArrayList list) { return false; } + @Override public List getAdvancedColisionBounds() { @@ -374,6 +379,7 @@ public int[] getEnergyPos() { return new int[]{9}; } + @Override public int[] getRedstonePos() { @@ -385,39 +391,46 @@ public boolean isInWorldProcessingMachine() { return false; } + @Override public boolean additionalCanProcessCheck(MultiblockProcess process) { return true; } + @Override public void doProcessOutput(ItemStack output) { - BlockPos pos = getPos().offset(facing,2); + BlockPos pos = getPos().offset(facing, 2); TileEntity inventoryTile = this.world.getTileEntity(pos); if(inventoryTile!=null) output = Utils.insertStackIntoInventory(inventoryTile, output, facing.getOpposite()); if(!output.isEmpty()) Utils.dropStackAtPos(world, pos, output, facing); } + @Override public void doProcessFluidOutput(FluidStack output) { } + @Override public void onProcessFinish(MultiblockProcess process) { } + @Override public int getMaxProcessPerTick() { return 8; } + @Override public int getProcessQueueMaxLength() { return 8; } + @Override public float getMinProcessDistance(MultiblockProcess process) { @@ -429,49 +442,58 @@ public NonNullList getInventory() { return inventory; } + @Override public boolean isStackValid(int slot, ItemStack stack) { return true; } + @Override public int getSlotLimit(int slot) { return 64; } + @Override public int[] getOutputSlots() { return new int[0]; } + @Override public int[] getOutputTanks() { return new int[]{0}; } + @Override public IFluidTank[] getInternalTanks() { return new IFluidTank[]{tank}; } + @Override protected IFluidTank[] getAccessibleFluidTanks(EnumFacing side) { TileEntityMixer master = master(); - if(master!=null &&( (pos==1&&(side==null||side==facing.getOpposite()))||(pos==3&&(side==null||side==(mirrored?facing.rotateY():facing.rotateYCCW()))) )) + if(master!=null&&((pos==1&&(side==null||side==facing.getOpposite()))||(pos==3&&(side==null||side==(mirrored?facing.rotateY(): facing.rotateYCCW()))))) return master.getInternalTanks(); return new FluidTank[0]; } + @Override protected boolean canFillTankFrom(int iTank, EnumFacing side, FluidStack resources) { - return side==null||side==(mirrored?facing.rotateY():facing.rotateYCCW()); + return side==null||side==(mirrored?facing.rotateY(): facing.rotateYCCW()); } + @Override protected boolean canDrainTankFrom(int iTank, EnumFacing side) { return side==null||side==facing.getOpposite(); } + @Override public void doGraphicalUpdates(int slot) { @@ -487,7 +509,9 @@ public boolean hasCapability(Capability capability, EnumFacing facing) return master()!=null; return super.hasCapability(capability, facing); } - IItemHandler insertionHandler = new IEInventoryHandler(8, this, 0, new boolean[]{true,true,true,true,true,true,true,true}, new boolean[8]); + + IItemHandler insertionHandler = new IEInventoryHandler(8, this, 0, new boolean[]{true, true, true, true, true, true, true, true}, new boolean[8]); + @Override public T getCapability(Capability capability, EnumFacing facing) { @@ -506,16 +530,18 @@ public MixerRecipe findRecipeForInsertion(ItemStack inserting) { return null; } + @Override protected MixerRecipe readRecipeFromNBT(NBTTagCompound tag) { return MixerRecipe.loadFromNBT(tag); } + @Override protected MultiblockProcess loadProcessFromNBT(NBTTagCompound tag) { IMultiblockRecipe recipe = readRecipeFromNBT(tag); - if(recipe!=null && recipe instanceof MixerRecipe) + if(recipe!=null&&recipe instanceof MixerRecipe) return new MultiblockProcessMixer((MixerRecipe)recipe, tag.getIntArray("process_inputSlots")).setInputTanks(tag.getIntArray("process_inputTanks")); return null; } @@ -532,6 +558,7 @@ protected List getRecipeFluidOutputs(TileEntityMultiblockMetal multi { return Collections.emptyList(); } + @Override protected List getRecipeFluidInputs(TileEntityMultiblockMetal multiblock) { @@ -539,12 +566,13 @@ protected List getRecipeFluidInputs(TileEntityMultiblockMetal multib } @Override - public boolean canProcess(TileEntityMultiblockMetal multiblock) { - if (!(multiblock instanceof TileEntityMixer)) + public boolean canProcess(TileEntityMultiblockMetal multiblock) + { + if(!(multiblock instanceof TileEntityMixer)) return false; - TileEntityMixer mixer = (TileEntityMixer) multiblock; + TileEntityMixer mixer = (TileEntityMixer)multiblock; // we don't need to check filling since after draining 1 mB of input fluid there will be space for 1 mB of output fluid - return mixer.energyStorage.extractEnergy(energyPerTick, true) == energyPerTick && mixer.tank.drain(Utils.copyFluidStackWithAmount(recipe.fluidInput, 1, false), false) != null; + return mixer.energyStorage.extractEnergy(energyPerTick, true)==energyPerTick&&mixer.tank.drain(Utils.copyFluidStackWithAmount(recipe.fluidInput, 1, false), false)!=null; } @Override @@ -553,13 +581,13 @@ public void doProcessTick(TileEntityMultiblockMetal multiblock) int timerStep = this.maxTicks/this.recipe.fluidAmount; if(this.processTick%timerStep==0) { - FluidStack drained = ((TileEntityMixer)multiblock).tank.drain(Utils.copyFluidStackWithAmount(recipe.fluidInput,1,false), true); + FluidStack drained = ((TileEntityMixer)multiblock).tank.drain(Utils.copyFluidStackWithAmount(recipe.fluidInput, 1, false), true); NonNullList components = NonNullList.withSize(this.inputSlots.length, ItemStack.EMPTY); - for(int i=0; i(recipe, tag.getIntArray("process_inputSlots")).setInputTanks(tag.getIntArray("process_inputTanks")); return null; } + protected NBTTagCompound writeProcessToNBT(MultiblockProcess process) { NBTTagCompound tag = process.recipe.writeToNBT(new NBTTagCompound()); @@ -151,6 +155,7 @@ protected NBTTagCompound writeProcessToNBT(MultiblockProcess process) // ENERGY MANAGEMENT // ================================= public abstract int[] getEnergyPos(); + public boolean isEnergyPos() { for(int i : getEnergyPos()) @@ -169,13 +174,16 @@ public FluxStorage getFluxStorage() return master.energyStorage; return energyStorage; } + @Nonnull @Override public SideConfig getEnergySideConfig(EnumFacing facing) { - return this.formed&&this.isEnergyPos()?SideConfig.INPUT:SideConfig.NONE; + return this.formed&&this.isEnergyPos()?SideConfig.INPUT: SideConfig.NONE; } + IEForgeEnergyWrapper wrapper = new IEForgeEnergyWrapper(this, null); + @Override public IEForgeEnergyWrapper getCapabilityWrapper(EnumFacing facing) { @@ -183,6 +191,7 @@ public IEForgeEnergyWrapper getCapabilityWrapper(EnumFacing facing) return wrapper; return null; } + @Override public void postEnergyTransferUpdate(int energy, boolean simulate) { @@ -197,7 +206,7 @@ public AxisAlignedBB getRenderBoundingBox() if(!isDummy()) { BlockPos nullPos = this.getBlockPosForPos(0); - return new AxisAlignedBB(nullPos, nullPos.offset(facing,structureDimensions[1]).offset(mirrored?facing.rotateYCCW():facing.rotateY(),structureDimensions[2]).up(structureDimensions[0])); + return new AxisAlignedBB(nullPos, nullPos.offset(facing, structureDimensions[1]).offset(mirrored?facing.rotateYCCW(): facing.rotateY(), structureDimensions[2]).up(structureDimensions[0])); } return super.getRenderBoundingBox(); } @@ -206,6 +215,7 @@ public AxisAlignedBB getRenderBoundingBox() // REDSTONE CONTROL // ================================= public abstract int[] getRedstonePos(); + public boolean isRedstonePos() { if(!hasRedstoneControl||getRedstonePos()==null) @@ -215,6 +225,7 @@ public boolean isRedstonePos() return true; return false; } + @Override public int getComparatorInputOverride() { @@ -233,26 +244,27 @@ public boolean hammerUseSide(EnumFacing side, EntityPlayer player, float hitX, f { TileEntityMultiblockMetal master = master(); master.redstoneControlInverted = !master.redstoneControlInverted; - ChatUtils.sendServerNoSpamMessages(player, new TextComponentTranslation(Lib.CHAT_INFO+"rsControl."+(master.redstoneControlInverted?"invertedOn":"invertedOff"))); + ChatUtils.sendServerNoSpamMessages(player, new TextComponentTranslation(Lib.CHAT_INFO+"rsControl."+(master.redstoneControlInverted?"invertedOn": "invertedOff"))); this.updateMasterBlock(null, true); return true; } return false; } + public boolean isRSDisabled() { if(computerOn.isPresent()) return !computerOn.get(); int[] rsPositions = getRedstonePos(); - if(rsPositions==null || rsPositions.length<1) + if(rsPositions==null||rsPositions.length < 1) return false; for(int rsPos : rsPositions) { T tile = this.getTileForPos(rsPos); if(tile!=null) { - boolean b = world.isBlockIndirectlyGettingPowered(tile.getPos())>0; - return redstoneControlInverted != b; + boolean b = world.isBlockIndirectlyGettingPowered(tile.getPos()) > 0; + return redstoneControlInverted!=b; } } return false; @@ -271,19 +283,24 @@ public T getTileForPos(int targetPos) return (T)tile; return null; } + @Override public ItemStack getOriginalBlock() { - if(pos<0) + if(pos < 0) return ItemStack.EMPTY; ItemStack s = ItemStack.EMPTY; - try{ + try + { int blocksPerLevel = structureDimensions[1]*structureDimensions[2]; int h = (pos/blocksPerLevel); - int l = (pos%blocksPerLevel / structureDimensions[2]); + int l = (pos%blocksPerLevel/structureDimensions[2]); int w = (pos%structureDimensions[2]); s = this.mutliblockInstance.getStructureManual()[h][l][w]; - }catch(Exception e){e.printStackTrace();} + } catch(Exception e) + { + e.printStackTrace(); + } return s.copy(); } @@ -292,6 +309,7 @@ public boolean getIsMirrored() { return this.mirrored; } + @Override public PropertyBoolInverted getBoolProperty(Class inf) { @@ -303,19 +321,20 @@ public PropertyBoolInverted getBoolProperty(Class> processQueue = new ArrayList>(); public int tickedProcesses = 0; + @Override public void update() { ApiUtils.checkForNeedlessTicking(this); tickedProcesses = 0; - if(world.isRemote || isDummy() || isRSDisabled()) + if(world.isRemote||isDummy()||isRSDisabled()) return; int max = getMaxProcessPerTick(); int i = 0; Iterator> processIterator = processQueue.iterator(); tickedProcesses = 0; - while(processIterator.hasNext() && i++ process = processIterator.next(); if(process.canProcess(this)) @@ -328,36 +347,50 @@ public void update() processIterator.remove(); } } + public abstract IFluidTank[] getInternalTanks(); + public abstract R findRecipeForInsertion(ItemStack inserting); + public abstract int[] getOutputSlots(); + public abstract int[] getOutputTanks(); + public abstract boolean additionalCanProcessCheck(MultiblockProcess process); + public abstract void doProcessOutput(ItemStack output); + public abstract void doProcessFluidOutput(FluidStack output); + public abstract void onProcessFinish(MultiblockProcess process); + public abstract int getMaxProcessPerTick(); + public abstract int getProcessQueueMaxLength(); + public abstract float getMinProcessDistance(MultiblockProcess process); + public abstract boolean isInWorldProcessingMachine(); + public boolean addProcessToQueue(MultiblockProcess process, boolean simulate) { return addProcessToQueue(process, simulate, false); } + public boolean addProcessToQueue(MultiblockProcess process, boolean simulate, boolean addToPrevious) { if(addToPrevious&&process instanceof MultiblockProcessInWorld) { - for(MultiblockProcess curr:processQueue) - if(curr instanceof MultiblockProcessInWorld && process.recipe.equals(curr.recipe)) + for(MultiblockProcess curr : processQueue) + if(curr instanceof MultiblockProcessInWorld&&process.recipe.equals(curr.recipe)) { MultiblockProcessInWorld p = (MultiblockProcessInWorld)curr; boolean canStack = true; for(ItemStack old : (List)p.inputItems) { for(ItemStack in : (List)((MultiblockProcessInWorld)process).inputItems) - if(OreDictionary.itemMatches(old, in, true) && Utils.compareItemNBT(old, in)) - if(old.getCount() + in.getCount() >old.getMaxStackSize()) + if(OreDictionary.itemMatches(old, in, true)&&Utils.compareItemNBT(old, in)) + if(old.getCount()+in.getCount() > old.getMaxStackSize()) { canStack = false; break; @@ -371,7 +404,7 @@ public boolean addProcessToQueue(MultiblockProcess process, boolean simulate, for(ItemStack old : (List)p.inputItems) { for(ItemStack in : (List)((MultiblockProcessInWorld)process).inputItems) - if(OreDictionary.itemMatches(old, in, true) && Utils.compareItemNBT(old, in)) + if(OreDictionary.itemMatches(old, in, true)&&Utils.compareItemNBT(old, in)) { old.grow(in.getCount()); break; @@ -381,17 +414,17 @@ public boolean addProcessToQueue(MultiblockProcess process, boolean simulate, } } } - if(getProcessQueueMaxLength()<0 || processQueue.size() < getProcessQueueMaxLength()) + if(getProcessQueueMaxLength() < 0||processQueue.size() < getProcessQueueMaxLength()) { float dist = 1; MultiblockProcess p = null; - if(processQueue.size()>0) + if(processQueue.size() > 0) { - p = processQueue.get(processQueue.size() - 1); - if(p != null) - dist = p.processTick / (float) p.maxTicks; + p = processQueue.get(processQueue.size()-1); + if(p!=null) + dist = p.processTick/(float)p.maxTicks; } - if(p != null && dist < getMinProcessDistance(p)) + if(p!=null&&dist < getMinProcessDistance(p)) return false; if(!simulate) @@ -400,32 +433,34 @@ public boolean addProcessToQueue(MultiblockProcess process, boolean simulate, } return false; } + @Override public int[] getCurrentProcessesStep() { T master = master(); - if(master!=this && master!=null) + if(master!=this&&master!=null) return master.getCurrentProcessesStep(); int[] ia = new int[processQueue.size()]; - for(int i=0; i 0 && !isRSDisabled() && !processQueue.isEmpty(); + return getEnergyStored(null) > 0&&!isRSDisabled()&&!processQueue.isEmpty(); } public abstract static class MultiblockProcess @@ -448,6 +483,7 @@ protected List getRecipeItemOutputs(TileEntityMultiblockMetal multibl { return recipe.getActualItemOutputs(multiblock); } + protected List getRecipeFluidOutputs(TileEntityMultiblockMetal multiblock) { return recipe.getActualFluidOutputs(multiblock); @@ -458,7 +494,7 @@ public boolean canProcess(TileEntityMultiblockMetal multiblock) if(multiblock.energyStorage.extractEnergy(energyPerTick, true)==energyPerTick) { List outputs = recipe.getItemOutputs(); - if(outputs!=null && !outputs.isEmpty()) + if(outputs!=null&&!outputs.isEmpty()) { int[] outputSlots = multiblock.getOutputSlots(); for(ItemStack output : outputs) @@ -472,7 +508,7 @@ public boolean canProcess(TileEntityMultiblockMetal multiblock) for(int iOutputSlot : outputSlots) { ItemStack s = multiblock.getInventory().get(iOutputSlot); - if(s.isEmpty() || (ItemHandlerHelper.canItemStacksStack(s, output) && s.getCount() + output.getCount() <= multiblock.getSlotLimit(iOutputSlot))) + if(s.isEmpty()||(ItemHandlerHelper.canItemStacksStack(s, output)&&s.getCount()+output.getCount() <= multiblock.getSlotLimit(iOutputSlot))) { canOutput = true; break; @@ -484,20 +520,20 @@ public boolean canProcess(TileEntityMultiblockMetal multiblock) } } List fluidOutputs = recipe.getFluidOutputs(); - if(fluidOutputs!=null && !fluidOutputs.isEmpty()) + if(fluidOutputs!=null&&!fluidOutputs.isEmpty()) { IFluidTank[] tanks = multiblock.getInternalTanks(); int[] outputTanks = multiblock.getOutputTanks(); for(FluidStack output : fluidOutputs) - if(output!=null && output.amount>0) + if(output!=null&&output.amount > 0) { boolean canOutput = false; - if(tanks==null || outputTanks==null) + if(tanks==null||outputTanks==null) canOutput = true; else { for(int iOutputTank : outputTanks) - if(iOutputTank>=0&&iOutputTank= 0&&iOutputTank < tanks.length&&tanks[iOutputTank]!=null&&tanks[iOutputTank].fill(output, false)==output.amount) { canOutput = true; break; @@ -516,16 +552,16 @@ public void doProcessTick(TileEntityMultiblockMetal multiblock) { int energyExtracted = energyPerTick; int ticksAdded = 1; - if(this.recipe.getMultipleProcessTicks()>1) + if(this.recipe.getMultipleProcessTicks() > 1) { //Average Insertion, tracked by the advanced flux storage int averageInsertion = multiblock.energyStorage.getAverageInsertion(); //Average Insertion musn'T be greater than possible extraction averageInsertion = multiblock.energyStorage.extractEnergy(averageInsertion, true); - if(averageInsertion>energyExtracted) + if(averageInsertion > energyExtracted) { int possibleTicks = Math.min(averageInsertion/energyPerTick, Math.min(this.recipe.getMultipleProcessTicks(), this.maxTicks-this.processTick)); - if(possibleTicks>1) + if(possibleTicks > 1) { ticksAdded = possibleTicks; energyExtracted *= ticksAdded; @@ -533,9 +569,9 @@ public void doProcessTick(TileEntityMultiblockMetal multiblock) } } multiblock.energyStorage.extractEnergy(energyExtracted, false); - this.processTick+=ticksAdded; + this.processTick += ticksAdded; - if(this.processTick>=this.maxTicks) + if(this.processTick >= this.maxTicks) { this.processFinish(multiblock); } @@ -544,16 +580,16 @@ public void doProcessTick(TileEntityMultiblockMetal multiblock) protected void processFinish(TileEntityMultiblockMetal multiblock) { List outputs = getRecipeItemOutputs(multiblock); - if(outputs!=null && !outputs.isEmpty()) + if(outputs!=null&&!outputs.isEmpty()) { int[] outputSlots = multiblock.getOutputSlots(); for(ItemStack output : outputs) if(!output.isEmpty()) - if(outputSlots==null || multiblock.getInventory()==null) + if(outputSlots==null||multiblock.getInventory()==null) multiblock.doProcessOutput(output.copy()); else { - for(int iOutputSlot:outputSlots) + for(int iOutputSlot : outputSlots) { ItemStack s = multiblock.getInventory().get(iOutputSlot); if(s.isEmpty()) @@ -561,7 +597,7 @@ protected void processFinish(TileEntityMultiblockMetal multiblock) multiblock.getInventory().set(iOutputSlot, output.copy()); break; } - else if(ItemHandlerHelper.canItemStacksStack(s, output) && s.getCount() + output.getCount() <= multiblock.getSlotLimit(iOutputSlot)) + else if(ItemHandlerHelper.canItemStacksStack(s, output)&&s.getCount()+output.getCount() <= multiblock.getSlotLimit(iOutputSlot)) { multiblock.getInventory().get(iOutputSlot).grow(output.getCount()); break; @@ -570,14 +606,14 @@ else if(ItemHandlerHelper.canItemStacksStack(s, output) && s.getCount() + output } } List fluidOutputs = getRecipeFluidOutputs(multiblock); - if(fluidOutputs!=null && !fluidOutputs.isEmpty()) + if(fluidOutputs!=null&&!fluidOutputs.isEmpty()) { IFluidTank[] tanks = multiblock.getInternalTanks(); int[] outputTanks = multiblock.getOutputTanks(); for(FluidStack output : fluidOutputs) - if(output!=null && output.amount>0) + if(output!=null&&output.amount > 0) { - if(tanks==null || outputTanks==null) + if(tanks==null||outputTanks==null) multiblock.doProcessFluidOutput(output); else { @@ -602,11 +638,13 @@ public static class MultiblockProcessInMachine exte { protected int[] inputSlots = new int[0]; protected int[] inputTanks = new int[0]; + public MultiblockProcessInMachine(R recipe, int... inputSlots) { super(recipe); this.inputSlots = inputSlots; } + public MultiblockProcessInMachine setInputTanks(int... inputTanks) { this.inputTanks = inputTanks; @@ -617,6 +655,7 @@ public int[] getInputSlots() { return this.inputSlots; } + public int[] getInputTanks() { return this.inputTanks; @@ -626,6 +665,7 @@ protected List getRecipeItemInputs(TileEntityMultiblockMetal mu { return recipe.getItemInputs(); } + protected List getRecipeFluidInputs(TileEntityMultiblockMetal multiblock) { return recipe.getFluidInputs(); @@ -635,11 +675,11 @@ protected List getRecipeFluidInputs(TileEntityMultiblockMetal multib public void doProcessTick(TileEntityMultiblockMetal multiblock) { NonNullList inv = multiblock.getInventory(); - if(recipe.getItemInputs()!=null && inv!=null) + if(recipe.getItemInputs()!=null&&inv!=null) { NonNullList query = NonNullList.withSize(inputSlots.length, ItemStack.EMPTY); - for(int i=0; i=0&&inputSlots[i]< inv.size()) + for(int i = 0; i < inputSlots.length; i++) + if(inputSlots[i] >= 0&&inputSlots[i] < inv.size()) query.set(i, multiblock.getInventory().get(inputSlots[i])); if(!ApiUtils.stacksMatchIngredientList(recipe.getItemInputs(), query)) { @@ -662,13 +702,14 @@ public void doProcessTick(TileEntityMultiblockMetal multiblock) // } super.doProcessTick(multiblock); } + @Override protected void processFinish(TileEntityMultiblockMetal multiblock) { super.processFinish(multiblock); NonNullList inv = multiblock.getInventory(); List itemInputList = this.getRecipeItemInputs(multiblock); - if(inv != null && this.inputSlots != null && itemInputList != null) + if(inv!=null&&this.inputSlots!=null&&itemInputList!=null) { Iterator iterator = new ArrayList(itemInputList).iterator(); while(iterator.hasNext()) @@ -676,7 +717,7 @@ protected void processFinish(TileEntityMultiblockMetal multiblock) IngredientStack ingr = iterator.next(); int ingrSize = ingr.inputSize; for(int slot : this.inputSlots) - if(!inv.get(slot).isEmpty() && ingr.matchesItemStackIgnoringSize(inv.get(slot))) + if(!inv.get(slot).isEmpty()&&ingr.matchesItemStackIgnoringSize(inv.get(slot))) { int taken = Math.min(inv.get(slot).getCount(), ingrSize); inv.get(slot).shrink(taken); @@ -689,7 +730,7 @@ protected void processFinish(TileEntityMultiblockMetal multiblock) } IFluidTank[] tanks = multiblock.getInternalTanks(); List fluidInputList = this.getRecipeFluidInputs(multiblock); - if(tanks != null && this.inputTanks != null && fluidInputList != null) + if(tanks!=null&&this.inputTanks!=null&&fluidInputList!=null) { Iterator iterator = new ArrayList(fluidInputList).iterator(); while(iterator.hasNext()) @@ -699,7 +740,7 @@ protected void processFinish(TileEntityMultiblockMetal multiblock) for(int tank : this.inputTanks) if(tanks[tank]!=null) { - if(tanks[tank] instanceof IFluidHandler && ((IFluidHandler)tanks[tank]).drain(ingr, false)!=null) + if(tanks[tank] instanceof IFluidHandler&&((IFluidHandler)tanks[tank]).drain(ingr, false)!=null) { FluidStack taken = ((IFluidHandler)tanks[tank]).drain(ingr, true); if((ingrSize -= taken.amount) <= 0) @@ -716,6 +757,7 @@ else if(tanks[tank].getFluid()!=null&&tanks[tank].getFluid().isFluidEqual(ingr)) } } } + @Override protected void writeExtraDataToNBT(NBTTagCompound nbt) { @@ -730,6 +772,7 @@ public static class MultiblockProcessInWorld extend { public List inputItems; protected float transformationPoint; + public MultiblockProcessInWorld(R recipe, float transformationPoint, NonNullList inputItem) { super(recipe); @@ -741,7 +784,7 @@ public MultiblockProcessInWorld(R recipe, float transformationPoint, NonNullList public List getDisplayItem() { - if(processTick / (float)maxTicks > transformationPoint) + if(processTick/(float)maxTicks > transformationPoint) { List list = this.recipe.getItemOutputs(); if(!list.isEmpty()) @@ -756,6 +799,7 @@ protected void writeExtraDataToNBT(NBTTagCompound nbt) nbt.setTag("process_inputItem", Utils.writeInventory(inputItems)); nbt.setFloat("process_transformationPoint", transformationPoint); } + @Override protected void processFinish(TileEntityMultiblockMetal multiblock) { @@ -771,7 +815,7 @@ protected void processFinish(TileEntityMultiblockMetal multiblock) break; } - if(size>0 && inputItem.getCount() > size) + if(size > 0&&inputItem.getCount() > size) { inputItem.splitStack(size); processTick = 0; @@ -786,6 +830,7 @@ public static class MultiblockInventoryHandler_DirectProcessing implements IItem TileEntityMultiblockMetal multiblock; float transformationPoint = .5f; boolean doProcessStacking = false; + public MultiblockInventoryHandler_DirectProcessing(TileEntityMultiblockMetal multiblock) { this.multiblock = multiblock; @@ -796,6 +841,7 @@ public MultiblockInventoryHandler_DirectProcessing setTransformationPoint(float this.transformationPoint = point; return this; } + public MultiblockInventoryHandler_DirectProcessing setProcessStacking(boolean stacking) { this.doProcessStacking = stacking; @@ -807,6 +853,7 @@ public int getSlots() { return 1; } + @Override public ItemStack getStackInSlot(int slot) { @@ -826,7 +873,7 @@ public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) multiblock.markDirty(); multiblock.markContainingBlockForUpdate(null); stack.shrink(displayStack.getCount()); - if(stack.getCount()<=0) + if(stack.getCount() <= 0) stack = ItemStack.EMPTY; } return stack; @@ -839,7 +886,8 @@ public ItemStack extractItem(int slot, int amount, boolean simulate) } @Override - public int getSlotLimit(int slot) { + public int getSlotLimit(int slot) + { return 64; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityRazorWire.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityRazorWire.java index b0067ff9f5..7a2f1ae338 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityRazorWire.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityRazorWire.java @@ -50,7 +50,7 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { super.writeCustomNBT(nbt, descPacket); - nbt.setInteger("facing",facing.ordinal()); + nbt.setInteger("facing", facing.ordinal()); } @Override @@ -58,26 +58,31 @@ public EnumFacing getFacing() { return facing; } + @Override public void setFacing(EnumFacing facing) { this.facing = facing; } + @Override public int getFacingLimitation() { return 2; } + @Override public boolean mirrorFacingOnPlacement(EntityLivingBase placer) { return false; } + @Override public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) { return true; } + @Override public boolean canRotate(EnumFacing axis) { @@ -91,8 +96,8 @@ public void onEntityCollision(World world, Entity entity) { entity.motionX *= 0.2D; entity.motionZ *= 0.2D; - int protection = (!((EntityLivingBase)entity).getItemStackFromSlot(EntityEquipmentSlot.FEET).isEmpty()?1:0)+(!((EntityLivingBase)entity).getItemStackFromSlot(EntityEquipmentSlot.LEGS).isEmpty()?1:0); - float dmg = protection==2?.5f:protection==1?1:1.5f; + int protection = (!((EntityLivingBase)entity).getItemStackFromSlot(EntityEquipmentSlot.FEET).isEmpty()?1: 0)+(!((EntityLivingBase)entity).getItemStackFromSlot(EntityEquipmentSlot.LEGS).isEmpty()?1: 0); + float dmg = protection==2?.5f: protection==1?1: 1.5f; entity.attackEntityFrom(IEDamageSources.razorWire, dmg); } } @@ -108,19 +113,19 @@ public List getAdvancedColisionBounds() { boolean wallL = renderWall(true); boolean wallR = renderWall(false); - if((!isOnGround() && !isStacked()) || !(wallL||wallR)) + if((!isOnGround()&&!isStacked())||!(wallL||wallR)) return Collections.singletonList(null); - List list = new ArrayList<>(wallL&&wallR?2:1); + List list = new ArrayList<>(wallL&&wallR?2: 1); if(wallL) - list.add(new AxisAlignedBB(facing==EnumFacing.SOUTH?.8125:0,0,facing==EnumFacing.WEST?.8125:0, facing==EnumFacing.NORTH?.1875:1,1,facing==EnumFacing.EAST?.1875:1).offset(getPos())); + list.add(new AxisAlignedBB(facing==EnumFacing.SOUTH?.8125: 0, 0, facing==EnumFacing.WEST?.8125: 0, facing==EnumFacing.NORTH?.1875: 1, 1, facing==EnumFacing.EAST?.1875: 1).offset(getPos())); if(wallR) - list.add(new AxisAlignedBB(facing==EnumFacing.NORTH?.8125:0,0,facing==EnumFacing.EAST?.8125:0, facing==EnumFacing.SOUTH?.1875:1,1,facing==EnumFacing.WEST?.1875:1).offset(getPos())); + list.add(new AxisAlignedBB(facing==EnumFacing.NORTH?.8125: 0, 0, facing==EnumFacing.EAST?.8125: 0, facing==EnumFacing.SOUTH?.1875: 1, 1, facing==EnumFacing.WEST?.1875: 1).offset(getPos())); return list; } private boolean renderWall(boolean left) { - EnumFacing dir = left?facing.rotateY():facing.rotateYCCW(); + EnumFacing dir = left?facing.rotateY(): facing.rotateYCCW(); BlockPos neighbourPos = getPos().offset(dir, -1); if(!world.isBlockLoaded(neighbourPos)) return true; @@ -129,11 +134,13 @@ private boolean renderWall(boolean left) IBlockState neighbour = world.getBlockState(neighbourPos); return !neighbour.isSideSolid(world, neighbourPos, dir); } + private boolean isOnGround() { BlockPos down = getPos().down(); - return world.getBlockState(down).isSideSolid(world,down,EnumFacing.UP); + return world.getBlockState(down).isSideSolid(world, down, EnumFacing.UP); } + private boolean isStacked() { BlockPos down = getPos().down(); @@ -150,9 +157,9 @@ public boolean shouldRenderGroup(IBlockState object, String group) if(group==null) return false; boolean stack = isStacked(); - if(!stack && !isOnGround()) + if(!stack&&!isOnGround()) return !group.startsWith("wood"); - if(group.startsWith("wood") && !(group.endsWith("inverted")==stack)) + if(group.startsWith("wood")&&!(group.endsWith("inverted")==stack)) return false; if(group.startsWith("wood_left")) return renderWall(true); @@ -164,14 +171,15 @@ else if("wire_right".equals(group)||"barbs_right".equals(group)) return !renderWall(false); return true; } + @SideOnly(Side.CLIENT) @Override public String getCacheKey(IBlockState object) { boolean stack = isStacked(); - if(!stack && !isOnGround()) + if(!stack&&!isOnGround()) return "default"; - return (renderWall(true)?"L":" ")+(renderWall(false)?"R":" ")+(stack?"_stack":""); + return (renderWall(true)?"L": " ")+(renderWall(false)?"R": " ")+(stack?"_stack": ""); } @Override @@ -179,15 +187,17 @@ protected boolean canTakeLV() { return true; } + @Override public boolean isEnergyOutput() { return true; } + @Override public int outputEnergy(int amount, boolean simulate, int energyType) { - if(amount>0) + if(amount > 0) { if(!simulate) { @@ -199,23 +209,23 @@ public int outputEnergy(int amount, boolean simulate, int energyType) EnumFacing dir = facing.rotateY(); if(dir.getAxisDirection()==AxisDirection.NEGATIVE) dir = dir.getOpposite(); - for(int i=1; i<=maxReach; i++) + for(int i = 1; i <= maxReach; i++) { - BlockPos posP = getPos().offset(dir,i); - if(connectP && world.isBlockLoaded(posP) && world.getTileEntity(posP) instanceof TileEntityRazorWire) + BlockPos posP = getPos().offset(dir, i); + if(connectP&&world.isBlockLoaded(posP)&&world.getTileEntity(posP) instanceof TileEntityRazorWire) widthP++; else connectP = false; - BlockPos posN = getPos().offset(dir,-i); - if(connectN && world.isBlockLoaded(posN) && world.getTileEntity(posN) instanceof TileEntityRazorWire) + BlockPos posN = getPos().offset(dir, -i); + if(connectN&&world.isBlockLoaded(posN)&&world.getTileEntity(posN) instanceof TileEntityRazorWire) widthN++; else connectN = false; } - AxisAlignedBB aabb = new AxisAlignedBB(getPos().add(facing.getAxis()==Axis.Z?-widthN:0,0,facing.getAxis()==Axis.X?-widthN:0),getPos().add(facing.getAxis()==Axis.Z?1+widthP:1,1,facing.getAxis()==Axis.X?1+widthP:1)); + AxisAlignedBB aabb = new AxisAlignedBB(getPos().add(facing.getAxis()==Axis.Z?-widthN: 0, 0, facing.getAxis()==Axis.X?-widthN: 0), getPos().add(facing.getAxis()==Axis.Z?1+widthP: 1, 1, facing.getAxis()==Axis.X?1+widthP: 1)); List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, aabb); for(EntityLivingBase ent : entities) - ent.attackEntityFrom(IEDamageSources.razorShock,2); + ent.attackEntityFrom(IEDamageSources.razorShock, 2); } return 64; } @@ -225,27 +235,27 @@ public int outputEnergy(int amount, boolean simulate, int energyType) @Override public Vec3d getConnectionOffset(Connection con) { - int xDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(Utils.toCC(this))&&con.end!=null)? con.end.getX()-getPos().getX(): (con.end.equals(Utils.toCC(this))&& con.start!=null)?con.start.getX()-getPos().getX(): 0; - int yDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(Utils.toCC(this))&&con.end!=null)? con.end.getY()-getPos().getY(): (con.end.equals(Utils.toCC(this))&& con.start!=null)?con.start.getY()-getPos().getY(): 0; - int zDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(Utils.toCC(this))&&con.end!=null)? con.end.getZ()-getPos().getZ(): (con.end.equals(Utils.toCC(this))&& con.start!=null)?con.start.getZ()-getPos().getZ(): 0; + int xDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(Utils.toCC(this))&&con.end!=null)?con.end.getX()-getPos().getX(): (con.end.equals(Utils.toCC(this))&&con.start!=null)?con.start.getX()-getPos().getX(): 0; + int yDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(Utils.toCC(this))&&con.end!=null)?con.end.getY()-getPos().getY(): (con.end.equals(Utils.toCC(this))&&con.start!=null)?con.start.getY()-getPos().getY(): 0; + int zDif = (con==null||con.start==null||con.end==null)?0: (con.start.equals(Utils.toCC(this))&&con.end!=null)?con.end.getZ()-getPos().getZ(): (con.end.equals(Utils.toCC(this))&&con.start!=null)?con.start.getZ()-getPos().getZ(): 0; boolean wallL = renderWall(true); boolean wallR = renderWall(false); - if(!isOnGround() || !(wallL||wallR)) + if(!isOnGround()||!(wallL||wallR)) { - if(yDif>0) - return new Vec3d(facing.getFrontOffsetX()!=0?.5:xDif<0?.40625:.59375, .9375, facing.getFrontOffsetZ()!=0?.5:zDif<0?.40625:.59375); + if(yDif > 0) + return new Vec3d(facing.getFrontOffsetX()!=0?.5: xDif < 0?.40625: .59375, .9375, facing.getFrontOffsetZ()!=0?.5: zDif < 0?.40625: .59375); else { - boolean right = facing.rotateY().getAxisDirection().getOffset()==Math.copySign(1, facing.getFrontOffsetX()!=0?zDif:xDif); + boolean right = facing.rotateY().getAxisDirection().getOffset()==Math.copySign(1, facing.getFrontOffsetX()!=0?zDif: xDif); int faceX = facing.getFrontOffsetX(); int faceZ = facing.getFrontOffsetZ(); - return new Vec3d(faceX!=0?.5+(right?0:faceX*.1875):(xDif<0?0:1), .046875, faceZ!=0?.5+(right?0:faceZ*.1875):(zDif<0?0:1)); + return new Vec3d(faceX!=0?.5+(right?0: faceX*.1875): (xDif < 0?0: 1), .046875, faceZ!=0?.5+(right?0: faceZ*.1875): (zDif < 0?0: 1)); } } else { - boolean wallN = facing==EnumFacing.NORTH||facing==EnumFacing.EAST?wallL:wallR; - return new Vec3d(facing.getFrontOffsetX()!=0?.5: xDif<0&&wallN?.125:.875, .9375, facing.getFrontOffsetZ()!=0?.5:zDif<0&&wallN?.125:.875); + boolean wallN = facing==EnumFacing.NORTH||facing==EnumFacing.EAST?wallL: wallR; + return new Vec3d(facing.getFrontOffsetX()!=0?.5: xDif < 0&&wallN?.125: .875, .9375, facing.getFrontOffsetZ()!=0?.5: zDif < 0&&wallN?.125: .875); } } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityRedstoneBreaker.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityRedstoneBreaker.java index 11d22cb383..069ff10916 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityRedstoneBreaker.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityRedstoneBreaker.java @@ -24,12 +24,13 @@ public class TileEntityRedstoneBreaker extends TileEntityBreakerSwitch implement @Override public void update() { - if (!world.isRemote&&(world.isBlockIndirectlyGettingPowered(getPos())>0)==active) + if(!world.isRemote&&(world.isBlockIndirectlyGettingPowered(getPos()) > 0)==active) { active = !active; ImmersiveNetHandler.INSTANCE.resetCachedIndirectConnections(world, pos); } } + @Override protected boolean canTakeHV() { @@ -45,14 +46,14 @@ public boolean allowEnergyToPass(Connection con) @Override public float[] getBlockBounds() { - Vec3d start = new Vec3d(0,.125f,0); - Vec3d end = new Vec3d(1,.875f,1); + Vec3d start = new Vec3d(0, .125f, 0); + Vec3d end = new Vec3d(1, .875f, 1); Matrix4 mat = new Matrix4(facing); mat.translate(.5, .5, 0).rotate(Math.PI/2*rotation, 0, 0, 1).translate(-.5, -.5, 0); start = mat.apply(start); end = mat.apply(end); - return new float[]{(float) start.x, (float) start.y, (float) start.z, - (float) end.x, (float) end.y, (float) end.z}; + return new float[]{(float)start.x, (float)start.y, (float)start.z, + (float)end.x, (float)end.y, (float)end.z}; } @Override @@ -60,10 +61,10 @@ public Vec3d getConnectionOffset(Connection con) { Matrix4 mat = new Matrix4(facing); mat.translate(.5, .5, 0).rotate(Math.PI/2*rotation, 0, 0, 1).translate(-.5, -.5, 0); - if (endOfLeftConnection==null) + if(endOfLeftConnection==null) calculateLeftConn(mat); boolean isLeft = con.end.equals(endOfLeftConnection)||con.start.equals(endOfLeftConnection); - Vec3d ret = mat.apply(isLeft?new Vec3d(.125, .5, 1):new Vec3d(.875, .5, 1)); + Vec3d ret = mat.apply(isLeft?new Vec3d(.125, .5, 1): new Vec3d(.875, .5, 1)); return ret; } @@ -72,16 +73,19 @@ public int getWeakRSOutput(IBlockState state, EnumFacing side) { return 0; } + @Override public int getStrongRSOutput(IBlockState state, EnumFacing side) { return 0; } + @Override public boolean interact(EnumFacing side, EntityPlayer player, EnumHand hand, ItemStack heldItem, float hitX, float hitY, float hitZ) { return false; } + @Override public boolean canConnectRedstone(IBlockState state, EnumFacing side) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityRefinery.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityRefinery.java index c56a31bd8d..4e74783fd5 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityRefinery.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityRefinery.java @@ -40,6 +40,7 @@ public class TileEntityRefinery extends TileEntityMultiblockMetal inventory = NonNullList.withSize(6, ItemStack.EMPTY); + public TileEntityRefinery() { super(MultiblockRefinery.instance, new int[]{3, 3, 5}, 16000, true); diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityRelayHV.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityRelayHV.java index d652942599..e96c26d1e1 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityRelayHV.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityRelayHV.java @@ -35,6 +35,6 @@ protected boolean isRelay() @Override public boolean shouldRenderGroup(IBlockState object, String group) { - return MinecraftForgeClient.getRenderLayer()== BlockRenderLayer.TRANSLUCENT; + return MinecraftForgeClient.getRenderLayer()==BlockRenderLayer.TRANSLUCENT; } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntitySampleDrill.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntitySampleDrill.java index ea4b464269..3cfcc6ae2e 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntitySampleDrill.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntitySampleDrill.java @@ -14,7 +14,6 @@ import blusunrize.immersiveengineering.api.energy.immersiveflux.FluxStorage; import blusunrize.immersiveengineering.api.tool.ExcavatorHandler; import blusunrize.immersiveengineering.api.tool.ExcavatorHandler.MineralWorldInfo; -import blusunrize.immersiveengineering.common.Config; import blusunrize.immersiveengineering.common.Config.IEConfig; import blusunrize.immersiveengineering.common.IEContent; import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IHasDummyBlocks; @@ -23,7 +22,6 @@ import blusunrize.immersiveengineering.common.blocks.TileEntityIEBase; import blusunrize.immersiveengineering.common.util.EnergyHelper.IEForgeEnergyWrapper; import blusunrize.immersiveengineering.common.util.EnergyHelper.IIEInternalFluxHandler; -import blusunrize.immersiveengineering.common.util.IELogger; import blusunrize.immersiveengineering.common.util.ItemNBTHelper; import com.google.common.collect.Lists; import net.minecraft.block.state.IBlockState; @@ -49,8 +47,8 @@ public class TileEntitySampleDrill extends TileEntityIEBase implements ITickable, IIEInternalFluxHandler, IHasDummyBlocks, IPlayerInteraction, IHasObjProperty { public FluxStorage energyStorage = new FluxStorage(8000); - public int dummy=0; - public int process=0; + public int dummy = 0; + public int process = 0; public boolean active = false; @Nonnull public ItemStack sample = ItemStack.EMPTY; @@ -64,37 +62,37 @@ public static boolean _Immovable() public void update() { ApiUtils.checkForNeedlessTicking(this); - if(dummy!=0 || world.isAirBlock(getPos().add(0,-1,0)) || !sample.isEmpty()) + if(dummy!=0||world.isAirBlock(getPos().add(0, -1, 0))||!sample.isEmpty()) return; - if (world.isRemote && active) + if(world.isRemote&&active) { process++; return; } - boolean powered = world.isBlockIndirectlyGettingPowered(getPos())>0; + boolean powered = world.isBlockIndirectlyGettingPowered(getPos()) > 0; final boolean prevActive = active; - if(!active && powered) + if(!active&&powered) active = true; - else if(active && !powered && process>= IEConfig.Machines.coredrill_time) + else if(active&&!powered&&process >= IEConfig.Machines.coredrill_time) active = false; - if(active && process< IEConfig.Machines.coredrill_time) - if(energyStorage.extractEnergy(IEConfig.Machines.coredrill_consumption, false)== IEConfig.Machines.coredrill_consumption) + if(active&&process < IEConfig.Machines.coredrill_time) + if(energyStorage.extractEnergy(IEConfig.Machines.coredrill_consumption, false)==IEConfig.Machines.coredrill_consumption) { process++; - if(process>= IEConfig.Machines.coredrill_time) + if(process >= IEConfig.Machines.coredrill_time) { - int cx = getPos().getX()>>4; - int cz = getPos().getZ()>>4; + int cx = getPos().getX() >> 4; + int cz = getPos().getZ() >> 4; MineralWorldInfo info = ExcavatorHandler.getMineralWorldInfo(world, cx, cz); - this.sample = createCoreSample(world, (getPos().getX()>>4), (getPos().getZ()>>4), info); + this.sample = createCoreSample(world, (getPos().getX() >> 4), (getPos().getZ() >> 4), info); } this.markDirty(); this.markContainingBlockForUpdate(null); } - if (prevActive!=active) + if(prevActive!=active) { this.markDirty(); this.markContainingBlockForUpdate(null); @@ -105,10 +103,12 @@ public float getSampleProgress() { return process/(float)IEConfig.Machines.coredrill_time; } + public boolean isSamplingFinished() { - return process>= IEConfig.Machines.coredrill_time; + return process >= IEConfig.Machines.coredrill_time; } + public String getVein() { if(sample.isEmpty()) @@ -120,7 +120,7 @@ public int getExpectedVeinYield() { if(sample.isEmpty()) return -1; - return ExcavatorHandler.mineralVeinCapacity - sample.getTagCompound().getInteger("depletion"); + return ExcavatorHandler.mineralVeinCapacity-sample.getTagCompound().getInteger("depletion"); } @Nonnull @@ -128,8 +128,8 @@ public ItemStack createCoreSample(World world, int chunkX, int chunkZ, @Nullable { ItemStack stack = new ItemStack(IEContent.itemCoresample); ItemNBTHelper.setLong(stack, "timestamp", world.getTotalWorldTime()); - ItemNBTHelper.setIntArray(stack, "coords", new int[]{world.provider.getDimension(), chunkX,chunkZ}); - if (info==null) + ItemNBTHelper.setIntArray(stack, "coords", new int[]{world.provider.getDimension(), chunkX, chunkZ}); + if(info==null) return stack; if(info.mineralOverride!=null) ItemNBTHelper.setString(stack, "mineral", info.mineralOverride.name); @@ -137,7 +137,7 @@ else if(info.mineral!=null) ItemNBTHelper.setString(stack, "mineral", info.mineral.name); else return stack; - if(ExcavatorHandler.mineralVeinCapacity<0||info.depletion<0) + if(ExcavatorHandler.mineralVeinCapacity < 0||info.depletion < 0) ItemNBTHelper.setBoolean(stack, "infinite", true); else ItemNBTHelper.setInt(stack, "depletion", info.depletion); @@ -154,6 +154,7 @@ public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) if(!sample.isEmpty()) nbt.setTag("sample", sample.writeToNBT(new NBTTagCompound())); } + @Override public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) { @@ -168,13 +169,14 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) @SideOnly(Side.CLIENT) private AxisAlignedBB renderAABB; + @SideOnly(Side.CLIENT) @Override public AxisAlignedBB getRenderBoundingBox() { if(renderAABB==null) if(dummy==0) - renderAABB = new AxisAlignedBB(getPos(), getPos().add(1,3,1)); + renderAABB = new AxisAlignedBB(getPos(), getPos().add(1, 3, 1)); else renderAABB = new AxisAlignedBB(getPos(), getPos()); return renderAABB; @@ -185,26 +187,29 @@ public AxisAlignedBB getRenderBoundingBox() @Override public FluxStorage getFluxStorage() { - if(dummy>0) + if(dummy > 0) { - TileEntity te = world.getTileEntity(getPos().add(0,-dummy,0)); + TileEntity te = world.getTileEntity(getPos().add(0, -dummy, 0)); if(te instanceof TileEntitySampleDrill) return ((TileEntitySampleDrill)te).getFluxStorage(); } return energyStorage; } + @Nonnull @Override public SideConfig getEnergySideConfig(EnumFacing facing) { - return dummy==0&&facing!=null&&facing.getAxis()!=Axis.Y?SideConfig.INPUT:SideConfig.NONE; + return dummy==0&&facing!=null&&facing.getAxis()!=Axis.Y?SideConfig.INPUT: SideConfig.NONE; } + IEForgeEnergyWrapper[] wrappers = { new IEForgeEnergyWrapper(this, EnumFacing.NORTH), new IEForgeEnergyWrapper(this, EnumFacing.SOUTH), new IEForgeEnergyWrapper(this, EnumFacing.WEST), new IEForgeEnergyWrapper(this, EnumFacing.EAST) }; + @Override public IEForgeEnergyWrapper getCapabilityWrapper(EnumFacing facing) { @@ -216,23 +221,25 @@ public IEForgeEnergyWrapper getCapabilityWrapper(EnumFacing facing) @Override public boolean isDummy() { - return dummy>0; + return dummy > 0; } + @Override public void placeDummies(BlockPos pos, IBlockState state, EnumFacing side, float hitX, float hitY, float hitZ) { - for(int i=1; i<=2; i++) + for(int i = 1; i <= 2; i++) { - world.setBlockState(pos.add(0,i,0), state); - ((TileEntitySampleDrill)world.getTileEntity(pos.add(0,i,0))).dummy = i; + world.setBlockState(pos.add(0, i, 0), state); + ((TileEntitySampleDrill)world.getTileEntity(pos.add(0, i, 0))).dummy = i; } } + @Override public void breakDummies(BlockPos pos, IBlockState state) { - for(int i=0; i<=2; i++) - if(world.getTileEntity(getPos().add(0,-dummy,0).add(0,i,0)) instanceof TileEntitySampleDrill) - world.setBlockToAir(getPos().add(0,-dummy,0).add(0,i,0)); + for(int i = 0; i <= 2; i++) + if(world.getTileEntity(getPos().add(0, -dummy, 0).add(0, i, 0)) instanceof TileEntitySampleDrill) + world.setBlockToAir(getPos().add(0, -dummy, 0).add(0, i, 0)); } @Override @@ -240,7 +247,7 @@ public boolean interact(EnumFacing side, EntityPlayer player, EnumHand hand, Ite { if(dummy!=0) { - TileEntity te = world.getTileEntity(getPos().add(0,-dummy,0)); + TileEntity te = world.getTileEntity(getPos().add(0, -dummy, 0)); if(te instanceof TileEntitySampleDrill) return ((TileEntitySampleDrill)te).interact(side, player, hand, heldItem, hitX, hitY, hitZ); } @@ -257,7 +264,7 @@ public boolean interact(EnumFacing side, EntityPlayer player, EnumHand hand, Ite } else if(!this.active) { - if (energyStorage.getEnergyStored()>=IEConfig.Machines.coredrill_consumption) + if(energyStorage.getEnergyStored() >= IEConfig.Machines.coredrill_consumption) { this.active = true; markDirty(); @@ -310,6 +317,7 @@ else if(!this.active) } static ArrayList displayList = Lists.newArrayList("drill_base"); + @Override public ArrayList compileDisplayList() { @@ -328,13 +336,14 @@ public String getVeinLocalizedName() return name; return localizedName; } + public float getVeinIntegrity() { - if (sample.isEmpty()) + if(sample.isEmpty()) return 0; - else if (ItemNBTHelper.hasKey(sample, "infinite")) + else if(ItemNBTHelper.hasKey(sample, "infinite")) return -1; - else if (ItemNBTHelper.hasKey(sample, "depletion")) + else if(ItemNBTHelper.hasKey(sample, "depletion")) return 1-ItemNBTHelper.getInt(sample, "depletion")/(float)ExcavatorHandler.mineralVeinCapacity; return 0; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntitySheetmetalTank.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntitySheetmetalTank.java index f0cc3f6799..3838f347d2 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntitySheetmetalTank.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntitySheetmetalTank.java @@ -10,7 +10,6 @@ import blusunrize.immersiveengineering.api.ApiUtils; import blusunrize.immersiveengineering.api.Lib; -import blusunrize.immersiveengineering.common.Config.IEConfig; import blusunrize.immersiveengineering.common.IEContent; import blusunrize.immersiveengineering.common.blocks.BlockTypes_MetalsAll; import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IBlockOverlayText; @@ -43,7 +42,9 @@ public class TileEntitySheetmetalTank extends TileEntityMultiblockPart0) - for(int i=0; i<6; i++) - if(i!=1 && tank.getFluidAmount()>0) + if(pos==4&&!world.isRemote&&world.isBlockIndirectlyGettingPowered(getPos()) > 0) + for(int i = 0; i < 6; i++) + if(i!=1&&tank.getFluidAmount() > 0) { EnumFacing f = EnumFacing.getFront(i); int outSize = Math.min(144, tank.getFluidAmount()); FluidStack out = Utils.copyFluidStackWithAmount(tank.getFluid(), outSize, false); BlockPos outputPos = getPos().offset(f); IFluidHandler output = FluidUtil.getFluidHandler(world, outputPos, f.getOpposite()); - if(output != null) + if(output!=null) { int accepted = output.fill(out, false); if(accepted > 0) @@ -123,16 +125,16 @@ public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) public float[] getBlockBounds() { if(pos==9) - return new float[]{.375f,0,.375f,.625f,1,.625f}; + return new float[]{.375f, 0, .375f, .625f, 1, .625f}; if(pos==0||pos==2||pos==6||pos==8) - return new float[]{.375f,0,.375f,.625f,1,.625f}; - return new float[]{0,0,0,1,1,1}; + return new float[]{.375f, 0, .375f, .625f, 1, .625f}; + return new float[]{0, 0, 0, 1, 1, 1}; } @Override public ItemStack getOriginalBlock() { - return pos==0||pos==2||pos==6||pos==8?new ItemStack(IEContent.blockWoodenDecoration,1,BlockTypes_WoodenDecoration.FENCE.getMeta()):new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.IRON.getMeta()); + return pos==0||pos==2||pos==6||pos==8?new ItemStack(IEContent.blockWoodenDecoration, 1, BlockTypes_WoodenDecoration.FENCE.getMeta()): new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.IRON.getMeta()); } @Override @@ -145,15 +147,17 @@ public BlockPos getOrigin() protected IFluidTank[] getAccessibleFluidTanks(EnumFacing side) { TileEntitySheetmetalTank master = master(); - if(master!=null && (pos==4||pos==40)) + if(master!=null&&(pos==4||pos==40)) return new FluidTank[]{master.tank}; return new FluidTank[0]; } + @Override protected boolean canFillTankFrom(int iTank, EnumFacing side, FluidStack resource) { return pos==4||pos==40; } + @Override protected boolean canDrainTankFrom(int iTank, EnumFacing side) { @@ -177,25 +181,26 @@ public boolean interact(EnumFacing side, EntityPlayer player, EnumHand hand, Ite @SideOnly(Side.CLIENT) private AxisAlignedBB renderAABB; + @Override @SideOnly(Side.CLIENT) public AxisAlignedBB getRenderBoundingBox() { if(renderAABB==null) if(pos==4) - renderAABB = new AxisAlignedBB(getPos().add(-1,0,-1), getPos().add(2,5,2)); + renderAABB = new AxisAlignedBB(getPos().add(-1, 0, -1), getPos().add(2, 5, 2)); else - renderAABB = new AxisAlignedBB(getPos(),getPos()); + renderAABB = new AxisAlignedBB(getPos(), getPos()); return renderAABB; } @Override public int getComparatorInputOverride() { - if (pos==4) + if(pos==4) return (15*tank.getFluidAmount())/tank.getCapacity(); TileEntitySheetmetalTank master = master(); - if (offset[1]>=1&&offset[1]<=4&&master!=null)//4 layers of storage + if(offset[1] >= 1&&offset[1] <= 4&&master!=null)//4 layers of storage { FluidTank t = master.tank; int layer = offset[1]-1; @@ -209,10 +214,10 @@ public int getComparatorInputOverride() private void updateComparatorValuesPart1() { - int vol = tank.getCapacity() / 4; - for (int i = 0; i < 4; i++) + int vol = tank.getCapacity()/4; + for(int i = 0; i < 4; i++) { - int filled = tank.getFluidAmount() - i * vol; + int filled = tank.getFluidAmount()-i*vol; oldComps[i] = Math.min(15, Math.max((15*filled)/vol, 0)); } masterCompOld = (15*tank.getFluidAmount())/tank.getCapacity(); @@ -220,17 +225,17 @@ private void updateComparatorValuesPart1() private void updateComparatorValuesPart2() { - int vol = tank.getCapacity() / 6; - if ((15*tank.getFluidAmount())/tank.getCapacity()!=masterCompOld) + int vol = tank.getCapacity()/6; + if((15*tank.getFluidAmount())/tank.getCapacity()!=masterCompOld) world.notifyNeighborsOfStateChange(getPos(), getBlockType(), true); - for(int i=0; i<4; i++) + for(int i = 0; i < 4; i++) { - int filled = tank.getFluidAmount() - i * vol; + int filled = tank.getFluidAmount()-i*vol; int now = Math.min(15, Math.max((15*filled)/vol, 0)); - if (now!=oldComps[i]) + if(now!=oldComps[i]) { - for(int x=-1; x<=1; x++) - for(int z=-1; z<=1; z++) + for(int x = -1; x <= 1; x++) + for(int z = -1; z <= 1; z++) { BlockPos pos = getPos().add(-offset[0]+x, -offset[1]+i+1, -offset[2]+z); world.notifyNeighborsOfStateChange(pos, world.getBlockState(pos).getBlock(), true); diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntitySilo.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntitySilo.java index 196391f7f9..68f7681bff 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntitySilo.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntitySilo.java @@ -9,7 +9,6 @@ package blusunrize.immersiveengineering.common.blocks.metal; import blusunrize.immersiveengineering.api.ApiUtils; -import blusunrize.immersiveengineering.common.Config.IEConfig; import blusunrize.immersiveengineering.common.IEContent; import blusunrize.immersiveengineering.common.blocks.BlockTypes_MetalsAll; import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IComparatorOverride; @@ -48,31 +47,34 @@ public class TileEntitySilo extends TileEntityMultiblockPart imp private boolean forceUpdate = false; private static final int[] size = {7, 3, 3}; - public TileEntitySilo() { + + public TileEntitySilo() + { super(size); } + @Override public void update() { ApiUtils.checkForNeedlessTicking(this); - if(pos==4 && !world.isRemote && !this.identStack.isEmpty() && storageAmount>0 && world.isBlockIndirectlyGettingPowered(getPos())>0 && world.getTotalWorldTime()%8==0) + if(pos==4&&!world.isRemote&&!this.identStack.isEmpty()&&storageAmount > 0&&world.isBlockIndirectlyGettingPowered(getPos()) > 0&&world.getTotalWorldTime()%8==0) { updateComparatorValuesPart1(); for(EnumFacing f : EnumFacing.values()) if(f!=EnumFacing.UP) { TileEntity inventory = Utils.getExistingTileEntity(world, getPos().offset(f)); - ItemStack stack = Utils.copyStackWithAmount(identStack,1); + ItemStack stack = Utils.copyStackWithAmount(identStack, 1); stack = Utils.insertStackIntoInventory(inventory, stack, f.getOpposite()); if(stack.isEmpty()) { storageAmount--; - if(storageAmount<=0) + if(storageAmount <= 0) identStack = ItemStack.EMPTY; this.markDirty(); markContainingBlockForUpdate(null); - if(storageAmount<=0) + if(storageAmount <= 0) break; } } @@ -113,11 +115,13 @@ protected IFluidTank[] getAccessibleFluidTanks(EnumFacing side) { return new FluidTank[0]; } + @Override protected boolean canFillTankFrom(int iTank, EnumFacing side, FluidStack resources) { return false; } + @Override protected boolean canDrainTankFrom(int iTank, EnumFacing side) { @@ -129,19 +133,19 @@ public float[] getBlockBounds() { if(pos==0||pos==2||pos==6||pos==8) { - float xMin = (facing.getAxis() == Axis.X ? (pos > 2 ^ facing == EnumFacing.EAST) : (pos % 3 == 2 ^ facing == EnumFacing.SOUTH)) ? .75f : 0; - float xMax = (facing.getAxis() == Axis.X ? (pos < 3 ^ facing == EnumFacing.EAST) : (pos % 3 == 0 ^ facing == EnumFacing.SOUTH)) ? .25f : 1; - float zMin = (facing.getAxis() == Axis.X ? (pos % 3 == 2 ^ facing == EnumFacing.EAST) : (pos < 3 ^ facing == EnumFacing.SOUTH)) ? .75f : 0; - float zMax = (facing.getAxis() == Axis.X ? (pos % 3 == 0 ^ facing == EnumFacing.EAST) : (pos > 2 ^ facing == EnumFacing.SOUTH)) ? .25f : 1; + float xMin = (facing.getAxis()==Axis.X?(pos > 2^facing==EnumFacing.EAST): (pos%3==2^facing==EnumFacing.SOUTH))?.75f: 0; + float xMax = (facing.getAxis()==Axis.X?(pos < 3^facing==EnumFacing.EAST): (pos%3==0^facing==EnumFacing.SOUTH))?.25f: 1; + float zMin = (facing.getAxis()==Axis.X?(pos%3==2^facing==EnumFacing.EAST): (pos < 3^facing==EnumFacing.SOUTH))?.75f: 0; + float zMax = (facing.getAxis()==Axis.X?(pos%3==0^facing==EnumFacing.EAST): (pos > 2^facing==EnumFacing.SOUTH))?.25f: 1; return new float[]{xMin, 0, zMin, xMax, 1, zMax}; } - return new float[]{0,0,0,1,1,1}; + return new float[]{0, 0, 0, 1, 1, 1}; } @Override public ItemStack getOriginalBlock() { - return pos==0||pos==2||pos==6||pos==8?new ItemStack(IEContent.blockWoodenDecoration,1,BlockTypes_WoodenDecoration.FENCE.getMeta()):new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.IRON.getMeta()); + return pos==0||pos==2||pos==6||pos==8?new ItemStack(IEContent.blockWoodenDecoration, 1, BlockTypes_WoodenDecoration.FENCE.getMeta()): new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.IRON.getMeta()); } @Override @@ -149,17 +153,19 @@ public BlockPos getOrigin() { return getPos().add(-offset[0], -offset[1], -offset[2]).offset(facing.rotateYCCW()).offset(facing.getOpposite()); } + @SideOnly(Side.CLIENT) private AxisAlignedBB renderAABB; + @Override @SideOnly(Side.CLIENT) public AxisAlignedBB getRenderBoundingBox() { if(renderAABB==null) if(pos==4) - renderAABB = new AxisAlignedBB(getPos().add(-1,0,-1), getPos().add(2,7,2)); + renderAABB = new AxisAlignedBB(getPos().add(-1, 0, -1), getPos().add(2, 7, 2)); else - renderAABB = new AxisAlignedBB(getPos(),getPos()); + renderAABB = new AxisAlignedBB(getPos(), getPos()); return renderAABB; } @@ -224,17 +230,19 @@ public int getMaxStoredCount() @Override public boolean hasCapability(Capability capability, EnumFacing facing) { - if((pos==4||pos==58) && capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) + if((pos==4||pos==58)&&capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return true; // if(pos>30&&pos<44 && pos%5>0&&pos%5<4 ) // return true; return super.hasCapability(capability, facing); } + IItemHandler insertionHandler = new SiloInventoryHandler(this); + @Override public T getCapability(Capability capability, EnumFacing facing) { - if((pos==4||pos==58) && capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) + if((pos==4||pos==58)&&capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return (T)insertionHandler; return super.getCapability(capability, facing); } @@ -242,6 +250,7 @@ public T getCapability(Capability capability, EnumFacing facing) public static class SiloInventoryHandler implements IItemHandler { TileEntitySilo silo; + public SiloInventoryHandler(TileEntitySilo silo) { this.silo = silo; @@ -252,10 +261,11 @@ public int getSlots() { return 2; } + @Override public ItemStack getStackInSlot(int slot) { - if (slot==0) + if(slot==0) return ItemStack.EMPTY; else { @@ -270,7 +280,7 @@ public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) stack = stack.copy(); TileEntitySilo silo = this.silo.master(); int space = maxStorage-silo.storageAmount; - if(slot!=0 || space<1 || stack.isEmpty() || (!silo.identStack.isEmpty() && !ItemHandlerHelper.canItemStacksStack(silo.identStack,stack))) + if(slot!=0||space < 1||stack.isEmpty()||(!silo.identStack.isEmpty()&&!ItemHandlerHelper.canItemStacksStack(silo.identStack, stack))) return stack; int accepted = Math.min(space, stack.getCount()); if(!simulate) @@ -293,7 +303,7 @@ public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) public ItemStack extractItem(int slot, int amount, boolean simulate) { TileEntitySilo silo = this.silo.master(); - if(slot!=1 || silo.storageAmount<1 || amount<1 || silo.identStack.isEmpty()) + if(slot!=1||silo.storageAmount < 1||amount < 1||silo.identStack.isEmpty()) return ItemStack.EMPTY; ItemStack out; if(silo.storageAmount >= amount) @@ -304,7 +314,7 @@ public ItemStack extractItem(int slot, int amount, boolean simulate) { silo.updateComparatorValuesPart1(); silo.storageAmount -= out.getCount(); - if(silo.storageAmount<=0 && !silo.lockItem) + if(silo.storageAmount <= 0&&!silo.lockItem) silo.identStack = ItemStack.EMPTY; silo.markDirty(); silo.markContainingBlockForUpdate(null); @@ -326,7 +336,7 @@ public int getComparatorInputOverride() if(pos==4) return (15*storageAmount)/maxStorage; TileEntitySilo master = master(); - if (offset[1]>=1&&offset[1]<=6&&master!=null) //6 layers of storage + if(offset[1] >= 1&&offset[1] <= 6&&master!=null) //6 layers of storage { int layer = offset[1]-1; int vol = maxStorage/6; @@ -336,29 +346,31 @@ public int getComparatorInputOverride() } return 0; } + private void updateComparatorValuesPart1() { - int vol = maxStorage / 6; - for(int i=0; i<6; i++) + int vol = maxStorage/6; + for(int i = 0; i < 6; i++) { - int filled = storageAmount - i * vol; + int filled = storageAmount-i*vol; oldComps[i] = Math.min(15, Math.max((15*filled)/vol, 0)); } masterCompOld = (15*storageAmount)/maxStorage; } + private void updateComparatorValuesPart2() { - int vol = maxStorage / 6; + int vol = maxStorage/6; if((15*storageAmount)/maxStorage!=masterCompOld) world.notifyNeighborsOfStateChange(getPos(), getBlockType(), true); - for(int i=0; i<6; i++) + for(int i = 0; i < 6; i++) { - int filled = storageAmount - i * vol; + int filled = storageAmount-i*vol; int now = Math.min(15, Math.max((15*filled)/vol, 0)); if(now!=oldComps[i]) { - for(int x=-1; x<=1; x++) - for(int z=-1; z<=1; z++) + for(int x = -1; x <= 1; x++) + for(int z = -1; z <= 1; z++) { BlockPos pos = getPos().add(-offset[0]+x, -offset[1]+i+1, -offset[2]+z); world.notifyNeighborsOfStateChange(pos, world.getBlockState(pos).getBlock(), true); diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntitySqueezer.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntitySqueezer.java index 258ead9721..408d146bc4 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntitySqueezer.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntitySqueezer.java @@ -41,15 +41,16 @@ import java.util.Comparator; import java.util.List; -public class TileEntitySqueezer extends TileEntityMultiblockMetal implements IAdvancedSelectionBounds,IAdvancedCollisionBounds, IGuiTile +public class TileEntitySqueezer extends TileEntityMultiblockMetal implements IAdvancedSelectionBounds, IAdvancedCollisionBounds, IGuiTile { public FluidTank[] tanks = new FluidTank[]{new FluidTank(24000)}; public NonNullList inventory = NonNullList.withSize(11, ItemStack.EMPTY); public float animation_piston = 0; public boolean animation_down = true; + public TileEntitySqueezer() { - super(MultiblockSqueezer.instance, new int[]{3,3,3}, 16000, true); + super(MultiblockSqueezer.instance, new int[]{3, 3, 3}, 16000, true); } @Override @@ -60,6 +61,7 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) if(!descPacket) inventory = Utils.readInventory(nbt.getTagList("inventory", 10), 11); } + @Override public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { @@ -74,12 +76,12 @@ public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) public void update() { super.update(); - if(isDummy() || isRSDisabled()) + if(isDummy()||isRSDisabled()) return; if(world.isRemote) { - if(this.processQueue.isEmpty() && animation_piston<.6875) + if(this.processQueue.isEmpty()&&animation_piston < .6875) animation_piston = Math.min(.6875f, animation_piston+.03125f); else if(shouldRenderAsActive()) { @@ -87,16 +89,16 @@ else if(shouldRenderAsActive()) animation_piston = Math.max(0, animation_piston-.03125f); else animation_piston = Math.min(.6875f, animation_piston+.03125f); - if(animation_piston<=0 && animation_down) + if(animation_piston <= 0&&animation_down) animation_down = false; - else if(animation_piston>=.6875 && !animation_down) + else if(animation_piston >= .6875&&!animation_down) animation_down = true; } } else { boolean update = false; - if(energyStorage.getEnergyStored()>0 && processQueue.size() 0&&processQueue.size() < this.getProcessQueueMaxLength()) { final int[] usedInvSlots = new int[8]; for(MultiblockProcess process : processQueue) @@ -104,22 +106,24 @@ else if(animation_piston>=.6875 && !animation_down) for(int i : ((MultiblockProcessInMachine)process).inputSlots) usedInvSlots[i]++; - Integer[] preferredSlots = new Integer[]{0,1,2,3,4,5,6,7}; - Arrays.sort(preferredSlots, 0,8, new Comparator(){ + Integer[] preferredSlots = new Integer[]{0, 1, 2, 3, 4, 5, 6, 7}; + Arrays.sort(preferredSlots, 0, 8, new Comparator() + { @Override public int compare(Integer arg0, Integer arg1) { - return Integer.compare(usedInvSlots[arg0],usedInvSlots[arg1]); - }}); + return Integer.compare(usedInvSlots[arg0], usedInvSlots[arg1]); + } + }); for(int slot : preferredSlots) { ItemStack stack = this.getInventory().get(slot); if(!stack.isEmpty()) { stack = stack.copy(); - stack.shrink(usedInvSlots[slot]); + stack.shrink(usedInvSlots[slot]); } - if(!stack.isEmpty() && stack.getCount() > 0) + if(!stack.isEmpty()&&stack.getCount() > 0) { SqueezerRecipe recipe = this.findRecipeForInsertion(stack); if(recipe!=null) @@ -135,24 +139,24 @@ public int compare(Integer arg0, Integer arg1) } } - EnumFacing fw = mirrored?facing.rotateYCCW():facing.rotateY(); - if(this.tanks[0].getFluidAmount()>0) + EnumFacing fw = mirrored?facing.rotateYCCW(): facing.rotateY(); + if(this.tanks[0].getFluidAmount() > 0) { FluidStack out = Utils.copyFluidStackWithAmount(this.tanks[0].getFluid(), Math.min(this.tanks[0].getFluidAmount(), 80), false); - BlockPos outputPos = this.getPos().add(0,-1,0).offset(fw,2); + BlockPos outputPos = this.getPos().add(0, -1, 0).offset(fw, 2); IFluidHandler output = FluidUtil.getFluidHandler(world, outputPos, fw.getOpposite()); if(output!=null) { int accepted = output.fill(out, false); - if(accepted>0) + if(accepted > 0) { - int drained = output.fill(Utils.copyFluidStackWithAmount(out,Math.min(out.amount, accepted),false), true); + int drained = output.fill(Utils.copyFluidStackWithAmount(out, Math.min(out.amount, accepted), false), true); this.tanks[0].drain(drained, true); - update=true; + update = true; } } ItemStack empty = getInventory().get(9); - if (!empty.isEmpty()&&tanks[0].getFluidAmount()>0) + if(!empty.isEmpty()&&tanks[0].getFluidAmount() > 0) { ItemStack full = Utils.fillFluidContainer(tanks[0], empty, getInventory().get(10), null); if(!full.isEmpty()) @@ -173,18 +177,18 @@ public int compare(Integer arg0, Integer arg1) } } } - if(!inventory.get(8).isEmpty() && world.getTotalWorldTime()%8==0) + if(!inventory.get(8).isEmpty()&&world.getTotalWorldTime()%8==0) { BlockPos outputPos = this.getPos().offset(fw); TileEntity outputTile = Utils.getExistingTileEntity(world, outputPos); - if (outputTile != null) + if(outputTile!=null) { ItemStack stack = Utils.copyStackWithAmount(inventory.get(8), 1); stack = Utils.insertStackIntoInventory(outputTile, stack, fw.getOpposite()); - if (stack.isEmpty()) + if(stack.isEmpty()) { this.inventory.get(8).shrink(1); - if (this.inventory.get(8).getCount() <= 0) + if(this.inventory.get(8).getCount() <= 0) this.inventory.set(8, ItemStack.EMPTY); } } @@ -201,14 +205,15 @@ public int compare(Integer arg0, Integer arg1) @Override public float[] getBlockBounds() { - if(pos>0&&pos<9 && pos!=5) - return new float[]{0,0,0, 1,.5f,1}; + if(pos > 0&&pos < 9&&pos!=5) + return new float[]{0, 0, 0, 1, .5f, 1}; if(pos==11) - return new float[]{facing==EnumFacing.WEST?.5f:0,0,facing==EnumFacing.NORTH?.5f:0, facing==EnumFacing.EAST?.5f:1,1,facing==EnumFacing.SOUTH?.5f:1}; + return new float[]{facing==EnumFacing.WEST?.5f: 0, 0, facing==EnumFacing.NORTH?.5f: 0, facing==EnumFacing.EAST?.5f: 1, 1, facing==EnumFacing.SOUTH?.5f: 1}; - return new float[]{0,0,0, 1,1,1}; + return new float[]{0, 0, 0, 1, 1, 1}; } + @Override public List getAdvancedSelectionBounds() { @@ -218,24 +223,24 @@ public List getAdvancedSelectionBounds() fw = fw.getOpposite(); if(pos==2) { - List list = Lists.newArrayList(new AxisAlignedBB(0,0,0, 1,.5f,1).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + List list = Lists.newArrayList(new AxisAlignedBB(0, 0, 0, 1, .5f, 1).offset(getPos().getX(), getPos().getY(), getPos().getZ())); float minX = fl==EnumFacing.WEST?.625f: fl==EnumFacing.EAST?.125f: .125f; float maxX = fl==EnumFacing.EAST?.375f: fl==EnumFacing.WEST?.875f: .25f; float minZ = fl==EnumFacing.NORTH?.625f: fl==EnumFacing.SOUTH?.125f: .125f; float maxZ = fl==EnumFacing.SOUTH?.375f: fl==EnumFacing.NORTH?.875f: .25f; - list.add(new AxisAlignedBB(minX,.5f,minZ, maxX,1,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); minX = fl==EnumFacing.WEST?.625f: fl==EnumFacing.EAST?.125f: .75f; maxX = fl==EnumFacing.EAST?.375f: fl==EnumFacing.WEST?.875f: .875f; minZ = fl==EnumFacing.NORTH?.625f: fl==EnumFacing.SOUTH?.125f: .75f; maxZ = fl==EnumFacing.SOUTH?.375f: fl==EnumFacing.NORTH?.875f: .875f; - list.add(new AxisAlignedBB(minX,.5f,minZ, maxX,1,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); return list; } if(pos==3||pos==4||pos==6||pos==7) { - List list = Lists.newArrayList(new AxisAlignedBB(0,0,0, 1,.5f,1).offset(getPos().getX(),getPos().getY(),getPos().getZ())); - if(pos>5) + List list = Lists.newArrayList(new AxisAlignedBB(0, 0, 0, 1, .5f, 1).offset(getPos().getX(), getPos().getY(), getPos().getZ())); + if(pos > 5) fl = fl.getOpposite(); if(pos%3==1) fw = fw.getOpposite(); @@ -243,7 +248,7 @@ public List getAdvancedSelectionBounds() float maxX = fl==EnumFacing.EAST?.3125f: fl==EnumFacing.WEST?.9375f: fw==EnumFacing.EAST?.3125f: .9375f; float minZ = fl==EnumFacing.NORTH?.6875f: fl==EnumFacing.SOUTH?.0625f: fw==EnumFacing.SOUTH?.0625f: .6875f; float maxZ = fl==EnumFacing.SOUTH?.3125f: fl==EnumFacing.NORTH?.9375f: fw==EnumFacing.SOUTH?.3125f: .9375f; - list.add(new AxisAlignedBB(minX,.5f,minZ, maxX,1,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); if(pos==4) { @@ -251,19 +256,19 @@ public List getAdvancedSelectionBounds() maxX = fl==EnumFacing.EAST?.375f: fl==EnumFacing.WEST?.625f: fw==EnumFacing.EAST?1.125f: 1; minZ = fl==EnumFacing.NORTH?.375f: fl==EnumFacing.SOUTH?.625f: fw==EnumFacing.NORTH?-.125f: 0; maxZ = fl==EnumFacing.SOUTH?.375f: fl==EnumFacing.NORTH?.625f: fw==EnumFacing.SOUTH?1.125f: 1; - list.add(new AxisAlignedBB(minX,.5f,minZ, maxX,.75f,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, .75f, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); minX = fl==EnumFacing.WEST?-.125f: fl==EnumFacing.EAST?.625f: fw==EnumFacing.WEST?-.125f: .875f; maxX = fl==EnumFacing.EAST?1.125f: fl==EnumFacing.WEST?.375f: fw==EnumFacing.EAST?1.125f: .125f; minZ = fl==EnumFacing.NORTH?-.125f: fl==EnumFacing.SOUTH?.625f: fw==EnumFacing.NORTH?-.125f: .875f; maxZ = fl==EnumFacing.SOUTH?1.25f: fl==EnumFacing.NORTH?.375f: fw==EnumFacing.SOUTH?1.125f: .125f; - list.add(new AxisAlignedBB(minX,.5f,minZ, maxX,.75f,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, .75f, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); minX = fl==EnumFacing.WEST?-.125f: fl==EnumFacing.EAST?.875f: fw==EnumFacing.WEST?-.125f: .875f; maxX = fl==EnumFacing.EAST?1.125f: fl==EnumFacing.WEST?.125f: fw==EnumFacing.EAST?1.125f: .125f; minZ = fl==EnumFacing.NORTH?-.125f: fl==EnumFacing.SOUTH?.875f: fw==EnumFacing.NORTH?-.125f: .875f; maxZ = fl==EnumFacing.SOUTH?1.25f: fl==EnumFacing.NORTH?.125f: fw==EnumFacing.SOUTH?1.125f: .125f; - list.add(new AxisAlignedBB(minX,.75f,minZ, maxX,1,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, .75f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); } return list; @@ -271,50 +276,52 @@ public List getAdvancedSelectionBounds() if((pos==12||pos==13||pos==15||pos==16)||(pos==21||pos==22||pos==24||pos==25)) { List list = new ArrayList(2); - if(pos<18) - list.add(new AxisAlignedBB(0,0,0, 1,.125f,1).offset(getPos().getX(),getPos().getY(),getPos().getZ())); - if(pos%9>5) + if(pos < 18) + list.add(new AxisAlignedBB(0, 0, 0, 1, .125f, 1).offset(getPos().getX(), getPos().getY(), getPos().getZ())); + if(pos%9 > 5) fl = fl.getOpposite(); if(pos%3==1) fw = fw.getOpposite(); - float minY = pos<18?.125f:-.875f; - float maxY = pos<18?1.125f:.125f; + float minY = pos < 18?.125f: -.875f; + float maxY = pos < 18?1.125f: .125f; float minX = fl==EnumFacing.WEST?.84375f: fl==EnumFacing.EAST?0f: fw==EnumFacing.EAST?0f: .84375f; float maxX = fl==EnumFacing.EAST?.15625f: fl==EnumFacing.WEST?1f: fw==EnumFacing.EAST?.15625f: 1; float minZ = fl==EnumFacing.NORTH?.84375f: fl==EnumFacing.SOUTH?0f: fw==EnumFacing.SOUTH?0f: .84375f; float maxZ = fl==EnumFacing.SOUTH?.15625f: fl==EnumFacing.NORTH?1f: fw==EnumFacing.SOUTH?.15625f: 1; - list.add(new AxisAlignedBB(minX,minY,minZ, maxX,maxY,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); minX = fl==EnumFacing.WEST?0f: fl==EnumFacing.EAST?.15625f: fw==EnumFacing.EAST?.0625f: .8125f; maxX = fl==EnumFacing.EAST?1f: fl==EnumFacing.WEST?.84375f: fw==EnumFacing.EAST?.1875f: .9375f; minZ = fl==EnumFacing.NORTH?0f: fl==EnumFacing.SOUTH?.15625f: fw==EnumFacing.SOUTH?.0625f: .8125f; maxZ = fl==EnumFacing.SOUTH?1f: fl==EnumFacing.NORTH?.84375f: fw==EnumFacing.SOUTH?.1875f: .9375f; - list.add(new AxisAlignedBB(minX,minY,minZ, maxX,maxY,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); minX = fl==EnumFacing.WEST?.8125f: fl==EnumFacing.EAST?.0625f: fw==EnumFacing.EAST?.15625f: 0f; maxX = fl==EnumFacing.EAST?.1875f: fl==EnumFacing.WEST?.9375f: fw==EnumFacing.EAST?1f: .84375f; minZ = fl==EnumFacing.NORTH?.8125f: fl==EnumFacing.SOUTH?.0625f: fw==EnumFacing.SOUTH?.15625f: 0f; maxZ = fl==EnumFacing.SOUTH?.1875f: fl==EnumFacing.NORTH?.9375f: fw==EnumFacing.SOUTH?1f: .84375f; - list.add(new AxisAlignedBB(minX,minY,minZ, maxX,maxY,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); - if(pos>18) + if(pos > 18) { minX = fl==EnumFacing.WEST?-.25f: fl==EnumFacing.EAST?1.25f: fw==EnumFacing.EAST?.75f: -.25f; maxX = fl==EnumFacing.EAST?.75f: fl==EnumFacing.WEST?.25f: fw==EnumFacing.EAST?1.25f: .25f; minZ = fl==EnumFacing.NORTH?-.25f: fl==EnumFacing.SOUTH?1.25f: fw==EnumFacing.SOUTH?.75f: -.25f; maxZ = fl==EnumFacing.SOUTH?.75f: fl==EnumFacing.NORTH?.25f: fw==EnumFacing.SOUTH?1.25f: .25f; - list.add(new AxisAlignedBB(minX,.375f,minZ, maxX,.9375f,maxZ).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + list.add(new AxisAlignedBB(minX, .375f, minZ, maxX, .9375f, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ())); } return list; } return null; } + @Override public boolean isOverrideBox(AxisAlignedBB box, EntityPlayer player, RayTraceResult mop, ArrayList list) { return false; } + @Override public List getAdvancedColisionBounds() { @@ -358,6 +365,7 @@ public int[] getEnergyPos() { return new int[]{9}; } + @Override public int[] getRedstonePos() { @@ -369,39 +377,46 @@ public boolean isInWorldProcessingMachine() { return false; } + @Override public boolean additionalCanProcessCheck(MultiblockProcess process) { return true; } + @Override public void doProcessOutput(ItemStack output) { - BlockPos pos = getPos().offset(facing,2); + BlockPos pos = getPos().offset(facing, 2); TileEntity inventoryTile = this.world.getTileEntity(pos); if(inventoryTile!=null) output = Utils.insertStackIntoInventory(inventoryTile, output, facing.getOpposite()); if(!output.isEmpty()) Utils.dropStackAtPos(world, pos, output, facing); } + @Override public void doProcessFluidOutput(FluidStack output) { } + @Override public void onProcessFinish(MultiblockProcess process) { } + @Override public int getMaxProcessPerTick() { return 8; } + @Override public int getProcessQueueMaxLength() { return 8; } + @Override public float getMinProcessDistance(MultiblockProcess process) { @@ -414,54 +429,64 @@ public int getComparatedSize() { return 8; } + @Override public NonNullList getInventory() { return inventory; } + @Override public boolean isStackValid(int slot, ItemStack stack) { return true; } + @Override public int getSlotLimit(int slot) { return 64; } + @Override public int[] getOutputSlots() { return new int[]{8}; } + @Override public int[] getOutputTanks() { return new int[]{0}; } + @Override public IFluidTank[] getInternalTanks() { return tanks; } + @Override protected IFluidTank[] getAccessibleFluidTanks(EnumFacing side) { TileEntitySqueezer master = master(); - if(master!=null && pos==5 && (side==null||side==(mirrored?facing.rotateYCCW():facing.rotateY()))) + if(master!=null&&pos==5&&(side==null||side==(mirrored?facing.rotateYCCW(): facing.rotateY()))) return master.tanks; return new FluidTank[0]; } + @Override protected boolean canFillTankFrom(int iTank, EnumFacing side, FluidStack resources) { return false; } + @Override protected boolean canDrainTankFrom(int iTank, EnumFacing side) { return true; } + @Override public void doGraphicalUpdates(int slot) { @@ -477,8 +502,10 @@ public boolean hasCapability(Capability capability, EnumFacing facing) return master()!=null; return super.hasCapability(capability, facing); } - IItemHandler insertionHandler = new IEInventoryHandler(8, this, 0, new boolean[]{true,true,true,true,true,true,true,true}, new boolean[8]); + + IItemHandler insertionHandler = new IEInventoryHandler(8, this, 0, new boolean[]{true, true, true, true, true, true, true, true}, new boolean[8]); IItemHandler extractionHandler = new IEInventoryHandler(1, this, 8, new boolean[1], new boolean[]{true}); + @Override public T getCapability(Capability capability, EnumFacing facing) { @@ -501,11 +528,13 @@ public SqueezerRecipe findRecipeForInsertion(ItemStack inserting) { return SqueezerRecipe.findRecipe(inserting); } + @Override protected SqueezerRecipe readRecipeFromNBT(NBTTagCompound tag) { return SqueezerRecipe.loadFromNBT(tag); } + // @Override // public void updateEntity() // { @@ -783,11 +812,13 @@ public boolean canOpenGui() { return formed; } + @Override public int getGuiID() { return Lib.GUIID_Squeezer; } + @Override public TileEntity getGuiMaster() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityStructuralArm.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityStructuralArm.java index f61d271a0a..0ce71882a6 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityStructuralArm.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityStructuralArm.java @@ -18,7 +18,7 @@ public class TileEntityStructuralArm extends TileEntityIEBase implements IDirect { public EnumFacing facing = EnumFacing.NORTH; public boolean inverted = false; - + @Override public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) { @@ -38,26 +38,31 @@ public EnumFacing getFacing() { return facing; } + @Override public void setFacing(EnumFacing facing) { - this.facing = facing; + this.facing = facing; } + @Override public int getFacingLimitation() { return 2; } + @Override public boolean mirrorFacingOnPlacement(EntityLivingBase placer) { return false; } + @Override public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) { return true; } + @Override public boolean canRotate(EnumFacing axis) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityTeslaCoil.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityTeslaCoil.java index 95be68a51f..81c5ebd7ec 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityTeslaCoil.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityTeslaCoil.java @@ -62,7 +62,7 @@ public class TileEntityTeslaCoil extends TileEntityIEBase implements ITickable, public boolean lowPower = false; private Vec3d soundPos = null; @SideOnly(Side.CLIENT) - public static ArrayListMultimap effectMap; + public static ArrayListMultimap effectMap; private static final ElectricSource TC_FIELD = new ElectricSource(-1); @Override @@ -71,53 +71,53 @@ public void update() ApiUtils.checkForNeedlessTicking(this); if(dummy) return; - synchronized (this) + synchronized(this) { - if (world.isRemote && soundPos!=null) + if(world.isRemote&&soundPos!=null) { - world.playSound(soundPos.x,soundPos.y,soundPos.z, IESounds.tesla, SoundCategory.BLOCKS, 2.5F,0.5F+ Utils.RAND.nextFloat(), true); + world.playSound(soundPos.x, soundPos.y, soundPos.z, IESounds.tesla, SoundCategory.BLOCKS, 2.5F, 0.5F+Utils.RAND.nextFloat(), true); soundPos = null; } } - if (world.isRemote && effectMap.containsKey(pos)) + if(world.isRemote&&effectMap.containsKey(pos)) effectMap.get(pos).removeIf(LightningAnimation::tick); int timeKey = getPos().getX()^getPos().getZ(); int energyDrain = IEConfig.Machines.teslacoil_consumption; - if (lowPower) - energyDrain/=2; - if(!world.isRemote && world.getTotalWorldTime()%32==(timeKey&31) && canRun(energyDrain)) + if(lowPower) + energyDrain /= 2; + if(!world.isRemote&&world.getTotalWorldTime()%32==(timeKey&31)&&canRun(energyDrain)) { - this.energyStorage.extractEnergy(energyDrain,false); + this.energyStorage.extractEnergy(energyDrain, false); double radius = 6; - if (lowPower) - radius/=2; - AxisAlignedBB aabbSmall = new AxisAlignedBB(getPos().getX()+.5-radius,getPos().getY()+.5-radius,getPos().getZ()+.5-radius, getPos().getX()+.5+radius,getPos().getY()+.5+radius,getPos().getZ()+.5+radius); + if(lowPower) + radius /= 2; + AxisAlignedBB aabbSmall = new AxisAlignedBB(getPos().getX()+.5-radius, getPos().getY()+.5-radius, getPos().getZ()+.5-radius, getPos().getX()+.5+radius, getPos().getY()+.5+radius, getPos().getZ()+.5+radius); AxisAlignedBB aabb = aabbSmall.grow(radius/2); List targetsAll = world.getEntitiesWithinAABB(Entity.class, aabb); - List targets = targetsAll.stream().filter((e)->(e instanceof EntityLivingBase&&aabbSmall.intersects(e.getEntityBoundingBox()))).collect(Collectors.toList()); + List targets = targetsAll.stream().filter((e) -> (e instanceof EntityLivingBase&&aabbSmall.intersects(e.getEntityBoundingBox()))).collect(Collectors.toList()); EntityLivingBase target = null; if(!targets.isEmpty()) { ElectricDamageSource dmgsrc = IEDamageSources.causeTeslaDamage(IEConfig.Machines.teslacoil_damage, lowPower); int randomTarget = Utils.RAND.nextInt(targets.size()); - target = (EntityLivingBase) targets.get(randomTarget); + target = (EntityLivingBase)targets.get(randomTarget); if(target!=null) { if(!world.isRemote) { energyDrain = IEConfig.Machines.teslacoil_consumption_active; - if (lowPower) - energyDrain/=2; - if(energyStorage.extractEnergy(energyDrain,true)==energyDrain) + if(lowPower) + energyDrain /= 2; + if(energyStorage.extractEnergy(energyDrain, true)==energyDrain) { - energyStorage.extractEnergy(energyDrain,false); - if (dmgsrc.apply(target)) + energyStorage.extractEnergy(energyDrain, false); + if(dmgsrc.apply(target)) { int prevFire = target.fire; target.fire = 1; - target.addPotionEffect(new PotionEffect(IEPotions.stunned,128)); + target.addPotionEffect(new PotionEffect(IEPotions.stunned, 128)); target.fire = prevFire; } this.sendRenderPacket(target); @@ -125,30 +125,30 @@ public void update() } } } - for (Entity e:targetsAll) - if (e!=target) + for(Entity e : targetsAll) + if(e!=target) { - if (e instanceof ITeslaEntity) - ((ITeslaEntity) e).onHit(this, lowPower); - else if (e instanceof EntityLivingBase) + if(e instanceof ITeslaEntity) + ((ITeslaEntity)e).onHit(this, lowPower); + else if(e instanceof EntityLivingBase) IElectricEquipment.applyToEntity((EntityLivingBase)e, null, TC_FIELD); } - if(targets.isEmpty() && world.getTotalWorldTime()%128==(timeKey&127)) + if(targets.isEmpty()&&world.getTotalWorldTime()%128==(timeKey&127)) { //target up to 4 blocks away double tV = (Utils.RAND.nextDouble()-.5)*8; double tH = (Utils.RAND.nextDouble()-.5)*8; - if (lowPower) + if(lowPower) { - tV/=2; - tH/=2; + tV /= 2; + tH /= 2; } //Minimal distance to the coil is 2 blocks - tV += tV<0?-2:2; - tH += tH<0?-2:2; + tV += tV < 0?-2: 2; + tH += tH < 0?-2: 2; - BlockPos targetBlock = getPos().add(facing.getAxis()==Axis.X?0:tH, facing.getAxis()==Axis.Y?0:tV, facing.getAxis()==Axis.Y?tV:facing.getAxis()==Axis.X?tH:0); - double tL=0; + BlockPos targetBlock = getPos().add(facing.getAxis()==Axis.X?0: tH, facing.getAxis()==Axis.Y?0: tV, facing.getAxis()==Axis.Y?tV: facing.getAxis()==Axis.X?tH: 0); + double tL = 0; boolean targetFound = false; if(!world.isAirBlock(targetBlock)) { @@ -156,33 +156,33 @@ else if (e instanceof EntityLivingBase) AxisAlignedBB blockBounds = state.getBoundingBox(world, targetBlock); // ty = (blockY-getPos().getY())+state.getBlock().getBlockBoundsMaxY(); if(facing==EnumFacing.UP) - tL = targetBlock.getY()-getPos().getY() + blockBounds.maxY; + tL = targetBlock.getY()-getPos().getY()+blockBounds.maxY; else if(facing==EnumFacing.DOWN) - tL = targetBlock.getY()-getPos().getY() + blockBounds.minY; + tL = targetBlock.getY()-getPos().getY()+blockBounds.minY; else if(facing==EnumFacing.NORTH) - tL = targetBlock.getZ()-getPos().getZ() + blockBounds.minZ; + tL = targetBlock.getZ()-getPos().getZ()+blockBounds.minZ; else if(facing==EnumFacing.SOUTH) - tL = targetBlock.getZ()-getPos().getZ() + blockBounds.maxZ; + tL = targetBlock.getZ()-getPos().getZ()+blockBounds.maxZ; else if(facing==EnumFacing.WEST) - tL = targetBlock.getX()-getPos().getX() + blockBounds.minX; + tL = targetBlock.getX()-getPos().getX()+blockBounds.minX; else - tL = targetBlock.getX()-getPos().getX() + blockBounds.maxX; + tL = targetBlock.getX()-getPos().getX()+blockBounds.maxX; targetFound = true; } else { boolean positiveFirst = Utils.RAND.nextBoolean(); - for(int i=0; i<2; i++) + for(int i = 0; i < 2; i++) { - for(int ll=0;ll<=6;ll++) + for(int ll = 0; ll <= 6; ll++) { - BlockPos targetBlock2 = targetBlock.offset(positiveFirst?facing:facing.getOpposite(), ll); + BlockPos targetBlock2 = targetBlock.offset(positiveFirst?facing: facing.getOpposite(), ll); if(!world.isAirBlock(targetBlock2)) { IBlockState state = world.getBlockState(targetBlock2); AxisAlignedBB blockBounds = state.getBoundingBox(world, targetBlock2); tL = facing.getAxis()==Axis.Y?(targetBlock2.getY()-getPos().getY()): facing.getAxis()==Axis.Z?(targetBlock2.getZ()-getPos().getZ()): (targetBlock2.getZ()-getPos().getZ()); - EnumFacing tempF = positiveFirst?facing:facing.getOpposite(); + EnumFacing tempF = positiveFirst?facing: facing.getOpposite(); if(tempF==EnumFacing.UP) tL += blockBounds.maxY; else if(tempF==EnumFacing.DOWN) @@ -204,7 +204,7 @@ else if(tempF==EnumFacing.WEST) positiveFirst = !positiveFirst; } } - if (targetFound) + if(targetFound) sendFreePacket(tL, tH, tV); } this.markDirty(); @@ -242,27 +242,27 @@ public void receiveMessageFromServer(NBTTagCompound message) EnumFacing f = null; if(facing.getAxis()==Axis.Y) { - if(Math.abs(dz)>Math.abs(dx)) - f = dz<0?EnumFacing.NORTH:EnumFacing.SOUTH; - else - f = dx<0?EnumFacing.WEST:EnumFacing.EAST; + if(Math.abs(dz) > Math.abs(dx)) + f = dz < 0?EnumFacing.NORTH: EnumFacing.SOUTH; + else + f = dx < 0?EnumFacing.WEST: EnumFacing.EAST; } else if(facing.getAxis()==Axis.Z) { - if(Math.abs(dy)>Math.abs(dx)) - f = dy<0?EnumFacing.DOWN:EnumFacing.UP; - else - f = dx<0?EnumFacing.WEST:EnumFacing.EAST; + if(Math.abs(dy) > Math.abs(dx)) + f = dy < 0?EnumFacing.DOWN: EnumFacing.UP; + else + f = dx < 0?EnumFacing.WEST: EnumFacing.EAST; } else { - if(Math.abs(dy)>Math.abs(dz)) - f = dy<0?EnumFacing.DOWN:EnumFacing.UP; - else - f = dz<0?EnumFacing.NORTH:EnumFacing.SOUTH; + if(Math.abs(dy) > Math.abs(dz)) + f = dy < 0?EnumFacing.DOWN: EnumFacing.UP; + else + f = dz < 0?EnumFacing.NORTH: EnumFacing.SOUTH; } double verticalOffset = 1+Utils.RAND.nextDouble()*.25; - Vec3d coilPos = new Vec3d(getPos()).addVector(.5,.5,.5); + Vec3d coilPos = new Vec3d(getPos()).addVector(.5, .5, .5); //Vertical offset coilPos = coilPos.addVector(facing.getFrontOffsetX()*verticalOffset, facing.getFrontOffsetY()*verticalOffset, facing.getFrontOffsetZ()*verticalOffset); //offset to direction @@ -275,46 +275,48 @@ else if(facing.getAxis()==Axis.Z) coilPos = coilPos.addVector(f.getFrontOffsetX()*dShift, f.getFrontOffsetY()*dShift, f.getFrontOffsetZ()*dShift); } - addAnimation(new LightningAnimation(coilPos,(EntityLivingBase)target)); - synchronized (this) + addAnimation(new LightningAnimation(coilPos, (EntityLivingBase)target)); + synchronized(this) { soundPos = coilPos; } } - } else if (message.hasKey("tL")) + } + else if(message.hasKey("tL")) initFreeStreamer(message.getDouble("tL"), message.getDouble("tV"), message.getDouble("tH")); } - public void initFreeStreamer(double tL, double tV, double tH) { - double tx = facing.getAxis()==Axis.X?tL:tH; - double ty = facing.getAxis()==Axis.Y?tL:tV; - double tz = facing.getAxis()==Axis.Y?tV:facing.getAxis()==Axis.X?tH:tL; + public void initFreeStreamer(double tL, double tV, double tH) + { + double tx = facing.getAxis()==Axis.X?tL: tH; + double ty = facing.getAxis()==Axis.Y?tL: tV; + double tz = facing.getAxis()==Axis.Y?tV: facing.getAxis()==Axis.X?tH: tL; EnumFacing f = null; if(facing.getAxis()==Axis.Y) { - if(Math.abs(tz)>Math.abs(tx)) - f = tz<0?EnumFacing.NORTH:EnumFacing.SOUTH; + if(Math.abs(tz) > Math.abs(tx)) + f = tz < 0?EnumFacing.NORTH: EnumFacing.SOUTH; else - f = tx<0?EnumFacing.WEST:EnumFacing.EAST; + f = tx < 0?EnumFacing.WEST: EnumFacing.EAST; } else if(facing.getAxis()==Axis.Z) { - if(Math.abs(ty)>Math.abs(tx)) - f = ty<0?EnumFacing.DOWN:EnumFacing.UP; + if(Math.abs(ty) > Math.abs(tx)) + f = ty < 0?EnumFacing.DOWN: EnumFacing.UP; else - f = tx<0?EnumFacing.WEST:EnumFacing.EAST; + f = tx < 0?EnumFacing.WEST: EnumFacing.EAST; } else { - if(Math.abs(ty)>Math.abs(tz)) - f = ty<0?EnumFacing.DOWN:EnumFacing.UP; + if(Math.abs(ty) > Math.abs(tz)) + f = ty < 0?EnumFacing.DOWN: EnumFacing.UP; else - f = tz<0?EnumFacing.NORTH:EnumFacing.SOUTH; + f = tz < 0?EnumFacing.NORTH: EnumFacing.SOUTH; } double verticalOffset = 1+Utils.RAND.nextDouble()*.25; - Vec3d coilPos = new Vec3d(getPos()).addVector(.5,.5,.5); + Vec3d coilPos = new Vec3d(getPos()).addVector(.5, .5, .5); //Vertical offset coilPos = coilPos.addVector(facing.getFrontOffsetX()*verticalOffset, facing.getFrontOffsetY()*verticalOffset, facing.getFrontOffsetZ()*verticalOffset); //offset to direction @@ -323,14 +325,14 @@ else if(facing.getAxis()==Axis.Z) f = f.rotateAround(facing.getAxis()); double dShift = (Utils.RAND.nextDouble()-.5)*.75; coilPos = coilPos.addVector(f.getFrontOffsetX()*dShift, f.getFrontOffsetY()*dShift, f.getFrontOffsetZ()*dShift); - addAnimation(new LightningAnimation(coilPos, new Vec3d(getPos()).addVector(tx,ty,tz))); + addAnimation(new LightningAnimation(coilPos, new Vec3d(getPos()).addVector(tx, ty, tz))); // world.playSound(null, getPos(), IESounds.tesla, SoundCategory.BLOCKS,2.5f, .5f + Utils.RAND.nextFloat()); - world.playSound(getPos().getX(),getPos().getY(),getPos().getZ(), IESounds.tesla, SoundCategory.BLOCKS, 2.5F,0.5F+ Utils.RAND.nextFloat(), true); + world.playSound(getPos().getX(), getPos().getY(), getPos().getZ(), IESounds.tesla, SoundCategory.BLOCKS, 2.5F, 0.5F+Utils.RAND.nextFloat(), true); } private void addAnimation(LightningAnimation ani) { - Minecraft.getMinecraft().addScheduledTask(()->effectMap.put(getPos(),ani)); + Minecraft.getMinecraft().addScheduledTask(() -> effectMap.put(getPos(), ani)); } @Override @@ -361,29 +363,30 @@ public float[] getBlockBounds() return null; switch(facing) { - case DOWN: - return new float[]{.125f,.125f,.125f, .875f,1,.875f}; - case UP: - return new float[]{.125f,0,.125f, .875f,.875f,.875f}; - case NORTH: - return new float[]{.125f,.125f,.125f, .875f,.875f,1}; - case SOUTH: - return new float[]{.125f,.125f,0, .875f,.875f,.875f}; - case WEST: - return new float[]{.125f,.125f,.125f, 1,.875f,.875f}; - case EAST: - return new float[]{0,.125f,.125f, .875f,.875f,.875f}; + case DOWN: + return new float[]{.125f, .125f, .125f, .875f, 1, .875f}; + case UP: + return new float[]{.125f, 0, .125f, .875f, .875f, .875f}; + case NORTH: + return new float[]{.125f, .125f, .125f, .875f, .875f, 1}; + case SOUTH: + return new float[]{.125f, .125f, 0, .875f, .875f, .875f}; + case WEST: + return new float[]{.125f, .125f, .125f, 1, .875f, .875f}; + case EAST: + return new float[]{0, .125f, .125f, .875f, .875f, .875f}; } return null; } AxisAlignedBB renderBB; + @Override @SideOnly(Side.CLIENT) public AxisAlignedBB getRenderBoundingBox() { if(renderBB==null) - renderBB = new AxisAlignedBB(getPos().add(-8,-8,-8),getPos().add(8,8,8)); + renderBB = new AxisAlignedBB(getPos().add(-8, -8, -8), getPos().add(8, 8, 8)); return renderBB; } @@ -392,29 +395,29 @@ public boolean hammerUseSide(EnumFacing side, EntityPlayer player, float hitX, f { if(dummy) { - TileEntity te = world.getTileEntity(getPos().offset(facing,-1)); + TileEntity te = world.getTileEntity(getPos().offset(facing, -1)); if(te instanceof TileEntityTeslaCoil) return ((TileEntityTeslaCoil)te).hammerUseSide(side, player, hitX, hitY, hitZ); return false; } - if (player.isSneaking()) + if(player.isSneaking()) { int energyDrain = IEConfig.Machines.teslacoil_consumption; - if (lowPower) - energyDrain/=2; - if (canRun(energyDrain)) + if(lowPower) + energyDrain /= 2; + if(canRun(energyDrain)) player.attackEntityFrom(IEDamageSources.causeTeslaPrimaryDamage(), Float.MAX_VALUE); else { lowPower = !lowPower; - ChatUtils.sendServerNoSpamMessages(player, new TextComponentTranslation(Lib.CHAT_INFO+"tesla."+(lowPower?"lowPower":"highPower"))); + ChatUtils.sendServerNoSpamMessages(player, new TextComponentTranslation(Lib.CHAT_INFO+"tesla."+(lowPower?"lowPower": "highPower"))); markDirty(); } } else { redstoneControlInverted = !redstoneControlInverted; - ChatUtils.sendServerNoSpamMessages(player, new TextComponentTranslation(Lib.CHAT_INFO+"rsControl."+(redstoneControlInverted?"invertedOn":"invertedOff"))); + ChatUtils.sendServerNoSpamMessages(player, new TextComponentTranslation(Lib.CHAT_INFO+"rsControl."+(redstoneControlInverted?"invertedOn": "invertedOff"))); markDirty(); this.markContainingBlockForUpdate(null); } @@ -426,26 +429,31 @@ public EnumFacing getFacing() { return facing; } + @Override public void setFacing(EnumFacing facing) { this.facing = facing; } + @Override public int getFacingLimitation() { return 0; } + @Override public boolean mirrorFacingOnPlacement(EntityLivingBase placer) { return false; } + @Override public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) { return false; } + @Override public boolean canRotate(EnumFacing axis) { @@ -457,6 +465,7 @@ public boolean isDummy() { return dummy; } + @Override public void placeDummies(BlockPos pos, IBlockState state, EnumFacing side, float hitX, float hitY, float hitZ) { @@ -464,12 +473,13 @@ public void placeDummies(BlockPos pos, IBlockState state, EnumFacing side, float ((TileEntityTeslaCoil)world.getTileEntity(pos.offset(facing))).dummy = true; ((TileEntityTeslaCoil)world.getTileEntity(pos.offset(facing))).facing = facing; } + @Override public void breakDummies(BlockPos pos, IBlockState state) { - for(int i=0; i<=1; i++) - if(world.getTileEntity(getPos().offset(facing, dummy?-1:0).offset(facing, i)) instanceof TileEntityTeslaCoil) - world.setBlockToAir(getPos().offset(facing, dummy?-1:0).offset(facing, i)); + for(int i = 0; i <= 1; i++) + if(world.getTileEntity(getPos().offset(facing, dummy?-1: 0).offset(facing, i)) instanceof TileEntityTeslaCoil) + world.setBlockToAir(getPos().offset(facing, dummy?-1: 0).offset(facing, i)); } @Nonnull @@ -478,30 +488,33 @@ public FluxStorage getFluxStorage() { if(dummy) { - TileEntity te = world.getTileEntity(getPos().offset(facing,-1)); + TileEntity te = world.getTileEntity(getPos().offset(facing, -1)); if(te instanceof TileEntityTeslaCoil) return ((TileEntityTeslaCoil)te).getFluxStorage(); } return energyStorage; } + @Nonnull @Override public SideConfig getEnergySideConfig(EnumFacing facing) { - return !dummy?SideConfig.INPUT:SideConfig.NONE; + return !dummy?SideConfig.INPUT: SideConfig.NONE; } + IEForgeEnergyWrapper[] wrappers = IEForgeEnergyWrapper.getDefaultWrapperArray(this); + @Override public IEForgeEnergyWrapper getCapabilityWrapper(EnumFacing facing) { if(!dummy) - return wrappers[facing==null?0:facing.ordinal()]; + return wrappers[facing==null?0: facing.ordinal()]; return null; } public boolean canRun(int energyDrain) { - return (world.isBlockIndirectlyGettingPowered(getPos())>0^redstoneControlInverted) && energyStorage.getEnergyStored()>=energyDrain; + return (world.isBlockIndirectlyGettingPowered(getPos()) > 0^redstoneControlInverted)&&energyStorage.getEnergyStored() >= energyDrain; } public static class LightningAnimation @@ -521,6 +534,7 @@ public LightningAnimation(Vec3d startPos, EntityLivingBase targetEntity) this.startPos = startPos; this.targetEntity = targetEntity; } + public LightningAnimation(Vec3d startPos, Vec3d targetPos) { this.startPos = startPos; @@ -529,12 +543,12 @@ public LightningAnimation(Vec3d startPos, Vec3d targetPos) public boolean shoudlRecalculateLightning() { - if (subPoints.isEmpty() || animationTimer == 0) + if(subPoints.isEmpty()||animationTimer==0) return true; boolean b = false; - Vec3d end = targetEntity!=null?targetEntity.getPositionVector():targetPos; + Vec3d end = targetEntity!=null?targetEntity.getPositionVector(): targetPos; if(prevTarget!=null) - b = prevTarget.distanceTo(end)>1; + b = prevTarget.distanceTo(end) > 1; prevTarget = end; return b; } @@ -542,39 +556,41 @@ public boolean shoudlRecalculateLightning() public void createLightning(Random rand) { subPoints.clear(); - Vec3d end = targetEntity!=null?targetEntity.getPositionVector():targetPos; + Vec3d end = targetEntity!=null?targetEntity.getPositionVector(): targetPos; Vec3d dist = end.subtract(startPos); double points = 12; - for(int i=0; i getInventory() { return inventory; } + @Override public boolean isStackValid(int slot, ItemStack stack) { return IEApi.isAllowedInCrate(stack); } + @Override public int getSlotLimit(int slot) { return 64; } + @Override public void doGraphicalUpdates(int slot) { @@ -140,15 +146,17 @@ public ItemStack getTileDrop(EntityPlayer player, IBlockState state) ItemNBTHelper.getTag(stack).setTag("ench", enchantments); return stack; } + @Override public void readOnPlacement(EntityLivingBase placer, ItemStack stack) { if(stack.getItem() instanceof ItemInternalStorage) { IItemHandler inv = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); - if (inv!=null) { + if(inv!=null) + { inventory = NonNullList.withSize(inv.getSlots(), ItemStack.EMPTY); - for (int i = 0; i < inv.getSlots(); i++) + for(int i = 0; i < inv.getSlots(); i++) inventory.set(i, inv.getStackInSlot(i)); } @@ -157,6 +165,7 @@ public void readOnPlacement(EntityLivingBase placer, ItemStack stack) enchantments = stack.getEnchantmentTagList(); } } + @Override public boolean preventInventoryDrop() { @@ -168,37 +177,43 @@ public EnumFacing getFacing() { return facing; } + @Override public void setFacing(EnumFacing facing) { this.facing = facing; } + @Override public int getFacingLimitation() { return 2; } + @Override public boolean mirrorFacingOnPlacement(EntityLivingBase placer) { return false; } + @Override public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) { return false; } + @Override public boolean canRotate(EnumFacing axis) { return true; } - private static final float[] boundsZ = {.125f,0,.25f,.875f,.625f,.75f}; - private static final float[] boundsX = {.25f,0,.125f,.75f,.625f,.875f}; + private static final float[] boundsZ = {.125f, 0, .25f, .875f, .625f, .75f}; + private static final float[] boundsX = {.25f, 0, .125f, .75f, .625f, .875f}; + @Override public float[] getBlockBounds() { - return facing.getAxis()==Axis.Z?boundsZ:boundsX; + return facing.getAxis()==Axis.Z?boundsZ: boundsX; } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityTransformer.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityTransformer.java index 9c20c82971..0d2f2c9fb2 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityTransformer.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityTransformer.java @@ -20,7 +20,6 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; @@ -39,9 +38,9 @@ public class TileEntityTransformer extends TileEntityImmersiveConnectable implements IDirectionalTile, IMirrorAble, IHasDummyBlocks, IAdvancedSelectionBounds, IDualState { WireType secondCable; - public EnumFacing facing=EnumFacing.NORTH; - public int dummy=0; - public boolean onPost=false; + public EnumFacing facing = EnumFacing.NORTH; + public int dummy = 0; + public boolean onPost = false; protected Set acceptableLowerWires = ImmutableSet.of(WireType.LV_CATEGORY); public static boolean _Immovable() @@ -54,6 +53,7 @@ protected boolean canTakeLV() { return true; } + @Override protected boolean canTakeMV() { @@ -65,6 +65,7 @@ public boolean canConnect() { return true; } + // @Override // public boolean canUpdate() // { @@ -75,6 +76,7 @@ public boolean isEnergyOutput() { return false; } + @Override public int outputEnergy(int amount, boolean simulate, int energyType) { @@ -91,6 +93,7 @@ public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) nbt.setInteger("dummy", dummy); nbt.setBoolean("postAttached", onPost); } + @Override public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) { @@ -107,38 +110,41 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) @Override public BlockPos getConnectionMaster(WireType cableType, TargetingInfo target) { - return getPos().add(0,-dummy,0); - } + return getPos().add(0, -dummy, 0); + } + @Override public boolean canConnectCable(WireType cableType, TargetingInfo target, Vec3i offset) { - if(dummy!=0) { + if(dummy!=0) + { TileEntity master = world.getTileEntity(getPos().add(0, -dummy, 0)); - return master instanceof TileEntityTransformer && ((TileEntityTransformer) master).canConnectCable(cableType, target, offset); + return master instanceof TileEntityTransformer&&((TileEntityTransformer)master).canConnectCable(cableType, target, offset); } int tc = getTargetedConnector(target); switch(tc) { - case 0: - return canAttach(cableType, limitType, secondCable); - case 1: - return canAttach(cableType, secondCable, limitType); + case 0: + return canAttach(cableType, limitType, secondCable); + case 1: + return canAttach(cableType, secondCable, limitType); } return false; } + private boolean canAttach(WireType toAttach, @Nullable WireType atConn, @Nullable WireType other) { - if (atConn!=null) + if(atConn!=null) return false; String higherCat = getHigherWiretype(); String attachCat = toAttach.getCategory(); - if (other==null) - return higherCat.equals(attachCat) || acceptableLowerWires.contains(attachCat); + if(other==null) + return higherCat.equals(attachCat)||acceptableLowerWires.contains(attachCat); boolean isHigher = higherCat.equals(toAttach.getCategory()); boolean isOtherHigher = higherCat.equals(other.getCategory()); - if (isHigher^isOtherHigher) + if(isHigher^isOtherHigher) { - if (isHigher) + if(isHigher) return true; else return acceptableLowerWires.contains(attachCat); @@ -146,48 +152,51 @@ private boolean canAttach(WireType toAttach, @Nullable WireType atConn, @Nullabl else return false; } + @Override public void connectCable(WireType cableType, TargetingInfo target, IImmersiveConnectable other) { if(dummy!=0) { - TileEntity master = world.getTileEntity(getPos().add(0,-dummy,0)); + TileEntity master = world.getTileEntity(getPos().add(0, -dummy, 0)); if(master instanceof TileEntityTransformer) - ((TileEntityTransformer) master).connectCable(cableType, target, other); + ((TileEntityTransformer)master).connectCable(cableType, target, other); return; } switch(getTargetedConnector(target)) { - case 0: - if(this.limitType==null) - this.limitType = cableType; - break; - case 1: - if(secondCable==null) - this.secondCable = cableType; - break; + case 0: + if(this.limitType==null) + this.limitType = cableType; + break; + case 1: + if(secondCable==null) + this.secondCable = cableType; + break; } } + @Override public WireType getCableLimiter(TargetingInfo target) { switch(getTargetedConnector(target)) { - case 0: - return limitType; - case 1: - return secondCable; + case 0: + return limitType; + case 1: + return secondCable; } return null; } + @Override public void removeCable(Connection connection) { - WireType type = connection!=null?connection.cableType:null; + WireType type = connection!=null?connection.cableType: null; if(type==null) { - limitType=null; - secondCable=null; + limitType = null; + secondCable = null; } if(type==limitType) this.limitType = null; @@ -214,31 +223,31 @@ private Vec3d getConnectionOffset(Connection con, boolean right) if(onPost) { if(right) - return new Vec3d(.5+(facing==EnumFacing.EAST?.4375: facing==EnumFacing.WEST?-.4375: 0),1.4375,.5+(facing==EnumFacing.SOUTH?.4375: facing==EnumFacing.NORTH?-.4375: 0)); + return new Vec3d(.5+(facing==EnumFacing.EAST?.4375: facing==EnumFacing.WEST?-.4375: 0), 1.4375, .5+(facing==EnumFacing.SOUTH?.4375: facing==EnumFacing.NORTH?-.4375: 0)); else - return new Vec3d(.5+(facing==EnumFacing.EAST?-.0625: facing==EnumFacing.WEST?.0625: 0),.25,.5+(facing==EnumFacing.SOUTH?-.0625: facing==EnumFacing.NORTH?.0625: 0)); + return new Vec3d(.5+(facing==EnumFacing.EAST?-.0625: facing==EnumFacing.WEST?.0625: 0), .25, .5+(facing==EnumFacing.SOUTH?-.0625: facing==EnumFacing.NORTH?.0625: 0)); } else { double conRadius = con.cableType.getRenderDiameter()/2; - double offset = getHigherWiretype().equals(con.cableType.getCategory())?getHigherOffset():getLowerOffset(); + double offset = getHigherWiretype().equals(con.cableType.getCategory())?getHigherOffset(): getLowerOffset(); if(facing==EnumFacing.NORTH) - return new Vec3d(right?.8125:.1875, 2+offset-conRadius, .5); + return new Vec3d(right?.8125: .1875, 2+offset-conRadius, .5); if(facing==EnumFacing.SOUTH) - return new Vec3d(right?.1875:.8125, 2+offset-conRadius, .5); + return new Vec3d(right?.1875: .8125, 2+offset-conRadius, .5); if(facing==EnumFacing.WEST) - return new Vec3d(.5, 2+offset-conRadius, right?.1875:.8125); + return new Vec3d(.5, 2+offset-conRadius, right?.1875: .8125); if(facing==EnumFacing.EAST) - return new Vec3d(.5, 2+offset-conRadius, right?.8125:.1875); + return new Vec3d(.5, 2+offset-conRadius, right?.8125: .1875); } - return new Vec3d(.5,.5,.5); + return new Vec3d(.5, .5, .5); } public int getTargetedConnector(TargetingInfo target) { if(onPost) { - if(target.hitY>=.5) + if(target.hitY >= .5) return 0; else return 1; @@ -246,22 +255,22 @@ public int getTargetedConnector(TargetingInfo target) else { if(facing==EnumFacing.NORTH) - if(target.hitX<.5) + if(target.hitX < .5) return 1; else return 0; else if(facing==EnumFacing.SOUTH) - if(target.hitX<.5) + if(target.hitX < .5) return 0; else return 1; else if(facing==EnumFacing.WEST) - if(target.hitZ<.5) + if(target.hitZ < .5) return 0; else return 1; else if(facing==EnumFacing.EAST) - if(target.hitZ<.5) + if(target.hitZ < .5) return 1; else return 0; @@ -279,24 +288,26 @@ public WireType getLimiter(int side) @Override public PropertyBoolInverted getBoolProperty(Class inf) { - return inf==IMirrorAble.class?IEProperties.BOOLEANS[0]:inf==IDualState.class?IEProperties.BOOLEANS[1]:null; + return inf==IMirrorAble.class?IEProperties.BOOLEANS[0]: inf==IDualState.class?IEProperties.BOOLEANS[1]: null; } + @Override public boolean getIsMirrored() { - if (onPost) + if(onPost) return false; - if (dummy!=0) { + if(dummy!=0) + { TileEntity master = world.getTileEntity(pos.down(dummy)); - return master instanceof TileEntityTransformer && ((TileEntityTransformer) master).getIsMirrored(); + return master instanceof TileEntityTransformer&&((TileEntityTransformer)master).getIsMirrored(); } else { - if (limitType==null&&secondCable==null) + if(limitType==null&&secondCable==null) return true; String higher = getHigherWiretype(); - return (limitType != null && higher.equals(limitType.getCategory())) || - (secondCable != null && !higher.equals(secondCable.getCategory())); + return (limitType!=null&&higher.equals(limitType.getCategory()))|| + (secondCable!=null&&!higher.equals(secondCable.getCategory())); } } @@ -305,26 +316,31 @@ public EnumFacing getFacing() { return facing; } + @Override public void setFacing(EnumFacing facing) { this.facing = facing; } + @Override public int getFacingLimitation() { return 2; } + @Override public boolean mirrorFacingOnPlacement(EntityLivingBase placer) { return false; } + @Override public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) { return false; } + @Override public boolean canRotate(EnumFacing axis) { @@ -336,14 +352,16 @@ public boolean isDummy() { return dummy!=0; } + public boolean isOnPost() { return onPost; } + @Override public void placeDummies(BlockPos pos, IBlockState state, EnumFacing side, float hitX, float hitY, float hitZ) { - if (state.getValue(IEProperties.BOOLEANS[1])) + if(state.getValue(IEProperties.BOOLEANS[1])) { onPost = true; facing = side.getOpposite(); @@ -351,56 +369,61 @@ public void placeDummies(BlockPos pos, IBlockState state, EnumFacing side, float this.markContainingBlockForUpdate(null); } else - for(int i=1; i<=2; i++) + for(int i = 1; i <= 2; i++) { - world.setBlockState(pos.add(0,i,0), state); - ((TileEntityTransformer)world.getTileEntity(pos.add(0,i,0))).dummy = i; - ((TileEntityTransformer)world.getTileEntity(pos.add(0,i,0))).facing = this.facing; + world.setBlockState(pos.add(0, i, 0), state); + ((TileEntityTransformer)world.getTileEntity(pos.add(0, i, 0))).dummy = i; + ((TileEntityTransformer)world.getTileEntity(pos.add(0, i, 0))).facing = this.facing; } } + @Override public void breakDummies(BlockPos pos, IBlockState state) { - if (onPost) + if(onPost) return; - for(int i=0; i<=2; i++) - world.setBlockToAir(getPos().add(0,-dummy,0).add(0,i,0)); + for(int i = 0; i <= 2; i++) + world.setBlockToAir(getPos().add(0, -dummy, 0).add(0, i, 0)); } @Override public float[] getBlockBounds() { if(dummy==2) - return new float[]{facing.getAxis()==Axis.Z?0:.3125f, 0, facing.getAxis()==Axis.X?0:.3125f, facing.getAxis()==Axis.Z?1:.6875f,this instanceof TileEntityTransformerHV?.75f:.5625f,facing.getAxis()==Axis.X?1:.6875f}; - if (onPost) - return new float[]{facing.getAxis()==Axis.Z?.25F:facing==EnumFacing.WEST?-.375F:.6875F, + return new float[]{facing.getAxis()==Axis.Z?0: .3125f, 0, facing.getAxis()==Axis.X?0: .3125f, facing.getAxis()==Axis.Z?1: .6875f, this instanceof TileEntityTransformerHV?.75f: .5625f, facing.getAxis()==Axis.X?1: .6875f}; + if(onPost) + return new float[]{facing.getAxis()==Axis.Z?.25F: facing==EnumFacing.WEST?-.375F: .6875F, 0, - facing.getAxis()==Axis.X?.25F:facing==EnumFacing.NORTH?-.375F:.6875F, - facing.getAxis()==Axis.Z?.75F:facing==EnumFacing.EAST?1.375F:.3125F, + facing.getAxis()==Axis.X?.25F: facing==EnumFacing.NORTH?-.375F: .6875F, + facing.getAxis()==Axis.Z?.75F: facing==EnumFacing.EAST?1.375F: .3125F, 1, - facing.getAxis()==Axis.X?.75F:facing==EnumFacing.SOUTH?1.375F:.3125F}; + facing.getAxis()==Axis.X?.75F: facing==EnumFacing.SOUTH?1.375F: .3125F}; return null; } + boolean cachedMirrored = false; private List advSelectionBoxes = null; + @Override public List getAdvancedSelectionBounds() { boolean mirrored = getIsMirrored(); if(dummy==2&&(advSelectionBoxes==null||cachedMirrored!=mirrored)) { - double offsetA = mirrored?getHigherOffset():getLowerOffset(); - double offsetB = mirrored?getLowerOffset():getHigherOffset(); + double offsetA = mirrored?getHigherOffset(): getLowerOffset(); + double offsetB = mirrored?getLowerOffset(): getHigherOffset(); if(facing==EnumFacing.NORTH) - advSelectionBoxes = Lists.newArrayList(new AxisAlignedBB(0,0,.3125, .375, offsetB,.6875).offset(getPos().getX(),getPos().getY(),getPos().getZ()), new AxisAlignedBB(.625,0,.3125, 1, offsetA,.6875).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + advSelectionBoxes = Lists.newArrayList(new AxisAlignedBB(0, 0, .3125, .375, offsetB, .6875).offset(getPos().getX(), getPos().getY(), getPos().getZ()), new AxisAlignedBB(.625, 0, .3125, 1, offsetA, .6875).offset(getPos().getX(), getPos().getY(), getPos().getZ())); if(facing==EnumFacing.SOUTH) - advSelectionBoxes = Lists.newArrayList(new AxisAlignedBB(0,0,.3125, .375, offsetA,.6875).offset(getPos().getX(),getPos().getY(),getPos().getZ()), new AxisAlignedBB(.625,0,.3125, 1, offsetB,.6875).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + advSelectionBoxes = Lists.newArrayList(new AxisAlignedBB(0, 0, .3125, .375, offsetA, .6875).offset(getPos().getX(), getPos().getY(), getPos().getZ()), new AxisAlignedBB(.625, 0, .3125, 1, offsetB, .6875).offset(getPos().getX(), getPos().getY(), getPos().getZ())); if(facing==EnumFacing.WEST) - advSelectionBoxes = Lists.newArrayList(new AxisAlignedBB(.3125,0,0, .6875, offsetA,.375).offset(getPos().getX(),getPos().getY(),getPos().getZ()), new AxisAlignedBB(.3125,0,.625, .6875, offsetB,1).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + advSelectionBoxes = Lists.newArrayList(new AxisAlignedBB(.3125, 0, 0, .6875, offsetA, .375).offset(getPos().getX(), getPos().getY(), getPos().getZ()), new AxisAlignedBB(.3125, 0, .625, .6875, offsetB, 1).offset(getPos().getX(), getPos().getY(), getPos().getZ())); if(facing==EnumFacing.EAST) - advSelectionBoxes = Lists.newArrayList(new AxisAlignedBB(.3125,0,0, .6875, offsetB,.375).offset(getPos().getX(),getPos().getY(),getPos().getZ()), new AxisAlignedBB(.3125,0,.625, .6875, offsetA,1).offset(getPos().getX(),getPos().getY(),getPos().getZ())); + advSelectionBoxes = Lists.newArrayList(new AxisAlignedBB(.3125, 0, 0, .6875, offsetB, .375).offset(getPos().getX(), getPos().getY(), getPos().getZ()), new AxisAlignedBB(.3125, 0, .625, .6875, offsetA, 1).offset(getPos().getX(), getPos().getY(), getPos().getZ())); cachedMirrored = mirrored; - } else if (dummy!=2) { + } + else if(dummy!=2) + { advSelectionBoxes = null; } return advSelectionBoxes; @@ -411,10 +434,11 @@ public boolean isOverrideBox(AxisAlignedBB box, EntityPlayer player, RayTraceRes { return box.grow(.002).contains(mop.hitVec); } + @Override public Set getIgnored(IImmersiveConnectable other) { - if (onPost) + if(onPost) return super.getIgnored(other); return ImmutableSet.of(pos.up(2)); } @@ -425,11 +449,13 @@ public boolean getIsSecondState() return onPost; } - protected float getLowerOffset() { + protected float getLowerOffset() + { return .5F; } - protected float getHigherOffset() { + protected float getHigherOffset() + { return .5625F; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityTransformerHV.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityTransformerHV.java index 17580c4bf4..eb29a44428 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityTransformerHV.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityTransformerHV.java @@ -8,12 +8,9 @@ package blusunrize.immersiveengineering.common.blocks.metal; -import blusunrize.immersiveengineering.api.energy.wires.WireApi; import blusunrize.immersiveengineering.api.energy.wires.WireType; import com.google.common.collect.ImmutableSet; -import java.util.Set; - import static blusunrize.immersiveengineering.api.energy.wires.WireType.HV_CATEGORY; public class TileEntityTransformerHV extends TileEntityTransformer @@ -21,6 +18,7 @@ public class TileEntityTransformerHV extends TileEntityTransformer { acceptableLowerWires = ImmutableSet.of(WireType.LV_CATEGORY, WireType.MV_CATEGORY); } + @Override protected boolean canTakeHV() { @@ -28,12 +26,14 @@ protected boolean canTakeHV() } @Override - protected float getLowerOffset() { + protected float getLowerOffset() + { return super.getHigherOffset(); } @Override - protected float getHigherOffset() { + protected float getHigherOffset() + { return .75F; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityTurret.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityTurret.java index 7f19ece0d9..d088bba386 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityTurret.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityTurret.java @@ -80,12 +80,12 @@ public void update() if(dummy) return; double range = getRange(); - if (targetId!=null) + if(targetId!=null) { AxisAlignedBB validBox = Block.FULL_BLOCK_AABB.offset(pos).grow(range); List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, validBox); - for (EntityLivingBase entity:entities) - if (entity.getUniqueID().equals(targetId)&&isValidTarget(entity, true)) + for(EntityLivingBase entity : entities) + if(entity.getUniqueID().equals(targetId)&&isValidTarget(entity, true)) { target = entity; break; @@ -98,9 +98,8 @@ public void update() Vec3d delta = getGunToTargetVec(target); double dSq = delta.lengthSquared(); if(dSq > range*range) - this.target=null; - else - if(world.isRemote) + this.target = null; + else if(world.isRemote) { float facingYaw = facing==EnumFacing.NORTH?180: facing==EnumFacing.WEST?-90: facing==EnumFacing.EAST?90: 0; double yaw = (MathHelper.atan2(delta.x, delta.z)*(180/Math.PI))-facingYaw; @@ -113,11 +112,11 @@ public void update() } else if(world.isRemote) { - this.rotationYaw*=.75; - if(Math.abs(rotationYaw)<10) + this.rotationYaw *= .75; + if(Math.abs(rotationYaw) < 10) this.rotationYaw = 0; - this.rotationPitch*=.75; - if(Math.abs(rotationPitch)<10) + this.rotationPitch *= .75; + if(Math.abs(rotationPitch) < 10) this.rotationPitch = 0; } @@ -128,7 +127,7 @@ else if(world.isRemote) markContainingBlockForUpdate(null); int energy = IEConfig.Machines.turret_consumption; - if(world.isBlockIndirectlyGettingPowered(getPos())>0^redstoneControlInverted) + if(world.isBlockIndirectlyGettingPowered(getPos()) > 0^redstoneControlInverted) { if(energyStorage.extractEnergy(energy, true)==energy) { @@ -157,12 +156,13 @@ else if(tick > chargeup) else if(tick==chargeup+getActiveTicks()) tick = 0; } - } else + } + else tick = 0; } } else if(target!=null) - target=null; + target = null; } private boolean canShootEntity(EntityLivingBase entity) @@ -170,16 +170,16 @@ private boolean canShootEntity(EntityLivingBase entity) Vec3d start = getGunPosition(); Vec3d end = getTargetVector(entity); //Don't shoot through walls - if (Utils.rayTraceForFirst(start, end, world, Collections.singleton(getPos().up())) + if(Utils.rayTraceForFirst(start, end, world, Collections.singleton(getPos().up())) !=null) return false; //Don't shoot non-targeted entities between the turret and the target AxisAlignedBB potentialCollateralArea = entity.getEntityBoundingBox().union(new AxisAlignedBB(pos.up())); List potentialCollateral = world.getEntitiesWithinAABB(EntityLivingBase.class, potentialCollateralArea); - for (EntityLivingBase coll:potentialCollateral) + for(EntityLivingBase coll : potentialCollateral) { AxisAlignedBB entityBB = coll.getEntityBoundingBox().grow(.125f/2+.4);//Add the range of a revolver bullet in all directions - if (!isValidTarget(coll, false) && entityBB.calculateIntercept(start, end)!=null) + if(!isValidTarget(coll, false)&&entityBB.calculateIntercept(start, end)!=null) return false; } return true; @@ -205,57 +205,64 @@ protected Vec3d getGunToTargetVec(EntityLivingBase target) private EntityLivingBase getTarget() { double range = getRange(); - List list = world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(getPos().getX()-range,getPos().getY(),getPos().getZ()-range, getPos().getX()+range,getPos().getY()+3,getPos().getZ()+range)); + List list = world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(getPos().getX()-range, getPos().getY(), getPos().getZ()-range, getPos().getX()+range, getPos().getY()+3, getPos().getZ()+range)); if(list.isEmpty()) return null; for(EntityLivingBase entity : list) - if (isValidTarget(entity, true)) + if(isValidTarget(entity, true)) return entity; return null; } + public boolean isValidTarget(EntityLivingBase entity, boolean checkCanShoot) { - if (entity == null || entity.isDead || entity.getHealth() <= 0) + if(entity==null||entity.isDead||entity.getHealth() <= 0) return false; //Continue if blacklist and name is in list, or whitelist and name is not in list - if (whitelist ^ isListedName(targetList, entity.getName())) + if(whitelist^isListedName(targetList, entity.getName())) return false; //Same as above but for the owner of the pet, to prevent shooting wolves - if (entity instanceof IEntityOwnable) + if(entity instanceof IEntityOwnable) { - Entity entityOwner = ((IEntityOwnable) entity).getOwner(); - if (entityOwner != null && (whitelist ^ isListedName(targetList, entityOwner.getName()))) + Entity entityOwner = ((IEntityOwnable)entity).getOwner(); + if(entityOwner!=null&&(whitelist^isListedName(targetList, entityOwner.getName()))) return false; } - if (entity instanceof EntityAnimal && !attackAnimals) + if(entity instanceof EntityAnimal&&!attackAnimals) return false; - if (entity instanceof EntityPlayer && !attackPlayers) + if(entity instanceof EntityPlayer&&!attackPlayers) return false; - if (!(entity instanceof EntityPlayer) && !(entity instanceof EntityAnimal) && !entity.isCreatureType(EnumCreatureType.MONSTER, false) && !attackNeutrals) + if(!(entity instanceof EntityPlayer)&&!(entity instanceof EntityAnimal)&&!entity.isCreatureType(EnumCreatureType.MONSTER, false)&&!attackNeutrals) return false; - if (target == null || entity.getDistanceSq(getPos()) < target.getDistanceSq(getPos())) return true; - return !checkCanShoot || canShootEntity(entity); + if(target==null||entity.getDistanceSq(getPos()) < target.getDistanceSq(getPos())) return true; + return !checkCanShoot||canShootEntity(entity); } + private boolean isListedName(List list, String name) { for(String s : list) - if(s!=null && s.equalsIgnoreCase(name)) + if(name.equalsIgnoreCase(s)) return true; return false; } protected abstract double getRange(); + protected abstract boolean canActivate(); + protected abstract int getChargeupTicks(); + protected abstract int getActiveTicks(); + protected abstract boolean loopActivation(); + protected abstract void activate(); protected boolean hasOwnerRights(EntityPlayer player) { - if(player.capabilities.isCreativeMode || owner==null || owner.isEmpty()) + if(player.capabilities.isCreativeMode||owner==null||owner.isEmpty()) return true; return owner.equalsIgnoreCase(player.getName()); } @@ -291,7 +298,7 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) owner = nbt.getString("owner"); NBTTagList list = nbt.getTagList("targetList", 8); targetList.clear(); - for(int i=0; i getInventory() { return NonNullList.create(); } + @Override public boolean isStackValid(int slot, ItemStack stack) { return true; } + @Override public int getSlotLimit(int slot) { return 64; } + @Override public void doGraphicalUpdates(int slot) { @@ -404,16 +415,19 @@ public boolean canOpenGui(EntityPlayer player) ChatUtils.sendServerNoSpamMessages(player, new TextComponentTranslation(Lib.CHAT_INFO+"notOwner", owner)); return false; } + @Override public boolean canOpenGui() { return false; } + @Override public int getGuiID() { return Lib.GUIID_Turret; } + @Override public TileEntity getGuiMaster() { @@ -430,26 +444,31 @@ public EnumFacing getFacing() { return facing; } + @Override public void setFacing(EnumFacing facing) { this.facing = facing; } + @Override public int getFacingLimitation() { return 2; } + @Override public boolean mirrorFacingOnPlacement(EntityLivingBase placer) { return false; } + @Override public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) { return false; } + @Override public boolean canRotate(EnumFacing axis) { @@ -475,6 +494,7 @@ public boolean isDummy() { return dummy; } + @Override public void placeDummies(BlockPos pos, IBlockState state, EnumFacing side, float hitX, float hitY, float hitZ) { @@ -482,11 +502,12 @@ public void placeDummies(BlockPos pos, IBlockState state, EnumFacing side, float ((TileEntityTurret)world.getTileEntity(pos.up())).dummy = true; ((TileEntityTurret)world.getTileEntity(pos.up())).facing = facing; } + @Override public void breakDummies(BlockPos pos, IBlockState state) { - if(world.getTileEntity(dummy?getPos().down():getPos().up()) instanceof TileEntityTurret) - world.setBlockToAir(dummy?getPos().down():getPos().up()); + if(world.getTileEntity(dummy?getPos().down(): getPos().up()) instanceof TileEntityTurret) + world.setBlockToAir(dummy?getPos().down(): getPos().up()); } @Override @@ -505,30 +526,31 @@ public ItemStack getTileDrop(EntityPlayer player, IBlockState state) NBTTagCompound tag = new NBTTagCompound(); //Only writing values when they are different from defaults - if(turret.owner!=null && (player==null || !player.getName().equalsIgnoreCase(turret.owner))) + if(turret.owner!=null&&(player==null||!player.getName().equalsIgnoreCase(turret.owner))) tag.setString("owner", turret.owner); - if(turret.targetList.size()!=1 || !isListedName(turret.targetList, turret.owner)) + if(turret.targetList.size()!=1||!isListedName(turret.targetList, turret.owner)) { NBTTagList list = new NBTTagList(); for(String s : turret.targetList) list.appendTag(new NBTTagString(s)); - tag.setTag("targetList",list); + tag.setTag("targetList", list); } if(turret.whitelist) - tag.setBoolean("whitelist",turret.whitelist); + tag.setBoolean("whitelist", turret.whitelist); if(turret.attackAnimals) - tag.setBoolean("attackAnimals",turret.attackAnimals); + tag.setBoolean("attackAnimals", turret.attackAnimals); if(!turret.attackPlayers) - tag.setBoolean("attackPlayers",turret.attackPlayers); + tag.setBoolean("attackPlayers", turret.attackPlayers); if(turret.attackNeutrals) - tag.setBoolean("attackNeutrals",turret.attackNeutrals); + tag.setBoolean("attackNeutrals", turret.attackNeutrals); if(turret.redstoneControlInverted) - tag.setBoolean("redstoneControlInverted",turret.redstoneControlInverted); + tag.setBoolean("redstoneControlInverted", turret.redstoneControlInverted); if(!tag.hasNoTags()) stack.setTagCompound(tag); return stack; } + @Override public void readOnPlacement(@Nullable EntityLivingBase placer, ItemStack stack) { @@ -543,7 +565,7 @@ else if(placer!=null) { NBTTagList list = tag.getTagList("targetList", 8); targetList.clear(); - for(int i=0; i displayList = Lists.newArrayList("base"); + @Override public ArrayList compileDisplayList() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityTurretChem.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityTurretChem.java index f9dd846f5d..922369a32c 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityTurretChem.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityTurretChem.java @@ -34,35 +34,40 @@ protected double getRange() { return 8; } + @Override protected boolean canActivate() { - return tank.getFluidAmount()>0 && this.energyStorage.getEnergyStored()>= IEConfig.Machines.turret_chem_consumption; + return tank.getFluidAmount() > 0&&this.energyStorage.getEnergyStored() >= IEConfig.Machines.turret_chem_consumption; } + @Override protected int getChargeupTicks() { return 10; } + @Override protected int getActiveTicks() { return 1; } + @Override protected boolean loopActivation() { return true; } + @Override protected void activate() { FluidStack fs = this.tank.getFluid(); - if(fs!=null && fs.getFluid()!=null) + if(fs!=null&&fs.getFluid()!=null) { int consumed = IEConfig.Tools.chemthrower_consumption; int energy = IEConfig.Machines.turret_chem_consumption; - if(consumed<=fs.amount && this.energyStorage.extractEnergy(energy, true)>=energy) + if(consumed <= fs.amount&&this.energyStorage.extractEnergy(energy, true) >= energy) { tank.drain(consumed, true); this.energyStorage.extractEnergy(energy, false); @@ -83,8 +88,8 @@ protected void activate() { Vec3d vecDir = v.addVector(Utils.RAND.nextGaussian()*scatter, Utils.RAND.nextGaussian()*scatter, Utils.RAND.nextGaussian()*scatter); Vec3d throwerPos = getGunPosition(); - EntityChemthrowerShot chem = new EntityChemthrowerShot(world, throwerPos.x+v.x*0.875,throwerPos.y+v.y*0.875, - throwerPos.z+v.z*0.875, 0,0,0, fs); + EntityChemthrowerShot chem = new EntityChemthrowerShot(world, throwerPos.x+v.x*0.875, throwerPos.y+v.y*0.875, + throwerPos.z+v.z*0.875, 0, 0, 0, fs); chem.motionX = vecDir.x*range; chem.motionY = vecDir.y*range; chem.motionZ = vecDir.z*range; @@ -95,9 +100,9 @@ protected void activate() } if(tick%4==0) if(ignite) - world.playSound(null, getPos(), IESounds.sprayFire, SoundCategory.BLOCKS, .5F,1.5F); + world.playSound(null, getPos(), IESounds.sprayFire, SoundCategory.BLOCKS, .5F, 1.5F); else - world.playSound(null, getPos(), IESounds.spray, SoundCategory.BLOCKS, .5F,.75F); + world.playSound(null, getPos(), IESounds.spray, SoundCategory.BLOCKS, .5F, .75F); } } } @@ -130,14 +135,15 @@ public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) @Override public boolean hasCapability(Capability capability, @Nullable EnumFacing facing) { - if(!dummy && capability==CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && (facing==null||facing==EnumFacing.DOWN||facing==this.facing.getOpposite())) + if(!dummy&&capability==CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY&&(facing==null||facing==EnumFacing.DOWN||facing==this.facing.getOpposite())) return true; return super.hasCapability(capability, facing); } + @Override public T getCapability(Capability capability, @Nullable EnumFacing facing) { - if(!dummy && capability==CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && (facing==null||facing==EnumFacing.DOWN||facing==this.facing.getOpposite())) + if(!dummy&&capability==CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY&&(facing==null||facing==EnumFacing.DOWN||facing==this.facing.getOpposite())) return (T)tank; return super.getCapability(capability, facing); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityTurretGun.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityTurretGun.java index 7002770503..49ac052001 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityTurretGun.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityTurretGun.java @@ -43,41 +43,46 @@ protected double getRange() { return 16; } + @Override protected boolean canActivate() { - return this.energyStorage.getEnergyStored()>= IEConfig.Machines.turret_gun_consumption && !inventory.get(0).isEmpty(); + return this.energyStorage.getEnergyStored() >= IEConfig.Machines.turret_gun_consumption&&!inventory.get(0).isEmpty(); } + @Override protected int getChargeupTicks() { return 5; } + @Override protected int getActiveTicks() { return 5; } + @Override protected boolean loopActivation() { return false; } + @Override protected void activate() { int energy = IEConfig.Machines.turret_gun_consumption; ItemStack bulletStack = inventory.get(0); - if(!bulletStack.isEmpty() && this.energyStorage.extractEnergy(energy,true)==energy) + if(!bulletStack.isEmpty()&&this.energyStorage.extractEnergy(energy, true)==energy) { String key = ItemNBTHelper.getString(bulletStack, "bullet"); IBullet bullet = BulletHandler.getBullet(key); if(bullet!=null&&bullet.isValidForTurret()) { ItemStack casing = bullet.getCasing(bulletStack); - if(expelCasings||casing.isEmpty()|| inventory.get(1).isEmpty()||(OreDictionary.itemMatches(casing, inventory.get(1), false)&& inventory.get(1).getCount() + casing.getCount() <= inventory.get(1).getMaxStackSize())) + if(expelCasings||casing.isEmpty()||inventory.get(1).isEmpty()||(OreDictionary.itemMatches(casing, inventory.get(1), false)&&inventory.get(1).getCount()+casing.getCount() <= inventory.get(1).getMaxStackSize())) { - this.energyStorage.extractEnergy(energy,false); + this.energyStorage.extractEnergy(energy, false); this.sendRenderPacket(); Vec3d vec = getGunToTargetVec(target).normalize(); @@ -87,7 +92,8 @@ protected void activate() { Entity entBullet = getBulletEntity(world, vec, bullet); world.spawnEntity(bullet.getProjectile(null, bulletStack, entBullet, false)); - } else + } + else for(int i = 0; i < count; i++) { Vec3d vecDir = vec.addVector(Utils.RAND.nextGaussian()*.1, Utils.RAND.nextGaussian()*.1, Utils.RAND.nextGaussian()*.1); @@ -105,13 +111,14 @@ protected void activate() double cY = getPos().getY()+1.375; double cZ = getPos().getZ()+.5; Vec3d vCasing = vec.rotateYaw(-1.57f); - world.spawnParticle(EnumParticleTypes.REDSTONE, cX+vCasing.x, cY+vCasing.y, cZ+vCasing.z, 0,0,0, 1,0); + world.spawnParticle(EnumParticleTypes.REDSTONE, cX+vCasing.x, cY+vCasing.y, cZ+vCasing.z, 0, 0, 0, 1, 0); EntityItem entCasing = new EntityItem(world, cX+vCasing.x, cY+vCasing.y, cZ+vCasing.z, casing.copy()); entCasing.motionX = 0; entCasing.motionY = -0.01; entCasing.motionZ = 0; world.spawnEntity(entCasing); - } else + } + else { if(inventory.get(1).isEmpty()) inventory.set(1, casing.copy()); @@ -122,7 +129,7 @@ protected void activate() SoundEvent sound = bullet.getSound(); if(sound==null) sound = IESounds.revolverFire; - world.playSound(null, getPos(), sound, SoundCategory.BLOCKS, 1,1); + world.playSound(null, getPos(), sound, SoundCategory.BLOCKS, 1, 1); } } } @@ -138,7 +145,7 @@ protected void sendRenderPacket() EntityRevolvershot getBulletEntity(World world, Vec3d vecDir, IBullet type) { Vec3d gunPos = getGunPosition(); - EntityRevolvershot bullet = new EntityRevolvershot(world, gunPos.x+vecDir.x,gunPos.y+vecDir.y,gunPos.z+vecDir.z, 0,0,0, type); + EntityRevolvershot bullet = new EntityRevolvershot(world, gunPos.x+vecDir.x, gunPos.y+vecDir.y, gunPos.z+vecDir.z, 0, 0, 0, type); bullet.motionX = vecDir.x; bullet.motionY = vecDir.y; bullet.motionZ = vecDir.z; @@ -150,6 +157,7 @@ public NonNullList getInventory() { return inventory; } + @Override public boolean isStackValid(int slot, ItemStack stack) { @@ -159,7 +167,7 @@ public boolean isStackValid(int slot, ItemStack stack) @Override public void update() { - if(world.isRemote&&!dummy&&cycleRender>0) + if(world.isRemote&&!dummy&&cycleRender > 0) cycleRender--; super.update(); } @@ -170,6 +178,7 @@ public void receiveMessageFromServer(NBTTagCompound message) if(message.hasKey("cycle")) cycleRender = 5; } + @Override public void receiveMessageFromClient(NBTTagCompound message) { @@ -196,18 +205,20 @@ public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) nbt.setTag("inventory", Utils.writeInventory(inventory)); } - IItemHandler itemHandler = new IEInventoryHandler(2,this, 0, new boolean[]{true,false},new boolean[]{false,true}); + IItemHandler itemHandler = new IEInventoryHandler(2, this, 0, new boolean[]{true, false}, new boolean[]{false, true}); + @Override public boolean hasCapability(Capability capability, @Nullable EnumFacing facing) { - if(!dummy && capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && (facing==null||facing==EnumFacing.DOWN||facing==this.facing.getOpposite())) + if(!dummy&&capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY&&(facing==null||facing==EnumFacing.DOWN||facing==this.facing.getOpposite())) return true; return super.hasCapability(capability, facing); } + @Override public T getCapability(Capability capability, @Nullable EnumFacing facing) { - if(!dummy && capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && (facing==null||facing==EnumFacing.DOWN||facing==this.facing.getOpposite())) + if(!dummy&&capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY&&(facing==null||facing==EnumFacing.DOWN||facing==this.facing.getOpposite())) return (T)itemHandler; return super.getCapability(capability, facing); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/conveyors/ConveyorBasic.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/conveyors/ConveyorBasic.java index 7f8a482174..fe34c279bb 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/conveyors/ConveyorBasic.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/conveyors/ConveyorBasic.java @@ -31,7 +31,7 @@ public ConveyorDirection getConveyorDirection() @Override public boolean changeConveyorDirection() { - direction = direction == ConveyorDirection.HORIZONTAL ? ConveyorDirection.UP : direction == ConveyorDirection.UP ? ConveyorDirection.DOWN : ConveyorDirection.HORIZONTAL; + direction = direction==ConveyorDirection.HORIZONTAL?ConveyorDirection.UP: direction==ConveyorDirection.UP?ConveyorDirection.DOWN: ConveyorDirection.HORIZONTAL; return true; } @@ -57,7 +57,7 @@ public boolean canBeDyed() @Override public boolean setDyeColour(int colour) { - if(colour == this.dyeColour) + if(colour==this.dyeColour) return false; this.dyeColour = colour; return true; @@ -82,7 +82,7 @@ public NBTTagCompound writeConveyorNBT() public void readConveyorNBT(NBTTagCompound nbt) { direction = ConveyorDirection.values()[nbt.getInteger("direction")]; - dyeColour = nbt.hasKey("dyeColour") ? nbt.getInteger("dyeColour") : -1; + dyeColour = nbt.hasKey("dyeColour")?nbt.getInteger("dyeColour"): -1; } public static ResourceLocation texture_on = new ResourceLocation("immersiveengineering:blocks/conveyor"); diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/conveyors/ConveyorCovered.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/conveyors/ConveyorCovered.java index 22b02cfffb..4fec3a4436 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/conveyors/ConveyorCovered.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/conveyors/ConveyorCovered.java @@ -52,6 +52,7 @@ public class ConveyorCovered extends ConveyorBasic { public static ArrayList> validCoveyorCovers = new ArrayList(); + static { final ArrayList scaffolds = Lists.newArrayList( @@ -85,7 +86,7 @@ public void onEntityCollision(TileEntity tile, Entity entity, EnumFacing facing) { super.onEntityCollision(tile, entity, facing); if(entity instanceof EntityItem) - ((EntityItem) entity).setPickupDelay(10); + ((EntityItem)entity).setPickupDelay(10); } @Override @@ -103,7 +104,8 @@ public String getModelCacheKey(TileEntity tile, EnumFacing facing) return key; } - static final ItemStack defaultCover = new ItemStack(IEContent.blockMetalDecoration1,1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); + static final ItemStack defaultCover = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); + @Override @SideOnly(Side.CLIENT) public List modifyQuads(List baseModel, @Nullable TileEntity tile, EnumFacing facing) @@ -116,14 +118,14 @@ public List modifyQuads(List baseModel, @Nullable TileEnti static void addCoverToQuads(List baseModel, @Nullable TileEntity tile, EnumFacing facing, Supplier coverGet, ConveyorDirection conDir, boolean[] walls) { - ItemStack cover = !coverGet.get().isEmpty()?coverGet.get():defaultCover; + ItemStack cover = !coverGet.get().isEmpty()?coverGet.get(): defaultCover; Block b = Block.getBlockFromItem(cover.getItem()); - IBlockState state = !cover.isEmpty() ? b.getStateFromMeta(cover.getMetadata()) : Blocks.STONE.getDefaultState(); + IBlockState state = !cover.isEmpty()?b.getStateFromMeta(cover.getMetadata()): Blocks.STONE.getDefaultState(); IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(state); - if(model != null) + if(model!=null) { TextureAtlasSprite sprite = model.getParticleTexture(); - HashMap sprites = new HashMap<>(); + HashMap sprites = new HashMap<>(); for(EnumFacing f : EnumFacing.VALUES) for(BakedQuad q : model.getQuads(state, f, 0)) @@ -133,33 +135,33 @@ static void addCoverToQuads(List baseModel, @Nullable TileEntity tile if(q!=null&&q.getSprite()!=null&&q.getFace()!=null) sprites.put(q.getFace(), q.getSprite()); - Function getSprite = f -> sprites.containsKey(f)?sprites.get(f):sprite; - Function getSpriteHorizontal = f -> f.getAxis()==Axis.Y?null:sprites.containsKey(f)?sprites.get(f):sprite; + Function getSprite = f -> sprites.containsKey(f)?sprites.get(f): sprite; + Function getSpriteHorizontal = f -> f.getAxis()==Axis.Y?null: sprites.containsKey(f)?sprites.get(f): sprite; float[] colour = {1, 1, 1, 1}; Matrix4 matrix = new Matrix4(facing); - Function vertexTransformer = conDir==ConveyorDirection.HORIZONTAL?vertices->vertices: vertices -> { + Function vertexTransformer = conDir==ConveyorDirection.HORIZONTAL?vertices -> vertices: vertices -> { Vector3f[] ret = new Vector3f[vertices.length]; - for(int i=0; i getColisionBoxes(TileEntity tile, EnumFacing facing) { @@ -217,11 +220,12 @@ public List getColisionBoxes(TileEntity tile, EnumFacing facing) else { boolean up = getConveyorDirection()==ConveyorDirection.UP; - list.add(new AxisAlignedBB((facing==EnumFacing.WEST&&!up)||(facing==EnumFacing.EAST&&up)?.5:0,1.75,(facing==EnumFacing.NORTH&&!up)||(facing==EnumFacing.SOUTH&&up)?.5:0, (facing==EnumFacing.WEST&&up)||(facing==EnumFacing.EAST&&!up)?.5:1,2,(facing==EnumFacing.NORTH&&up)||(facing==EnumFacing.SOUTH&&!up)?.5:1)); - list.add(new AxisAlignedBB((facing==EnumFacing.WEST&&up)||(facing==EnumFacing.EAST&&!up)?.5:0,1.25,(facing==EnumFacing.NORTH&&up)||(facing==EnumFacing.SOUTH&&!up)?.5:0, (facing==EnumFacing.WEST&&!up)||(facing==EnumFacing.EAST&&up)?.5:1,1.5,(facing==EnumFacing.NORTH&&!up)||(facing==EnumFacing.SOUTH&&up)?.5:1)); + list.add(new AxisAlignedBB((facing==EnumFacing.WEST&&!up)||(facing==EnumFacing.EAST&&up)?.5: 0, 1.75, (facing==EnumFacing.NORTH&&!up)||(facing==EnumFacing.SOUTH&&up)?.5: 0, (facing==EnumFacing.WEST&&up)||(facing==EnumFacing.EAST&&!up)?.5: 1, 2, (facing==EnumFacing.NORTH&&up)||(facing==EnumFacing.SOUTH&&!up)?.5: 1)); + list.add(new AxisAlignedBB((facing==EnumFacing.WEST&&up)||(facing==EnumFacing.EAST&&!up)?.5: 0, 1.25, (facing==EnumFacing.NORTH&&up)||(facing==EnumFacing.SOUTH&&!up)?.5: 0, (facing==EnumFacing.WEST&&!up)||(facing==EnumFacing.EAST&&up)?.5: 1, 1.5, (facing==EnumFacing.NORTH&&!up)||(facing==EnumFacing.SOUTH&&up)?.5: 1)); } return list; } + @Override public List getSelectionBoxes(TileEntity tile, EnumFacing facing) { @@ -231,8 +235,8 @@ public List getSelectionBoxes(TileEntity tile, EnumFacing facing) { boolean up = getConveyorDirection()==ConveyorDirection.UP; List list = Lists.newArrayList( - new AxisAlignedBB((facing==EnumFacing.WEST&&!up)||(facing==EnumFacing.EAST&&up)?.5:0,.5,(facing==EnumFacing.NORTH&&!up)||(facing==EnumFacing.SOUTH&&up)?.5:0, (facing==EnumFacing.WEST&&up)||(facing==EnumFacing.EAST&&!up)?.5:1,2,(facing==EnumFacing.NORTH&&up)||(facing==EnumFacing.SOUTH&&!up)?.5:1), - new AxisAlignedBB((facing==EnumFacing.WEST&&up)||(facing==EnumFacing.EAST&&!up)?.5:0,0,(facing==EnumFacing.NORTH&&up)||(facing==EnumFacing.SOUTH&&!up)?.5:0, (facing==EnumFacing.WEST&&!up)||(facing==EnumFacing.EAST&&up)?.5:1,1.5,(facing==EnumFacing.NORTH&&!up)||(facing==EnumFacing.SOUTH&&up)?.5:1)); + new AxisAlignedBB((facing==EnumFacing.WEST&&!up)||(facing==EnumFacing.EAST&&up)?.5: 0, .5, (facing==EnumFacing.NORTH&&!up)||(facing==EnumFacing.SOUTH&&up)?.5: 0, (facing==EnumFacing.WEST&&up)||(facing==EnumFacing.EAST&&!up)?.5: 1, 2, (facing==EnumFacing.NORTH&&up)||(facing==EnumFacing.SOUTH&&!up)?.5: 1), + new AxisAlignedBB((facing==EnumFacing.WEST&&up)||(facing==EnumFacing.EAST&&!up)?.5: 0, 0, (facing==EnumFacing.NORTH&&up)||(facing==EnumFacing.SOUTH&&!up)?.5: 0, (facing==EnumFacing.WEST&&!up)||(facing==EnumFacing.EAST&&up)?.5: 1, 1.5, (facing==EnumFacing.NORTH&&!up)||(facing==EnumFacing.SOUTH&&up)?.5: 1)); return list; } } @@ -241,7 +245,7 @@ public List getSelectionBoxes(TileEntity tile, EnumFacing facing) public NBTTagCompound writeConveyorNBT() { NBTTagCompound nbt = super.writeConveyorNBT(); - if(cover != null) + if(cover!=null) nbt.setTag("cover", cover.writeToNBT(new NBTTagCompound())); return nbt; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/conveyors/ConveyorDrop.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/conveyors/ConveyorDrop.java index d28bcc0f51..108b30a711 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/conveyors/ConveyorDrop.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/conveyors/ConveyorDrop.java @@ -33,9 +33,9 @@ public void handleInsertion(TileEntity tile, EntityItem entity, EnumFacing facin { BlockPos posDown = tile.getPos().down(); TileEntity inventoryTile = tile.getWorld().getTileEntity(posDown); - boolean contact = Math.abs(facing.getAxis() == Axis.Z ? (tile.getPos().getZ() + .5 - entity.posZ) : (tile.getPos().getX() + .5 - entity.posX)) < .2; + boolean contact = Math.abs(facing.getAxis()==Axis.Z?(tile.getPos().getZ()+.5-entity.posZ): (tile.getPos().getX()+.5-entity.posX)) < .2; - if(contact && inventoryTile != null && !(inventoryTile instanceof IConveyorTile)) + if(contact&&inventoryTile!=null&&!(inventoryTile instanceof IConveyorTile)) { if(!tile.getWorld().isRemote) { @@ -50,16 +50,16 @@ else if(ret.getCount() < stack.getCount()) } } } - else if(contact && isEmptySpace(tile.getWorld(), posDown, inventoryTile)) + else if(contact&&isEmptySpace(tile.getWorld(), posDown, inventoryTile)) { entity.motionX = 0; entity.motionZ = 0; - entity.setPosition(tile.getPos().getX() + .5, tile.getPos().getY() - .5, tile.getPos().getZ() + .5); + entity.setPosition(tile.getPos().getX()+.5, tile.getPos().getY()-.5, tile.getPos().getZ()+.5); if(!(inventoryTile instanceof IConveyorTile)) - ConveyorHandler.revertMagnetSupression(entity, (IConveyorTile) tile); + ConveyorHandler.revertMagnetSupression(entity, (IConveyorTile)tile); } else - super.handleInsertion(tile,entity,facing,conDir,distX,distZ); + super.handleInsertion(tile, entity, facing, conDir, distX, distZ); } boolean isEmptySpace(World world, BlockPos pos, TileEntity tile) diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/conveyors/ConveyorSplit.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/conveyors/ConveyorSplit.java index a34565b35c..3293dab759 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/conveyors/ConveyorSplit.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/conveyors/ConveyorSplit.java @@ -76,8 +76,8 @@ public void handleInsertion(TileEntity tile, EntityItem entity, EnumFacing facin { EnumFacing redirect = EnumFacing.values()[entity.getEntityData().getInteger(nbtKey)]; BlockPos nextPos = tile.getPos().offset(redirect); - double distNext = Math.abs((redirect.getAxis() == Axis.Z ? nextPos.getZ() : nextPos.getX()) + .5 - (redirect.getAxis() == Axis.Z ? entity.posZ : entity.posX)); - if(distNext<.7) + double distNext = Math.abs((redirect.getAxis()==Axis.Z?nextPos.getZ(): nextPos.getX())+.5-(redirect.getAxis()==Axis.Z?entity.posZ: entity.posX)); + if(distNext < .7) super.handleInsertion(tile, entity, redirect, conDir, distX, distZ); } } @@ -88,7 +88,7 @@ public void onEntityCollision(TileEntity tile, Entity entity, EnumFacing facing) if(!isActive(tile)) return; EnumFacing redirect = null; - if(entity != null && !entity.isDead) + if(entity!=null&&!entity.isDead) { String nbtKey = "immersiveengineering:conveyorDir"+Integer.toHexString(tile.getPos().hashCode()); if(entity.getEntityData().hasKey(nbtKey)) @@ -103,17 +103,17 @@ public void onEntityCollision(TileEntity tile, Entity entity, EnumFacing facing) TileEntity nextTile = tile.getWorld().getTileEntity(nextPos); if(!(nextTile instanceof IConveyorTile)) this.outputFace = outputFace.getOpposite(); - else if(((IConveyorTile)nextTile).getFacing() != this.outputFace) + else if(((IConveyorTile)nextTile).getFacing()!=this.outputFace) this.outputFace = outputFace.getOpposite(); } } } super.onEntityCollision(tile, entity, facing); - if(redirect != null) + if(redirect!=null) { String nbtKey = "immersiveengineering:conveyorDir"+Integer.toHexString(tile.getPos().hashCode()); BlockPos nextPos = tile.getPos().offset(redirect); - double distNext = Math.abs((redirect.getAxis() == Axis.Z ? nextPos.getZ() : nextPos.getX()) + .5 - (redirect.getAxis() == Axis.Z ? entity.posZ : entity.posX)); + double distNext = Math.abs((redirect.getAxis()==Axis.Z?nextPos.getZ(): nextPos.getX())+.5-(redirect.getAxis()==Axis.Z?entity.posZ: entity.posX)); double treshold = .4; boolean contact = distNext < treshold; if(contact) @@ -142,13 +142,13 @@ public Vec3d getDirection(TileEntity conveyorTile, Entity entity, EnumFacing fac return vec; EnumFacing redirect = EnumFacing.getFront(entity.getEntityData().getInteger(nbtKey)); BlockPos wallPos = conveyorTile.getPos().offset(facing); - double distNext = Math.abs((facing.getAxis() == Axis.Z ? wallPos.getZ() : wallPos.getX()) + .5 - (facing.getAxis() == Axis.Z ? entity.posZ : entity.posX)); + double distNext = Math.abs((facing.getAxis()==Axis.Z?wallPos.getZ(): wallPos.getX())+.5-(facing.getAxis()==Axis.Z?entity.posZ: entity.posX)); if(distNext < 1.33) { - double sideMove = Math.pow(1 + distNext, 0.1) * .2; + double sideMove = Math.pow(1+distNext, 0.1)*.2; if(distNext < .8) - vec = new Vec3d(facing.getAxis() == Axis.X ? 0 : vec.x, vec.y, facing.getAxis() == Axis.Z ? 0 : vec.z); - vec = vec.addVector(redirect.getFrontOffsetX() * sideMove, 0, redirect.getFrontOffsetZ() * sideMove); + vec = new Vec3d(facing.getAxis()==Axis.X?0: vec.x, vec.y, facing.getAxis()==Axis.Z?0: vec.z); + vec = vec.addVector(redirect.getFrontOffsetX()*sideMove, 0, redirect.getFrontOffsetZ()*sideMove); } return vec; } @@ -205,17 +205,17 @@ public List modifyQuads(List baseModel, @Nullable TileEnti { for(int iv = 0; iv < vertices.length; iv++) { - vertices[iv].setZ((i + 1) * .0625f); - vertices2[iv].setX(vertices2[iv].getX() + .0625f); - vertices3[iv].setX(vertices3[iv].getX() - .0625f); + vertices[iv].setZ((i+1)*.0625f); + vertices2[iv].setX(vertices2[iv].getX()+.0625f); + vertices3[iv].setX(vertices3[iv].getX()-.0625f); } - double v = 16 - i; - baseModel.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), facing, tex_casing0, new double[]{1, v - 1, 15, v}, colour, true)); + double v = 16-i; + baseModel.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), facing, tex_casing0, new double[]{1, v-1, 15, v}, colour, true)); if(i < 7) { - double u = 8 - i; - baseModel.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices2), facing, tex_casing0, new double[]{u - 1, 16, u, 8}, colour, true)); - baseModel.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices3), facing, tex_casing0, new double[]{u - 1, 16, u, 8}, colour, false)); + double u = 8-i; + baseModel.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices2), facing, tex_casing0, new double[]{u-1, 16, u, 8}, colour, true)); + baseModel.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices3), facing, tex_casing0, new double[]{u-1, 16, u, 8}, colour, false)); } } return baseModel; diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/conveyors/ConveyorVertical.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/conveyors/ConveyorVertical.java index 4a6da4a29b..0767f2f01e 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/conveyors/ConveyorVertical.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/conveyors/ConveyorVertical.java @@ -66,55 +66,58 @@ public boolean setConveyorDirection(ConveyorDirection dir) public String getModelCacheKey(TileEntity tile, EnumFacing facing) { String key = ConveyorHandler.reverseClassRegistry.get(this.getClass()).toString(); - key += "f" + facing.ordinal(); - key += "a" + (isActive(tile) ? 1 : 0); - key += "b" + (renderBottomBelt(tile, facing)?("1"+(renderBottomWall(tile,facing,0)?"1":"0")+(renderBottomWall(tile,facing,1)?"1":"0")):"000"); - key += "c" + getDyeColour(); + key += "f"+facing.ordinal(); + key += "a"+(isActive(tile)?1: 0); + key += "b"+(renderBottomBelt(tile, facing)?("1"+(renderBottomWall(tile, facing, 0)?"1": "0")+(renderBottomWall(tile, facing, 1)?"1": "0")): "000"); + key += "c"+getDyeColour(); return key; } + boolean renderBottomBelt(TileEntity tile, EnumFacing facing) { TileEntity te = tile.getWorld().getTileEntity(tile.getPos().add(0, -1, 0)); - if(te instanceof IConveyorTile && ((IConveyorTile)te).getConveyorSubtype() != null) + if(te instanceof IConveyorTile&&((IConveyorTile)te).getConveyorSubtype()!=null) for(EnumFacing f : ((IConveyorTile)te).getConveyorSubtype().sigTransportDirections(te, ((IConveyorTile)te).getFacing())) - if(f == EnumFacing.UP) + if(f==EnumFacing.UP) return false; for(EnumFacing f : EnumFacing.HORIZONTALS) - if(f != facing && isInwardConveyor(tile, f)) + if(f!=facing&&isInwardConveyor(tile, f)) return true; return false; } + protected boolean isInwardConveyor(TileEntity tile, EnumFacing f) { TileEntity te = tile.getWorld().getTileEntity(tile.getPos().offset(f)); if(te instanceof IConveyorTile) { IConveyorBelt sub = ((IConveyorTile)te).getConveyorSubtype(); - if (sub!=null) + if(sub!=null) for(EnumFacing f2 : sub.sigTransportDirections(te, ((IConveyorTile)te).getFacing())) - if(f == f2.getOpposite()) + if(f==f2.getOpposite()) return true; } te = tile.getWorld().getTileEntity(tile.getPos().add(0, -1, 0).offset(f)); if(te instanceof IConveyorTile) { IConveyorBelt sub = ((IConveyorTile)te).getConveyorSubtype(); - if (sub!=null) + if(sub!=null) { int b = 0; for(EnumFacing f2 : sub.sigTransportDirections(te, ((IConveyorTile)te).getFacing())) { - if(f == f2.getOpposite()) + if(f==f2.getOpposite()) b++; - else if(EnumFacing.UP == f2) + else if(EnumFacing.UP==f2) b++; - if(b == 2) + if(b==2) return true; } } } return false; } + protected boolean renderBottomWall(TileEntity tile, EnumFacing facing, int wall) { return super.renderWall(tile, facing, wall); @@ -130,43 +133,44 @@ public EnumFacing[] sigTransportDirections(TileEntity conveyorTile, EnumFacing f public Vec3d getDirection(TileEntity conveyorTile, Entity entity, EnumFacing facing) { BlockPos posWall = conveyorTile.getPos().offset(facing); - double d = .625 + entity.width; - double distToWall = Math.abs((facing.getAxis() == Axis.Z ? posWall.getZ() : posWall.getX()) + .5 - (facing.getAxis() == Axis.Z ? entity.posZ : entity.posX)); + double d = .625+entity.width; + double distToWall = Math.abs((facing.getAxis()==Axis.Z?posWall.getZ(): posWall.getX())+.5-(facing.getAxis()==Axis.Z?entity.posZ: entity.posX)); if(distToWall > d) return super.getDirection(conveyorTile, entity, facing); - double vBase = entity instanceof EntityLivingBase ? 1.5 : 1.15; - double distY = Math.abs(conveyorTile.getPos().add(0, 1, 0).getY() + .5 - entity.posY); + double vBase = entity instanceof EntityLivingBase?1.5: 1.15; + double distY = Math.abs(conveyorTile.getPos().add(0, 1, 0).getY()+.5-entity.posY); double treshold = .9; boolean contact = distY < treshold; double vX = entity.motionX; - double vY = 0.1 * vBase; + double vY = 0.1*vBase; double vZ = entity.motionZ; if(entity.motionY < 0) - vY += entity.motionY * .9; + vY += entity.motionY*.9; if(!(entity instanceof EntityPlayer)) { - vX = 0.05 * facing.getFrontOffsetX(); - vZ = 0.05 * facing.getFrontOffsetZ(); - if(facing == EnumFacing.WEST || facing == EnumFacing.EAST) + vX = 0.05*facing.getFrontOffsetX(); + vZ = 0.05*facing.getFrontOffsetZ(); + if(facing==EnumFacing.WEST||facing==EnumFacing.EAST) { - if(entity.posZ > conveyorTile.getPos().getZ() + 0.65D) - vZ = -0.1D * vBase; - else if(entity.posZ < conveyorTile.getPos().getZ() + 0.35D) - vZ = 0.1D * vBase; - } else if(facing == EnumFacing.NORTH || facing == EnumFacing.SOUTH) + if(entity.posZ > conveyorTile.getPos().getZ()+0.65D) + vZ = -0.1D*vBase; + else if(entity.posZ < conveyorTile.getPos().getZ()+0.35D) + vZ = 0.1D*vBase; + } + else if(facing==EnumFacing.NORTH||facing==EnumFacing.SOUTH) { - if(entity.posX > conveyorTile.getPos().getX() + 0.65D) - vX = -0.1D * vBase; - else if(entity.posX < conveyorTile.getPos().getX() + 0.35D) - vX = 0.1D * vBase; + if(entity.posX > conveyorTile.getPos().getX()+0.65D) + vX = -0.1D*vBase; + else if(entity.posX < conveyorTile.getPos().getX()+0.35D) + vX = 0.1D*vBase; } } //Little boost at the top of a conveyor to help players and minecarts to get off BlockPos upForward = conveyorTile.getPos().add(0, 1, 0); - if(contact && !(Utils.getExistingTileEntity(conveyorTile.getWorld(), upForward) instanceof IConveyorTile)) + if(contact&&!(Utils.getExistingTileEntity(conveyorTile.getWorld(), upForward) instanceof IConveyorTile)) vY *= 2.25; return new Vec3d(vX, vY, vZ); } @@ -178,17 +182,17 @@ public void onEntityCollision(TileEntity tile, Entity entity, EnumFacing facing) return; BlockPos posWall = tile.getPos().offset(facing); - double d = .625 + entity.width; - double distToWall = Math.abs((facing.getAxis() == Axis.Z ? posWall.getZ() : posWall.getX()) + .5 - (facing.getAxis() == Axis.Z ? entity.posZ : entity.posX)); + double d = .625+entity.width; + double distToWall = Math.abs((facing.getAxis()==Axis.Z?posWall.getZ(): posWall.getX())+.5-(facing.getAxis()==Axis.Z?entity.posZ: entity.posX)); if(distToWall > d) { super.onEntityCollision(tile, entity, facing); return; } - if(entity != null && !entity.isDead && !(entity instanceof EntityPlayer && entity.isSneaking())) + if(entity!=null&&!entity.isDead&&!(entity instanceof EntityPlayer&&entity.isSneaking())) { - double distY = Math.abs(tile.getPos().add(0, 1, 0).getY() + .5 - entity.posY); + double distY = Math.abs(tile.getPos().add(0, 1, 0).getY()+.5-entity.posY); double treshold = .9; boolean contact = distY < treshold; @@ -203,31 +207,31 @@ public void onEntityCollision(TileEntity tile, Entity entity, EnumFacing facing) entity.motionZ = vec.z; if(!contact) - ConveyorHandler.applyMagnetSupression(entity, (IConveyorTile) tile); + ConveyorHandler.applyMagnetSupression(entity, (IConveyorTile)tile); else { BlockPos posTop = tile.getPos().add(0, 1, 0); - if(!((tile.getWorld().getTileEntity(posTop) instanceof IConveyorTile) || (tile.getWorld().isAirBlock(posTop) && (tile.getWorld().getTileEntity(posTop.offset(facing)) instanceof IConveyorTile)))) - ConveyorHandler.revertMagnetSupression(entity, (IConveyorTile) tile); + if(!((tile.getWorld().getTileEntity(posTop) instanceof IConveyorTile)||(tile.getWorld().isAirBlock(posTop)&&(tile.getWorld().getTileEntity(posTop.offset(facing)) instanceof IConveyorTile)))) + ConveyorHandler.revertMagnetSupression(entity, (IConveyorTile)tile); } if(entity instanceof EntityItem) { - ((EntityItem) entity).setNoDespawn(); + ((EntityItem)entity).setNoDespawn(); TileEntity inventoryTile; inventoryTile = tile.getWorld().getTileEntity(tile.getPos().add(0, 1, 0)); if(!tile.getWorld().isRemote) { - if(contact && inventoryTile != null && !(inventoryTile instanceof IConveyorTile)) + if(contact&&inventoryTile!=null&&!(inventoryTile instanceof IConveyorTile)) { - ItemStack stack = ((EntityItem) entity).getItem(); + ItemStack stack = ((EntityItem)entity).getItem(); if(!stack.isEmpty()) { ItemStack ret = Utils.insertStackIntoInventory(inventoryTile, stack, EnumFacing.DOWN); if(ret.isEmpty()) entity.setDead(); else if(ret.getCount() < stack.getCount()) - ((EntityItem) entity).setItem(ret); + ((EntityItem)entity).setItem(ret); } } } @@ -242,8 +246,8 @@ public List getSelectionBoxes(TileEntity tile, EnumFacing facing) { ArrayList list = new ArrayList(); if(facing.ordinal() > 1) - list.add(verticalBounds[facing.ordinal() - 2]); - if(renderBottomBelt(tile, facing) || list.isEmpty()) + list.add(verticalBounds[facing.ordinal()-2]); + if(renderBottomBelt(tile, facing)||list.isEmpty()) list.add(conveyorBounds); return list; } @@ -253,8 +257,8 @@ public List getColisionBoxes(TileEntity tile, EnumFacing facing) { ArrayList list = new ArrayList(); if(facing.ordinal() > 1) - list.add(verticalBounds[facing.ordinal() - 2]); - if(renderBottomBelt(tile, facing) || list.isEmpty()) + list.add(verticalBounds[facing.ordinal()-2]); + if(renderBottomBelt(tile, facing)||list.isEmpty()) list.add(conveyorBounds); return list; } @@ -263,7 +267,7 @@ public List getColisionBoxes(TileEntity tile, EnumFacing facing) @SideOnly(Side.CLIENT) public Matrix4f modifyBaseRotationMatrix(Matrix4f matrix, TileEntity tile, EnumFacing facing) { - return new Matrix4(matrix).translate(0, 1, 0).rotate(Math.PI / 2, 1, 0, 0).toMatrix4f(); + return new Matrix4(matrix).translate(0, 1, 0).rotate(Math.PI/2, 1, 0, 0).toMatrix4f(); } public static ResourceLocation texture_on = new ResourceLocation("immersiveengineering:blocks/conveyor_vertical"); @@ -285,9 +289,9 @@ public ResourceLocation getInactiveTexture() @SideOnly(Side.CLIENT) public List modifyQuads(List baseModel, @Nullable TileEntity tile, EnumFacing facing) { - if(tile != null && this.renderBottomBelt(tile, facing)) + if(tile!=null&&this.renderBottomBelt(tile, facing)) { - TextureAtlasSprite sprite = ClientUtils.getSprite(isActive(tile) ? ConveyorBasic.texture_on : ConveyorBasic.texture_off); + TextureAtlasSprite sprite = ClientUtils.getSprite(isActive(tile)?ConveyorBasic.texture_on: ConveyorBasic.texture_off); TextureAtlasSprite spriteColour = ClientUtils.getSprite(getColouredStripesTexture()); boolean[] walls = {renderBottomWall(tile, facing, 0), renderBottomWall(tile, facing, 1)}; baseModel.addAll(ModelConveyor.getBaseConveyor(facing, .875f, new Matrix4(facing), ConveyorDirection.HORIZONTAL, sprite, walls, new boolean[]{true, false}, spriteColour, getDyeColour())); diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/conveyors/ConveyorVerticalCovered.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/conveyors/ConveyorVerticalCovered.java index 82409d67e9..0844d69feb 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/conveyors/ConveyorVerticalCovered.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/conveyors/ConveyorVerticalCovered.java @@ -51,10 +51,10 @@ public class ConveyorVerticalCovered extends ConveyorVertical public String getModelCacheKey(TileEntity tile, EnumFacing facing) { String key = ConveyorHandler.reverseClassRegistry.get(this.getClass()).toString(); - key += "f" + facing.ordinal(); - key += "a" + (isActive(tile) ? 1 : 0); - key += "b" + (renderBottomBelt(tile, facing)?("1"+(isInwardConveyor(tile, facing.getOpposite())?"1":"0")+(renderBottomWall(tile,facing,0)?"1":"0")+(renderBottomWall(tile,facing,1)?"1":"0")):"0000"); - key += "c" + getDyeColour(); + key += "f"+facing.ordinal(); + key += "a"+(isActive(tile)?1: 0); + key += "b"+(renderBottomBelt(tile, facing)?("1"+(isInwardConveyor(tile, facing.getOpposite())?"1": "0")+(renderBottomWall(tile, facing, 0)?"1": "0")+(renderBottomWall(tile, facing, 1)?"1": "0")): "0000"); + key += "c"+getDyeColour(); if(!cover.isEmpty()) key += "s"+cover.getItem().getRegistryName()+cover.getMetadata(); return key; @@ -65,7 +65,7 @@ public void onEntityCollision(TileEntity tile, Entity entity, EnumFacing facing) { super.onEntityCollision(tile, entity, facing); if(entity instanceof EntityItem) - ((EntityItem) entity).setPickupDelay(10); + ((EntityItem)entity).setPickupDelay(10); } @Override @@ -81,6 +81,7 @@ public boolean playerInteraction(TileEntity tile, EntityPlayer player, EnumHand } static final List selectionBoxes = Collections.singletonList(Block.FULL_BLOCK_AABB); + @Override public List getSelectionBoxes(TileEntity tile, EnumFacing facing) { @@ -89,6 +90,7 @@ public List getSelectionBoxes(TileEntity tile, EnumFacing facing) static final AxisAlignedBB[] topBounds = {new AxisAlignedBB(0, 0, .75, 1, 1, 1), new AxisAlignedBB(0, 0, 0, 1, 1, .25), new AxisAlignedBB(.75, 0, 0, 1, 1, 1), new AxisAlignedBB(0, 0, 0, .25, 1, 1)}; static final AxisAlignedBB[] topBoundsCorner = {new AxisAlignedBB(0, .75, .75, 1, 1, 1), new AxisAlignedBB(0, .75, 0, 1, 1, .25), new AxisAlignedBB(.75, .75, 0, 1, 1, 1), new AxisAlignedBB(0, .75, 0, .25, 1, 1)}; + @Override public List getColisionBoxes(TileEntity tile, EnumFacing facing) { @@ -96,10 +98,10 @@ public List getColisionBoxes(TileEntity tile, EnumFacing facing) boolean bottom = renderBottomBelt(tile, facing); if(facing.ordinal() > 1) { - list.add(verticalBounds[facing.ordinal() - 2]); - list.add((bottom?topBoundsCorner:topBounds)[facing.ordinal() - 2]); + list.add(verticalBounds[facing.ordinal()-2]); + list.add((bottom?topBoundsCorner: topBounds)[facing.ordinal()-2]); } - if(bottom || list.isEmpty()) + if(bottom||list.isEmpty()) list.add(conveyorBounds); return list; } @@ -112,22 +114,22 @@ public List modifyQuads(List baseModel, @Nullable TileEnti boolean[] walls; if(renderBottom) { - TextureAtlasSprite sprite = ClientUtils.getSprite(isActive(tile) ? ConveyorBasic.texture_on : ConveyorBasic.texture_off); + TextureAtlasSprite sprite = ClientUtils.getSprite(isActive(tile)?ConveyorBasic.texture_on: ConveyorBasic.texture_off); TextureAtlasSprite spriteColour = ClientUtils.getSprite(getColouredStripesTexture()); walls = new boolean[]{renderBottomWall(tile, facing, 0), renderBottomWall(tile, facing, 1)}; baseModel.addAll(ModelConveyor.getBaseConveyor(facing, .875f, new Matrix4(facing), ConveyorDirection.HORIZONTAL, sprite, walls, new boolean[]{true, false}, spriteColour, getDyeColour())); } else - walls = new boolean[]{true,true}; + walls = new boolean[]{true, true}; - ItemStack cover = !this.cover.isEmpty()?this.cover:ConveyorCovered.defaultCover; + ItemStack cover = !this.cover.isEmpty()?this.cover: ConveyorCovered.defaultCover; Block b = Block.getBlockFromItem(cover.getItem()); - IBlockState state = !cover.isEmpty() ? b.getStateFromMeta(cover.getMetadata()) : Blocks.STONE.getDefaultState(); + IBlockState state = !cover.isEmpty()?b.getStateFromMeta(cover.getMetadata()): Blocks.STONE.getDefaultState(); IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(state); - if(model != null) + if(model!=null) { TextureAtlasSprite sprite = model.getParticleTexture(); - HashMap sprites = new HashMap<>(); + HashMap sprites = new HashMap<>(); for(EnumFacing f : EnumFacing.VALUES) for(BakedQuad q : model.getQuads(state, f, 0)) @@ -137,7 +139,7 @@ public List modifyQuads(List baseModel, @Nullable TileEnti if(q!=null&&q.getSprite()!=null&&q.getFace()!=null) sprites.put(q.getFace(), q.getSprite()); - Function getSprite = f -> sprites.containsKey(f)?sprites.get(f):sprite; + Function getSprite = f -> sprites.containsKey(f)?sprites.get(f): sprite; float[] colour = {1, 1, 1, 1}; Matrix4 matrix = new Matrix4(facing); @@ -162,14 +164,14 @@ public List modifyQuads(List baseModel, @Nullable TileEnti } if(walls[0])//wall to the left - baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(0, .1875f, .1875f),new Vector3f(.0625f, 1, .9375f),matrix, facing, getSprite, colour)); + baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(0, .1875f, .1875f), new Vector3f(.0625f, 1, .9375f), matrix, facing, getSprite, colour)); else//cutout to the left - baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(0, .75f, .1875f),new Vector3f(.0625f, 1, .9375f),matrix, facing, getSprite, colour)); + baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(0, .75f, .1875f), new Vector3f(.0625f, 1, .9375f), matrix, facing, getSprite, colour)); if(walls[1])//wall to the right - baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(.9375f, .1875f, .1875f),new Vector3f(1, 1, .9375f),matrix, facing, getSprite, colour)); + baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(.9375f, .1875f, .1875f), new Vector3f(1, 1, .9375f), matrix, facing, getSprite, colour)); else//cutout to the right - baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(.9375f, .75f, .1875f),new Vector3f(1, 1, .9375f),matrix, facing, getSprite, colour)); + baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(.9375f, .75f, .1875f), new Vector3f(1, 1, .9375f), matrix, facing, getSprite, colour)); } } return baseModel; @@ -179,7 +181,7 @@ public List modifyQuads(List baseModel, @Nullable TileEnti public NBTTagCompound writeConveyorNBT() { NBTTagCompound nbt = super.writeConveyorNBT(); - if(cover != null) + if(cover!=null) nbt.setTag("cover", cover.writeToNBT(new NBTTagCompound())); return nbt; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/package-info.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/package-info.java index c46ab580e0..d8b0c147a0 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/package-info.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/package-info.java @@ -3,4 +3,5 @@ package blusunrize.immersiveengineering.common.blocks.metal; import mcp.MethodsReturnNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockAlloySmelter.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockAlloySmelter.java index f8f382ce2c..9f12a150a6 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockAlloySmelter.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockAlloySmelter.java @@ -31,34 +31,41 @@ public class MultiblockAlloySmelter implements IMultiblock public static MultiblockAlloySmelter instance = new MultiblockAlloySmelter(); static ItemStack[][][] structure = new ItemStack[3][3][3]; - static{ - for(int h=0;h<2;h++) - for(int l=0;l<2;l++) - for(int w=0;w<2;w++) - structure[h][l][w]=new ItemStack(IEContent.blockStoneDecoration,1,BlockTypes_StoneDecoration.ALLOYBRICK.getMeta()); + + static + { + for(int h = 0; h < 2; h++) + for(int l = 0; l < 2; l++) + for(int w = 0; w < 2; w++) + structure[h][l][w] = new ItemStack(IEContent.blockStoneDecoration, 1, BlockTypes_StoneDecoration.ALLOYBRICK.getMeta()); } + @Override public ItemStack[][][] getStructureManual() { return structure; } + @Override @SideOnly(Side.CLIENT) public boolean overwriteBlockRender(ItemStack stack, int iterator) { return false; } + @Override public float getManualScale() { return 20; } + @Override @SideOnly(Side.CLIENT) public boolean canRenderFormedStructure() { return false; } + @Override @SideOnly(Side.CLIENT) public void renderFormedStructure() @@ -74,7 +81,7 @@ public String getUniqueName() @Override public boolean isBlockTrigger(IBlockState state) { - return state.getBlock()==IEContent.blockStoneDecoration && state.getBlock().getMetaFromState(state)==BlockTypes_StoneDecoration.ALLOYBRICK.getMeta(); + return state.getBlock()==IEContent.blockStoneDecoration&&state.getBlock().getMetaFromState(state)==BlockTypes_StoneDecoration.ALLOYBRICK.getMeta(); } @Override @@ -87,29 +94,29 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit if(!Utils.isBlockAt(world, pos.offset(f.rotateY()), IEContent.blockStoneDecoration, BlockTypes_StoneDecoration.ALLOYBRICK.getMeta())) pos = pos.offset(f.rotateYCCW()); - for(int h=0;h<=1;h++) - for(int l=0;l<=1;l++) - for(int w=0;w<=1;w++) + for(int h = 0; h <= 1; h++) + for(int l = 0; l <= 1; l++) + for(int w = 0; w <= 1; w++) { - BlockPos pos2 = pos.up(h).offset(f,l).offset(f.rotateY(),w); + BlockPos pos2 = pos.up(h).offset(f, l).offset(f.rotateY(), w); if(!Utils.isBlockAt(world, pos2, IEContent.blockStoneDecoration, BlockTypes_StoneDecoration.ALLOYBRICK.getMeta())) return false; } IBlockState state = IEContent.blockStoneDevice.getStateFromMeta(BlockTypes_StoneDevices.ALLOY_SMELTER.getMeta()); state = state.withProperty(IEProperties.FACING_HORIZONTAL, f.getOpposite()); - for(int h=0;h<=1;h++) - for(int l=0;l<=1;l++) - for(int w=0;w<=1;w++) + for(int h = 0; h <= 1; h++) + for(int l = 0; l <= 1; l++) + for(int w = 0; w <= 1; w++) { - BlockPos pos2 = pos.up(h).offset(f,l).offset(f.rotateY(),w); + BlockPos pos2 = pos.up(h).offset(f, l).offset(f.rotateY(), w); world.setBlockState(pos2, state); TileEntity curr = world.getTileEntity(pos2); if(curr instanceof TileEntityAlloySmelter) { - TileEntityAlloySmelter currBlast = (TileEntityAlloySmelter) curr; - currBlast.offset=new int[]{pos2.getX()-pos.getX(),pos2.getY()-pos.getY(),pos2.getZ()-pos.getZ()}; - currBlast.pos = (h+1)*9 + (l+1)*3 + (w+1); - currBlast.formed=true; + TileEntityAlloySmelter currBlast = (TileEntityAlloySmelter)curr; + currBlast.offset = new int[]{pos2.getX()-pos.getX(), pos2.getY()-pos.getY(), pos2.getZ()-pos.getZ()}; + currBlast.pos = (h+1)*9+(l+1)*3+(w+1); + currBlast.formed = true; currBlast.markDirty(); world.addBlockEvent(pos2, IEContent.blockStoneDevice, 255, 0); } @@ -118,6 +125,7 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit } static final IngredientStack[] materials = new IngredientStack[]{new IngredientStack(new ItemStack(IEContent.blockStoneDecoration, 8, BlockTypes_StoneDecoration.ALLOYBRICK.getMeta()))}; + @Override public IngredientStack[] getTotalMaterials() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockArcFurnace.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockArcFurnace.java index 60ddf56621..a0cb431506 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockArcFurnace.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockArcFurnace.java @@ -42,109 +42,118 @@ public class MultiblockArcFurnace implements IMultiblock { public static MultiblockArcFurnace instance = new MultiblockArcFurnace(); static ItemStack[][][] structure = new ItemStack[5][5][5]; - static{ - for(int h=0;h<5;h++) - for(int l=0;l<5;l++) - for(int w=0;w<5;w++) + + static + { + for(int h = 0; h < 5; h++) + for(int l = 0; l < 5; l++) + for(int w = 0; w < 5; w++) { if(h==0) { if(l==0&&w==2) structure[h][l][w] = new ItemStack(Items.CAULDRON); else if(l==2&&(w==0||w==4)) - structure[h][l][w] = new ItemStack(IEContent.blockStorage,1,BlockTypes_MetalsIE.STEEL.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockStorage, 1, BlockTypes_MetalsIE.STEEL.getMeta()); else if(l==0&&w==0) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); - else if(l==4&& w==2) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); - else if(l==4||(l>2 &&(w==0||w==4))) - structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.STEEL.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); + else if(l==4&&w==2) + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); + else if(l==4||(l > 2&&(w==0||w==4))) + structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.STEEL.getMeta()); else - structure[h][l][w] = new ItemStack(IEContent.blockSheetmetalSlabs,1,BlockTypes_MetalsAll.STEEL.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockSheetmetalSlabs, 1, BlockTypes_MetalsAll.STEEL.getMeta()); } else if(h==1) { if(l==2&&(w==0||w==4)) - structure[h][l][w] = new ItemStack(IEContent.blockStorage,1,BlockTypes_MetalsIE.STEEL.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockStorage, 1, BlockTypes_MetalsIE.STEEL.getMeta()); else if(l==0&&w==0) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); - else if(l==4&&w>0&&w<4) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); - else if((w==0||w==4)&&l>2) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); - else if(l>=2 && w>0&&w<4) - structure[h][l][w] = new ItemStack(IEContent.blockStoneDecoration,1,BlockTypes_StoneDecoration.BLASTBRICK_REINFORCED.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); + else if(l==4&&w > 0&&w < 4) + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + else if((w==0||w==4)&&l > 2) + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); + else if(l >= 2&&w > 0&&w < 4) + structure[h][l][w] = new ItemStack(IEContent.blockStoneDecoration, 1, BlockTypes_StoneDecoration.BLASTBRICK_REINFORCED.getMeta()); } else if(h==2) { if(l==2&&(w==0||w==4)) - structure[h][l][w] = new ItemStack(IEContent.blockStorage,1,BlockTypes_MetalsIE.STEEL.getMeta()); - else if(l==4&&w>0&&w<4) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockStorage, 1, BlockTypes_MetalsIE.STEEL.getMeta()); + else if(l==4&&w > 0&&w < 4) + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); else if(l==4) - structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.STEEL.getMeta()); - else if(w>0&&w<4) - structure[h][l][w] = new ItemStack(IEContent.blockStoneDecoration,1,BlockTypes_StoneDecoration.BLASTBRICK_REINFORCED.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.STEEL.getMeta()); + else if(w > 0&&w < 4) + structure[h][l][w] = new ItemStack(IEContent.blockStoneDecoration, 1, BlockTypes_StoneDecoration.BLASTBRICK_REINFORCED.getMeta()); } else if(h==3) { if(l==4&&w==2) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); else if(l==4&&(w==1||w==3)) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); - else if(l>0&&w>0&&w<4) - structure[h][l][w] = new ItemStack(IEContent.blockStoneDecoration,1,BlockTypes_StoneDecoration.BLASTBRICK_REINFORCED.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); + else if(l > 0&&w > 0&&w < 4) + structure[h][l][w] = new ItemStack(IEContent.blockStoneDecoration, 1, BlockTypes_StoneDecoration.BLASTBRICK_REINFORCED.getMeta()); } else if(h==4) { - if(l>1&&w==2) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + if(l > 1&&w==2) + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); else if(l==4&&(w==1||w==3)) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); } - if (structure[h][l][w] == null) { + if(structure[h][l][w]==null) + { structure[h][l][w] = ItemStack.EMPTY; } } } + @Override public ItemStack[][][] getStructureManual() { return structure; } + @Override @SideOnly(Side.CLIENT) public boolean overwriteBlockRender(ItemStack stack, int iterator) { return false; } + @Override public IBlockState getBlockstateFromStack(int index, ItemStack stack) { if(!stack.isEmpty()) { - if(stack.getItem() == Items.CAULDRON) + if(stack.getItem()==Items.CAULDRON) return Blocks.CAULDRON.getDefaultState(); else if(stack.getItem() instanceof ItemBlock) return ((ItemBlock)stack.getItem()).getBlock().getStateFromMeta(stack.getItemDamage()); } return null; } + @Override @SideOnly(Side.CLIENT) public boolean canRenderFormedStructure() { return true; } + //@SideOnly(Side.CLIENT) static ItemStack renderStack = ItemStack.EMPTY; + @Override @SideOnly(Side.CLIENT) public void renderFormedStructure() { if(renderStack.isEmpty()) - renderStack = new ItemStack(IEContent.blockMetalMultiblock,1,BlockTypes_MetalMultiblock.ARC_FURNACE.getMeta()); + renderStack = new ItemStack(IEContent.blockMetalMultiblock, 1, BlockTypes_MetalMultiblock.ARC_FURNACE.getMeta()); GlStateManager.translate(2.5, 2.25, 2.25); GlStateManager.rotate(-45, 0, 1, 0); @@ -155,6 +164,7 @@ public void renderFormedStructure() ClientUtils.mc().getRenderItem().renderItem(renderStack, ItemCameraTransforms.TransformType.GUI); GlStateManager.enableCull(); } + @Override public float getManualScale() { @@ -181,31 +191,31 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit BlockPos startPos = pos; side = side.getOpposite(); - if(Utils.isOreBlockAt(world, startPos.add(0,-1,0), "scaffoldingSteel") - && Utils.isBlockAt(world, startPos.offset(side,2).add(0,-1,0), IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())) + if(Utils.isOreBlockAt(world, startPos.add(0, -1, 0), "scaffoldingSteel") + &&Utils.isBlockAt(world, startPos.offset(side, 2).add(0, -1, 0), IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())) { - startPos = startPos.offset(side,2); + startPos = startPos.offset(side, 2); side = side.getOpposite(); } boolean mirrored = false; - boolean b = structureCheck(world,startPos, side, mirrored); + boolean b = structureCheck(world, startPos, side, mirrored); if(!b) { mirrored = true; - b = structureCheck(world,startPos, side, mirrored); + b = structureCheck(world, startPos, side, mirrored); } if(b) { IBlockState state = IEContent.blockMetalMultiblock.getStateFromMeta(BlockTypes_MetalMultiblock.ARC_FURNACE.getMeta()); state = state.withProperty(IEProperties.FACING_HORIZONTAL, side); - for(int l=0;l<5;l++) - for(int w=-2;w<=2;w++) - for(int h=0;h<5;h++) + for(int l = 0; l < 5; l++) + for(int w = -2; w <= 2; w++) + for(int h = 0; h < 5; h++) if(!structure[h][l][w+2].isEmpty()) { - int ww = mirrored?-w:w; + int ww = mirrored?-w: w; BlockPos pos2 = startPos.offset(side, l).offset(side.rotateY(), ww).add(0, h, 0); world.setBlockState(pos2, state); @@ -213,9 +223,9 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit if(curr instanceof TileEntityArcFurnace) { TileEntityArcFurnace tile = (TileEntityArcFurnace)curr; - tile.formed=true; - tile.pos = h*25 + l*5 + (w+2); - tile.offset = new int[]{(side==EnumFacing.WEST?-l+2: side==EnumFacing.EAST?l-2: side==EnumFacing.NORTH?ww: -ww),h-1,(side==EnumFacing.NORTH?-l+2: side==EnumFacing.SOUTH?l-2: side==EnumFacing.EAST?ww : -ww)}; + tile.formed = true; + tile.pos = h*25+l*5+(w+2); + tile.offset = new int[]{(side==EnumFacing.WEST?-l+2: side==EnumFacing.EAST?l-2: side==EnumFacing.NORTH?ww: -ww), h-1, (side==EnumFacing.NORTH?-l+2: side==EnumFacing.SOUTH?l-2: side==EnumFacing.EAST?ww: -ww)}; tile.mirrored = mirrored; tile.markDirty(); world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0); @@ -227,12 +237,12 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit boolean structureCheck(World world, BlockPos startPos, EnumFacing dir, boolean mirror) { - for(int l=0;l<5;l++) - for(int w=-2;w<=2;w++) - for(int h=0;h<5;h++) + for(int l = 0; l < 5; l++) + for(int w = -2; w <= 2; w++) + for(int h = 0; h < 5; h++) if(!structure[h][l][w+2].isEmpty()) { - int ww = mirror?-w:w; + int ww = mirror?-w: w; BlockPos pos = startPos.offset(dir, l).offset(dir.rotateY(), ww).add(0, h, 0); if(world.isAirBlock(pos)) @@ -242,22 +252,22 @@ boolean structureCheck(World world, BlockPos startPos, EnumFacing dir, boolean m if(!Utils.isBlockAt(world, pos, Blocks.CAULDRON, OreDictionary.WILDCARD_VALUE)) return false; } - else if(OreDictionary.itemMatches(structure[h][l][w+2], new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()), true)) + else if(OreDictionary.itemMatches(structure[h][l][w+2], new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()), true)) { if(!Utils.isOreBlockAt(world, pos, "scaffoldingSteel")) return false; } - else if(OreDictionary.itemMatches(structure[h][l][w+2], new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.STEEL.getMeta()), true)) + else if(OreDictionary.itemMatches(structure[h][l][w+2], new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.STEEL.getMeta()), true)) { if(!Utils.isOreBlockAt(world, pos, "blockSheetmetalSteel")) return false; } - else if(OreDictionary.itemMatches(structure[h][l][w+2], new ItemStack(IEContent.blockSheetmetalSlabs,1,BlockTypes_MetalsAll.STEEL.getMeta()), true)) + else if(OreDictionary.itemMatches(structure[h][l][w+2], new ItemStack(IEContent.blockSheetmetalSlabs, 1, BlockTypes_MetalsAll.STEEL.getMeta()), true)) { if(!Utils.isOreBlockAt(world, pos, "slabSheetmetalSteel")) return false; } - else if(OreDictionary.itemMatches(structure[h][l][w+2], new ItemStack(IEContent.blockStorage,1,BlockTypes_MetalsIE.STEEL.getMeta()), true)) + else if(OreDictionary.itemMatches(structure[h][l][w+2], new ItemStack(IEContent.blockStorage, 1, BlockTypes_MetalsIE.STEEL.getMeta()), true)) { if(!Utils.isOreBlockAt(world, pos, "blockSteel")) return false; @@ -266,7 +276,7 @@ else if(OreDictionary.itemMatches(structure[h][l][w+2], new ItemStack(IEContent. { Block b = Block.getBlockFromItem(structure[h][l][w+2].getItem()); if(b!=null) - if(!Utils.isBlockAt(world, pos, b,structure[h][l][w+2].getItemDamage())) + if(!Utils.isBlockAt(world, pos, b, structure[h][l][w+2].getItemDamage())) return false; } } @@ -283,6 +293,7 @@ else if(OreDictionary.itemMatches(structure[h][l][w+2], new ItemStack(IEContent. new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 10, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())), new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 5, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta())), new IngredientStack(new ItemStack(IEContent.blockStoneDecoration, 27, BlockTypes_StoneDecoration.BLASTBRICK_REINFORCED.getMeta()))}; + @Override public IngredientStack[] getTotalMaterials() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockAssembler.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockAssembler.java index 8ac156881f..b1bf321381 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockAssembler.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockAssembler.java @@ -38,43 +38,47 @@ public class MultiblockAssembler implements IMultiblock { public static MultiblockAssembler instance = new MultiblockAssembler(); static ItemStack[][][] structure = new ItemStack[3][3][3]; - static{ - for(int h=0;h<3;h++) - for(int l=0;l<3;l++) - for(int w=0;w<3;w++) + + static + { + for(int h = 0; h < 3; h++) + for(int l = 0; l < 3; l++) + for(int w = 0; w < 3; w++) { if(h==0) { if(l==1&&w!=1) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); else if(l==1&&w==1) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); else - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); } else if(h==1) { - if(w==0 || w==2) - structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.IRON.getMeta()); + if(w==0||w==2) + structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.IRON.getMeta()); else if(l==1) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); else - structure[h][l][w] = ConveyorHandler.getConveyorStack(ImmersiveEngineering.MODID + ":conveyor"); + structure[h][l][w] = ConveyorHandler.getConveyorStack(ImmersiveEngineering.MODID+":conveyor"); } else if(h==2) { if(w==1) - structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.IRON.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.IRON.getMeta()); else - structure[h][l][w] = new ItemStack(IEContent.blockSheetmetalSlabs,1,BlockTypes_MetalsAll.IRON.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockSheetmetalSlabs, 1, BlockTypes_MetalsAll.IRON.getMeta()); } } } + @Override public ItemStack[][][] getStructureManual() { return structure; } + @Override @SideOnly(Side.CLIENT) public boolean overwriteBlockRender(ItemStack stack, int iterator) @@ -83,20 +87,23 @@ public boolean overwriteBlockRender(ItemStack stack, int iterator) return ImmersiveEngineering.proxy.drawConveyorInGui("immersiveengineering:conveyor", EnumFacing.EAST); return false; } + @Override @SideOnly(Side.CLIENT) public boolean canRenderFormedStructure() { return true; } + //@SideOnly(Side.CLIENT) static ItemStack renderStack = ItemStack.EMPTY; + @Override @SideOnly(Side.CLIENT) public void renderFormedStructure() { if(renderStack.isEmpty()) - renderStack = new ItemStack(IEContent.blockMetalMultiblock,1,BlockTypes_MetalMultiblock.ASSEMBLER.getMeta()); + renderStack = new ItemStack(IEContent.blockMetalMultiblock, 1, BlockTypes_MetalMultiblock.ASSEMBLER.getMeta()); GlStateManager.translate(1.5, 1.5, 1.5); GlStateManager.rotate(-45, 0, 1, 0); GlStateManager.rotate(-20, 1, 0, 0); @@ -105,6 +112,7 @@ public void renderFormedStructure() ClientUtils.mc().getRenderItem().renderItem(renderStack, ItemCameraTransforms.TransformType.GUI); GlStateManager.enableCull(); } + @Override public float getManualScale() { @@ -120,7 +128,7 @@ public String getUniqueName() @Override public boolean isBlockTrigger(IBlockState state) { - return state.getBlock() == IEContent.blockConveyor; + return state.getBlock()==IEContent.blockConveyor; } @Override @@ -132,11 +140,11 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit side = side.getOpposite(); boolean mirror = false; - for(int l=0;l<3;l++) - for(int h=-1;h<=1;h++) - for(int w=-1;w<=1;w++) + for(int l = 0; l < 3; l++) + for(int h = -1; h <= 1; h++) + for(int w = -1; w <= 1; w++) { - int ww = mirror?-w:w; + int ww = mirror?-w: w; BlockPos pos2 = pos.offset(side, l).offset(side.rotateY(), ww).add(0, h, 0); if(h==-1) @@ -159,7 +167,7 @@ else if(l==1&&w==0) } else if(h==0) { - if(w==-1 || w==1) + if(w==-1||w==1) { if(!Utils.isOreBlockAt(world, pos2, "blockSheetmetalIron")) return false; @@ -171,7 +179,7 @@ else if(l==1) } else { - if(!ConveyorHandler.isConveyor(world, pos2, ImmersiveEngineering.MODID + ":conveyor", null)) + if(!ConveyorHandler.isConveyor(world, pos2, ImmersiveEngineering.MODID+":conveyor", null)) return false; } } @@ -193,11 +201,11 @@ else if(h==1) IBlockState state = IEContent.blockMetalMultiblock.getStateFromMeta(BlockTypes_MetalMultiblock.ASSEMBLER.getMeta()); state = state.withProperty(IEProperties.FACING_HORIZONTAL, side); - for(int l=0;l<3;l++) - for(int w=-1;w<=1;w++) - for(int h=-1;h<=1;h++) + for(int l = 0; l < 3; l++) + for(int w = -1; w <= 1; w++) + for(int h = -1; h <= 1; h++) { - int ww = mirror?-w:w; + int ww = mirror?-w: w; BlockPos pos2 = pos.offset(side, l).offset(side.rotateY(), ww).add(0, h, 0); world.setBlockState(pos2, state); @@ -205,10 +213,10 @@ else if(h==1) if(curr instanceof TileEntityAssembler) { TileEntityAssembler tile = (TileEntityAssembler)curr; - tile.formed=true; - tile.pos = (h+1)*9 + l*3 + (w+1); - tile.offset = new int[]{(side==EnumFacing.WEST?1-l: side==EnumFacing.EAST?l-1: side==EnumFacing.NORTH?ww: -ww),h,(side==EnumFacing.NORTH?1-l: side==EnumFacing.SOUTH?l-1: side==EnumFacing.EAST?ww : -ww)}; - tile.mirrored=mirror; + tile.formed = true; + tile.pos = (h+1)*9+l*3+(w+1); + tile.offset = new int[]{(side==EnumFacing.WEST?1-l: side==EnumFacing.EAST?l-1: side==EnumFacing.NORTH?ww: -ww), h, (side==EnumFacing.NORTH?1-l: side==EnumFacing.SOUTH?l-1: side==EnumFacing.EAST?ww: -ww)}; + tile.mirrored = mirror; tile.markDirty(); world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0); } @@ -222,7 +230,8 @@ else if(h==1) new IngredientStack("slabSheetmetalIron", 6), new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 2, BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta())), new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 2, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())), - new IngredientStack(Utils.copyStackWithAmount(ConveyorHandler.getConveyorStack(ImmersiveEngineering.MODID + ":conveyor"), 2))}; + new IngredientStack(Utils.copyStackWithAmount(ConveyorHandler.getConveyorStack(ImmersiveEngineering.MODID+":conveyor"), 2))}; + @Override public IngredientStack[] getTotalMaterials() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockAutoWorkbench.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockAutoWorkbench.java index 6929ebe8a3..782f6aeb9f 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockAutoWorkbench.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockAutoWorkbench.java @@ -38,40 +38,44 @@ public class MultiblockAutoWorkbench implements IMultiblock { public static MultiblockAutoWorkbench instance = new MultiblockAutoWorkbench(); static ItemStack[][][] structure = new ItemStack[2][3][3]; - static{ - for(int h=0;h<2;h++) - for(int l=0;l<3;l++) - for(int w=0;w<3;w++) + + static + { + for(int h = 0; h < 2; h++) + for(int l = 0; l < 3; l++) + for(int w = 0; w < 3; w++) { if(h==0) { if(l==0&&w==1) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); - else if(w==0 && l<2) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); + else if(w==0&&l < 2) + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); else if(w==2&&l==2) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); else - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); } else if(h==1) { - if(w==0&&l<2) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + if(w==0&&l < 2) + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); else if(w==2&&l==2) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); else if(l==0) - structure[h][l][w] = new ItemStack(IEContent.blockTreatedWoodSlabs,1,BlockTypes_TreatedWood.HORIZONTAL.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockTreatedWoodSlabs, 1, BlockTypes_TreatedWood.HORIZONTAL.getMeta()); else - structure[h][l][w] = ConveyorHandler.getConveyorStack(ImmersiveEngineering.MODID + ":conveyor"); + structure[h][l][w] = ConveyorHandler.getConveyorStack(ImmersiveEngineering.MODID+":conveyor"); } } } + @Override public ItemStack[][][] getStructureManual() { return structure; } + @Override @SideOnly(Side.CLIENT) public boolean overwriteBlockRender(ItemStack stack, int iterator) @@ -82,20 +86,23 @@ public boolean overwriteBlockRender(ItemStack stack, int iterator) return ImmersiveEngineering.proxy.drawConveyorInGui("immersiveengineering:conveyor", EnumFacing.WEST); return false; } + @Override @SideOnly(Side.CLIENT) public boolean canRenderFormedStructure() { return true; } + //@SideOnly(Side.CLIENT) static ItemStack renderStack = ItemStack.EMPTY; + @Override @SideOnly(Side.CLIENT) public void renderFormedStructure() { if(renderStack.isEmpty()) - renderStack = new ItemStack(IEContent.blockMetalMultiblock,1,BlockTypes_MetalMultiblock.AUTO_WORKBENCH.getMeta()); + renderStack = new ItemStack(IEContent.blockMetalMultiblock, 1, BlockTypes_MetalMultiblock.AUTO_WORKBENCH.getMeta()); GlStateManager.translate(1.5, 1.5, 1.5); GlStateManager.rotate(-45, 0, 1, 0); GlStateManager.rotate(-20, 1, 0, 0); @@ -104,6 +111,7 @@ public void renderFormedStructure() ClientUtils.mc().getRenderItem().renderItem(renderStack, ItemCameraTransforms.TransformType.GUI); GlStateManager.enableCull(); } + @Override public float getManualScale() { @@ -119,7 +127,7 @@ public String getUniqueName() @Override public boolean isBlockTrigger(IBlockState state) { - return Utils.compareToOreName(new ItemStack(state.getBlock(),1,state.getBlock().getMetaFromState(state)), "slabTreatedWood"); + return Utils.compareToOreName(new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)), "slabTreatedWood"); } @Override @@ -132,11 +140,11 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit boolean mirrored = false; - boolean b = structureCheck(world,pos, side, mirrored); + boolean b = structureCheck(world, pos, side, mirrored); if(!b) { mirrored = true; - b = structureCheck(world,pos, side, mirrored); + b = structureCheck(world, pos, side, mirrored); } if(!b) @@ -181,34 +189,41 @@ boolean structureCheck(World world, BlockPos startPos, EnumFacing dir, boolean m { if(!Utils.isBlockAt(world, pos2, IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta())) return false; - } else if(w==-1&&l < 2) + } + else if(w==-1&&l < 2) { if(!Utils.isBlockAt(world, pos2, IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())) return false; - } else if(w==1&&l==2) + } + else if(w==1&&l==2) { if(!Utils.isBlockAt(world, pos2, IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta())) return false; - } else + } + else { if(!Utils.isOreBlockAt(world, pos2, "scaffoldingSteel")) return false; } - } else if(h==0) + } + else if(h==0) { if(w==-1&&l < 2) { if(!Utils.isBlockAt(world, pos2, IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())) return false; - } else if(w==1&&l==2) + } + else if(w==1&&l==2) { if(!Utils.isBlockAt(world, pos2, IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta())) return false; - } else if(l==0) + } + else if(l==0) { if(!Utils.isOreBlockAt(world, pos2, "slabTreatedWood")) return false; - } else + } + else { if(!ConveyorHandler.isConveyor(world, pos2, ImmersiveEngineering.MODID+":conveyor", null)) return false; @@ -224,7 +239,8 @@ boolean structureCheck(World world, BlockPos startPos, EnumFacing dir, boolean m new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta())), new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 4, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())), new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 2, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta())), - new IngredientStack(Utils.copyStackWithAmount(ConveyorHandler.getConveyorStack(ImmersiveEngineering.MODID + ":conveyor"), 4))}; + new IngredientStack(Utils.copyStackWithAmount(ConveyorHandler.getConveyorStack(ImmersiveEngineering.MODID+":conveyor"), 4))}; + @Override public IngredientStack[] getTotalMaterials() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockBlastFurnace.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockBlastFurnace.java index 3281020acf..6b7b0d1dce 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockBlastFurnace.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockBlastFurnace.java @@ -32,12 +32,15 @@ public class MultiblockBlastFurnace implements IMultiblock public static MultiblockBlastFurnace instance = new MultiblockBlastFurnace(); static ItemStack[][][] structure = new ItemStack[3][3][3]; - static{ - for(int h=0;h<3;h++) - for(int l=0;l<3;l++) - for(int w=0;w<3;w++) - structure[h][l][w]=new ItemStack(IEContent.blockStoneDecoration,1,BlockTypes_StoneDecoration.BLASTBRICK.getMeta()); + + static + { + for(int h = 0; h < 3; h++) + for(int l = 0; l < 3; l++) + for(int w = 0; w < 3; w++) + structure[h][l][w] = new ItemStack(IEContent.blockStoneDecoration, 1, BlockTypes_StoneDecoration.BLASTBRICK.getMeta()); } + @Override public ItemStack[][][] getStructureManual() { @@ -49,18 +52,21 @@ public float getManualScale() { return 16; } + @Override @SideOnly(Side.CLIENT) public boolean overwriteBlockRender(ItemStack stack, int iterator) { return false; } + @Override @SideOnly(Side.CLIENT) public boolean canRenderFormedStructure() { return false; } + @Override @SideOnly(Side.CLIENT) public void renderFormedStructure() @@ -76,7 +82,7 @@ public String getUniqueName() @Override public boolean isBlockTrigger(IBlockState state) { - return state.getBlock()==IEContent.blockStoneDecoration && (state.getBlock().getMetaFromState(state)==BlockTypes_StoneDecoration.BLASTBRICK.getMeta()); + return state.getBlock()==IEContent.blockStoneDecoration&&(state.getBlock().getMetaFromState(state)==BlockTypes_StoneDecoration.BLASTBRICK.getMeta()); } @Override @@ -85,31 +91,31 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit EnumFacing f = EnumFacing.fromAngle(player.rotationYaw); pos = pos.offset(f); - for(int h=-1;h<=1;h++) - for(int xx=-1;xx<=1;xx++) - for(int zz=-1;zz<=1;zz++) + for(int h = -1; h <= 1; h++) + for(int xx = -1; xx <= 1; xx++) + for(int zz = -1; zz <= 1; zz++) { if(!Utils.isBlockAt(world, pos.add(xx, h, zz), IEContent.blockStoneDecoration, BlockTypes_StoneDecoration.BLASTBRICK.getMeta())) return false; } IBlockState state = IEContent.blockStoneDevice.getStateFromMeta(BlockTypes_StoneDevices.BLAST_FURNACE.getMeta()); state = state.withProperty(IEProperties.FACING_HORIZONTAL, f.getOpposite()); - for(int h=-1;h<=1;h++) - for(int l=-1;l<=1;l++) - for(int w=-1;w<=1;w++) + for(int h = -1; h <= 1; h++) + for(int l = -1; l <= 1; l++) + for(int w = -1; w <= 1; w++) { - int xx = f==EnumFacing.EAST?l: f==EnumFacing.WEST?-l: f==EnumFacing.NORTH?-w:w; - int zz = f==EnumFacing.NORTH?l: f==EnumFacing.SOUTH?-l: f==EnumFacing.EAST?w:-w; + int xx = f==EnumFacing.EAST?l: f==EnumFacing.WEST?-l: f==EnumFacing.NORTH?-w: w; + int zz = f==EnumFacing.NORTH?l: f==EnumFacing.SOUTH?-l: f==EnumFacing.EAST?w: -w; BlockPos pos2 = pos.add(xx, h, zz); world.setBlockState(pos2, state); TileEntity curr = world.getTileEntity(pos2); if(curr instanceof TileEntityBlastFurnace) { - TileEntityBlastFurnace currBlast = (TileEntityBlastFurnace) curr; - currBlast.offset=new int[]{xx,h,zz}; - currBlast.pos = (h+1)*9 + (l+1)*3 + (w+1); - currBlast.formed=true; + TileEntityBlastFurnace currBlast = (TileEntityBlastFurnace)curr; + currBlast.offset = new int[]{xx, h, zz}; + currBlast.pos = (h+1)*9+(l+1)*3+(w+1); + currBlast.formed = true; currBlast.markDirty(); world.addBlockEvent(pos2, IEContent.blockStoneDevice, 255, 0); } @@ -118,6 +124,7 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit } static final IngredientStack[] materials = new IngredientStack[]{new IngredientStack(new ItemStack(IEContent.blockStoneDecoration, 27, BlockTypes_StoneDecoration.BLASTBRICK.getMeta()))}; + @Override public IngredientStack[] getTotalMaterials() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockBlastFurnaceAdvanced.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockBlastFurnaceAdvanced.java index eaee664332..38632ae949 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockBlastFurnaceAdvanced.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockBlastFurnaceAdvanced.java @@ -37,15 +37,18 @@ public class MultiblockBlastFurnaceAdvanced implements IMultiblock public static MultiblockBlastFurnaceAdvanced instance = new MultiblockBlastFurnaceAdvanced(); static ItemStack[][][] structure = new ItemStack[4][3][3]; - static{ - for(int h=0;h<4;h++) - for(int l=0;l<3;l++) - for(int w=0;w<3;w++) - if(h==3 && w==1 && l==1) - structure[h][l][w]=new ItemStack(Blocks.HOPPER); - else if(h<3) - structure[h][l][w]=new ItemStack(IEContent.blockStoneDecoration,1,BlockTypes_StoneDecoration.BLASTBRICK_REINFORCED.getMeta()); + + static + { + for(int h = 0; h < 4; h++) + for(int l = 0; l < 3; l++) + for(int w = 0; w < 3; w++) + if(h==3&&w==1&&l==1) + structure[h][l][w] = new ItemStack(Blocks.HOPPER); + else if(h < 3) + structure[h][l][w] = new ItemStack(IEContent.blockStoneDecoration, 1, BlockTypes_StoneDecoration.BLASTBRICK_REINFORCED.getMeta()); } + @Override public ItemStack[][][] getStructureManual() { @@ -57,18 +60,21 @@ public float getManualScale() { return 14; } + @Override @SideOnly(Side.CLIENT) public boolean overwriteBlockRender(ItemStack stack, int iterator) { return false; } + @Override @SideOnly(Side.CLIENT) public boolean canRenderFormedStructure() { return true; } + //@SideOnly(Side.CLIENT) static ItemStack renderStack = ItemStack.EMPTY; @@ -77,8 +83,8 @@ public boolean canRenderFormedStructure() public void renderFormedStructure() { if(renderStack.isEmpty()) - renderStack = new ItemStack(IEContent.blockStoneDevice,1,BlockTypes_StoneDecoration.BLASTBRICK_REINFORCED.getMeta()); - GlStateManager.translate(1.5,1.5,1.5); + renderStack = new ItemStack(IEContent.blockStoneDevice, 1, BlockTypes_StoneDecoration.BLASTBRICK_REINFORCED.getMeta()); + GlStateManager.translate(1.5, 1.5, 1.5); GlStateManager.rotate(-45, 0, 1, 0); GlStateManager.rotate(-20, 1, 0, 0); GlStateManager.scale(4, 4, 4); @@ -94,7 +100,7 @@ public String getUniqueName() @Override public boolean isBlockTrigger(IBlockState state) { - return state.getBlock()==IEContent.blockStoneDecoration && (state.getBlock().getMetaFromState(state)==2); + return state.getBlock()==IEContent.blockStoneDecoration&&(state.getBlock().getMetaFromState(state)==2); } @Override @@ -103,10 +109,10 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit EnumFacing f = EnumFacing.fromAngle(player.rotationYaw); pos = pos.offset(f); - for(int h=-1;h<=2;h++) - for(int xx=-1;xx<=1;xx++) - for(int zz=-1;zz<=1;zz++) - if(h!=2 || (xx==0 && zz==0)) + for(int h = -1; h <= 2; h++) + for(int xx = -1; xx <= 1; xx++) + for(int zz = -1; zz <= 1; zz++) + if(h!=2||(xx==0&&zz==0)) { if(h==2) { @@ -122,23 +128,23 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit IBlockState state = IEContent.blockStoneDevice.getStateFromMeta(BlockTypes_StoneDevices.BLAST_FURNACE_ADVANCED.getMeta()); state = state.withProperty(IEProperties.FACING_HORIZONTAL, f.getOpposite()); - for(int h=-1;h<=2;h++) - for(int l=-1;l<=1;l++) - for(int w=-1;w<=1;w++) - if(h!=2 || (w==0 && l==0)) + for(int h = -1; h <= 2; h++) + for(int l = -1; l <= 1; l++) + for(int w = -1; w <= 1; w++) + if(h!=2||(w==0&&l==0)) { - int xx = f==EnumFacing.EAST?l: f==EnumFacing.WEST?-l: f==EnumFacing.NORTH?-w:w; - int zz = f==EnumFacing.NORTH?l: f==EnumFacing.SOUTH?-l: f==EnumFacing.EAST?w:-w; + int xx = f==EnumFacing.EAST?l: f==EnumFacing.WEST?-l: f==EnumFacing.NORTH?-w: w; + int zz = f==EnumFacing.NORTH?l: f==EnumFacing.SOUTH?-l: f==EnumFacing.EAST?w: -w; world.setBlockState(pos.add(xx, h, zz), state); BlockPos pos2 = pos.add(xx, h, zz); TileEntity curr = world.getTileEntity(pos2); if(curr instanceof TileEntityBlastFurnace) { - TileEntityBlastFurnace currBlast = (TileEntityBlastFurnace) curr; - currBlast.offset=new int[]{xx,h,zz}; - currBlast.pos = (h+1)*9 + (l+1)*3 + (w+1); - currBlast.formed=true; + TileEntityBlastFurnace currBlast = (TileEntityBlastFurnace)curr; + currBlast.offset = new int[]{xx, h, zz}; + currBlast.pos = (h+1)*9+(l+1)*3+(w+1); + currBlast.formed = true; currBlast.markDirty(); world.addBlockEvent(pos2, IEContent.blockStoneDevice, 255, 0); } @@ -147,6 +153,7 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit } static final IngredientStack[] materials = new IngredientStack[]{new IngredientStack(new ItemStack(IEContent.blockStoneDecoration, 27, BlockTypes_StoneDecoration.BLASTBRICK_REINFORCED.getMeta())), ApiUtils.createIngredientStack(Blocks.HOPPER)}; + @Override public IngredientStack[] getTotalMaterials() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockBottlingMachine.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockBottlingMachine.java index 506076bc1d..16d63a9d11 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockBottlingMachine.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockBottlingMachine.java @@ -36,47 +36,51 @@ public class MultiblockBottlingMachine implements IMultiblock { public static MultiblockBottlingMachine instance = new MultiblockBottlingMachine(); static ItemStack[][][] structure = new ItemStack[3][2][3]; - static{ - for(int h=0;h<3;h++) - for(int l=0;l<2;l++) - for(int w=0;w<3;w++) + + static + { + for(int h = 0; h < 3; h++) + for(int l = 0; l < 2; l++) + for(int w = 0; w < 3; w++) { if(h==0) { if(l==0&&w==1) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); else if(l==1&&w==0) - structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.IRON.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.IRON.getMeta()); else if(l==1&&w==2) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); else - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); } else if(h==1) { if(l==0) - structure[h][l][w] = ConveyorHandler.getConveyorStack(ImmersiveEngineering.MODID + ":conveyor"); + structure[h][l][w] = ConveyorHandler.getConveyorStack(ImmersiveEngineering.MODID+":conveyor"); else if(l==1&&w==0) - structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.IRON.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.IRON.getMeta()); else if(l==1&&w==2) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); else - structure[h][l][w] = new ItemStack(IEContent.blockMetalDevice0,1,BlockTypes_MetalDevice0.FLUID_PUMP.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDevice0, 1, BlockTypes_MetalDevice0.FLUID_PUMP.getMeta()); } else if(h==2) { if(l==0&&w==1) structure[h][l][w] = new ItemStack(Blocks.GLASS); else if(l==1&&w==1) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDevice0,1,BlockTypes_MetalDevice0.FLUID_PUMP.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDevice0, 1, BlockTypes_MetalDevice0.FLUID_PUMP.getMeta()); } } } + @Override public ItemStack[][][] getStructureManual() { return structure; } + @Override @SideOnly(Side.CLIENT) public boolean overwriteBlockRender(ItemStack stack, int iterator) @@ -86,24 +90,27 @@ public boolean overwriteBlockRender(ItemStack stack, int iterator) ImmersiveEngineering.proxy.drawFluidPumpTop(); return true; } - if(iterator>=6&&iterator<=8) + if(iterator >= 6&&iterator <= 8) return ImmersiveEngineering.proxy.drawConveyorInGui("immersiveengineering:conveyor", EnumFacing.SOUTH); return false; } + @Override @SideOnly(Side.CLIENT) public boolean canRenderFormedStructure() { return true; } + //@SideOnly(Side.CLIENT) static ItemStack renderStack = ItemStack.EMPTY; + @Override @SideOnly(Side.CLIENT) public void renderFormedStructure() { if(renderStack.isEmpty()) - renderStack = new ItemStack(IEContent.blockMetalMultiblock,1,BlockTypes_MetalMultiblock.BOTTLING_MACHINE.getMeta()); + renderStack = new ItemStack(IEContent.blockMetalMultiblock, 1, BlockTypes_MetalMultiblock.BOTTLING_MACHINE.getMeta()); GlStateManager.translate(2.1875, 1.125, .8125); GlStateManager.rotate(-45, 0, 1, 0); GlStateManager.rotate(-20, 1, 0, 0); @@ -112,6 +119,7 @@ public void renderFormedStructure() ClientUtils.mc().getRenderItem().renderItem(renderStack, ItemCameraTransforms.TransformType.GUI); GlStateManager.enableCull(); } + @Override public float getManualScale() { @@ -127,7 +135,7 @@ public String getUniqueName() @Override public boolean isBlockTrigger(IBlockState state) { - return state.getBlock() == IEContent.blockConveyor; + return state.getBlock()==IEContent.blockConveyor; } @Override @@ -140,21 +148,21 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit boolean mirrored = false; - boolean b = structureCheck(world,pos, side, mirrored); + boolean b = structureCheck(world, pos, side, mirrored); if(!b) { mirrored = true; - b = structureCheck(world,pos, side, mirrored); + b = structureCheck(world, pos, side, mirrored); } if(!b) return false; IBlockState state = IEContent.blockMetalMultiblock.getStateFromMeta(BlockTypes_MetalMultiblock.BOTTLING_MACHINE.getMeta()); state = state.withProperty(IEProperties.FACING_HORIZONTAL, side); - for(int l=0; l<2; l++) - for(int w=-1; w<=1; w++) - for(int h=-1; h<=1; h++) - if(h<1 || w==0) + for(int l = 0; l < 2; l++) + for(int w = -1; w <= 1; w++) + for(int h = -1; h <= 1; h++) + if(h < 1||w==0) { int ww = mirrored?-w: w; BlockPos pos2 = pos.offset(side, l).offset(side.rotateY(), ww).add(0, h, 0); @@ -177,7 +185,7 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit boolean structureCheck(World world, BlockPos startPos, EnumFacing dir, boolean mirror) { - EnumFacing conveyorDir = mirror?dir.rotateYCCW():dir.rotateY(); + EnumFacing conveyorDir = mirror?dir.rotateYCCW(): dir.rotateY(); for(int l = 0; l < 2; l++) for(int h = -1; h <= 1; h++) for(int w = -1; w <= 1; w++) @@ -191,40 +199,47 @@ boolean structureCheck(World world, BlockPos startPos, EnumFacing dir, boolean m { if(!Utils.isBlockAt(world, pos2, IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta())) return false; - } else if(w==-1&&l==1) + } + else if(w==-1&&l==1) { if(!Utils.isOreBlockAt(world, pos2, "blockSheetmetalIron")) return false; - } else if(w==1&&l==1) + } + else if(w==1&&l==1) { if(!Utils.isBlockAt(world, pos2, IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())) return false; - } else + } + else { if(!Utils.isOreBlockAt(world, pos2, "scaffoldingSteel")) return false; } - } else if(h==0) + } + else if(h==0) { if(l==0) { if(!ConveyorHandler.isConveyor(world, pos2, ImmersiveEngineering.MODID+":conveyor", conveyorDir)) return false; - } else if(w==-1&&l==1) + } + else if(w==-1&&l==1) { if(!Utils.isOreBlockAt(world, pos2, "blockSheetmetalIron")) return false; - } else if(w==1&&l==1) + } + else if(w==1&&l==1) { if(!Utils.isBlockAt(world, pos2, IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())) return false; - } else + } + else { if(!Utils.isBlockAt(world, pos2, IEContent.blockMetalDevice0, BlockTypes_MetalDevice0.FLUID_PUMP.getMeta())) return false; } } - else if(h==1 && w==0 && l==0) + else if(h==1&&w==0&&l==0) if(!Utils.isOreBlockAt(world, pos2, "blockGlass")) return false; @@ -237,9 +252,10 @@ else if(h==1 && w==0 && l==0) new IngredientStack("blockSheetmetalIron", 2), new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta())), new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 2, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())), - new IngredientStack(Utils.copyStackWithAmount(ConveyorHandler.getConveyorStack(ImmersiveEngineering.MODID + ":conveyor"), 3)), + new IngredientStack(Utils.copyStackWithAmount(ConveyorHandler.getConveyorStack(ImmersiveEngineering.MODID+":conveyor"), 3)), new IngredientStack(new ItemStack(IEContent.blockMetalDevice0, 1, BlockTypes_MetalDevice0.FLUID_PUMP.getMeta())), new IngredientStack("blockGlass", 1)}; + @Override public IngredientStack[] getTotalMaterials() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockBucketWheel.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockBucketWheel.java index 35bd8a963b..f02cc4e5f1 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockBucketWheel.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockBucketWheel.java @@ -34,50 +34,58 @@ public class MultiblockBucketWheel implements IMultiblock { public static MultiblockBucketWheel instance = new MultiblockBucketWheel(); static ItemStack[][][] structure = new ItemStack[7][7][1]; - static{ - for(int h=0;h<7;h++) - for(int l=0;l<7;l++) + + static + { + for(int h = 0; h < 7; h++) + for(int l = 0; l < 7; l++) { - if((h==0||h==6) && l!=3) + if((h==0||h==6)&&l!=3) continue; - if((l==0||l==6) && h!=3) + if((l==0||l==6)&&h!=3) continue; - if(l==0||h==0||l==6||h==6 || ((l==1||l==5) && (h==1||h==5)) || (h==3&&l==3)) - structure[h][l][0]= new ItemStack(IEContent.blockStorage,1,BlockTypes_MetalsIE.STEEL.getMeta()); + if(l==0||h==0||l==6||h==6||((l==1||l==5)&&(h==1||h==5))||(h==3&&l==3)) + structure[h][l][0] = new ItemStack(IEContent.blockStorage, 1, BlockTypes_MetalsIE.STEEL.getMeta()); else - structure[h][l][0]= new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); + structure[h][l][0] = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); } } + @Override public ItemStack[][][] getStructureManual() { return structure; } + @Override @SideOnly(Side.CLIENT) public boolean overwriteBlockRender(ItemStack stack, int iterator) { return false; } + @Override public float getManualScale() { return 12; } + @Override @SideOnly(Side.CLIENT) public boolean canRenderFormedStructure() { return true; } + //@SideOnly(Side.CLIENT) static ItemStack renderStack = ItemStack.EMPTY; + @Override @SideOnly(Side.CLIENT) public void renderFormedStructure() { if(renderStack.isEmpty()) - renderStack = new ItemStack(IEContent.blockMetalMultiblock,1,BlockTypes_MetalMultiblock.BUCKET_WHEEL.getMeta()); + renderStack = new ItemStack(IEContent.blockMetalMultiblock, 1, BlockTypes_MetalMultiblock.BUCKET_WHEEL.getMeta()); GlStateManager.translate(3.5, 3.5, 0.5); GlStateManager.rotate(-45, 0, 1, 0); GlStateManager.rotate(-20, 1, 0, 0); @@ -96,7 +104,7 @@ public String getUniqueName() @Override public boolean isBlockTrigger(IBlockState state) { - return Utils.compareToOreName(new ItemStack(state.getBlock(),1,state.getBlock().getMetaFromState(state)), "blockSteel"); + return Utils.compareToOreName(new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)), "blockSteel"); } @Override @@ -105,16 +113,16 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit if(side==EnumFacing.UP||side==EnumFacing.DOWN) side = EnumFacing.fromAngle(player.rotationYaw); - for(int h=-3;h<=3;h++) - for(int w=-3;w<=3;w++) + for(int h = -3; h <= 3; h++) + for(int w = -3; w <= 3; w++) { BlockPos pos2 = pos.add((side==EnumFacing.NORTH?w: side==EnumFacing.SOUTH?-w: 0), h, (side==EnumFacing.WEST?w: side==EnumFacing.EAST?-w: 0)); - if((h==-3||h==3) && w!=0) + if((h==-3||h==3)&&w!=0) continue; - if((w==-3||w==3) && h!=0) + if((w==-3||w==3)&&h!=0) continue; - if(w==-3||h==-3||w==3||h==3 || ((w==-2||w==2) && (h==-2||h==2)) || (h==0&&w==0)) + if(w==-3||h==-3||w==3||h==3||((w==-2||w==2)&&(h==-2||h==2))||(h==0&&w==0)) { if(!Utils.isOreBlockAt(world, pos2, "blockSteel")) return false; @@ -129,25 +137,25 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit IBlockState state = IEContent.blockMetalMultiblock.getStateFromMeta(BlockTypes_MetalMultiblock.BUCKET_WHEEL.getMeta()); state = state.withProperty(IEProperties.FACING_HORIZONTAL, side); - for(int h=-3;h<=3;h++) - for(int w=-3;w<=3;w++) + for(int h = -3; h <= 3; h++) + for(int w = -3; w <= 3; w++) { BlockPos pos2 = pos.add((side==EnumFacing.NORTH?w: side==EnumFacing.SOUTH?-w: 0), h, (side==EnumFacing.WEST?w: side==EnumFacing.EAST?-w: 0)); - if((h==-3||h==3) && w!=0) + if((h==-3||h==3)&&w!=0) continue; - if((w==-3||w==3) && h!=0) + if((w==-3||w==3)&&h!=0) continue; world.setBlockState(pos2, state); TileEntity curr = world.getTileEntity(pos2); if(curr instanceof TileEntityBucketWheel) { - TileEntityBucketWheel tile = (TileEntityBucketWheel) curr; - tile.formed=true; - tile.pos = (w+3) + (h+3)*7; + TileEntityBucketWheel tile = (TileEntityBucketWheel)curr; + tile.formed = true; + tile.pos = (w+3)+(h+3)*7; - tile.offset = new int[]{(side==EnumFacing.NORTH?w: side==EnumFacing.SOUTH?-w: 0),h,(side==EnumFacing.WEST?w: side==EnumFacing.EAST?-w: 0)}; + tile.offset = new int[]{(side==EnumFacing.NORTH?w: side==EnumFacing.SOUTH?-w: 0), h, (side==EnumFacing.WEST?w: side==EnumFacing.EAST?-w: 0)}; tile.markDirty(); world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0); } @@ -158,6 +166,7 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit static final IngredientStack[] materials = new IngredientStack[]{ new IngredientStack("blockSteel", 9), new IngredientStack("scaffoldingSteel", 20)}; + @Override public IngredientStack[] getTotalMaterials() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockCokeOven.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockCokeOven.java index 3483d57023..3fcb3f93d1 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockCokeOven.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockCokeOven.java @@ -31,34 +31,41 @@ public class MultiblockCokeOven implements IMultiblock public static MultiblockCokeOven instance = new MultiblockCokeOven(); static ItemStack[][][] structure = new ItemStack[3][3][3]; - static{ - for(int h=0;h<3;h++) - for(int l=0;l<3;l++) - for(int w=0;w<3;w++) - structure[h][l][w]=new ItemStack(IEContent.blockStoneDecoration,1,BlockTypes_StoneDecoration.COKEBRICK.getMeta()); + + static + { + for(int h = 0; h < 3; h++) + for(int l = 0; l < 3; l++) + for(int w = 0; w < 3; w++) + structure[h][l][w] = new ItemStack(IEContent.blockStoneDecoration, 1, BlockTypes_StoneDecoration.COKEBRICK.getMeta()); } + @Override public ItemStack[][][] getStructureManual() { return structure; } + @Override @SideOnly(Side.CLIENT) public boolean overwriteBlockRender(ItemStack stack, int iterator) { return false; } + @Override public float getManualScale() { return 16; } + @Override @SideOnly(Side.CLIENT) public boolean canRenderFormedStructure() { return false; } + @Override @SideOnly(Side.CLIENT) public void renderFormedStructure() @@ -74,7 +81,7 @@ public String getUniqueName() @Override public boolean isBlockTrigger(IBlockState state) { - return state.getBlock()==IEContent.blockStoneDecoration && (state.getBlock().getMetaFromState(state)==BlockTypes_StoneDecoration.COKEBRICK.getMeta()); + return state.getBlock()==IEContent.blockStoneDecoration&&(state.getBlock().getMetaFromState(state)==BlockTypes_StoneDecoration.COKEBRICK.getMeta()); } @Override @@ -83,31 +90,31 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit EnumFacing f = EnumFacing.fromAngle(player.rotationYaw); pos = pos.offset(f); - for(int h=-1;h<=1;h++) - for(int xx=-1;xx<=1;xx++) - for(int zz=-1;zz<=1;zz++) + for(int h = -1; h <= 1; h++) + for(int xx = -1; xx <= 1; xx++) + for(int zz = -1; zz <= 1; zz++) { if(!Utils.isBlockAt(world, pos.add(xx, h, zz), IEContent.blockStoneDecoration, BlockTypes_StoneDecoration.COKEBRICK.getMeta())) return false; } IBlockState state = IEContent.blockStoneDevice.getStateFromMeta(BlockTypes_StoneDevices.COKE_OVEN.getMeta()); state = state.withProperty(IEProperties.FACING_HORIZONTAL, f.getOpposite()); - for(int h=-1;h<=1;h++) - for(int l=-1;l<=1;l++) - for(int w=-1;w<=1;w++) + for(int h = -1; h <= 1; h++) + for(int l = -1; l <= 1; l++) + for(int w = -1; w <= 1; w++) { - int xx = f==EnumFacing.EAST?l: f==EnumFacing.WEST?-l: f==EnumFacing.NORTH?-w:w; - int zz = f==EnumFacing.NORTH?l: f==EnumFacing.SOUTH?-l: f==EnumFacing.EAST?w:-w; + int xx = f==EnumFacing.EAST?l: f==EnumFacing.WEST?-l: f==EnumFacing.NORTH?-w: w; + int zz = f==EnumFacing.NORTH?l: f==EnumFacing.SOUTH?-l: f==EnumFacing.EAST?w: -w; world.setBlockState(pos.add(xx, h, zz), state); BlockPos pos2 = pos.add(xx, h, zz); TileEntity curr = world.getTileEntity(pos2); if(curr instanceof TileEntityCokeOven) { - TileEntityCokeOven currBlast = (TileEntityCokeOven) curr; - currBlast.offset=new int[]{xx,h,zz}; - currBlast.pos = (h+1)*9 + (l+1)*3 + (w+1); - currBlast.formed=true; + TileEntityCokeOven currBlast = (TileEntityCokeOven)curr; + currBlast.offset = new int[]{xx, h, zz}; + currBlast.pos = (h+1)*9+(l+1)*3+(w+1); + currBlast.formed = true; currBlast.markDirty(); world.addBlockEvent(pos2, IEContent.blockStoneDevice, 255, 0); } @@ -116,6 +123,7 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit } static final IngredientStack[] materials = new IngredientStack[]{new IngredientStack(new ItemStack(IEContent.blockStoneDecoration, 27, BlockTypes_StoneDecoration.COKEBRICK.getMeta()))}; + @Override public IngredientStack[] getTotalMaterials() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockCrusher.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockCrusher.java index e00b25c241..7cdc2b4ca4 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockCrusher.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockCrusher.java @@ -36,67 +36,74 @@ public class MultiblockCrusher implements IMultiblock { public static MultiblockCrusher instance = new MultiblockCrusher(); static ItemStack[][][] structure = new ItemStack[3][3][5]; - static{ - for(int h=0;h<3;h++) - for(int l=0;l<3;l++) - for(int w=0;w<5;w++) + + static + { + for(int h = 0; h < 3; h++) + for(int l = 0; l < 3; l++) + for(int w = 0; w < 5; w++) { - if((w==0&&h==2)||(w==4&&h==2)||(w==4&&l==2&&h>0)) + if((w==0&&h==2)||(w==4&&h==2)||(w==4&&l==2&&h > 0)) continue; if(w==0) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); else if(w==4) { - if(h<1) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); - else if(h<2&&l==0) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); - else if(h<2&&l==1) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + if(h < 1) + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); + else if(h < 2&&l==0) + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); + else if(h < 2&&l==1) + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); } else if(h==0) { if(w==2&&(l==0||l==1)) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); else - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); } else if(h==1) { if(l==1&&w==2) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); else - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_FENCE.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_FENCE.getMeta()); } else if(h==2) structure[h][l][w] = new ItemStack(Blocks.HOPPER); } } + @Override public ItemStack[][][] getStructureManual() { return structure; } + @Override @SideOnly(Side.CLIENT) public boolean overwriteBlockRender(ItemStack stack, int iterator) { return false; } + @Override @SideOnly(Side.CLIENT) public boolean canRenderFormedStructure() { return true; } + //@SideOnly(Side.CLIENT) static ItemStack renderStack = ItemStack.EMPTY; + @Override @SideOnly(Side.CLIENT) public void renderFormedStructure() { if(renderStack.isEmpty()) - renderStack = new ItemStack(IEContent.blockMetalMultiblock,1,BlockTypes_MetalMultiblock.CRUSHER.getMeta()); + renderStack = new ItemStack(IEContent.blockMetalMultiblock, 1, BlockTypes_MetalMultiblock.CRUSHER.getMeta()); GlStateManager.translate(1.5, 1.5, 2.5); GlStateManager.rotate(-45, 0, 1, 0); GlStateManager.rotate(-20, 1, 0, 0); @@ -106,6 +113,7 @@ public void renderFormedStructure() ClientUtils.mc().getRenderItem().renderItem(renderStack, ItemCameraTransforms.TransformType.GUI); GlStateManager.enableCull(); } + @Override public float getManualScale() { @@ -121,7 +129,7 @@ public String getUniqueName() @Override public boolean isBlockTrigger(IBlockState state) { - return state.getBlock()==IEContent.blockMetalDecoration1 && (state.getBlock().getMetaFromState(state)==BlockTypes_MetalDecoration1.STEEL_FENCE.getMeta()); + return state.getBlock()==IEContent.blockMetalDecoration1&&(state.getBlock().getMetaFromState(state)==BlockTypes_MetalDecoration1.STEEL_FENCE.getMeta()); } @Override @@ -132,32 +140,32 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit BlockPos startPos = pos; side = side.getOpposite(); - if(Utils.isOreBlockAt(world, startPos.add(0,-1,0), "scaffoldingSteel") - && Utils.isBlockAt(world, startPos.offset(side,2).add(0,-1,0), IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())) + if(Utils.isOreBlockAt(world, startPos.add(0, -1, 0), "scaffoldingSteel") + &&Utils.isBlockAt(world, startPos.offset(side, 2).add(0, -1, 0), IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())) { - startPos = startPos.offset(side,2); + startPos = startPos.offset(side, 2); side = side.getOpposite(); } boolean mirrored = false; - boolean b = structureCheck(world,startPos, side, mirrored); + boolean b = structureCheck(world, startPos, side, mirrored); if(!b) { mirrored = true; - b = structureCheck(world,startPos, side, mirrored); + b = structureCheck(world, startPos, side, mirrored); } if(b) { IBlockState state = IEContent.blockMetalMultiblock.getStateFromMeta(BlockTypes_MetalMultiblock.CRUSHER.getMeta()); state = state.withProperty(IEProperties.FACING_HORIZONTAL, side); - for(int l=0;l<3;l++) - for(int w=-2;w<=2;w++) - for(int h=-1;h<=1;h++) + for(int l = 0; l < 3; l++) + for(int w = -2; w <= 2; w++) + for(int h = -1; h <= 1; h++) { - if((w==-2&&h==1)||(w==2&&h==1)||(w==2&&l==2&&h>-1)) + if((w==-2&&h==1)||(w==2&&h==1)||(w==2&&l==2&&h > -1)) continue; - int ww = mirrored?-w:w; + int ww = mirrored?-w: w; BlockPos pos2 = startPos.offset(side, l).offset(side.rotateY(), ww).add(0, h, 0); world.setBlockState(pos2, state); @@ -165,9 +173,9 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit if(curr instanceof TileEntityCrusher) { TileEntityCrusher tile = (TileEntityCrusher)curr; - tile.formed=true; - tile.pos = (h+1)*15 + l*5 + (w+2); - tile.offset = new int[]{(side==EnumFacing.WEST?-l+1: side==EnumFacing.EAST?l-1: side==EnumFacing.NORTH?ww: -ww),h,(side==EnumFacing.NORTH?-l+1: side==EnumFacing.SOUTH?l-1: side==EnumFacing.EAST?ww : -ww)}; + tile.formed = true; + tile.pos = (h+1)*15+l*5+(w+2); + tile.offset = new int[]{(side==EnumFacing.WEST?-l+1: side==EnumFacing.EAST?l-1: side==EnumFacing.NORTH?ww: -ww), h, (side==EnumFacing.NORTH?-l+1: side==EnumFacing.SOUTH?l-1: side==EnumFacing.EAST?ww: -ww)}; tile.mirrored = mirrored; tile.markDirty(); world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0); @@ -179,13 +187,13 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit boolean structureCheck(World world, BlockPos startPos, EnumFacing dir, boolean mirror) { - for(int l=0;l<3;l++) - for(int w=-2;w<=2;w++) - for(int h=-1;h<=1;h++) + for(int l = 0; l < 3; l++) + for(int w = -2; w <= 2; w++) + for(int h = -1; h <= 1; h++) { - if((w==-2&&h==1)||(w==2&&h==1)||(w==2&&l==2&&h>-1)) + if((w==-2&&h==1)||(w==2&&h==1)||(w==2&&l==2&&h > -1)) continue; - int ww = mirror?-w:w; + int ww = mirror?-w: w; BlockPos pos = startPos.offset(dir, l).offset(dir.rotateY(), ww).add(0, h, 0); if(w==-2) @@ -193,7 +201,7 @@ boolean structureCheck(World world, BlockPos startPos, EnumFacing dir, boolean m if(!Utils.isBlockAt(world, pos, IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())) return false; } - else if(w==2 && h==0) + else if(w==2&&h==0) { if(l==0) { @@ -208,7 +216,7 @@ else if(w==2 && h==0) } else if(h==-1) { - if(w==0 && l<2) + if(w==0&&l < 2) { if(!Utils.isBlockAt(world, pos, IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())) return false; @@ -221,7 +229,7 @@ else if(h==-1) } else if(h==0) { - if(w==0 && l==1) + if(w==0&&l==1) { if(!Utils.isBlockAt(world, pos, IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())) return false; @@ -247,6 +255,7 @@ else if(h==1) new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 10, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())), new IngredientStack("fenceSteel", 8), new IngredientStack(new ItemStack(Blocks.HOPPER, 9))}; + @Override public IngredientStack[] getTotalMaterials() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockDieselGenerator.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockDieselGenerator.java index c99c54b5ce..6c8a4efd9d 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockDieselGenerator.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockDieselGenerator.java @@ -32,42 +32,46 @@ public class MultiblockDieselGenerator implements IMultiblock { public static MultiblockDieselGenerator instance = new MultiblockDieselGenerator(); static ItemStack[][][] structure = new ItemStack[3][5][3]; - static{ - for(int h=0;h<3;h++) - for(int l=0;l<5;l++) - for(int w=0;w<3;w++) + + static + { + for(int h = 0; h < 3; h++) + for(int l = 0; l < 5; l++) + for(int w = 0; w < 3; w++) { if((h==2&&l==0)||(h==2&&(l==1||l==3)&&w!=1)) continue; if(l==4) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.RADIATOR.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.RADIATOR.getMeta()); else if(h==0) { if(l==0&&w==1) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.GENERATOR.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.GENERATOR.getMeta()); else if(l==0||w==1) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDevice1,1,BlockTypes_MetalDevice1.FLUID_PIPE.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDevice1, 1, BlockTypes_MetalDevice1.FLUID_PIPE.getMeta()); else - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); } else if(h==1) { if(l==0) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.GENERATOR.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.GENERATOR.getMeta()); else if(l==2&&w==2) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); else - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); } else if(h==2) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); } } + @Override public ItemStack[][][] getStructureManual() { return structure; } + @Override @SideOnly(Side.CLIENT) public boolean overwriteBlockRender(ItemStack stack, int iterator) @@ -101,14 +105,16 @@ public boolean canRenderFormedStructure() { return true; } + //@SideOnly(Side.CLIENT) static ItemStack renderStack = ItemStack.EMPTY; + @Override @SideOnly(Side.CLIENT) public void renderFormedStructure() { if(renderStack.isEmpty()) - renderStack = new ItemStack(IEContent.blockMetalMultiblock,1,BlockTypes_MetalMultiblock.DIESEL_GENERATOR.getMeta()); + renderStack = new ItemStack(IEContent.blockMetalMultiblock, 1, BlockTypes_MetalMultiblock.DIESEL_GENERATOR.getMeta()); GlStateManager.translate(2.5, 1.5, 1.5); GlStateManager.rotate(-45, 0, 1, 0); GlStateManager.rotate(-20, 1, 0, 0); @@ -118,6 +124,7 @@ public void renderFormedStructure() ClientUtils.mc().getRenderItem().renderItem(renderStack, ItemCameraTransforms.TransformType.GUI); GlStateManager.enableCull(); } + @Override public float getManualScale() { @@ -133,7 +140,7 @@ public String getUniqueName() @Override public boolean isBlockTrigger(IBlockState state) { - return state.getBlock()==IEContent.blockMetalDecoration0 && (state.getBlock().getMetaFromState(state)==BlockTypes_MetalDecoration0.GENERATOR.getMeta()); + return state.getBlock()==IEContent.blockMetalDecoration0&&(state.getBlock().getMetaFromState(state)==BlockTypes_MetalDecoration0.GENERATOR.getMeta()); } @Override @@ -158,13 +165,13 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit { IBlockState state = IEContent.blockMetalMultiblock.getStateFromMeta(BlockTypes_MetalMultiblock.DIESEL_GENERATOR.getMeta()); state = state.withProperty(IEProperties.FACING_HORIZONTAL, side); - for(int l=0;l<5;l++) - for(int w=-1;w<=1;w++) - for(int h=-1;h<=1;h++) + for(int l = 0; l < 5; l++) + for(int w = -1; w <= 1; w++) + for(int h = -1; h <= 1; h++) { if((l==0&&h==1)||(h==1&&(l==1||l==3)&&w!=0)) continue; - int ww = mirror?-w:w; + int ww = mirror?-w: w; BlockPos pos2 = pos.offset(side, l).offset(side.rotateY(), ww).add(0, h, 0); world.setBlockState(pos2, state); @@ -172,10 +179,10 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit if(curr instanceof TileEntityDieselGenerator) { TileEntityDieselGenerator tile = (TileEntityDieselGenerator)curr; - tile.formed=true; - tile.pos = (h+1)*15 + l*3 + (w+1); - tile.offset = new int[]{(side==EnumFacing.WEST?-l+2: side==EnumFacing.EAST?l-2: side==EnumFacing.NORTH?ww: -ww),h,(side==EnumFacing.NORTH?-l+2: side==EnumFacing.SOUTH?l-2: side==EnumFacing.EAST?ww : -ww)}; - tile.mirrored=mirror; + tile.formed = true; + tile.pos = (h+1)*15+l*3+(w+1); + tile.offset = new int[]{(side==EnumFacing.WEST?-l+2: side==EnumFacing.EAST?l-2: side==EnumFacing.NORTH?ww: -ww), h, (side==EnumFacing.NORTH?-l+2: side==EnumFacing.SOUTH?l-2: side==EnumFacing.EAST?ww: -ww)}; + tile.mirrored = mirror; tile.markDirty(); world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0); } @@ -186,13 +193,13 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit boolean structureCheck(World world, BlockPos startPos, EnumFacing dir, boolean mirror) { - for(int l=0;l<5;l++) - for(int w=-1;w<=1;w++) - for(int h=-1;h<=1;h++) + for(int l = 0; l < 5; l++) + for(int w = -1; w <= 1; w++) + for(int h = -1; h <= 1; h++) { if((l==0&&h==1)||(h==1&&(l==1||l==3)&&w!=0)) continue; - int ww = mirror?-w:w; + int ww = mirror?-w: w; BlockPos pos = startPos.offset(dir, l).offset(dir.rotateY(), ww).add(0, h, 0); if(l==4) @@ -207,7 +214,7 @@ else if(h==-1) if(!Utils.isBlockAt(world, pos, IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.GENERATOR.getMeta())) return false; } - else if(l==0 || w==0) + else if(l==0||w==0) { if(!Utils.isBlockAt(world, pos, IEContent.blockMetalDevice1, BlockTypes_MetalDevice1.FLUID_PIPE.getMeta())) return false; @@ -253,6 +260,7 @@ else if(h==1) new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 13, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta())), new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 4, BlockTypes_MetalDecoration0.GENERATOR.getMeta())), new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 9, BlockTypes_MetalDecoration0.RADIATOR.getMeta()))}; + @Override public IngredientStack[] getTotalMaterials() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockExcavator.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockExcavator.java index 642785d551..983531b51f 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockExcavator.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockExcavator.java @@ -35,75 +35,82 @@ public class MultiblockExcavator implements IMultiblock { public static MultiblockExcavator instance = new MultiblockExcavator(); static ItemStack[][][] structure = new ItemStack[3][6][3]; - static{ - for(int h=0;h<3;h++) - for(int l=0;l<6;l++) - for(int w=0;w<3;w++) + + static + { + for(int h = 0; h < 3; h++) + for(int l = 0; l < 6; l++) + for(int w = 0; w < 3; w++) { - if(l>0&&w==1) + if(l > 0&&w==1) continue; if(l==0) { if(w==0&&h==1) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); else if((w==1&&h==1)||(w==0&&h==2)) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); else if(w==0&&h==0) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.RADIATOR.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.RADIATOR.getMeta()); else - structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.STEEL.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.STEEL.getMeta()); } else if(w==0) { - if(l<3 && h==2) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.RADIATOR.getMeta()); - else if(l<3) - structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.STEEL.getMeta()); + if(l < 3&&h==2) + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.RADIATOR.getMeta()); + else if(l < 3) + structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.STEEL.getMeta()); else if(h==0) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); else - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); } else if(w==2) { if(l==1) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); else if(l==2) - structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.STEEL.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.STEEL.getMeta()); else if(h==0) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); else if(h==1) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); else - structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.STEEL.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.STEEL.getMeta()); } } } + @Override public ItemStack[][][] getStructureManual() { return structure; } + @Override @SideOnly(Side.CLIENT) public boolean overwriteBlockRender(ItemStack stack, int iterator) { return false; } + @Override @SideOnly(Side.CLIENT) public boolean canRenderFormedStructure() { return true; } + //@SideOnly(Side.CLIENT) static ItemStack renderStack = ItemStack.EMPTY; + @Override @SideOnly(Side.CLIENT) public void renderFormedStructure() { if(renderStack.isEmpty()) - renderStack = new ItemStack(IEContent.blockMetalMultiblock,1,BlockTypes_MetalMultiblock.EXCAVATOR.getMeta()); + renderStack = new ItemStack(IEContent.blockMetalMultiblock, 1, BlockTypes_MetalMultiblock.EXCAVATOR.getMeta()); GlStateManager.translate(2, 1.5, 2.875); GlStateManager.rotate(-225, 0, 1, 0); GlStateManager.rotate(-20, 1, 0, 0); @@ -113,6 +120,7 @@ public void renderFormedStructure() ClientUtils.mc().getRenderItem().renderItem(renderStack, ItemCameraTransforms.TransformType.GUI); GlStateManager.enableCull(); } + @Override public float getManualScale() { @@ -128,45 +136,45 @@ public String getUniqueName() @Override public boolean isBlockTrigger(IBlockState state) { - return state.getBlock()==IEContent.blockMetalDecoration0 && (state.getBlock().getMetaFromState(state)==BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); + return state.getBlock()==IEContent.blockMetalDecoration0&&(state.getBlock().getMetaFromState(state)==BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); } @Override public boolean createStructure(World world, BlockPos pos, EnumFacing side, EntityPlayer player) { side = side.getOpposite(); - if (side == EnumFacing.UP || side == EnumFacing.DOWN) + if(side==EnumFacing.UP||side==EnumFacing.DOWN) side = EnumFacing.fromAngle(player.rotationYaw); boolean mirror = false; boolean b = this.structureCheck(world, pos, side, mirror); - if (!b) + if(!b) { mirror = true; b = structureCheck(world, pos, side, mirror); } - if (!b) + if(!b) return false; IBlockState state = IEContent.blockMetalMultiblock.getStateFromMeta(BlockTypes_MetalMultiblock.EXCAVATOR.getMeta()); state = state.withProperty(IEProperties.FACING_HORIZONTAL, side); - for (int l = 0; l < 6; l++) - for (int w = -1; w <= 1; w++) - for (int h = -1; h <= 1; h++) + for(int l = 0; l < 6; l++) + for(int w = -1; w <= 1; w++) + for(int h = -1; h <= 1; h++) { - if (l > 0 && w == 0) + if(l > 0&&w==0) continue; - int ww = mirror ? -w : w; + int ww = mirror?-w: w; BlockPos pos2 = pos.offset(side, l).offset(side.rotateY(), ww).add(0, h, 0); world.setBlockState(pos2, state); TileEntity curr = world.getTileEntity(pos2); - if (curr instanceof TileEntityExcavator) + if(curr instanceof TileEntityExcavator) { - TileEntityExcavator tile = (TileEntityExcavator) curr; + TileEntityExcavator tile = (TileEntityExcavator)curr; tile.formed = true; - tile.pos = (h + 1) * 18 + l * 3 + (w + 1); - tile.offset = new int[]{(side == EnumFacing.WEST ? -l : side == EnumFacing.EAST ? l : side == EnumFacing.NORTH ? ww : -ww), h, (side == EnumFacing.NORTH ? -l : side == EnumFacing.SOUTH ? l : side == EnumFacing.EAST ? ww : -ww)}; + tile.pos = (h+1)*18+l*3+(w+1); + tile.offset = new int[]{(side==EnumFacing.WEST?-l: side==EnumFacing.EAST?l: side==EnumFacing.NORTH?ww: -ww), h, (side==EnumFacing.NORTH?-l: side==EnumFacing.SOUTH?l: side==EnumFacing.EAST?ww: -ww)}; tile.mirrored = mirror; tile.markDirty(); world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0); @@ -174,21 +182,21 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit } BlockPos wheelPos = pos.offset(side, 4); - if (MultiblockBucketWheel.instance.isBlockTrigger(world.getBlockState(wheelPos))) + if(MultiblockBucketWheel.instance.isBlockTrigger(world.getBlockState(wheelPos))) MultiblockBucketWheel.instance.createStructure(world, wheelPos, side.rotateYCCW(), player); return true; } boolean structureCheck(World world, BlockPos startPos, EnumFacing dir, boolean mirror) { - for(int l=0;l<6;l++) - for(int w=-1;w<=1;w++) - for(int h=-1;h<=1;h++) + for(int l = 0; l < 6; l++) + for(int w = -1; w <= 1; w++) + for(int h = -1; h <= 1; h++) { - if(l>0&&w==0) + if(l > 0&&w==0) continue; - int ww = mirror?-w:w; + int ww = mirror?-w: w; BlockPos pos = startPos.offset(dir, l).offset(dir.rotateY(), ww).add(0, h, 0); if(l==0) @@ -216,12 +224,12 @@ else if(w==-1&&h==-1) } else if(w==-1) { - if(l<3 && h==1) + if(l < 3&&h==1) { if(!Utils.isBlockAt(world, pos, IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.RADIATOR.getMeta())) return false; } - else if(l<3) + else if(l < 3) { if(!Utils.isOreBlockAt(world, pos, "blockSheetmetalSteel")) return false; @@ -276,6 +284,7 @@ else if(h==0) new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 9, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())), new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 5, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta())), new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 3, BlockTypes_MetalDecoration0.RADIATOR.getMeta()))}; + @Override public IngredientStack[] getTotalMaterials() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockExcavatorDemo.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockExcavatorDemo.java index 71e3684013..21f7622185 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockExcavatorDemo.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockExcavatorDemo.java @@ -32,108 +32,116 @@ public class MultiblockExcavatorDemo implements IMultiblock { public static MultiblockExcavatorDemo instance = new MultiblockExcavatorDemo(); static ItemStack[][][] structure = new ItemStack[7][8][3]; - static{ - for(int h=0;h<3;h++) - for(int l=0;l<6;l++) - for(int w=0;w<3;w++) + + static + { + for(int h = 0; h < 3; h++) + for(int l = 0; l < 6; l++) + for(int w = 0; w < 3; w++) { - if(l>0&&w==1) + if(l > 0&&w==1) continue; if(l==0) { if(w==0&&h==1) - structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); + structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); else if((w==1&&h==1)||(w==0&&h==2)) - structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); + structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); else if(w==0&&h==0) - structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.RADIATOR.getMeta()); + structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.RADIATOR.getMeta()); else - structure[h+2][l][w] = new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.STEEL.getMeta()); + structure[h+2][l][w] = new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.STEEL.getMeta()); } else if(w==0) { - if(l<3 && h==2) - structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.RADIATOR.getMeta()); - else if(l<3) - structure[h+2][l][w] = new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.STEEL.getMeta()); + if(l < 3&&h==2) + structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.RADIATOR.getMeta()); + else if(l < 3) + structure[h+2][l][w] = new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.STEEL.getMeta()); else if(h==0) - structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); + structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); else - structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); } else if(w==2) { if(l==1) - structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); else if(l==2) - structure[h+2][l][w] = new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.STEEL.getMeta()); + structure[h+2][l][w] = new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.STEEL.getMeta()); else if(h==0) - structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); + structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); else if(h==1) - structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); + structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); else - structure[h+2][l][w] = new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.STEEL.getMeta()); + structure[h+2][l][w] = new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.STEEL.getMeta()); } } - for(int h=0;h<7;h++) - for(int l=0;l<7;l++) + for(int h = 0; h < 7; h++) + for(int l = 0; l < 7; l++) { - if((h==0||h==6) && l!=3) + if((h==0||h==6)&&l!=3) continue; - if((l==0||l==6) && h!=3) + if((l==0||l==6)&&h!=3) continue; - if(l==0||h==0||l==6||h==6 || ((l==1||l==5) && (h==1||h==5)) || (h==3&&l==3)) - structure[h][l+1][1]= new ItemStack(IEContent.blockStorage,1,BlockTypes_MetalsIE.STEEL.getMeta()); + if(l==0||h==0||l==6||h==6||((l==1||l==5)&&(h==1||h==5))||(h==3&&l==3)) + structure[h][l+1][1] = new ItemStack(IEContent.blockStorage, 1, BlockTypes_MetalsIE.STEEL.getMeta()); else - structure[h][l+1][1]= new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); + structure[h][l+1][1] = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); } } + @Override public ItemStack[][][] getStructureManual() { return structure; } + @Override @SideOnly(Side.CLIENT) public boolean overwriteBlockRender(ItemStack stack, int iterator) { return false; } + @Override @SideOnly(Side.CLIENT) public boolean canRenderFormedStructure() { return true; } + //@SideOnly(Side.CLIENT) static ItemStack renderStack = ItemStack.EMPTY; //@SideOnly(Side.CLIENT) static ItemStack renderStack2 = ItemStack.EMPTY; + @Override @SideOnly(Side.CLIENT) public void renderFormedStructure() { if(renderStack.isEmpty()) - renderStack = new ItemStack(IEContent.blockMetalMultiblock,1,BlockTypes_MetalMultiblock.EXCAVATOR.getMeta()); + renderStack = new ItemStack(IEContent.blockMetalMultiblock, 1, BlockTypes_MetalMultiblock.EXCAVATOR.getMeta()); if(renderStack2.isEmpty()) - renderStack2 = new ItemStack(IEContent.blockMetalMultiblock,1,BlockTypes_MetalMultiblock.BUCKET_WHEEL.getMeta()); + renderStack2 = new ItemStack(IEContent.blockMetalMultiblock, 1, BlockTypes_MetalMultiblock.BUCKET_WHEEL.getMeta()); GlStateManager.translate(2, 3.5, 2.875); GlStateManager.rotate(-225, 0, 1, 0); GlStateManager.rotate(-20, 1, 0, 0); double s = 5.25; - GlStateManager.scale(s,s,s); + GlStateManager.scale(s, s, s); GlStateManager.disableCull(); ClientUtils.mc().getRenderItem().renderItem(renderStack, ItemCameraTransforms.TransformType.GUI); - GlStateManager.scale(1/s,1/s,1/s); + GlStateManager.scale(1/s, 1/s, 1/s); GlStateManager.rotate(20, 1, 0, 0); GlStateManager.rotate(225, 0, 1, 0); - GlStateManager.translate(2.5,0,-1.375); + GlStateManager.translate(2.5, 0, -1.375); GlStateManager.rotate(-45, 0, 1, 0); GlStateManager.rotate(-20, 1, 0, 0); GlStateManager.scale(6.875, 6.875, 6.875); ClientUtils.mc().getRenderItem().renderItem(renderStack2, ItemCameraTransforms.TransformType.GUI); GlStateManager.enableCull(); } + @Override public float getManualScale() { @@ -166,6 +174,7 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 9, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())), new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 5, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta())), new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 3, BlockTypes_MetalDecoration0.RADIATOR.getMeta()))}; + @Override public IngredientStack[] getTotalMaterials() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockFeedthrough.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockFeedthrough.java index c679e660ed..e7eb517967 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockFeedthrough.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockFeedthrough.java @@ -38,22 +38,27 @@ public class MultiblockFeedthrough implements IMultiblock { public static MultiblockFeedthrough instance = new MultiblockFeedthrough(); static ItemStack[][][] structure = new ItemStack[1][1][3]; - static{ + + static + { structure[0][0][0] = new ItemStack(IEContent.blockConnectors, 1); structure[0][0][1] = new ItemStack(Blocks.BOOKSHELF, 1).setTranslatableName("tile.immersiveengineering.arb_solid.name"); structure[0][0][2] = new ItemStack(IEContent.blockConnectors, 1); } + @Override public ItemStack[][][] getStructureManual() { return structure; } + @Override @SideOnly(Side.CLIENT) public boolean overwriteBlockRender(ItemStack stack, int iterator) { return false; } + @Override @SideOnly(Side.CLIENT) public boolean canRenderFormedStructure() @@ -62,12 +67,13 @@ public boolean canRenderFormedStructure() } private ItemStack renderStack; + @Override @SideOnly(Side.CLIENT) public void renderFormedStructure() { if(renderStack==null||renderStack.isEmpty()) - renderStack = new ItemStack(IEContent.blockConnectors,1,BlockTypes_Connector.FEEDTHROUGH.getMeta()); + renderStack = new ItemStack(IEContent.blockConnectors, 1, BlockTypes_Connector.FEEDTHROUGH.getMeta()); GlStateManager.translate(.5, .5, 1.5); GlStateManager.rotate(-45, 0, 1, 0); @@ -83,7 +89,7 @@ public void renderFormedStructure() public IBlockState getBlockstateFromStack(int index, ItemStack stack) { IBlockState ret = IMultiblock.super.getBlockstateFromStack(index, stack); - if (stack==structure[0][0][0]) + if(stack==structure[0][0][0]) return ret.withProperty(IEProperties.FACING_ALL, EnumFacing.SOUTH); return ret; } @@ -112,36 +118,36 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit IBlockState here = world.getBlockState(pos).getActualState(world, pos); side = here.getValue(IEProperties.FACING_ALL); Set conns = ImmersiveNetHandler.INSTANCE.getConnections(world, pos); - if (conns!=null&&!conns.isEmpty()) + if(conns!=null&&!conns.isEmpty()) return false; WireType wire = WireApi.getWireType(here); - if (wire==null)//This shouldn't ever happen + if(wire==null)//This shouldn't ever happen return false; BlockPos tmp = pos.offset(side); IBlockState middle = world.getBlockState(tmp).getActualState(world, tmp); - if (!middle.isFullCube()||middle.getBlock().hasTileEntity(middle)||middle.getRenderType()!= EnumBlockRenderType.MODEL) + if(!middle.isFullCube()||middle.getBlock().hasTileEntity(middle)||middle.getRenderType()!=EnumBlockRenderType.MODEL) return false; tmp = pos.offset(side, 2); IBlockState otherConn = world.getBlockState(tmp).getActualState(world, tmp); - if (WireApi.getWireType(otherConn)!=wire) + if(WireApi.getWireType(otherConn)!=wire) return false; - if (otherConn.getValue(IEProperties.FACING_ALL)!=side.getOpposite()) + if(otherConn.getValue(IEProperties.FACING_ALL)!=side.getOpposite()) return false; conns = ImmersiveNetHandler.INSTANCE.getConnections(world, tmp); - if (conns!=null&&!conns.isEmpty()) + if(conns!=null&&!conns.isEmpty()) return false; IBlockState state = IEContent.blockConnectors.getDefaultState().withProperty(IEContent.blockConnectors.property, BlockTypes_Connector.FEEDTHROUGH).withProperty(IEProperties.FACING_ALL, side); - for (int i = 0;i<=2;i++) + for(int i = 0; i <= 2; i++) { tmp = pos.offset(side, i); world.setBlockState(tmp, state); TileEntity te = world.getTileEntity(tmp); - if (te instanceof TileEntityFeedthrough) + if(te instanceof TileEntityFeedthrough) { - ((TileEntityFeedthrough) te).reference = wire; - ((TileEntityFeedthrough) te).stateForMiddle = middle; - ((TileEntityFeedthrough) te).offset = i-1; + ((TileEntityFeedthrough)te).reference = wire; + ((TileEntityFeedthrough)te).stateForMiddle = middle; + ((TileEntityFeedthrough)te).offset = i-1; world.checkLight(tmp); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockFermenter.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockFermenter.java index ff3f705362..07f18cae78 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockFermenter.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockFermenter.java @@ -37,32 +37,34 @@ public class MultiblockFermenter implements IMultiblock public static MultiblockFermenter instance = new MultiblockFermenter(); static ItemStack[][][] structure = new ItemStack[3][3][3]; - static{ - for(int h=0;h<3;h++) - for(int l=0;l<3;l++) - for(int w=0;w<3;w++) + + static + { + for(int h = 0; h < 3; h++) + for(int l = 0; l < 3; l++) + for(int w = 0; w < 3; w++) if(h==0) { if(l==0&&w==0) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); - else if(l==1 && w>0) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDevice1,1,BlockTypes_MetalDevice1.FLUID_PIPE.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + else if(l==1&&w > 0) + structure[h][l][w] = new ItemStack(IEContent.blockMetalDevice1, 1, BlockTypes_MetalDevice1.FLUID_PIPE.getMeta()); else - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); } else if(h==1) { if(l==0&&w==0) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); else if(l==0&&w==2) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); - else if(l>0 && w<2) + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); + else if(l > 0&&w < 2) structure[h][l][w] = new ItemStack(Items.CAULDRON); } else if(h==2) { - if(l>0 && w<2) - structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal,1, BlockTypes_MetalsAll.IRON.getMeta()); + if(l > 0&&w < 2) + structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.IRON.getMeta()); } } @@ -88,37 +90,42 @@ public boolean overwriteBlockRender(ItemStack stack, int iterator) } return false; } + @Override public IBlockState getBlockstateFromStack(int index, ItemStack stack) { if(!stack.isEmpty()) { - if(stack.getItem() == Items.CAULDRON) + if(stack.getItem()==Items.CAULDRON) return Blocks.CAULDRON.getDefaultState(); else if(stack.getItem() instanceof ItemBlock) return ((ItemBlock)stack.getItem()).getBlock().getStateFromMeta(stack.getItemDamage()); } return null; } + @Override public float getManualScale() { return 13; } + @Override @SideOnly(Side.CLIENT) public boolean canRenderFormedStructure() { return true; } + //@SideOnly(Side.CLIENT) static ItemStack renderStack = ItemStack.EMPTY; + @Override @SideOnly(Side.CLIENT) public void renderFormedStructure() { if(renderStack.isEmpty()) - renderStack = new ItemStack(IEContent.blockMetalMultiblock,1,BlockTypes_MetalMultiblock.FERMENTER.getMeta()); + renderStack = new ItemStack(IEContent.blockMetalMultiblock, 1, BlockTypes_MetalMultiblock.FERMENTER.getMeta()); GlStateManager.translate(1.5, 1.5, 1.5); GlStateManager.rotate(-45, 0, 1, 0); GlStateManager.rotate(-20, 1, 0, 0); @@ -159,14 +166,14 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit IBlockState state = IEContent.blockMetalMultiblock.getStateFromMeta(BlockTypes_MetalMultiblock.FERMENTER.getMeta()); state = state.withProperty(IEProperties.FACING_HORIZONTAL, side); - for(int h=-1;h<=1;h++) - for(int l=-1;l<=1;l++) - for(int w=-1;w<=1;w++) + for(int h = -1; h <= 1; h++) + for(int l = -1; l <= 1; l++) + for(int w = -1; w <= 1; w++) { - if((h==0&&w==0&&l==-1)||(h==0&&w==1&&l>-1)||(h==1&&(l<0||w>0))) + if((h==0&&w==0&&l==-1)||(h==0&&w==1&&l > -1)||(h==1&&(l < 0||w > 0))) continue; - int ww = mirror?-w:w; + int ww = mirror?-w: w; BlockPos pos2 = pos.offset(side, l).offset(side.rotateY(), ww).add(0, h, 0); world.setBlockState(pos2, state); @@ -174,10 +181,10 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit if(curr instanceof TileEntityFermenter) { TileEntityFermenter tile = (TileEntityFermenter)curr; - tile.formed=true; - tile.pos = (h+1)*9 + (l+1)*3 + (w+1); - tile.offset = new int[]{(side==EnumFacing.WEST?-l: side==EnumFacing.EAST?l: side==EnumFacing.NORTH?ww: -ww),h,(side==EnumFacing.NORTH?-l: side==EnumFacing.SOUTH?l: side==EnumFacing.EAST?ww : -ww)}; - tile.mirrored=mirror; + tile.formed = true; + tile.pos = (h+1)*9+(l+1)*3+(w+1); + tile.offset = new int[]{(side==EnumFacing.WEST?-l: side==EnumFacing.EAST?l: side==EnumFacing.NORTH?ww: -ww), h, (side==EnumFacing.NORTH?-l: side==EnumFacing.SOUTH?l: side==EnumFacing.EAST?ww: -ww)}; + tile.mirrored = mirror; tile.markDirty(); world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0); } @@ -187,14 +194,14 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit boolean structureCheck(World world, BlockPos startPos, EnumFacing dir, boolean mirror) { - for(int h=-1;h<=1;h++) - for(int l=-1;l<=1;l++) - for(int w=-1;w<=1;w++) + for(int h = -1; h <= 1; h++) + for(int l = -1; l <= 1; l++) + for(int w = -1; w <= 1; w++) { - if((h==0&&w==0&&l==-1)||(h==0&&w==1&&l>-1)||(h==1&&(l<0||w>0))) + if((h==0&&w==0&&l==-1)||(h==0&&w==1&&l > -1)||(h==1&&(l < 0||w > 0))) continue; - int ww = mirror?-w:w; + int ww = mirror?-w: w; BlockPos pos = startPos.offset(dir, l).offset(dir.rotateY(), ww).add(0, h, 0); if(h==-1) @@ -204,7 +211,7 @@ boolean structureCheck(World world, BlockPos startPos, EnumFacing dir, boolean m if(!Utils.isBlockAt(world, pos, IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())) return false; } - else if(l==0 && w>-1) + else if(l==0&&w > -1) { if(!Utils.isBlockAt(world, pos, IEContent.blockMetalDevice1, BlockTypes_MetalDevice1.FLUID_PIPE.getMeta())) return false; @@ -227,7 +234,7 @@ else if(l==-1&&w==1) if(!Utils.isBlockAt(world, pos, IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta())) return false; } - else if(l>-1 && w<1) + else if(l > -1&&w < 1) { if(!Utils.isBlockAt(world, pos, Blocks.CAULDRON, 0)) return false; @@ -235,7 +242,7 @@ else if(l>-1 && w<1) } else if(h==1) { - if(l>-1&&w<1) + if(l > -1&&w < 1) { if(!Utils.isOreBlockAt(world, pos, "blockSheetmetalIron")) return false; @@ -252,6 +259,7 @@ else if(h==1) new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 2, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())), new IngredientStack(new ItemStack(Items.CAULDRON, 4, 0)), new IngredientStack("blockSheetmetalIron", 4)}; + @Override public IngredientStack[] getTotalMaterials() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockLightningrod.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockLightningrod.java index 1ccc9bd37f..33ea0f5e52 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockLightningrod.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockLightningrod.java @@ -33,56 +33,63 @@ public class MultiblockLightningrod implements IMultiblock { public static MultiblockLightningrod instance = new MultiblockLightningrod(); static ItemStack[][][] structure = new ItemStack[3][3][3]; - static{ - for(int h=0;h<3;h++) - for(int l=0;l<3;l++) - for(int w=0;w<3;w++) + + static + { + for(int h = 0; h < 3; h++) + for(int l = 0; l < 3; l++) + for(int w = 0; w < 3; w++) { if(l==1&&w==1) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.COIL_HV.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.COIL_HV.getMeta()); else if(h==0) { if(l==1|w==1) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDevice0,1, BlockTypes_MetalDevice0.CAPACITOR_HV.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDevice0, 1, BlockTypes_MetalDevice0.CAPACITOR_HV.getMeta()); else - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); } else if(h==1) { if(l==1|w==1) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); else - structure[h][l][w] = new ItemStack(IEContent.blockWoodenDecoration,1, BlockTypes_WoodenDecoration.FENCE.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockWoodenDecoration, 1, BlockTypes_WoodenDecoration.FENCE.getMeta()); } else if(h==2) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.COIL_LV.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.COIL_LV.getMeta()); } } + @Override public ItemStack[][][] getStructureManual() { return structure; } + @Override @SideOnly(Side.CLIENT) public boolean overwriteBlockRender(ItemStack stack, int iterator) { return false; } + @Override @SideOnly(Side.CLIENT) public boolean canRenderFormedStructure() { return true; } + //@SideOnly(Side.CLIENT) static ItemStack renderStack = ItemStack.EMPTY; + @Override @SideOnly(Side.CLIENT) public void renderFormedStructure() { if(renderStack.isEmpty()) - renderStack = new ItemStack(IEContent.blockMetalMultiblock,1,BlockTypes_MetalMultiblock.LIGHTNINGROD.getMeta()); + renderStack = new ItemStack(IEContent.blockMetalMultiblock, 1, BlockTypes_MetalMultiblock.LIGHTNINGROD.getMeta()); GlStateManager.translate(1.5, 1.5, 1.5); GlStateManager.rotate(-45, 0, 1, 0); GlStateManager.rotate(-20, 1, 0, 0); @@ -91,6 +98,7 @@ public void renderFormedStructure() ClientUtils.mc().getRenderItem().renderItem(renderStack, ItemCameraTransforms.TransformType.GUI); GlStateManager.enableCull(); } + @Override public float getManualScale() { @@ -106,7 +114,7 @@ public String getUniqueName() @Override public boolean isBlockTrigger(IBlockState state) { - return state.getBlock()==IEContent.blockMetalDecoration0 && (state.getBlock().getMetaFromState(state)==BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + return state.getBlock()==IEContent.blockMetalDecoration0&&(state.getBlock().getMetaFromState(state)==BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); } @Override @@ -118,11 +126,11 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit side = side.getOpposite(); boolean mirror = false; - for(int l=0;l<3;l++) - for(int h=-1;h<=1;h++) - for(int w=-1;w<=1;w++) + for(int l = 0; l < 3; l++) + for(int h = -1; h <= 1; h++) + for(int w = -1; w <= 1; w++) { - int ww = mirror?-w:w; + int ww = mirror?-w: w; BlockPos pos2 = pos.offset(side, l).offset(side.rotateY(), ww).add(0, h, 0); if(l==1&&w==0) @@ -165,11 +173,11 @@ else if(h==1) IBlockState state = IEContent.blockMetalMultiblock.getStateFromMeta(BlockTypes_MetalMultiblock.LIGHTNINGROD.getMeta()); state = state.withProperty(IEProperties.FACING_HORIZONTAL, side); - for(int l=0;l<3;l++) - for(int w=-1;w<=1;w++) - for(int h=-1;h<=1;h++) + for(int l = 0; l < 3; l++) + for(int w = -1; w <= 1; w++) + for(int h = -1; h <= 1; h++) { - int ww = mirror?-w:w; + int ww = mirror?-w: w; BlockPos pos2 = pos.offset(side, l).offset(side.rotateY(), ww).add(0, h, 0); world.setBlockState(pos2, state); @@ -177,10 +185,10 @@ else if(h==1) if(curr instanceof TileEntityLightningrod) { TileEntityLightningrod tile = (TileEntityLightningrod)curr; - tile.formed=true; - tile.pos = (h+1)*9 + l*3 + (w+1); - tile.offset = new int[]{(side==EnumFacing.WEST?1-l: side==EnumFacing.EAST?l-1: side==EnumFacing.NORTH?ww: -ww),h,(side==EnumFacing.NORTH?1-l: side==EnumFacing.SOUTH?l-1: side==EnumFacing.EAST?ww : -ww)}; - tile.mirrored=mirror; + tile.formed = true; + tile.pos = (h+1)*9+l*3+(w+1); + tile.offset = new int[]{(side==EnumFacing.WEST?1-l: side==EnumFacing.EAST?l-1: side==EnumFacing.NORTH?ww: -ww), h, (side==EnumFacing.NORTH?1-l: side==EnumFacing.SOUTH?l-1: side==EnumFacing.EAST?ww: -ww)}; + tile.mirrored = mirror; tile.markDirty(); world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0); } @@ -195,6 +203,7 @@ else if(h==1) new IngredientStack("fenceTreatedWood", 4), new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 3, BlockTypes_MetalDecoration0.COIL_HV.getMeta())), new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 8, BlockTypes_MetalDecoration0.COIL_LV.getMeta()))}; + @Override public IngredientStack[] getTotalMaterials() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockMetalPress.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockMetalPress.java index 75c69da77f..03e3ed0fd7 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockMetalPress.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockMetalPress.java @@ -35,25 +35,27 @@ public class MultiblockMetalPress implements IMultiblock public static MultiblockMetalPress instance = new MultiblockMetalPress(); static ItemStack[][][] structure = new ItemStack[3][3][1]; - static{ - for(int h=0;h<3;h++) - for(int l=0;l<3;l++) + + static + { + for(int h = 0; h < 3; h++) + for(int l = 0; l < 3; l++) if(h==0) { if(l==1) - structure[h][l][0] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); + structure[h][l][0] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); else - structure[h][l][0] = new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); + structure[h][l][0] = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); } else if(h==1) { if(l==1) - structure[h][l][0] = new ItemStack(Blocks.PISTON,1,0); + structure[h][l][0] = new ItemStack(Blocks.PISTON, 1, 0); else - structure[h][l][0] = ConveyorHandler.getConveyorStack(ImmersiveEngineering.MODID + ":conveyor"); + structure[h][l][0] = ConveyorHandler.getConveyorStack(ImmersiveEngineering.MODID+":conveyor"); } else if(h==2&&l==1) - structure[h][l][0] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); + structure[h][l][0] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); } @Override @@ -61,6 +63,7 @@ public ItemStack[][][] getStructureManual() { return structure; } + @Override @SideOnly(Side.CLIENT) public boolean overwriteBlockRender(ItemStack stack, int iterator) @@ -69,25 +72,29 @@ public boolean overwriteBlockRender(ItemStack stack, int iterator) return ImmersiveEngineering.proxy.drawConveyorInGui("immersiveengineering:conveyor", EnumFacing.EAST); return false; } + @Override public float getManualScale() { return 13; } + @Override @SideOnly(Side.CLIENT) public boolean canRenderFormedStructure() { return true; } + //@SideOnly(Side.CLIENT) static ItemStack renderStack = ItemStack.EMPTY; + @Override @SideOnly(Side.CLIENT) public void renderFormedStructure() { if(renderStack.isEmpty()) - renderStack = new ItemStack(IEContent.blockMetalMultiblock,1,BlockTypes_MetalMultiblock.METAL_PRESS.getMeta()); + renderStack = new ItemStack(IEContent.blockMetalMultiblock, 1, BlockTypes_MetalMultiblock.METAL_PRESS.getMeta()); GlStateManager.scale(4, 4, 4); GlStateManager.translate(.375, .375, .125f); GlStateManager.rotate(-45, 0, 1, 0); @@ -104,7 +111,7 @@ public String getUniqueName() @Override public boolean isBlockTrigger(IBlockState state) { - return state.getBlock()==Blocks.PISTON && (state.getBlock().getMetaFromState(state)==0); + return state.getBlock()==Blocks.PISTON&&(state.getBlock().getMetaFromState(state)==0); } @Override @@ -117,12 +124,12 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit if(world.getTileEntity(pos.offset(dir)) instanceof TileEntityConveyorBelt) dir = ((TileEntityConveyorBelt)world.getTileEntity(pos.offset(dir))).getFacing(); - for(int l=-1;l<=1;l++) - for(int h=-1;h<=1;h++) + for(int l = -1; l <= 1; l++) + for(int h = -1; h <= 1; h++) { if(h==1&&l!=0) continue; - BlockPos pos2 = pos.offset(dir, l).add(0,h,0); + BlockPos pos2 = pos.offset(dir, l).add(0, h, 0); if(h==-1) { @@ -146,7 +153,7 @@ else if(h==0) } else { - if(!ConveyorHandler.isConveyor(world, pos2, ImmersiveEngineering.MODID + ":conveyor", dir)) + if(!ConveyorHandler.isConveyor(world, pos2, ImmersiveEngineering.MODID+":conveyor", dir)) return false; } } @@ -158,20 +165,20 @@ else if(h==0) } IBlockState state = IEContent.blockMetalMultiblock.getStateFromMeta(BlockTypes_MetalMultiblock.METAL_PRESS.getMeta()); state = state.withProperty(IEProperties.FACING_HORIZONTAL, dir); - for(int l=-1;l<=1;l++) - for(int h=-1;h<=1;h++) + for(int l = -1; l <= 1; l++) + for(int h = -1; h <= 1; h++) { if(h==1&&l!=0) continue; - BlockPos pos2 = pos.offset(dir, l).add(0,h,0); + BlockPos pos2 = pos.offset(dir, l).add(0, h, 0); world.setBlockState(pos2, state); TileEntity curr = world.getTileEntity(pos2); if(curr instanceof TileEntityMetalPress) { TileEntityMetalPress tile = (TileEntityMetalPress)curr; - tile.formed=true; - tile.pos = (h+1)*3 + (l+1); - tile.offset = new int[]{(dir==EnumFacing.WEST?-l: dir==EnumFacing.EAST?l: 0),h,(dir==EnumFacing.NORTH?-l: dir==EnumFacing.SOUTH?l: 0)}; + tile.formed = true; + tile.pos = (h+1)*3+(l+1); + tile.offset = new int[]{(dir==EnumFacing.WEST?-l: dir==EnumFacing.EAST?l: 0), h, (dir==EnumFacing.NORTH?-l: dir==EnumFacing.SOUTH?l: 0)}; tile.markDirty(); world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0); } @@ -183,8 +190,9 @@ else if(h==0) new IngredientStack("scaffoldingSteel", 2), new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta())), new IngredientStack(new ItemStack(Blocks.PISTON)), - new IngredientStack(Utils.copyStackWithAmount(ConveyorHandler.getConveyorStack(ImmersiveEngineering.MODID + ":conveyor"), 2)), + new IngredientStack(Utils.copyStackWithAmount(ConveyorHandler.getConveyorStack(ImmersiveEngineering.MODID+":conveyor"), 2)), new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()))}; + @Override public IngredientStack[] getTotalMaterials() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockMixer.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockMixer.java index 43f73a11e7..8e9cc17eac 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockMixer.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockMixer.java @@ -34,34 +34,36 @@ public class MultiblockMixer implements IMultiblock public static MultiblockMixer instance = new MultiblockMixer(); static ItemStack[][][] structure = new ItemStack[3][3][3]; - static{ - for(int h=0;h<3;h++) - for(int l=0;l<3;l++) - for(int w=0;w<3;w++) + + static + { + for(int h = 0; h < 3; h++) + for(int l = 0; l < 3; l++) + for(int w = 0; w < 3; w++) if(h==0) { if(l==0&&w==0) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); - else if((l<2&&w==1) || (l==1&&w==0)) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDevice1,1,BlockTypes_MetalDevice1.FLUID_PIPE.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + else if((l < 2&&w==1)||(l==1&&w==0)) + structure[h][l][w] = new ItemStack(IEContent.blockMetalDevice1, 1, BlockTypes_MetalDevice1.FLUID_PIPE.getMeta()); else - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); } else if(h==1) { - if(l<2&&w==0) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + if(l < 2&&w==0) + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); else if(l==0&&w==2) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); - else if(l>0 && w>0) - structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.IRON.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); + else if(l > 0&&w > 0) + structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.IRON.getMeta()); } else if(h==2) { if(l==1&&w==0) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_FENCE.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_FENCE.getMeta()); else if(l==1&&w==1) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); } } @@ -70,6 +72,7 @@ public ItemStack[][][] getStructureManual() { return structure; } + @Override @SideOnly(Side.CLIENT) public boolean overwriteBlockRender(ItemStack stack, int iterator) @@ -91,25 +94,29 @@ public boolean overwriteBlockRender(ItemStack stack, int iterator) } return false; } + @Override public float getManualScale() { return 13; } + @Override @SideOnly(Side.CLIENT) public boolean canRenderFormedStructure() { return true; } + //@SideOnly(Side.CLIENT) static ItemStack renderStack = ItemStack.EMPTY; + @Override @SideOnly(Side.CLIENT) public void renderFormedStructure() { if(renderStack.isEmpty()) - renderStack = new ItemStack(IEContent.blockMetalMultiblock,1,BlockTypes_MetalMultiblock.MIXER.getMeta()); + renderStack = new ItemStack(IEContent.blockMetalMultiblock, 1, BlockTypes_MetalMultiblock.MIXER.getMeta()); GlStateManager.translate(1.5, 1.5, 1.5); GlStateManager.rotate(-45, 0, 1, 0); GlStateManager.rotate(-20, 1, 0, 0); @@ -128,7 +135,7 @@ public String getUniqueName() @Override public boolean isBlockTrigger(IBlockState state) { - return state.getBlock()==IEContent.blockSheetmetal && (state.getBlock().getMetaFromState(state)==BlockTypes_MetalsAll.IRON.getMeta()); + return state.getBlock()==IEContent.blockSheetmetal&&(state.getBlock().getMetaFromState(state)==BlockTypes_MetalsAll.IRON.getMeta()); } @Override @@ -150,14 +157,14 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit IBlockState state = IEContent.blockMetalMultiblock.getStateFromMeta(BlockTypes_MetalMultiblock.MIXER.getMeta()); state = state.withProperty(IEProperties.FACING_HORIZONTAL, side); - for(int h=-1;h<=1;h++) - for(int l=-1;l<=1;l++) - for(int w=-1;w<=1;w++) + for(int h = -1; h <= 1; h++) + for(int l = -1; l <= 1; l++) + for(int w = -1; w <= 1; w++) { - if((h==0&&w==0&&l==-1)||(h==0&&w==-1&&l==1)||(h==1&&(l!=0||w>0))) + if((h==0&&w==0&&l==-1)||(h==0&&w==-1&&l==1)||(h==1&&(l!=0||w > 0))) continue; - int ww = mirror?-w:w; + int ww = mirror?-w: w; BlockPos pos2 = pos.offset(side, l).offset(side.rotateY(), ww).add(0, h, 0); world.setBlockState(pos2, state); @@ -165,10 +172,10 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit if(curr instanceof TileEntityMixer) { TileEntityMixer tile = (TileEntityMixer)curr; - tile.formed=true; - tile.pos = (h+1)*9 + (l+1)*3 + (w+1); - tile.offset = new int[]{(side==EnumFacing.WEST?-l: side==EnumFacing.EAST?l: side==EnumFacing.NORTH?ww: -ww),h,(side==EnumFacing.NORTH?-l: side==EnumFacing.SOUTH?l: side==EnumFacing.EAST?ww : -ww)}; - tile.mirrored=mirror; + tile.formed = true; + tile.pos = (h+1)*9+(l+1)*3+(w+1); + tile.offset = new int[]{(side==EnumFacing.WEST?-l: side==EnumFacing.EAST?l: side==EnumFacing.NORTH?ww: -ww), h, (side==EnumFacing.NORTH?-l: side==EnumFacing.SOUTH?l: side==EnumFacing.EAST?ww: -ww)}; + tile.mirrored = mirror; tile.markDirty(); world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0); } @@ -178,14 +185,14 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit boolean structureCheck(World world, BlockPos startPos, EnumFacing dir, boolean mirror) { - for(int h=-1;h<=1;h++) - for(int l=-1;l<=1;l++) - for(int w=-1;w<=1;w++) + for(int h = -1; h <= 1; h++) + for(int l = -1; l <= 1; l++) + for(int w = -1; w <= 1; w++) { - if((h==0&&w==0&&l==-1)||(h==0&&w==1&&l>-1)||(h==1&&(l<0||w>0))) + if((h==0&&w==0&&l==-1)||(h==0&&w==1&&l > -1)||(h==1&&(l < 0||w > 0))) continue; - int ww = mirror?-w:w; + int ww = mirror?-w: w; BlockPos pos = startPos.offset(dir, l).offset(dir.rotateY(), ww).add(0, h, 0); if(h==-1) @@ -195,7 +202,7 @@ boolean structureCheck(World world, BlockPos startPos, EnumFacing dir, boolean m if(!Utils.isBlockAt(world, pos, IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())) return false; } - else if((l<1&&w==0)||(l==0&&w==-1)) + else if((l < 1&&w==0)||(l==0&&w==-1)) { if(!Utils.isBlockAt(world, pos, IEContent.blockMetalDevice1, BlockTypes_MetalDevice1.FLUID_PIPE.getMeta())) return false; @@ -208,7 +215,7 @@ else if((l<1&&w==0)||(l==0&&w==-1)) } else if(h==0) { - if(l<1&&w==-1) + if(l < 1&&w==-1) { if(!Utils.isBlockAt(world, pos, IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())) return false; @@ -218,7 +225,7 @@ else if(l==-1&&w==1) if(!Utils.isBlockAt(world, pos, IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta())) return false; } - else if(l>-1 && w>-1) + else if(l > -1&&w > -1) { if(!Utils.isOreBlockAt(world, pos, "blockSheetmetalIron")) return false; @@ -248,6 +255,7 @@ else if(l==0&&w==0) new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 4, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())), new IngredientStack("blockSheetmetalIron", 4), new IngredientStack("fenceSteel", 1)}; + @Override public IngredientStack[] getTotalMaterials() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockRefinery.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockRefinery.java index b22fa24abd..2cec59f612 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockRefinery.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockRefinery.java @@ -35,36 +35,38 @@ public class MultiblockRefinery implements IMultiblock public static MultiblockRefinery instance = new MultiblockRefinery(); static ItemStack[][][] structure = new ItemStack[3][3][5]; - static{ - for(int h=0;h<3;h++) - for(int l=0;l<3;l++) - for(int w=0;w<5;w++) + + static + { + for(int h = 0; h < 3; h++) + for(int l = 0; l < 3; l++) + for(int w = 0; w < 5; w++) if(h==0) { if((l==0||l==2)&&w!=2) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); else if(l==1) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDevice1,1,BlockTypes_MetalDevice1.FLUID_PIPE.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDevice1, 1, BlockTypes_MetalDevice1.FLUID_PIPE.getMeta()); else if(l==0) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); else if(l==2) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); } else if(h==1) { if(l==0&&w==4) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); else if(l==0&&w==2) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); else if(l==2&&w==2) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); - else if(l>0 && w!=2) - structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal,1, BlockTypes_MetalsAll.IRON.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + else if(l > 0&&w!=2) + structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.IRON.getMeta()); } else if(h==2) { - if(l>0 && w!=2) - structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal,1, BlockTypes_MetalsAll.IRON.getMeta()); + if(l > 0&&w!=2) + structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.IRON.getMeta()); } } @@ -78,49 +80,54 @@ public ItemStack[][][] getStructureManual() @SideOnly(Side.CLIENT) public boolean overwriteBlockRender(ItemStack stack, int iterator) { - if (iterator==5) + if(iterator==5) { ImmersiveEngineering.proxy.drawSpecificFluidPipe("000020"); return true; } - else if (iterator==9) + else if(iterator==9) { ImmersiveEngineering.proxy.drawSpecificFluidPipe("000002"); return true; } - else if(iterator>5&&iterator<9) + else if(iterator > 5&&iterator < 9) { ImmersiveEngineering.proxy.drawSpecificFluidPipe("000022"); return true; } return false; } + @Override public IBlockState getBlockstateFromStack(int index, ItemStack stack) { - if(!stack.isEmpty() && stack.getItem() instanceof ItemBlock) + if(!stack.isEmpty()&&stack.getItem() instanceof ItemBlock) return ((ItemBlock)stack.getItem()).getBlock().getStateFromMeta(stack.getItemDamage()); return null; } + @Override public float getManualScale() { return 13; } + @Override @SideOnly(Side.CLIENT) public boolean canRenderFormedStructure() { return true; } + //@SideOnly(Side.CLIENT) static ItemStack renderStack = ItemStack.EMPTY; + @Override @SideOnly(Side.CLIENT) public void renderFormedStructure() { if(renderStack.isEmpty()) - renderStack = new ItemStack(IEContent.blockMetalMultiblock,1,BlockTypes_MetalMultiblock.REFINERY.getMeta()); + renderStack = new ItemStack(IEContent.blockMetalMultiblock, 1, BlockTypes_MetalMultiblock.REFINERY.getMeta()); GlStateManager.translate(1, 1.5, 3); GlStateManager.rotate(-45, 0, 1, 0); GlStateManager.rotate(-20, 1, 0, 0); @@ -139,7 +146,7 @@ public String getUniqueName() @Override public boolean isBlockTrigger(IBlockState state) { - return state.getBlock()==IEContent.blockMetalDecoration0 && (state.getBlock().getMetaFromState(state)==BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); + return state.getBlock()==IEContent.blockMetalDecoration0&&(state.getBlock().getMetaFromState(state)==BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta()); } @Override @@ -161,15 +168,15 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit IBlockState state = IEContent.blockMetalMultiblock.getStateFromMeta(BlockTypes_MetalMultiblock.REFINERY.getMeta()); state = state.withProperty(IEProperties.FACING_HORIZONTAL, side); - for(int h=-1;h<=1;h++) - for(int l=0;l<=2;l++) - for(int w=-2;w<=2;w++) + for(int h = -1; h <= 1; h++) + for(int l = 0; l <= 2; l++) + for(int w = -2; w <= 2; w++) { if(h==0) { - if(l==0 && (w<0||w==1)) + if(l==0&&(w < 0||w==1)) continue; - else if(l==1 && w==0) + else if(l==1&&w==0) continue; } if(h==1) @@ -179,7 +186,7 @@ else if(l==1 && w==0) else if(w==0) continue; } - int ww = mirror?-w:w; + int ww = mirror?-w: w; BlockPos pos2 = pos.offset(side, l).offset(side.rotateY(), ww).add(0, h, 0); world.setBlockState(pos2, state); @@ -187,10 +194,10 @@ else if(w==0) if(curr instanceof TileEntityRefinery) { TileEntityRefinery tile = (TileEntityRefinery)curr; - tile.formed=true; - tile.pos = (h+1)*15 + l*5 + (w+2); - tile.offset = new int[]{(side==EnumFacing.WEST?-l: side==EnumFacing.EAST?l: side==EnumFacing.NORTH?ww: -ww),h,(side==EnumFacing.NORTH?-l: side==EnumFacing.SOUTH?l: side==EnumFacing.EAST?ww : -ww)}; - tile.mirrored=mirror; + tile.formed = true; + tile.pos = (h+1)*15+l*5+(w+2); + tile.offset = new int[]{(side==EnumFacing.WEST?-l: side==EnumFacing.EAST?l: side==EnumFacing.NORTH?ww: -ww), h, (side==EnumFacing.NORTH?-l: side==EnumFacing.SOUTH?l: side==EnumFacing.EAST?ww: -ww)}; + tile.mirrored = mirror; tile.markDirty(); world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0); } @@ -200,14 +207,14 @@ else if(w==0) boolean structureCheck(World world, BlockPos startPos, EnumFacing dir, boolean mirror) { - for(int h=-1;h<=1;h++) - for(int l=0;l<=2;l++) - for(int w=-2;w<=2;w++) + for(int h = -1; h <= 1; h++) + for(int l = 0; l <= 2; l++) + for(int w = -2; w <= 2; w++) { if((h==0&&l==0&&w!=0&&w!=2)||(h==0&&l==0&&w==0)||(h==1&&(l==0||w==0))) continue; - int ww = mirror?-w:w; + int ww = mirror?-w: w; BlockPos pos = startPos.offset(dir, l).offset(dir.rotateY(), ww).add(0, h, 0); if(h==-1) @@ -217,12 +224,12 @@ boolean structureCheck(World world, BlockPos startPos, EnumFacing dir, boolean m if(!Utils.isBlockAt(world, pos, IEContent.blockMetalDevice1, BlockTypes_MetalDevice1.FLUID_PIPE.getMeta())) return false; } - else if(l==0 && w==0) + else if(l==0&&w==0) { if(!Utils.isBlockAt(world, pos, IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta())) return false; } - else if(l==2 && w==0) + else if(l==2&&w==0) { if(!Utils.isBlockAt(world, pos, IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())) return false; @@ -250,7 +257,7 @@ else if(l==0&&w==2) if(!Utils.isBlockAt(world, pos, IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta())) return false; } - else if(l>0 && w!=0) + else if(l > 0&&w!=0) { if(!Utils.isOreBlockAt(world, pos, "blockSheetmetalIron")) return false; @@ -258,7 +265,7 @@ else if(l>0 && w!=0) } else if(h==1) { - if(l>0 && w!=0) + if(l > 0&&w!=0) { if(!Utils.isOreBlockAt(world, pos, "blockSheetmetalIron")) return false; @@ -275,6 +282,7 @@ else if(h==1) new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 2, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())), new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 2, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta())), new IngredientStack("blockSheetmetalIron", 16)}; + @Override public IngredientStack[] getTotalMaterials() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockSheetmetalTank.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockSheetmetalTank.java index aeb8c3e414..3e5bcbfc70 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockSheetmetalTank.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockSheetmetalTank.java @@ -35,52 +35,60 @@ public class MultiblockSheetmetalTank implements IMultiblock public static MultiblockSheetmetalTank instance = new MultiblockSheetmetalTank(); static ItemStack[][][] structure = new ItemStack[5][3][3]; - static{ - for(int h=0;h<5;h++) - for(int l=0;l<3;l++) - for(int w=0;w<3;w++) + + static + { + for(int h = 0; h < 5; h++) + for(int l = 0; l < 3; l++) + for(int w = 0; w < 3; w++) { if(h==0) { if((l==0||l==2)&&(w==0||w==2)) - structure[h][l][w]=new ItemStack(IEContent.blockWoodenDecoration,1,BlockTypes_WoodenDecoration.FENCE.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockWoodenDecoration, 1, BlockTypes_WoodenDecoration.FENCE.getMeta()); else if(l==1&&w==1) - structure[h][l][w]=new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.IRON.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.IRON.getMeta()); } - else if(h<1||h>3 || w!=1||l!=1) - structure[h][l][w]=new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.IRON.getMeta()); + else if(h < 1||h > 3||w!=1||l!=1) + structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.IRON.getMeta()); } } + @Override public ItemStack[][][] getStructureManual() { return structure; } + @Override @SideOnly(Side.CLIENT) public boolean overwriteBlockRender(ItemStack stack, int iterator) { return false; } + @Override public float getManualScale() { return 10; } + @Override @SideOnly(Side.CLIENT) public boolean canRenderFormedStructure() { return true; } + //@SideOnly(Side.CLIENT) static ItemStack renderStack = ItemStack.EMPTY; + @Override @SideOnly(Side.CLIENT) public void renderFormedStructure() { if(renderStack.isEmpty()) - renderStack = new ItemStack(IEContent.blockMetalMultiblock,1,BlockTypes_MetalMultiblock.TANK.getMeta()); + renderStack = new ItemStack(IEContent.blockMetalMultiblock, 1, BlockTypes_MetalMultiblock.TANK.getMeta()); GlStateManager.translate(1.875, 1.75, 1.125); GlStateManager.rotate(-45, 0, 1, 0); GlStateManager.rotate(-20, 1, 0, 0); @@ -97,7 +105,7 @@ public String getUniqueName() @Override public boolean isBlockTrigger(IBlockState state) { - return Utils.compareToOreName(new ItemStack(state.getBlock(),1,state.getBlock().getMetaFromState(state)), "blockSheetmetalIron"); + return Utils.compareToOreName(new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)), "blockSheetmetalIron"); } @Override @@ -105,17 +113,17 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit { EnumFacing f = EnumFacing.fromAngle(player.rotationYaw); pos = pos.offset(f); - if(!(Utils.isOreBlockAt(world, pos.offset(f,-1).offset(f.rotateY()), "fenceTreatedWood") && Utils.isOreBlockAt(world, pos.offset(f,-1).offset(f.rotateYCCW()), "fenceTreatedWood"))) - for(int i=0; i<4; i++) - if(Utils.isOreBlockAt(world, pos.add(0,-i,0).offset(f,-1).offset(f.rotateY()), "fenceTreatedWood") && Utils.isOreBlockAt(world, pos.add(0,-i,0).offset(f,-1).offset(f.rotateYCCW()), "fenceTreatedWood")) + if(!(Utils.isOreBlockAt(world, pos.offset(f, -1).offset(f.rotateY()), "fenceTreatedWood")&&Utils.isOreBlockAt(world, pos.offset(f, -1).offset(f.rotateYCCW()), "fenceTreatedWood"))) + for(int i = 0; i < 4; i++) + if(Utils.isOreBlockAt(world, pos.add(0, -i, 0).offset(f, -1).offset(f.rotateY()), "fenceTreatedWood")&&Utils.isOreBlockAt(world, pos.add(0, -i, 0).offset(f, -1).offset(f.rotateYCCW()), "fenceTreatedWood")) { - pos = pos.add(0,-i,0); + pos = pos.add(0, -i, 0); break; } - for(int h=0;h<=4;h++) - for(int xx=-1;xx<=1;xx++) - for(int zz=-1;zz<=1;zz++) + for(int h = 0; h <= 4; h++) + for(int xx = -1; xx <= 1; xx++) + for(int zz = -1; zz <= 1; zz++) if(h==0) { if(Math.abs(xx)==1&&Math.abs(zz)==1) @@ -129,7 +137,7 @@ else if(xx==0&&zz==0) } else { - if(h<4 && xx==0&&zz==0) + if(h < 4&&xx==0&&zz==0) { if(!world.isAirBlock(pos.add(xx, h, zz))) return false; @@ -140,28 +148,28 @@ else if(!Utils.isOreBlockAt(world, pos.add(xx, h, zz), "blockSheetmetalIron")) IBlockState state = IEContent.blockMetalMultiblock.getStateFromMeta(BlockTypes_MetalMultiblock.TANK.getMeta()); state = state.withProperty(IEProperties.FACING_HORIZONTAL, f.getOpposite()); - for(int h=0;h<=4;h++) - for(int l=-1;l<=1;l++) - for(int w=-1;w<=1;w++) + for(int h = 0; h <= 4; h++) + for(int l = -1; l <= 1; l++) + for(int w = -1; w <= 1; w++) { - if(h==0 && !((l==0&&w==0)||(Math.abs(l)==1&&Math.abs(w)==1))) + if(h==0&&!((l==0&&w==0)||(Math.abs(l)==1&&Math.abs(w)==1))) continue; - if(h>0&&h<4 && l==0&&w==0) + if(h > 0&&h < 4&&l==0&&w==0) continue; - int xx = f==EnumFacing.EAST?l: f==EnumFacing.WEST?-l: f==EnumFacing.NORTH?-w:w; - int zz = f==EnumFacing.NORTH?l: f==EnumFacing.SOUTH?-l: f==EnumFacing.EAST?w:-w; + int xx = f==EnumFacing.EAST?l: f==EnumFacing.WEST?-l: f==EnumFacing.NORTH?-w: w; + int zz = f==EnumFacing.NORTH?l: f==EnumFacing.SOUTH?-l: f==EnumFacing.EAST?w: -w; world.setBlockState(pos.add(xx, h, zz), state); BlockPos pos2 = pos.add(xx, h, zz); TileEntity curr = world.getTileEntity(pos2); if(curr instanceof TileEntitySheetmetalTank) { - TileEntitySheetmetalTank currTank = (TileEntitySheetmetalTank) curr; - currTank.offset=new int[]{xx,h,zz}; - currTank.pos = h*9 + (l+1)*3 + (w+1); - currTank.formed=true; - currTank.offset=new int[]{xx,h,zz}; + TileEntitySheetmetalTank currTank = (TileEntitySheetmetalTank)curr; + currTank.offset = new int[]{xx, h, zz}; + currTank.pos = h*9+(l+1)*3+(w+1); + currTank.formed = true; + currTank.offset = new int[]{xx, h, zz}; currTank.markDirty(); world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0); } @@ -170,6 +178,7 @@ else if(!Utils.isOreBlockAt(world, pos.add(xx, h, zz), "blockSheetmetalIron")) } static final IngredientStack[] materials = new IngredientStack[]{new IngredientStack("fenceTreatedWood", 4), new IngredientStack("blockSheetmetalIron", 34)}; + @Override public IngredientStack[] getTotalMaterials() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockSilo.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockSilo.java index 3c86cc9f92..de2d406d6e 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockSilo.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockSilo.java @@ -35,56 +35,64 @@ public class MultiblockSilo implements IMultiblock public static MultiblockSilo instance = new MultiblockSilo(); static ItemStack[][][] structure = new ItemStack[7][3][3]; - static{ - for(int h=0;h<7;h++) - for(int l=0;l<3;l++) - for(int w=0;w<3;w++) + + static + { + for(int h = 0; h < 7; h++) + for(int l = 0; l < 3; l++) + for(int w = 0; w < 3; w++) { if(h==0) { if((l==0||l==2)&&(w==0||w==2)) - structure[h][l][w]=new ItemStack(IEContent.blockWoodenDecoration,1,BlockTypes_WoodenDecoration.FENCE.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockWoodenDecoration, 1, BlockTypes_WoodenDecoration.FENCE.getMeta()); else if(l==1&&w==1) - structure[h][l][w]=new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.IRON.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.IRON.getMeta()); } - else if(h<1||h>5 || w!=1||l!=1) - structure[h][l][w]=new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.IRON.getMeta()); + else if(h < 1||h > 5||w!=1||l!=1) + structure[h][l][w] = new ItemStack(IEContent.blockSheetmetal, 1, BlockTypes_MetalsAll.IRON.getMeta()); } } + @Override public ItemStack[][][] getStructureManual() { return structure; } + @Override @SideOnly(Side.CLIENT) public boolean overwriteBlockRender(ItemStack stack, int iterator) { return false; } + @Override public float getManualScale() { return 10; } + @Override @SideOnly(Side.CLIENT) public boolean canRenderFormedStructure() { return true; } + //@SideOnly(Side.CLIENT) static ItemStack renderStack = ItemStack.EMPTY; + @Override @SideOnly(Side.CLIENT) public void renderFormedStructure() { if(renderStack.isEmpty()) - renderStack = new ItemStack(IEContent.blockMetalMultiblock,1,BlockTypes_MetalMultiblock.SILO.getMeta()); + renderStack = new ItemStack(IEContent.blockMetalMultiblock, 1, BlockTypes_MetalMultiblock.SILO.getMeta()); GlStateManager.translate(2, 2.5, 1); GlStateManager.rotate(-45, 0, 1, 0); GlStateManager.rotate(-20, 1, 0, 0); - GlStateManager.scale(8,8,8); + GlStateManager.scale(8, 8, 8); ClientUtils.mc().getRenderItem().renderItem(renderStack, ItemCameraTransforms.TransformType.GUI); } @@ -93,11 +101,11 @@ public String getUniqueName() { return "IE:Silo"; } - + @Override public boolean isBlockTrigger(IBlockState state) { - return Utils.compareToOreName(new ItemStack(state.getBlock(),1,state.getBlock().getMetaFromState(state)), "blockSheetmetalIron"); + return Utils.compareToOreName(new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)), "blockSheetmetalIron"); } @Override @@ -105,17 +113,17 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit { EnumFacing f = EnumFacing.fromAngle(player.rotationYaw); pos = pos.offset(f); - if(!(Utils.isOreBlockAt(world, pos.offset(f,-1).offset(f.rotateY()), "fenceTreatedWood") && Utils.isOreBlockAt(world, pos.offset(f,-1).offset(f.rotateYCCW()), "fenceTreatedWood"))) - for(int i=0; i<6; i++) - if(Utils.isOreBlockAt(world, pos.add(0,-i,0).offset(f,-1).offset(f.rotateY()), "fenceTreatedWood") && Utils.isOreBlockAt(world, pos.add(0,-i,0).offset(f,-1).offset(f.rotateYCCW()), "fenceTreatedWood")) + if(!(Utils.isOreBlockAt(world, pos.offset(f, -1).offset(f.rotateY()), "fenceTreatedWood")&&Utils.isOreBlockAt(world, pos.offset(f, -1).offset(f.rotateYCCW()), "fenceTreatedWood"))) + for(int i = 0; i < 6; i++) + if(Utils.isOreBlockAt(world, pos.add(0, -i, 0).offset(f, -1).offset(f.rotateY()), "fenceTreatedWood")&&Utils.isOreBlockAt(world, pos.add(0, -i, 0).offset(f, -1).offset(f.rotateYCCW()), "fenceTreatedWood")) { - pos = pos.add(0,-i,0); + pos = pos.add(0, -i, 0); break; } - for(int h=0;h<=6;h++) - for(int xx=-1;xx<=1;xx++) - for(int zz=-1;zz<=1;zz++) + for(int h = 0; h <= 6; h++) + for(int xx = -1; xx <= 1; xx++) + for(int zz = -1; zz <= 1; zz++) if(h==0) { if(Math.abs(xx)==1&&Math.abs(zz)==1) @@ -129,7 +137,7 @@ else if(xx==0&&zz==0) } else { - if(h<6 && xx==0&&zz==0) + if(h < 6&&xx==0&&zz==0) { if(!world.isAirBlock(pos.add(xx, h, zz))) return false; @@ -140,28 +148,28 @@ else if(!Utils.isOreBlockAt(world, pos.add(xx, h, zz), "blockSheetmetalIron")) IBlockState state = IEContent.blockMetalMultiblock.getStateFromMeta(BlockTypes_MetalMultiblock.SILO.getMeta()); state = state.withProperty(IEProperties.FACING_HORIZONTAL, f.getOpposite()); - for(int h=0;h<=6;h++) - for(int l=-1;l<=1;l++) - for(int w=-1;w<=1;w++) + for(int h = 0; h <= 6; h++) + for(int l = -1; l <= 1; l++) + for(int w = -1; w <= 1; w++) { - if(h==0 && !((l==0&&w==0)||(Math.abs(l)==1&&Math.abs(w)==1))) + if(h==0&&!((l==0&&w==0)||(Math.abs(l)==1&&Math.abs(w)==1))) continue; - if(h>0&&h<6 && l==0&&w==0) + if(h > 0&&h < 6&&l==0&&w==0) continue; - - int xx = f==EnumFacing.EAST?l: f==EnumFacing.WEST?-l: f==EnumFacing.NORTH?-w:w; - int zz = f==EnumFacing.NORTH?l: f==EnumFacing.SOUTH?-l: f==EnumFacing.EAST?w:-w; + + int xx = f==EnumFacing.EAST?l: f==EnumFacing.WEST?-l: f==EnumFacing.NORTH?-w: w; + int zz = f==EnumFacing.NORTH?l: f==EnumFacing.SOUTH?-l: f==EnumFacing.EAST?w: -w; world.setBlockState(pos.add(xx, h, zz), state); BlockPos pos2 = pos.add(xx, h, zz); TileEntity curr = world.getTileEntity(pos2); if(curr instanceof TileEntitySilo) { - TileEntitySilo currTank = (TileEntitySilo) curr; - currTank.offset=new int[]{xx,h,zz}; - currTank.pos = h*9 + (l+1)*3 + (w+1); - currTank.formed=true; - currTank.offset=new int[]{xx,h,zz}; + TileEntitySilo currTank = (TileEntitySilo)curr; + currTank.offset = new int[]{xx, h, zz}; + currTank.pos = h*9+(l+1)*3+(w+1); + currTank.formed = true; + currTank.offset = new int[]{xx, h, zz}; currTank.markDirty(); world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0); } @@ -170,6 +178,7 @@ else if(!Utils.isOreBlockAt(world, pos.add(xx, h, zz), "blockSheetmetalIron")) } static final IngredientStack[] materials = new IngredientStack[]{new IngredientStack("fenceTreatedWood", 4), new IngredientStack("blockSheetmetalIron", 50)}; + @Override public IngredientStack[] getTotalMaterials() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockSqueezer.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockSqueezer.java index b5c2cbf252..4c729fd986 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockSqueezer.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/MultiblockSqueezer.java @@ -35,34 +35,36 @@ public class MultiblockSqueezer implements IMultiblock public static MultiblockSqueezer instance = new MultiblockSqueezer(); static ItemStack[][][] structure = new ItemStack[3][3][3]; - static{ - for(int h=0;h<3;h++) - for(int l=0;l<3;l++) - for(int w=0;w<3;w++) + + static + { + for(int h = 0; h < 3; h++) + for(int l = 0; l < 3; l++) + for(int w = 0; w < 3; w++) if(h==0) { if(l==0&&w==0) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); - else if(l==1 && w>0) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDevice1,1,BlockTypes_MetalDevice1.FLUID_PIPE.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + else if(l==1&&w > 0) + structure[h][l][w] = new ItemStack(IEContent.blockMetalDevice1, 1, BlockTypes_MetalDevice1.FLUID_PIPE.getMeta()); else - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta()); } else if(h==1) { if(l==0&&w==0) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta()); else if(l==0&&w==2) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); - else if(l>0 && w<2) - structure[h][l][w] = new ItemStack(IEContent.blockWoodenDevice0,1, BlockTypes_WoodenDevice0.BARREL.getMeta()); + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta()); + else if(l > 0&&w < 2) + structure[h][l][w] = new ItemStack(IEContent.blockWoodenDevice0, 1, BlockTypes_WoodenDevice0.BARREL.getMeta()); } else if(h==2) { if(l==1&&w==1) structure[h][l][w] = new ItemStack(Blocks.PISTON); - else if(l>0&&w<2) - structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_FENCE.getMeta()); + else if(l > 0&&w < 2) + structure[h][l][w] = new ItemStack(IEContent.blockMetalDecoration1, 1, BlockTypes_MetalDecoration1.STEEL_FENCE.getMeta()); } } @@ -71,6 +73,7 @@ public ItemStack[][][] getStructureManual() { return structure; } + @Override @SideOnly(Side.CLIENT) public boolean overwriteBlockRender(ItemStack stack, int iterator) @@ -87,25 +90,29 @@ public boolean overwriteBlockRender(ItemStack stack, int iterator) } return false; } + @Override public float getManualScale() { return 13; } + @Override @SideOnly(Side.CLIENT) public boolean canRenderFormedStructure() { return true; } + //@SideOnly(Side.CLIENT) static ItemStack renderStack = ItemStack.EMPTY; + @Override @SideOnly(Side.CLIENT) public void renderFormedStructure() { if(renderStack.isEmpty()) - renderStack = new ItemStack(IEContent.blockMetalMultiblock,1,BlockTypes_MetalMultiblock.SQUEEZER.getMeta()); + renderStack = new ItemStack(IEContent.blockMetalMultiblock, 1, BlockTypes_MetalMultiblock.SQUEEZER.getMeta()); GlStateManager.translate(1.5, 1.5, 1.5); GlStateManager.rotate(-45, 0, 1, 0); GlStateManager.rotate(-20, 1, 0, 0); @@ -124,7 +131,7 @@ public String getUniqueName() @Override public boolean isBlockTrigger(IBlockState state) { - return state.getBlock()==IEContent.blockWoodenDevice0 && (state.getBlock().getMetaFromState(state)==BlockTypes_WoodenDevice0.BARREL.getMeta()); + return state.getBlock()==IEContent.blockWoodenDevice0&&(state.getBlock().getMetaFromState(state)==BlockTypes_WoodenDevice0.BARREL.getMeta()); } @Override @@ -146,14 +153,14 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit IBlockState state = IEContent.blockMetalMultiblock.getStateFromMeta(BlockTypes_MetalMultiblock.SQUEEZER.getMeta()); state = state.withProperty(IEProperties.FACING_HORIZONTAL, side); - for(int h=-1;h<=1;h++) - for(int l=-1;l<=1;l++) - for(int w=-1;w<=1;w++) + for(int h = -1; h <= 1; h++) + for(int l = -1; l <= 1; l++) + for(int w = -1; w <= 1; w++) { - if((h==0&&w==0&&l==-1)||(h==0&&w==1&&l>-1)||(h==1&&(l<0||w>0))) + if((h==0&&w==0&&l==-1)||(h==0&&w==1&&l > -1)||(h==1&&(l < 0||w > 0))) continue; - int ww = mirror?-w:w; + int ww = mirror?-w: w; BlockPos pos2 = pos.offset(side, l).offset(side.rotateY(), ww).add(0, h, 0); world.setBlockState(pos2, state); @@ -161,10 +168,10 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit if(curr instanceof TileEntitySqueezer) { TileEntitySqueezer tile = (TileEntitySqueezer)curr; - tile.formed=true; - tile.pos = (h+1)*9 + (l+1)*3 + (w+1); - tile.offset = new int[]{(side==EnumFacing.WEST?-l: side==EnumFacing.EAST?l: side==EnumFacing.NORTH?ww: -ww),h,(side==EnumFacing.NORTH?-l: side==EnumFacing.SOUTH?l: side==EnumFacing.EAST?ww : -ww)}; - tile.mirrored=mirror; + tile.formed = true; + tile.pos = (h+1)*9+(l+1)*3+(w+1); + tile.offset = new int[]{(side==EnumFacing.WEST?-l: side==EnumFacing.EAST?l: side==EnumFacing.NORTH?ww: -ww), h, (side==EnumFacing.NORTH?-l: side==EnumFacing.SOUTH?l: side==EnumFacing.EAST?ww: -ww)}; + tile.mirrored = mirror; tile.markDirty(); world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0); } @@ -174,14 +181,14 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit boolean structureCheck(World world, BlockPos startPos, EnumFacing dir, boolean mirror) { - for(int h=-1;h<=1;h++) - for(int l=-1;l<=1;l++) - for(int w=-1;w<=1;w++) + for(int h = -1; h <= 1; h++) + for(int l = -1; l <= 1; l++) + for(int w = -1; w <= 1; w++) { - if((h==0&&w==0&&l==-1)||(h==0&&w==1&&l>-1)||(h==1&&(l<0||w>0))) + if((h==0&&w==0&&l==-1)||(h==0&&w==1&&l > -1)||(h==1&&(l < 0||w > 0))) continue; - int ww = mirror?-w:w; + int ww = mirror?-w: w; BlockPos pos = startPos.offset(dir, l).offset(dir.rotateY(), ww).add(0, h, 0); if(h==-1) @@ -191,7 +198,7 @@ boolean structureCheck(World world, BlockPos startPos, EnumFacing dir, boolean m if(!Utils.isBlockAt(world, pos, IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())) return false; } - else if(l==0 && w>-1) + else if(l==0&&w > -1) { if(!Utils.isBlockAt(world, pos, IEContent.blockMetalDevice1, BlockTypes_MetalDevice1.FLUID_PIPE.getMeta())) return false; @@ -214,7 +221,7 @@ else if(l==-1&&w==1) if(!Utils.isBlockAt(world, pos, IEContent.blockMetalDecoration0, BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta())) return false; } - else if(l>-1 && w<1) + else if(l > -1&&w < 1) { if(!Utils.isBlockAt(world, pos, IEContent.blockWoodenDevice0, BlockTypes_WoodenDevice0.BARREL.getMeta())) return false; @@ -227,7 +234,7 @@ else if(h==1) if(!Utils.isBlockAt(world, pos, Blocks.PISTON, -1)) return false; } - else if(l>-1&&w<1) + else if(l > -1&&w < 1) { if(!Utils.isOreBlockAt(world, pos, "fenceSteel")) return false; @@ -245,6 +252,7 @@ else if(l>-1&&w<1) new IngredientStack(new ItemStack(IEContent.blockWoodenDevice0, 4, BlockTypes_WoodenDevice0.BARREL.getMeta())), new IngredientStack(new ItemStack(Blocks.PISTON)), new IngredientStack("fenceSteel", 3)}; + @Override public IngredientStack[] getTotalMaterials() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/package-info.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/package-info.java index fc11ad52b7..7832319ba3 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/package-info.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/multiblocks/package-info.java @@ -3,4 +3,5 @@ package blusunrize.immersiveengineering.common.blocks.multiblocks; import mcp.MethodsReturnNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/package-info.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/package-info.java index 3f14c0e819..4392df9775 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/package-info.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/package-info.java @@ -3,4 +3,5 @@ package blusunrize.immersiveengineering.common.blocks; import mcp.MethodsReturnNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/plant/BlockIECrop.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/plant/BlockIECrop.java index d53e37b0a6..a4b38b60b3 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/plant/BlockIECrop.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/plant/BlockIECrop.java @@ -71,38 +71,45 @@ public String getIEBlockName() { return this.name; } + @Override public Enum[] getMetaEnums() { return enumValues; } + @Override public IBlockState getInventoryState(int meta) { IBlockState state = this.blockState.getBaseState().withProperty(this.property, enumValues[meta]); return state; } + @Override public IProperty getMetaProperty() { return this.property; } + @Override public boolean useCustomStateMapper() { return false; } + @Override public String getCustomStateMapping(int meta, boolean itemBlock) { return null; } + @Override @SideOnly(Side.CLIENT) public StateMapperBase getCustomMapper() { return null; } + @Override public boolean appendPropertiesToState() { @@ -111,7 +118,7 @@ public boolean appendPropertiesToState() protected static Material setTempProperties(Material material, PropertyEnum property) { - tempProperties=new IProperty[1]; + tempProperties = new IProperty[1]; tempProperties[0] = property; return material; } @@ -122,6 +129,7 @@ protected BlockStateContainer createNotTempBlockState() array[0] = this.property; return new BlockStateContainer(this, array); } + protected IBlockState getInitDefaultState() { IBlockState state = this.blockState.getBaseState().withProperty(this.property, enumValues[0]); @@ -137,49 +145,56 @@ protected BlockStateContainer createBlockState() { return this.property!=null?createNotTempBlockState(): new BlockStateContainer(this, tempProperties); } + @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { super.onBlockPlacedBy(worldIn, pos, state, placer, stack); } + @Override public int getMetaFromState(IBlockState state) { return state.getValue(this.property).getMeta(); } + @Override public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) { return state; } + @Override public IBlockState getStateFromMeta(int meta) { IBlockState state = this.getDefaultState().withProperty(this.property, fromMeta(meta)); return state; } + protected E fromMeta(int meta) { - if(meta<0||meta>=enumValues.length) + if(meta < 0||meta >= enumValues.length) meta = 0; return enumValues[meta]; } public int getMinMeta(int meta) { - return meta<=4?0:5; + return meta <= 4?0: 5; } + public int getMaxMeta(int meta) { - return meta<=4?4:5; + return meta <= 4?4: 5; } + @Override public boolean canBlockStay(World world, BlockPos pos, IBlockState state) { boolean b = super.canBlockStay(world, pos, state); if(this.getMetaFromState(state)==5) { - IBlockState stateBelow = world.getBlockState(pos.add(0,-1,0)); + IBlockState stateBelow = world.getBlockState(pos.add(0, -1, 0)); b = stateBelow.getBlock().equals(this)&&this.getMetaFromState(stateBelow)==getMaxMeta(0); } return b; @@ -188,7 +203,7 @@ public boolean canBlockStay(World world, BlockPos pos, IBlockState state) @Override protected boolean canSustainBush(IBlockState state) { - return state.getBlock() == Blocks.FARMLAND; + return state.getBlock()==Blocks.FARMLAND; } @Override @@ -197,77 +212,81 @@ public EnumPlantType getPlantType(net.minecraft.world.IBlockAccess world, BlockP return EnumPlantType.Crop; } - static final AxisAlignedBB box0 = new AxisAlignedBB(0,0,0, 1,.375f,1); - static final AxisAlignedBB box1 = new AxisAlignedBB(0,0,0, 1,.625f,1); - static final AxisAlignedBB box2 = new AxisAlignedBB(0,0,0, 1,.875f,1); + static final AxisAlignedBB box0 = new AxisAlignedBB(0, 0, 0, 1, .375f, 1); + static final AxisAlignedBB box1 = new AxisAlignedBB(0, 0, 0, 1, .625f, 1); + static final AxisAlignedBB box2 = new AxisAlignedBB(0, 0, 0, 1, .875f, 1); + @Override public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World world, BlockPos pos) { int meta = this.getMetaFromState(world.getBlockState(pos)); return meta==0?box0: meta==1?box1: meta==2?box2: FULL_BLOCK_AABB; } + @Override public void getDrops(NonNullList drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { int meta = this.getMetaFromState(state); - if(meta>=4) + if(meta >= 4) { - for (int i=0; i<3+fortune; ++i) + for(int i = 0; i < 3+fortune; ++i) if(Utils.RAND.nextInt(8) <= meta) - drops.add(new ItemStack(IEContent.itemMaterial,1,4)); - drops.add(new ItemStack(IEContent.itemSeeds,1,0)); + drops.add(new ItemStack(IEContent.itemMaterial, 1, 4)); + drops.add(new ItemStack(IEContent.itemSeeds, 1, 0)); } } + @Override - public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos block) + public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos block) { - super.onNeighborChange(world, pos, block); - if(this.getMetaFromState(world.getBlockState(pos))= 12) { int meta = this.getMetaFromState(state); - if(meta>4) + if(meta > 4) return; float growth = this.getGrowthSpeed(world, pos, state, light); - if(random.nextInt((int)(50F/growth)+1) == 0) + if(random.nextInt((int)(50F/growth)+1)==0) { - if(this.getMaxMeta(meta) != meta) + if(this.getMaxMeta(meta)!=meta) { meta++; world.setBlockState(pos, this.getStateFromMeta(meta)); } - if(meta>3 && world.isAirBlock(pos.add(0,1,0))) - world.setBlockState(pos.add(0,1,0), this.getStateFromMeta(meta+1)); + if(meta > 3&&world.isAirBlock(pos.add(0, 1, 0))) + world.setBlockState(pos.add(0, 1, 0), this.getStateFromMeta(meta+1)); } } } + float getGrowthSpeed(World world, BlockPos pos, IBlockState sate, int light) { - float growth = 0.125f * (light - 11); + float growth = 0.125f*(light-11); if(world.canBlockSeeSky(pos)) growth += 2f; - IBlockState soil = world.getBlockState(pos.add(0,-1,0)); - if(soil.getBlock().isFertile(world,pos.add(0,-1,0))) + IBlockState soil = world.getBlockState(pos.add(0, -1, 0)); + if(soil.getBlock().isFertile(world, pos.add(0, -1, 0))) growth *= 1.5f; - return 1f + growth; + return 1f+growth; } @Override public boolean canPlaceBlockAt(World worldIn, BlockPos pos) { IBlockState soil = worldIn.getBlockState(pos.down()); - return super.canPlaceBlockAt(worldIn, pos) && soil.getBlock().canSustainPlant(soil, worldIn, pos.down(), net.minecraft.util.EnumFacing.UP, this); + return super.canPlaceBlockAt(worldIn, pos)&&soil.getBlock().canSustainPlant(soil, worldIn, pos.down(), net.minecraft.util.EnumFacing.UP, this); } //isNotGrown @@ -275,26 +294,28 @@ public boolean canPlaceBlockAt(World worldIn, BlockPos pos) public boolean canGrow(World world, BlockPos pos, IBlockState state, boolean isClient) { int meta = this.getMetaFromState(state); - if(meta { public BlockStoneDevice() { - super("stone_device",Material.ROCK, PropertyEnum.create("type", BlockTypes_StoneDevices.class), ItemBlockIEBase.class, IEProperties.BOOLEANS[0]); + super("stone_device", Material.ROCK, PropertyEnum.create("type", BlockTypes_StoneDevices.class), ItemBlockIEBase.class, IEProperties.BOOLEANS[0]); setHardness(2.0F); setResistance(20f); this.setAllNotNormalBlock(); @@ -50,15 +50,16 @@ public boolean isSideSolid(IBlockState state, IBlockAccess world, BlockPos pos, { TileEntity te = world.getTileEntity(pos); if(te instanceof TileEntityBlastFurnaceAdvanced) - return ((TileEntityBlastFurnaceAdvanced)te).pos==1 || ((TileEntityBlastFurnaceAdvanced)te).pos==4 || ((TileEntityBlastFurnaceAdvanced)te).pos==7 || (((TileEntityBlastFurnaceAdvanced)te).pos==31); + return ((TileEntityBlastFurnaceAdvanced)te).pos==1||((TileEntityBlastFurnaceAdvanced)te).pos==4||((TileEntityBlastFurnaceAdvanced)te).pos==7||(((TileEntityBlastFurnaceAdvanced)te).pos==31); return true; } - private static final AxisAlignedBB AABB_CARPET = new AxisAlignedBB(0,0,0, 1,.0625,1); - private static final AxisAlignedBB AABB_QUARTER = new AxisAlignedBB(0,0,0, 1,.25,1); - private static final AxisAlignedBB AABB_THREEQUARTER = new AxisAlignedBB(0,0,0, 1,.75,1); - private static final AxisAlignedBB AABB_CORESAMPLE_X = new AxisAlignedBB(0,0,.28125f, 1,1,.71875f); - private static final AxisAlignedBB AABB_CORESAMPLE_Z = new AxisAlignedBB(.28125f,0,0, .71875f,1,1); + private static final AxisAlignedBB AABB_CARPET = new AxisAlignedBB(0, 0, 0, 1, .0625, 1); + private static final AxisAlignedBB AABB_QUARTER = new AxisAlignedBB(0, 0, 0, 1, .25, 1); + private static final AxisAlignedBB AABB_THREEQUARTER = new AxisAlignedBB(0, 0, 0, 1, .75, 1); + private static final AxisAlignedBB AABB_CORESAMPLE_X = new AxisAlignedBB(0, 0, .28125f, 1, 1, .71875f); + private static final AxisAlignedBB AABB_CORESAMPLE_Z = new AxisAlignedBB(.28125f, 0, 0, .71875f, 1, 1); + @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { @@ -72,8 +73,8 @@ else if(meta==BlockTypes_StoneDevices.CONCRETE_THREEQUARTER) else if(meta==BlockTypes_StoneDevices.CORESAMPLE) { TileEntity te = world.getTileEntity(pos); - if(te!=null && te instanceof TileEntityCoresample) - return ((TileEntityCoresample)te).facing.getAxis()==Axis.Z?AABB_CORESAMPLE_Z:AABB_CORESAMPLE_X; + if(te!=null&&te instanceof TileEntityCoresample) + return ((TileEntityCoresample)te).facing.getAxis()==Axis.Z?AABB_CORESAMPLE_Z: AABB_CORESAMPLE_X; } return super.getBoundingBox(state, world, pos); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/BlockTypes_StoneDecoration.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/BlockTypes_StoneDecoration.java index 93316a2467..b66abca92f 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/BlockTypes_StoneDecoration.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/BlockTypes_StoneDecoration.java @@ -26,17 +26,19 @@ public enum BlockTypes_StoneDecoration implements IStringSerializable, BlockIEBa INSULATING_GLASS, CONCRETE_SPRAYED, ALLOYBRICK; - + @Override public String getName() { return this.toString().toLowerCase(Locale.ENGLISH); } + @Override public int getMeta() { return ordinal(); } + @Override public boolean listForCreative() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/BlockTypes_StoneDevices.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/BlockTypes_StoneDevices.java index 38b60b3676..79135ed77f 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/BlockTypes_StoneDevices.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/BlockTypes_StoneDevices.java @@ -29,14 +29,16 @@ public String getName() { return this.toString().toLowerCase(Locale.ENGLISH); } + @Override public int getMeta() { return ordinal(); } + @Override public boolean listForCreative() { - return ordinal()>2&&ordinal()<6; + return ordinal() > 2&&ordinal() < 6; } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/TileEntityAlloySmelter.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/TileEntityAlloySmelter.java index eb34741062..395bce56df 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/TileEntityAlloySmelter.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/TileEntityAlloySmelter.java @@ -48,26 +48,31 @@ public TileEntityAlloySmelter() { super(size); } + @Override public PropertyBoolInverted getBoolProperty(Class inf) { - return inf==IActiveState.class?IEProperties.BOOLEANS[0]:null; + return inf==IActiveState.class?IEProperties.BOOLEANS[0]: null; } + @Override public boolean getIsActive() { return this.active; } + @Override public boolean canOpenGui() { return formed; } + @Override public int getGuiID() { return Lib.GUIID_AlloySmelter; } + @Override public TileEntity getGuiMaster() { @@ -83,7 +88,7 @@ public float[] getBlockBounds() @Override public ItemStack getOriginalBlock() { - return new ItemStack(IEContent.blockStoneDecoration,1,BlockTypes_StoneDecoration.ALLOYBRICK.getMeta()); + return new ItemStack(IEContent.blockStoneDecoration, 1, BlockTypes_StoneDecoration.ALLOYBRICK.getMeta()); } @Override @@ -100,20 +105,20 @@ public void update() { boolean a = active; - if(burnTime>0) + if(burnTime > 0) { boolean doneWork = false; - if(process>0) + if(process > 0) { if(inventory.get(0).isEmpty()||inventory.get(1).isEmpty()) { - process=0; - processMax=0; + process = 0; + processMax = 0; } else { AlloyRecipe recipe = getRecipe(); - if (recipe!=null&&recipe.time!=processMax) + if(recipe!=null&&recipe.time!=processMax) { processMax = 0; process = 0; @@ -123,7 +128,7 @@ public void update() { process--; doneWork = true; - if (!active) + if(!active) active = true; } } @@ -131,42 +136,42 @@ public void update() } burnTime--; - if(process<=0) + if(process <= 0) { - if(processMax>0) + if(processMax > 0) { AlloyRecipe recipe = getRecipe(); if(recipe!=null) { boolean flip = !recipe.input0.matchesItemStack(inventory.get(0)); - Utils.modifyInvStackSize(inventory, flip?1:0, -recipe.input0.inputSize); - Utils.modifyInvStackSize(inventory, flip?0:1, -recipe.input1.inputSize); + Utils.modifyInvStackSize(inventory, flip?1: 0, -recipe.input0.inputSize); + Utils.modifyInvStackSize(inventory, flip?0: 1, -recipe.input1.inputSize); if(!inventory.get(3).isEmpty()) inventory.get(3).grow(recipe.output.copy().getCount()); else inventory.set(3, recipe.output.copy()); } - processMax=0; + processMax = 0; } AlloyRecipe recipe = getRecipe(); if(recipe!=null) { - this.process=recipe.time; - if (!doneWork) + this.process = recipe.time; + if(!doneWork) process--; - this.processMax=recipe.time; - this.active=true; + this.processMax = recipe.time; + this.active = true; } } } else { if(active) - active=false; + active = false; } - if(burnTime<=10 && getRecipe()!=null) + if(burnTime <= 10&&getRecipe()!=null) { ItemStack fuel = inventory.get(2); if(TileEntityFurnace.isItemFuel(fuel)) @@ -186,27 +191,28 @@ public void update() this.markDirty(); TileEntity tileEntity; - for(int yy=-1;yy<=1;yy++) - for(int xx=-1;xx<=1;xx++) - for(int zz=-1;zz<=1;zz++) + for(int yy = -1; yy <= 1; yy++) + for(int xx = -1; xx <= 1; xx++) + for(int zz = -1; zz <= 1; zz++) { tileEntity = Utils.getExistingTileEntity(world, getPos().add(xx, yy, zz)); - if (tileEntity != null) + if(tileEntity!=null) tileEntity.markDirty(); markBlockForUpdate(getPos().add(xx, yy, zz), null); - world.addBlockEvent(getPos().add(xx, yy, zz), IEContent.blockStoneDevice, 1, active ? 1 : 0); + world.addBlockEvent(getPos().add(xx, yy, zz), IEContent.blockStoneDevice, 1, active?1: 0); } } } } + public AlloyRecipe getRecipe() { - if(inventory.get(0).isEmpty() || inventory.get(1).isEmpty()) + if(inventory.get(0).isEmpty()||inventory.get(1).isEmpty()) return null; AlloyRecipe recipe = AlloyRecipe.findRecipe(inventory.get(0), inventory.get(1)); if(recipe==null) return null; - if(inventory.get(3).isEmpty() || (OreDictionary.itemMatches(inventory.get(3),recipe.output,true) && inventory.get(3).getCount() + recipe.output.getCount() <=getSlotLimit(3))) + if(inventory.get(3).isEmpty()||(OreDictionary.itemMatches(inventory.get(3), recipe.output, true)&&inventory.get(3).getCount()+recipe.output.getCount() <= getSlotLimit(3))) return recipe; return null; } @@ -215,15 +221,16 @@ public AlloyRecipe getRecipe() public int[] getCurrentProcessesStep() { TileEntityAlloySmelter master = master(); - if(master!=this && master!=null) + if(master!=this&&master!=null) return master.getCurrentProcessesStep(); return new int[]{processMax-process}; } + @Override public int[] getCurrentProcessesMax() { TileEntityAlloySmelter master = master(); - if(master!=this && master!=null) + if(master!=this&&master!=null) return master.getCurrentProcessesMax(); return new int[]{processMax}; } @@ -275,30 +282,36 @@ public NonNullList getInventory() { return this.inventory; } + @Override public boolean isStackValid(int slot, ItemStack stack) { return slot==0||slot==1&&TileEntityFurnace.isItemFuel(stack); } + @Override public int getSlotLimit(int slot) { return 64; } + @Override public void doGraphicalUpdates(int slot) { } + @Override protected IFluidTank[] getAccessibleFluidTanks(EnumFacing side) { return new FluidTank[0]; } + @Override protected boolean canFillTankFrom(int iTank, EnumFacing side, FluidStack resources) { return false; } + @Override protected boolean canDrainTankFrom(int iTank, EnumFacing side) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/TileEntityBlastFurnace.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/TileEntityBlastFurnace.java index 243e50fc3d..5db992a4d2 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/TileEntityBlastFurnace.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/TileEntityBlastFurnace.java @@ -43,32 +43,41 @@ public class TileEntityBlastFurnace extends TileEntityMultiblockPart inf) { - return inf==IActiveState.class?IEProperties.BOOLEANS[0]:null; + return inf==IActiveState.class?IEProperties.BOOLEANS[0]: null; } + @Override public boolean getIsActive() { return this.active; } + @Override public boolean canOpenGui() { return formed; } + @Override public int getGuiID() { return Lib.GUIID_BlastFurnace; } + @Override public TileEntity getGuiMaster() { @@ -84,7 +93,7 @@ public float[] getBlockBounds() @Override public ItemStack getOriginalBlock() { - return new ItemStack(IEContent.blockStoneDecoration,1,1); + return new ItemStack(IEContent.blockStoneDecoration, 1, 1); } @Override @@ -101,23 +110,23 @@ public void update() { boolean a = active; - if(burnTime>0) + if(burnTime > 0) { int processSpeed = 1; - if(process>0) + if(process > 0) processSpeed = getProcessSpeed(); - burnTime-=processSpeed; - if(process>0) + burnTime -= processSpeed; + if(process > 0) { if(inventory.get(0).isEmpty()) { - process=0; - processMax=0; + process = 0; + processMax = 0; } else { BlastFurnaceRecipe recipe = getRecipe(); - if (recipe!=null&&recipe.time!=processMax) + if(recipe!=null&&recipe.time!=processMax) { processMax = 0; process = 0; @@ -127,26 +136,26 @@ public void update() { process -= processSpeed; processSpeed = 0;//Process speed is "used up" - if (!active) + if(!active) active = true; } } markContainingBlockForUpdate(null); } - if(process<=0) + if(process <= 0) { - if(processMax>0) + if(processMax > 0) { BlastFurnaceRecipe recipe = getRecipe(); if(recipe!=null) { - Utils.modifyInvStackSize(inventory, 0, -(recipe.input instanceof ItemStack ? ((ItemStack) recipe.input).getCount() : 1)); + Utils.modifyInvStackSize(inventory, 0, -(recipe.input instanceof ItemStack?((ItemStack)recipe.input).getCount(): 1)); if(!inventory.get(2).isEmpty()) inventory.get(2).grow(recipe.output.copy().getCount()); else inventory.set(2, recipe.output.copy()); - if (!recipe.slag.isEmpty()) + if(!recipe.slag.isEmpty()) { if(!inventory.get(3).isEmpty()) inventory.get(3).grow(recipe.slag.copy().getCount()); @@ -154,25 +163,25 @@ public void update() inventory.set(3, recipe.slag.copy()); } } - processMax=0; + processMax = 0; burnTime -= process; } BlastFurnaceRecipe recipe = getRecipe(); if(recipe!=null) { - this.process=recipe.time - processSpeed; - this.processMax= recipe.time; - this.active=true; + this.process = recipe.time-processSpeed; + this.processMax = recipe.time; + this.active = true; } } } else { if(active) - active=false; + active = false; } - if(burnTime<=0 && getRecipe()!=null) + if(burnTime <= 0&&getRecipe()!=null) { if(BlastFurnaceRecipe.isValidBlastFuel(inventory.get(1))) { @@ -188,28 +197,29 @@ public void update() this.markDirty(); TileEntity tileEntity; - for(int yy=-1;yy<=1;yy++) - for(int xx=-1;xx<=1;xx++) - for(int zz=-1;zz<=1;zz++) + for(int yy = -1; yy <= 1; yy++) + for(int xx = -1; xx <= 1; xx++) + for(int zz = -1; zz <= 1; zz++) { tileEntity = Utils.getExistingTileEntity(world, getPos().add(xx, yy, zz)); - if (tileEntity != null) + if(tileEntity!=null) tileEntity.markDirty(); markBlockForUpdate(getPos().add(xx, yy, zz), null); - world.addBlockEvent(getPos().add(xx, yy, zz), IEContent.blockStoneDevice, 1, active ? 1 : 0); + world.addBlockEvent(getPos().add(xx, yy, zz), IEContent.blockStoneDevice, 1, active?1: 0); } } } } + @Nullable public BlastFurnaceRecipe getRecipe() { BlastFurnaceRecipe recipe = BlastFurnaceRecipe.findRecipe(inventory.get(0)); if(recipe==null) return null; - if((inventory.get(0).getCount() >= ((recipe.input instanceof ItemStack) ? ((ItemStack) recipe.input).getCount() : 1) - && inventory.get(2).isEmpty() || (OreDictionary.itemMatches(inventory.get(2),recipe.output,true) && inventory.get(2).getCount() + recipe.output.getCount() <=getSlotLimit(2)) ) - && (inventory.get(3).isEmpty() || (OreDictionary.itemMatches(inventory.get(3),recipe.slag,true) && inventory.get(3).getCount() + recipe.slag.getCount() <=getSlotLimit(3)) )) + if((inventory.get(0).getCount() >= ((recipe.input instanceof ItemStack)?((ItemStack)recipe.input).getCount(): 1) + &&inventory.get(2).isEmpty()||(OreDictionary.itemMatches(inventory.get(2), recipe.output, true)&&inventory.get(2).getCount()+recipe.output.getCount() <= getSlotLimit(2))) + &&(inventory.get(3).isEmpty()||(OreDictionary.itemMatches(inventory.get(3), recipe.slag, true)&&inventory.get(3).getCount()+recipe.slag.getCount() <= getSlotLimit(3)))) return recipe; return null; } @@ -223,15 +233,16 @@ protected int getProcessSpeed() public int[] getCurrentProcessesStep() { TileEntityBlastFurnace master = master(); - if(master!=this && master!=null) + if(master!=this&&master!=null) return master.getCurrentProcessesStep(); return new int[]{processMax-process}; } + @Override public int[] getCurrentProcessesMax() { TileEntityBlastFurnace master = master(); - if(master!=this && master!=null) + if(master!=this&&master!=null) return master.getCurrentProcessesMax(); return new int[]{processMax}; } @@ -289,30 +300,36 @@ public NonNullList getInventory() { return this.inventory; } + @Override public boolean isStackValid(int slot, ItemStack stack) { - return slot==0?BlastFurnaceRecipe.findRecipe(stack)!=null: slot == 1 && BlastFurnaceRecipe.isValidBlastFuel(stack); + return slot==0?BlastFurnaceRecipe.findRecipe(stack)!=null: slot==1&&BlastFurnaceRecipe.isValidBlastFuel(stack); } + @Override public int getSlotLimit(int slot) { return 64; } + @Override public void doGraphicalUpdates(int slot) { } + @Override protected IFluidTank[] getAccessibleFluidTanks(EnumFacing side) { return new FluidTank[0]; } + @Override protected boolean canFillTankFrom(int iTank, EnumFacing side, FluidStack resources) { return false; } + @Override protected boolean canDrainTankFrom(int iTank, EnumFacing side) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/TileEntityBlastFurnaceAdvanced.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/TileEntityBlastFurnaceAdvanced.java index 8ec69833c3..c27f968979 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/TileEntityBlastFurnaceAdvanced.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/TileEntityBlastFurnaceAdvanced.java @@ -25,16 +25,19 @@ public class TileEntityBlastFurnaceAdvanced extends TileEntityBlastFurnace { private static final int[] size = {4, 3, 3}; - public TileEntityBlastFurnaceAdvanced() { + + public TileEntityBlastFurnaceAdvanced() + { super(size); } + @Override public void update() { super.update(); - if(!world.isRemote && world.getTotalWorldTime()%8==0 && !isDummy()) + if(!world.isRemote&&world.getTotalWorldTime()%8==0&&!isDummy()) { - TileEntity inventoryFront = Utils.getExistingTileEntity(world, getPos().offset(facing,2).add(0,-1,0)); + TileEntity inventoryFront = Utils.getExistingTileEntity(world, getPos().offset(facing, 2).add(0, -1, 0)); if(!this.inventory.get(2).isEmpty()) { ItemStack stack = this.inventory.get(2); @@ -42,7 +45,7 @@ public void update() stack = Utils.insertStackIntoInventory(inventoryFront, stack, facing.getOpposite()); this.inventory.set(2, stack); } - TileEntity inventoryBack = Utils.getExistingTileEntity(world, getPos().offset(facing,-2).add(0,-1,0)); + TileEntity inventoryBack = Utils.getExistingTileEntity(world, getPos().offset(facing, -2).add(0, -1, 0)); if(!this.inventory.get(3).isEmpty()) { ItemStack stack = this.inventory.get(3); @@ -52,12 +55,12 @@ public void update() } } } - + @Override public float[] getBlockBounds() { - if(pos%9==4 || pos==1 || pos==10 || pos==31) - return new float[]{0,0,0,1,1,1}; + if(pos%9==4||pos==1||pos==10||pos==31) + return new float[]{0, 0, 0, 1, 1, 1}; float xMin = 0; float yMin = 0; @@ -68,55 +71,55 @@ public float[] getBlockBounds() if(pos==7) { - xMin = facing.getAxis()==Axis.Z?.1875f:0; - xMax = facing.getAxis()==Axis.Z?.8125f:1; - zMin = facing.getAxis()==Axis.X?.1875f:0; - zMax = facing.getAxis()==Axis.X?.8125f:1; + xMin = facing.getAxis()==Axis.Z?.1875f: 0; + xMax = facing.getAxis()==Axis.Z?.8125f: 1; + zMin = facing.getAxis()==Axis.X?.1875f: 0; + zMax = facing.getAxis()==Axis.X?.8125f: 1; yMax = .8125f; } else { float indent = 1; - if(pos<9) - indent = (pos>2&&pos<6)?.5f:.3125f; - else if(pos<18) + if(pos < 9) + indent = (pos > 2&&pos < 6)?.5f: .3125f; + else if(pos < 18) indent = .5f; - else if(pos<27) + else if(pos < 27) indent = .375f; - if((pos%9<3&&facing==EnumFacing.WEST)||(pos%9>5&&facing==EnumFacing.EAST)||(pos%3==2&&facing==EnumFacing.SOUTH)||(pos%3==0&&facing==EnumFacing.NORTH)) + if((pos%9 < 3&&facing==EnumFacing.WEST)||(pos%9 > 5&&facing==EnumFacing.EAST)||(pos%3==2&&facing==EnumFacing.SOUTH)||(pos%3==0&&facing==EnumFacing.NORTH)) xMin = (1-indent); - if((pos%9<3&&facing==EnumFacing.EAST)||(pos%9>5&&facing==EnumFacing.WEST)||(pos%3==2&&facing==EnumFacing.NORTH)||(pos%3==0&&facing==EnumFacing.SOUTH)) + if((pos%9 < 3&&facing==EnumFacing.EAST)||(pos%9 > 5&&facing==EnumFacing.WEST)||(pos%3==2&&facing==EnumFacing.NORTH)||(pos%3==0&&facing==EnumFacing.SOUTH)) xMax = indent; - if((pos%9<3&&facing==EnumFacing.SOUTH)||(pos%9>5&&facing==EnumFacing.NORTH)||(pos%3==2&&facing==EnumFacing.EAST)||(pos%3==0&&facing==EnumFacing.WEST)) + if((pos%9 < 3&&facing==EnumFacing.SOUTH)||(pos%9 > 5&&facing==EnumFacing.NORTH)||(pos%3==2&&facing==EnumFacing.EAST)||(pos%3==0&&facing==EnumFacing.WEST)) zMin = (1-indent); - if((pos%9<3&&facing==EnumFacing.NORTH)||(pos%9>5&&facing==EnumFacing.SOUTH)||(pos%3==2&&facing==EnumFacing.WEST)||(pos%3==0&&facing==EnumFacing.EAST)) + if((pos%9 < 3&&facing==EnumFacing.NORTH)||(pos%9 > 5&&facing==EnumFacing.SOUTH)||(pos%3==2&&facing==EnumFacing.WEST)||(pos%3==0&&facing==EnumFacing.EAST)) zMax = indent; } - return new float[]{xMin,yMin,zMin, xMax,yMax,zMax}; + return new float[]{xMin, yMin, zMin, xMax, yMax, zMax}; } @Override public ItemStack getOriginalBlock() { - if(this.pos == 31) + if(this.pos==31) return new ItemStack(Blocks.HOPPER); - return new ItemStack(IEContent.blockStoneDecoration,1,2); + return new ItemStack(IEContent.blockStoneDecoration, 1, 2); } @Override protected int getProcessSpeed() { int i = 1; - for(int j=0; j<2; j++) + for(int j = 0; j < 2; j++) { - EnumFacing phf = j==0?facing.rotateY():facing.rotateYCCW(); - BlockPos pos = getPos().add(0,-1,0).offset(phf,2); + EnumFacing phf = j==0?facing.rotateY(): facing.rotateYCCW(); + BlockPos pos = getPos().add(0, -1, 0).offset(phf, 2); TileEntity te = Utils.getExistingTileEntity(world, pos); if(te instanceof TileEntityBlastFurnacePreheater) { - if(((TileEntityBlastFurnacePreheater) te).facing==phf.getOpposite()) + if(((TileEntityBlastFurnacePreheater)te).facing==phf.getOpposite()) i += ((TileEntityBlastFurnacePreheater)te).doSpeedup(); } } @@ -129,19 +132,21 @@ public boolean hasCapability(Capability capability, EnumFacing facing) if((pos==1||pos==7||pos==31)&&capability==net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { TileEntityBlastFurnaceAdvanced master = (TileEntityBlastFurnaceAdvanced)master(); - if(master == null) + if(master==null) return false; - if(pos == 31 && facing == EnumFacing.UP) + if(pos==31&&facing==EnumFacing.UP) return true; - if(pos == 1 && facing == master.facing) + if(pos==1&&facing==master.facing) return true; - return pos == 7 && facing == master.facing.getOpposite(); + return pos==7&&facing==master.facing.getOpposite(); } return super.hasCapability(capability, facing); } - IItemHandler inputHandler = new IEInventoryHandler(2,this,0, new boolean[]{true,true},new boolean[]{false,false}); - IItemHandler outputHandler = new IEInventoryHandler(1,this,2, new boolean[]{false},new boolean[]{true}); - IItemHandler slagHandler = new IEInventoryHandler(1,this,3, new boolean[]{false},new boolean[]{true}); + + IItemHandler inputHandler = new IEInventoryHandler(2, this, 0, new boolean[]{true, true}, new boolean[]{false, false}); + IItemHandler outputHandler = new IEInventoryHandler(1, this, 2, new boolean[]{false}, new boolean[]{true}); + IItemHandler slagHandler = new IEInventoryHandler(1, this, 3, new boolean[]{false}, new boolean[]{true}); + @Override public T getCapability(Capability capability, EnumFacing facing) { @@ -150,11 +155,11 @@ public T getCapability(Capability capability, EnumFacing facing) TileEntityBlastFurnaceAdvanced master = (TileEntityBlastFurnaceAdvanced)master(); if(master==null) return null; - if(pos==31 && facing==EnumFacing.UP) + if(pos==31&&facing==EnumFacing.UP) return (T)master.inputHandler; - if(pos==1 && facing==master.facing) + if(pos==1&&facing==master.facing) return (T)master.outputHandler; - if(pos==7 && facing==master.facing.getOpposite()) + if(pos==7&&facing==master.facing.getOpposite()) return (T)master.slagHandler; return null; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/TileEntityCokeOven.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/TileEntityCokeOven.java index c91d7556d8..817f49db94 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/TileEntityCokeOven.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/TileEntityCokeOven.java @@ -44,29 +44,36 @@ public class TileEntityCokeOven extends TileEntityMultiblockPart inf) { - return inf==IActiveState.class?IEProperties.BOOLEANS[0]:null; + return inf==IActiveState.class?IEProperties.BOOLEANS[0]: null; } + @Override public boolean getIsActive() { return this.active; } + @Override public boolean canOpenGui() { return formed; } + @Override public int getGuiID() { return Lib.GUIID_CokeOven; } + @Override public TileEntity getGuiMaster() { @@ -82,7 +89,7 @@ public float[] getBlockBounds() @Override public ItemStack getOriginalBlock() { - return new ItemStack(IEContent.blockStoneDecoration,1,0); + return new ItemStack(IEContent.blockStoneDecoration, 1, 0); } @Override @@ -99,21 +106,21 @@ public void update() { boolean a = active; boolean b = false; - if(process>0) + if(process > 0) { if(inventory.get(0).isEmpty()) { - process=0; - processMax=0; + process = 0; + processMax = 0; } else { CokeOvenRecipe recipe = getRecipe(); - if(recipe==null || recipe.time!=processMax) + if(recipe==null||recipe.time!=processMax) { - process=0; - processMax=0; - active=false; + process = 0; + processMax = 0; + active = false; } else process--; @@ -132,26 +139,26 @@ public void update() inventory.get(1).grow(recipe.output.copy().getCount()); else if(inventory.get(1).isEmpty()) inventory.set(1, recipe.output.copy()); - this.tank.fill(new FluidStack(IEContent.fluidCreosote,recipe.creosoteOutput), true); + this.tank.fill(new FluidStack(IEContent.fluidCreosote, recipe.creosoteOutput), true); } - processMax=0; - active=false; + processMax = 0; + active = false; } CokeOvenRecipe recipe = getRecipe(); if(recipe!=null) { - this.process=recipe.time; - this.processMax=process; - this.active=true; + this.process = recipe.time; + this.processMax = process; + this.active = true; } } - if(tank.getFluidAmount()>0 && tank.getFluid()!=null && (inventory.get(3).isEmpty() || inventory.get(3).getCount() + 1<= inventory.get(3).getMaxStackSize())) + if(tank.getFluidAmount() > 0&&tank.getFluid()!=null&&(inventory.get(3).isEmpty()||inventory.get(3).getCount()+1 <= inventory.get(3).getMaxStackSize())) { ItemStack filledContainer = Utils.fillFluidContainer(tank, inventory.get(2), inventory.get(3), null); if(!filledContainer.isEmpty()) { - if(inventory.get(2).getCount()==1 && !Utils.isFluidContainerFull(filledContainer)) + if(inventory.get(2).getCount()==1&&!Utils.isFluidContainerFull(filledContainer)) { inventory.set(2, filledContainer.copy()); b = true; @@ -168,31 +175,32 @@ else if(inventory.get(3).isEmpty()) } } - if(a!=active || b) + if(a!=active||b) { this.markDirty(); TileEntity tileEntity; - for(int yy=-1;yy<=1;yy++) - for(int xx=-1;xx<=1;xx++) - for(int zz=-1;zz<=1;zz++) + for(int yy = -1; yy <= 1; yy++) + for(int xx = -1; xx <= 1; xx++) + for(int zz = -1; zz <= 1; zz++) { tileEntity = Utils.getExistingTileEntity(world, getPos().add(xx, yy, zz)); if(tileEntity!=null) tileEntity.markDirty(); this.markBlockForUpdate(getPos().add(xx, yy, zz), null); - world.addBlockEvent(getPos().add(xx, yy, zz), IEContent.blockStoneDevice, 1,active?1:0); + world.addBlockEvent(getPos().add(xx, yy, zz), IEContent.blockStoneDevice, 1, active?1: 0); } } } } + public CokeOvenRecipe getRecipe() { CokeOvenRecipe recipe = CokeOvenRecipe.findRecipe(inventory.get(0)); if(recipe==null) return null; - if(inventory.get(1).isEmpty() || (OreDictionary.itemMatches(inventory.get(1),recipe.output,false) && inventory.get(1).getCount() + recipe.output.getCount() <=getSlotLimit(1)) ) - if(tank.getFluidAmount()+recipe.creosoteOutput<=tank.getCapacity()) + if(inventory.get(1).isEmpty()||(OreDictionary.itemMatches(inventory.get(1), recipe.output, false)&&inventory.get(1).getCount()+recipe.output.getCount() <= getSlotLimit(1))) + if(tank.getFluidAmount()+recipe.creosoteOutput <= tank.getCapacity()) return recipe; return null; } @@ -201,15 +209,16 @@ public CokeOvenRecipe getRecipe() public int[] getCurrentProcessesStep() { TileEntityCokeOven master = master(); - if(master!=this && master!=null) + if(master!=this&&master!=null) return master.getCurrentProcessesStep(); return new int[]{processMax-process}; } + @Override public int[] getCurrentProcessesMax() { TileEntityCokeOven master = master(); - if(master!=this && master!=null) + if(master!=this&&master!=null) return master.getCurrentProcessesMax(); return new int[]{processMax}; } @@ -271,11 +280,13 @@ protected IFluidTank[] getAccessibleFluidTanks(EnumFacing side) return new FluidTank[]{master.tank}; return new FluidTank[0]; } + @Override protected boolean canFillTankFrom(int iTank, EnumFacing side, FluidStack resource) { return false; } + @Override protected boolean canDrainTankFrom(int iTank, EnumFacing side) { @@ -286,10 +297,11 @@ protected boolean canDrainTankFrom(int iTank, EnumFacing side) public NonNullList getInventory() { TileEntityCokeOven master = master(); - if (master!=null && master.formed && formed) + if(master!=null&&master.formed&&formed) return master.inventory; return this.inventory; } + @Override public boolean isStackValid(int slot, ItemStack stack) { @@ -301,11 +313,13 @@ public boolean isStackValid(int slot, ItemStack stack) return Utils.isFluidRelatedItemStack(stack); return false; } + @Override public int getSlotLimit(int slot) { return 64; } + @Override public void doGraphicalUpdates(int slot) { @@ -314,15 +328,17 @@ public void doGraphicalUpdates(int slot) @Override public boolean hasCapability(Capability capability, EnumFacing facing) { - if(capability== CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) + if(capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return master()!=null; return super.hasCapability(capability, facing); } - IItemHandler invHandler = new IEInventoryHandler(4,this,0, new boolean[]{true,false,true,false},new boolean[]{false,true,false,true}); + + IItemHandler invHandler = new IEInventoryHandler(4, this, 0, new boolean[]{true, false, true, false}, new boolean[]{false, true, false, true}); + @Override public T getCapability(Capability capability, EnumFacing facing) { - if(capability== CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) + if(capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { TileEntityCokeOven master = master(); if(master==null) diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/TileEntityCoresample.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/TileEntityCoresample.java index 0b06f8423e..a13337851f 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/TileEntityCoresample.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/TileEntityCoresample.java @@ -50,6 +50,7 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) coresample = new ItemStack(nbt.getCompoundTag("coresample")); facing = EnumFacing.getFront(nbt.getInteger("facing")); } + @Override public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { @@ -62,26 +63,31 @@ public EnumFacing getFacing() { return facing; } + @Override public void setFacing(EnumFacing facing) { this.facing = facing; } + @Override public int getFacingLimitation() { return 2; } + @Override public boolean mirrorFacingOnPlacement(EntityLivingBase placer) { return true; } + @Override public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) { return true; } + @Override public boolean canRotate(EnumFacing axis) { @@ -95,14 +101,14 @@ public boolean interact(EnumFacing side, EntityPlayer player, EnumHand hand, Ite { if(!getWorld().isRemote) { - EntityItem entityitem = new EntityItem(getWorld(), getPos().getX()+.5,getPos().getY()+.5,getPos().getZ()+.5, getTileDrop(player, getWorld().getBlockState(getPos()))); + EntityItem entityitem = new EntityItem(getWorld(), getPos().getX()+.5, getPos().getY()+.5, getPos().getZ()+.5, getTileDrop(player, getWorld().getBlockState(getPos()))); entityitem.setDefaultPickupDelay(); getWorld().setBlockToAir(getPos()); getWorld().spawnEntity(entityitem); } return true; } - else if(!heldItem.isEmpty() && heldItem.getItem()==Items.FILLED_MAP && ItemNBTHelper.hasKey(coresample, "coords")) + else if(!heldItem.isEmpty()&&heldItem.getItem()==Items.FILLED_MAP&&ItemNBTHelper.hasKey(coresample, "coords")) { if(!getWorld().isRemote) { @@ -140,7 +146,7 @@ else if(!heldItem.isEmpty() && heldItem.getItem()==Items.FILLED_MAP && ItemNBTHe @Nullable public ITextComponent getDisplayName() { - return coresample.hasDisplayName()?new TextComponentString(coresample.getDisplayName()) : new TextComponentTranslation("item.immersiveengineering.coresample.name"); + return coresample.hasDisplayName()?new TextComponentString(coresample.getDisplayName()): new TextComponentTranslation("item.immersiveengineering.coresample.name"); } @Override @@ -148,11 +154,13 @@ public ItemStack getTileDrop(EntityPlayer player, IBlockState state) { return this.coresample; } + @Override public void readOnPlacement(EntityLivingBase placer, ItemStack stack) { this.coresample = stack.copy(); } + @Override public boolean preventInventoryDrop() { @@ -160,10 +168,11 @@ public boolean preventInventoryDrop() } private String[] overlay = null; + @Override public String[] getOverlayText(EntityPlayer player, RayTraceResult mop, boolean hammer) { - if(coresample!=null && ItemNBTHelper.hasKey(coresample, "coords")) + if(coresample!=null&&ItemNBTHelper.hasKey(coresample, "coords")) { if(overlay==null) { @@ -196,6 +205,7 @@ public String[] getOverlayText(EntityPlayer player, RayTraceResult mop, boolean } return new String[0]; } + @Override public boolean useNixieFont(EntityPlayer player, RayTraceResult mop) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/package-info.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/package-info.java index 0f4c852cb4..2410107c54 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/package-info.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/stone/package-info.java @@ -3,4 +3,5 @@ package blusunrize.immersiveengineering.common.blocks.stone; import mcp.MethodsReturnNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/BlockTypes_TreatedWood.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/BlockTypes_TreatedWood.java index ace01d1f59..2bfdf8d2e3 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/BlockTypes_TreatedWood.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/BlockTypes_TreatedWood.java @@ -24,11 +24,13 @@ public String getName() { return this.toString().toLowerCase(Locale.ENGLISH); } + @Override public int getMeta() { return ordinal(); } + @Override public boolean listForCreative() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/BlockTypes_WoodenDecoration.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/BlockTypes_WoodenDecoration.java index e451282320..92ff6c456e 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/BlockTypes_WoodenDecoration.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/BlockTypes_WoodenDecoration.java @@ -23,11 +23,13 @@ public String getName() { return this.toString().toLowerCase(Locale.ENGLISH); } + @Override public int getMeta() { return ordinal(); } + @Override public boolean listForCreative() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/BlockTypes_WoodenDevice0.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/BlockTypes_WoodenDevice0.java index d4547f1c7a..31ca2ba436 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/BlockTypes_WoodenDevice0.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/BlockTypes_WoodenDevice0.java @@ -29,11 +29,13 @@ public String getName() { return this.toString().toLowerCase(Locale.ENGLISH); } + @Override public int getMeta() { return ordinal(); } + @Override public boolean listForCreative() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/BlockTypes_WoodenDevice1.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/BlockTypes_WoodenDevice1.java index c748e33e84..3dc54450b7 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/BlockTypes_WoodenDevice1.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/BlockTypes_WoodenDevice1.java @@ -26,11 +26,13 @@ public String getName() { return this.toString().toLowerCase(Locale.ENGLISH); } + @Override public int getMeta() { return ordinal(); } + @Override public boolean listForCreative() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/BlockWoodenDecoration.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/BlockWoodenDecoration.java index 809735a65e..589ef3105f 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/BlockWoodenDecoration.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/BlockWoodenDecoration.java @@ -36,7 +36,7 @@ public class BlockWoodenDecoration extends IELadderBlock=0 && !stack.isEmpty()) + if(explosivesType >= 0&&!stack.isEmpty()) { Item item = stack.getItem(); @@ -125,26 +127,29 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En this.doExplosion(world, pos, state, player, explosivesType); if(item==Items.FLINT_AND_STEEL) stack.damageItem(1, player); - else if (!player.capabilities.isCreativeMode) + else if(!player.capabilities.isCreativeMode) stack.shrink(1); return true; } } return super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ); } + @Override public boolean canDropFromExplosion(Explosion explosionIn) { isExploding = true; return super.canDropFromExplosion(explosionIn); } + @Override public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune) { - if(!isExploding || this.getExplosivesType(state)<0) + if(!isExploding||this.getExplosivesType(state) < 0) super.dropBlockAsItemWithChance(worldIn, pos, state, chance, fortune); isExploding = false; } + @Override public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion) { @@ -160,32 +165,35 @@ public void neighborChanged(IBlockState state, World world, BlockPos pos, Block // super.onNeighborChange(world, pos, neighbour); super.neighborChanged(state, world, pos, block, fromPos); int explosivesType = this.getExplosivesType(world.getBlockState(pos)); - if(world instanceof World && explosivesType>=0 && world.isBlockPowered(pos)) + if(world instanceof World&&explosivesType >= 0&&world.isBlockPowered(pos)) this.doExplosion(world, pos, world.getBlockState(pos), null, explosivesType); } + @Override public void onBlockAdded(World world, BlockPos pos, IBlockState state) { super.onBlockAdded(world, pos, state); int explosivesType = this.getExplosivesType(state); - if(explosivesType>=0 && world.isBlockPowered(pos)) + if(explosivesType >= 0&&world.isBlockPowered(pos)) this.doExplosion(world, pos, state, null, explosivesType); } + @Override public void onBlockExploded(World world, BlockPos pos, Explosion explosionIn) { int explosivesType = this.getExplosivesType(world.getBlockState(pos)); - if(explosivesType>=0) + if(explosivesType >= 0) this.doExplosion(world, pos, world.getBlockState(pos), null, explosivesType); super.onBlockExploded(world, pos, explosionIn); } + @Override public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) { super.onEntityCollidedWithBlock(world, pos, state, entity); int explosivesType = this.getExplosivesType(state); - if(!world.isRemote && entity instanceof EntityArrow && entity.isBurning() && explosivesType>=0) - this.doExplosion(world, pos, state, ((EntityArrow)entity).shootingEntity instanceof EntityLivingBase?(EntityLivingBase)((EntityArrow)entity).shootingEntity:null, explosivesType); + if(!world.isRemote&&entity instanceof EntityArrow&&entity.isBurning()&&explosivesType >= 0) + this.doExplosion(world, pos, state, ((EntityArrow)entity).shootingEntity instanceof EntityLivingBase?(EntityLivingBase)((EntityArrow)entity).shootingEntity: null, explosivesType); } // @Override diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/BlockWoodenDevice1.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/BlockWoodenDevice1.java index 809b895977..fb80a749c0 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/BlockWoodenDevice1.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/BlockWoodenDevice1.java @@ -34,7 +34,7 @@ public class BlockWoodenDevice1 extends BlockIETileProvider drops, IBlockAccess world, BlockPos return; super.getDrops(drops, world, pos, state, fortune); } + @Override public void breakBlock(World world, BlockPos pos, IBlockState state) { TileEntity tileEntity = world.getTileEntity(pos); if(tileEntity instanceof TileEntityWoodenPost) { - if(!((TileEntityWoodenPost)tileEntity).isDummy() && !world.isRemote && world.getGameRules().getBoolean("doTileDrops") && !world.restoringBlockSnapshots) - world.spawnEntity(new EntityItem(world, pos.getX()+.5,pos.getY()+.5,pos.getZ()+.5, new ItemStack(this,1,this.getMetaFromState(state)))); + if(!((TileEntityWoodenPost)tileEntity).isDummy()&&!world.isRemote&&world.getGameRules().getBoolean("doTileDrops")&&!world.restoringBlockSnapshots) + world.spawnEntity(new EntityItem(world, pos.getX()+.5, pos.getY()+.5, pos.getZ()+.5, new ItemStack(this, 1, this.getMetaFromState(state)))); } super.breakBlock(world, pos, state); } @@ -77,7 +78,7 @@ public boolean canBeConnectedTo(IBlockAccess world, BlockPos pos, EnumFacing fac else if(facing==EnumFacing.DOWN) return ((TileEntityWallmount)te).orientation==1||((TileEntityWallmount)te).orientation==3; else - return facing==(((TileEntityWallmount)te).orientation>1?((TileEntityWallmount)te).facing.getOpposite():((TileEntityWallmount)te).facing); + return facing==(((TileEntityWallmount)te).orientation > 1?((TileEntityWallmount)te).facing.getOpposite(): ((TileEntityWallmount)te).facing); } } return super.canBeConnectedTo(world, pos, facing); @@ -93,11 +94,11 @@ public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, B if(te instanceof TileEntityWallmount) { if(side==EnumFacing.UP) - return ((TileEntityWallmount)te).orientation==0||((TileEntityWallmount)te).orientation==2?BlockFaceShape.CENTER:BlockFaceShape.UNDEFINED; + return ((TileEntityWallmount)te).orientation==0||((TileEntityWallmount)te).orientation==2?BlockFaceShape.CENTER: BlockFaceShape.UNDEFINED; else if(side==EnumFacing.DOWN) - return ((TileEntityWallmount)te).orientation==1||((TileEntityWallmount)te).orientation==3?BlockFaceShape.CENTER:BlockFaceShape.UNDEFINED; + return ((TileEntityWallmount)te).orientation==1||((TileEntityWallmount)te).orientation==3?BlockFaceShape.CENTER: BlockFaceShape.UNDEFINED; else - return side==(((TileEntityWallmount)te).orientation>1?((TileEntityWallmount)te).facing.getOpposite():((TileEntityWallmount)te).facing)?BlockFaceShape.CENTER:BlockFaceShape.UNDEFINED; + return side==(((TileEntityWallmount)te).orientation > 1?((TileEntityWallmount)te).facing.getOpposite(): ((TileEntityWallmount)te).facing)?BlockFaceShape.CENTER: BlockFaceShape.UNDEFINED; } } return BlockFaceShape.SOLID; @@ -109,7 +110,7 @@ public boolean isSideSolid(IBlockState state, IBlockAccess world, BlockPos pos, TileEntity te = world.getTileEntity(pos); if(te instanceof TileEntityWoodenPost) { - return ((TileEntityWoodenPost)te).dummy==0?side==EnumFacing.DOWN: ((TileEntityWoodenPost)te).dummy==3?side==EnumFacing.UP: ((TileEntityWoodenPost)te).dummy>3?side.getAxis()==Axis.Y: side.getAxis()!=Axis.Y; + return ((TileEntityWoodenPost)te).dummy==0?side==EnumFacing.DOWN: ((TileEntityWoodenPost)te).dummy==3?side==EnumFacing.UP: ((TileEntityWoodenPost)te).dummy > 3?side.getAxis()==Axis.Y: side.getAxis()!=Axis.Y; } if(te instanceof TileEntityWallmount) { @@ -118,7 +119,7 @@ public boolean isSideSolid(IBlockState state, IBlockAccess world, BlockPos pos, else if(side==EnumFacing.DOWN) return ((TileEntityWallmount)te).orientation==1||((TileEntityWallmount)te).orientation==3; else - return side==(((TileEntityWallmount)te).orientation>1?((TileEntityWallmount)te).facing.getOpposite():((TileEntityWallmount)te).facing); + return side==(((TileEntityWallmount)te).orientation > 1?((TileEntityWallmount)te).facing.getOpposite(): ((TileEntityWallmount)te).facing); } return super.isSideSolid(state, world, pos, side); } @@ -142,20 +143,20 @@ public boolean canIEBlockBePlaced(World world, BlockPos pos, IBlockState newStat if(stack.getItemDamage()==BlockTypes_WoodenDevice1.WATERMILL.getMeta()) { EnumFacing f = EnumFacing.fromAngle(player.rotationYaw); - for(int hh=-2; hh<=2; hh++) - for(int ww=-2; ww<=2; ww++) - if((hh>-2&&hh<2)||(ww>-2&&ww<2)) + for(int hh = -2; hh <= 2; hh++) + for(int ww = -2; ww <= 2; ww++) + if((hh > -2&&hh < 2)||(ww > -2&&ww < 2)) { - BlockPos pos2 = pos.add(f.getAxis()==Axis.Z?ww:0, hh, f.getAxis()==Axis.Z?0:ww); + BlockPos pos2 = pos.add(f.getAxis()==Axis.Z?ww: 0, hh, f.getAxis()==Axis.Z?0: ww); if(world.isOutsideBuildHeight(pos2)||!world.getBlockState(pos2).getBlock().isReplaceable(world, pos2)) return false; } } else if(stack.getItemDamage()==BlockTypes_WoodenDevice1.POST.getMeta()) { - for(int hh=1; hh<=3; hh++) + for(int hh = 1; hh <= 3; hh++) { - BlockPos pos2 = pos.add(0,hh,0); + BlockPos pos2 = pos.add(0, hh, 0); if(world.isOutsideBuildHeight(pos2)||!world.getBlockState(pos2).getBlock().isReplaceable(world, pos2)) return false; } @@ -349,16 +350,16 @@ public TileEntity createBasicTE(World world, BlockTypes_WoodenDevice1 type) { switch(type) { - case WATERMILL: - return new TileEntityWatermill(); - case WINDMILL: - return new TileEntityWindmill(); + case WATERMILL: + return new TileEntityWatermill(); + case WINDMILL: + return new TileEntityWindmill(); // case WINDMILL_ADVANCED: // return new TileEntityWindmillAdvanced(); - case POST: - return new TileEntityWoodenPost(); - case WALLMOUNT: - return new TileEntityWallmount(); + case POST: + return new TileEntityWoodenPost(); + case WALLMOUNT: + return new TileEntityWallmount(); } return null; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityFluidSorter.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityFluidSorter.java index ea61ce712c..eed0d8f821 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityFluidSorter.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityFluidSorter.java @@ -30,7 +30,7 @@ */ public class TileEntityFluidSorter extends TileEntityIEBase implements IGuiTile { - public byte[] sortWithNBT = {1,1,1,1,1,1}; + public byte[] sortWithNBT = {1, 1, 1, 1, 1, 1}; // public static final int filterSlotsPerSide = 8; public FluidStack[][] filters = new FluidStack[6][8]; private boolean isRouting = false; @@ -41,21 +41,21 @@ public int routeFluid(EnumFacing inputSide, FluidStack stack, boolean doFill) { this.isRouting = true; IFluidHandler[][] validOutputs = getValidOutputs(inputSide, stack, true); - if(validOutputs[0].length>0) + if(validOutputs[0].length > 0) { int rand = Utils.RAND.nextInt(validOutputs[0].length); int accepted = validOutputs[0][rand].fill(stack.copy(), doFill); - if(accepted>0) + if(accepted > 0) { isRouting = false; return accepted; } } - if(validOutputs[1].length>0) + if(validOutputs[1].length > 0) { int rand = Utils.RAND.nextInt(validOutputs[1].length); int accepted = validOutputs[1][rand].fill(stack.copy(), doFill); - if(accepted>0) + if(accepted > 0) { isRouting = false; return accepted; @@ -68,7 +68,7 @@ public int routeFluid(EnumFacing inputSide, FluidStack stack, boolean doFill) public boolean doNBT(int side) { - if(side>=0 && side= 0&&side < this.sortWithNBT.length) return this.sortWithNBT[side]==1; return false; } @@ -78,11 +78,13 @@ public boolean canOpenGui() { return true; } + @Override public int getGuiID() { return Lib.GUIID_FluidSorter; } + @Override public TileEntity getGuiMaster() { @@ -110,7 +112,7 @@ public IFluidHandler[][] getValidOutputs(EnumFacing inputSide, FluidStack fluidS ArrayList validFilteredInvOuts = new ArrayList(6); ArrayList validUnfilteredInvOuts = new ArrayList(6); for(EnumFacing side : EnumFacing.values()) - if(side!=inputSide && world.isBlockLoaded(getPos().offset(side))) + if(side!=inputSide&&world.isBlockLoaded(getPos().offset(side))) { boolean unmapped = true; boolean allowed = false; @@ -125,15 +127,15 @@ public IFluidHandler[][] getValidOutputs(EnumFacing inputSide, FluidStack fluidS b &= FluidStack.areFluidStackTagsEqual(filterStack, fluidStack); if(b) { - allowed=true; + allowed = true; break filterIteration; } } } - if(allowed || (allowUnmapped&&unmapped)) + if(allowed||(allowUnmapped&&unmapped)) { TileEntity tile = Utils.getExistingTileEntity(world, getPos().offset(side)); - if(tile!=null && tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite())) + if(tile!=null&&tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite())) { IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite()); if(handler.fill(fluidStack.copy(), false) > 0) @@ -154,21 +156,22 @@ public IFluidHandler[][] getValidOutputs(EnumFacing inputSide, FluidStack fluidS public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) { sortWithNBT = nbt.getByteArray("sortWithNBT"); - for(int side=0; side<6; side++) + for(int side = 0; side < 6; side++) { NBTTagList filterList = nbt.getTagList("filter_"+side, 10); - for(int i=0; i capability, EnumFacing facing) { - if(capability==CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && facing!=null) + if(capability==CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY&&facing!=null) return true; return super.hasCapability(capability, facing); } + IFluidHandler[] insertionHandlers = { - new SorterFluidHandler(this,EnumFacing.DOWN), - new SorterFluidHandler(this,EnumFacing.UP), - new SorterFluidHandler(this,EnumFacing.NORTH), - new SorterFluidHandler(this,EnumFacing.SOUTH), - new SorterFluidHandler(this,EnumFacing.WEST), - new SorterFluidHandler(this,EnumFacing.EAST)}; + new SorterFluidHandler(this, EnumFacing.DOWN), + new SorterFluidHandler(this, EnumFacing.UP), + new SorterFluidHandler(this, EnumFacing.NORTH), + new SorterFluidHandler(this, EnumFacing.SOUTH), + new SorterFluidHandler(this, EnumFacing.WEST), + new SorterFluidHandler(this, EnumFacing.EAST)}; @Override public T getCapability(Capability capability, EnumFacing facing) { - if(capability==CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && facing!=null) + if(capability==CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY&&facing!=null) return (T)insertionHandlers[facing.ordinal()]; return super.getCapability(capability, facing); } @@ -206,6 +210,7 @@ static class SorterFluidHandler implements IFluidHandler { TileEntityFluidSorter tile; EnumFacing facing; + SorterFluidHandler(TileEntityFluidSorter tile, EnumFacing facing) { this.tile = tile; @@ -215,24 +220,27 @@ static class SorterFluidHandler implements IFluidHandler @Override public int fill(FluidStack resource, boolean doFill) { - if(resource == null) + if(resource==null) return 0; return tile.routeFluid(facing, resource, doFill); } + @Override public FluidStack drain(FluidStack resource, boolean doDrain) { return null; } + @Override public FluidStack drain(int maxDrain, boolean doDrain) { return null; } + @Override public IFluidTankProperties[] getTankProperties() { - return new IFluidTankProperties[]{new FluidTankProperties(null,0)}; + return new IFluidTankProperties[]{new FluidTankProperties(null, 0)}; } } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityModWorkbench.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityModWorkbench.java index b1f54f4ae4..d7a78f5c3b 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityModWorkbench.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityModWorkbench.java @@ -34,7 +34,7 @@ public class TileEntityModWorkbench extends TileEntityIEBase implements IIEInven NonNullList inventory = NonNullList.withSize(1, ItemStack.EMPTY); EnumFacing facing = EnumFacing.NORTH; public boolean dummy = false; - public int dummyOffset=0; + public int dummyOffset = 0; @Override public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) @@ -48,6 +48,7 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) inventory = Utils.readInventory(nbt.getTagList("inventory", 10), 1); // } } + @Override public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { @@ -62,12 +63,13 @@ public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) @SideOnly(Side.CLIENT) private AxisAlignedBB renderAABB; + @SideOnly(Side.CLIENT) @Override public AxisAlignedBB getRenderBoundingBox() { if(renderAABB==null) - renderAABB = new AxisAlignedBB(getPos().getX()-1,getPos().getY(),getPos().getZ()-1, getPos().getX()+2,getPos().getY()+2,getPos().getZ()+2); + renderAABB = new AxisAlignedBB(getPos().getX()-1, getPos().getY(), getPos().getZ()-1, getPos().getX()+2, getPos().getY()+2, getPos().getZ()+2); return renderAABB; } @@ -76,16 +78,19 @@ public NonNullList getInventory() { return this.inventory; } + @Override public boolean isStackValid(int slot, ItemStack stack) { return true; } + @Override public int getSlotLimit(int slot) { return 1; } + @Override public void doGraphicalUpdates(int slot) { @@ -96,26 +101,31 @@ public EnumFacing getFacing() { return facing; } + @Override public void setFacing(EnumFacing facing) { this.facing = facing; } + @Override public int getFacingLimitation() { return 2; } + @Override public boolean mirrorFacingOnPlacement(EntityLivingBase placer) { return false; } + @Override public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) { return false; } + @Override public boolean canRotate(EnumFacing axis) { @@ -125,13 +135,13 @@ public boolean canRotate(EnumFacing axis) @Override public void receiveMessageFromClient(NBTTagCompound message) { - if(!inventory.get(0).isEmpty() && inventory.get(0).getItem() instanceof IConfigurableTool) + if(!inventory.get(0).isEmpty()&&inventory.get(0).getItem() instanceof IConfigurableTool) for(String key : message.getKeySet()) { if(key.startsWith("b_")) - ((IConfigurableTool) inventory.get(0).getItem()).applyConfigOption(inventory.get(0), key.substring(2), message.getBoolean(key)); + ((IConfigurableTool)inventory.get(0).getItem()).applyConfigOption(inventory.get(0), key.substring(2), message.getBoolean(key)); else if(key.startsWith("f_")) - ((IConfigurableTool) inventory.get(0).getItem()).applyConfigOption(inventory.get(0), key.substring(2), message.getFloat(key)); + ((IConfigurableTool)inventory.get(0).getItem()).applyConfigOption(inventory.get(0), key.substring(2), message.getFloat(key)); } } @@ -140,10 +150,11 @@ public boolean isDummy() { return this.dummy; } + @Override public void placeDummies(BlockPos pos, IBlockState state, EnumFacing side, float hitX, float hitY, float hitZ) { - EnumFacing dummyDir = facing.getAxis()==Axis.X?(hitZ<.5?EnumFacing.NORTH:EnumFacing.SOUTH):(hitX<.5?EnumFacing.WEST:EnumFacing.EAST); + EnumFacing dummyDir = facing.getAxis()==Axis.X?(hitZ < .5?EnumFacing.NORTH: EnumFacing.SOUTH): (hitX < .5?EnumFacing.WEST: EnumFacing.EAST); boolean mirror = false; BlockPos dummyPos = pos.offset(dummyDir); if(!world.getBlockState(dummyPos).getBlock().isReplaceable(world, dummyPos)) @@ -152,19 +163,20 @@ public void placeDummies(BlockPos pos, IBlockState state, EnumFacing side, float dummyPos = pos.offset(dummyDir); } mirror = dummyDir!=facing.rotateY(); - dummyOffset=mirror?-1:1; + dummyOffset = mirror?-1: 1; if(mirror) this.dummy = true; world.setBlockState(dummyPos, state); TileEntityModWorkbench tileEntityDummy = ((TileEntityModWorkbench)world.getTileEntity(dummyPos)); tileEntityDummy.facing = this.facing; tileEntityDummy.dummy = !mirror; - tileEntityDummy.dummyOffset=mirror?-1:1; + tileEntityDummy.dummyOffset = mirror?-1: 1; } + @Override public void breakDummies(BlockPos pos, IBlockState state) { - EnumFacing dummyDir = dummy?facing.rotateYCCW():facing.rotateY(); + EnumFacing dummyDir = dummy?facing.rotateYCCW(): facing.rotateY(); world.setBlockToAir(pos.offset(dummyDir)); } @@ -173,17 +185,19 @@ public boolean canOpenGui() { return true; } + @Override public int getGuiID() { return Lib.GUIID_Workbench; } + @Override public TileEntity getGuiMaster() { if(!dummy) return this; - EnumFacing dummyDir = dummy?facing.rotateYCCW():facing.rotateY(); + EnumFacing dummyDir = dummy?facing.rotateYCCW(): facing.rotateY(); TileEntity tileEntityModWorkbench = world.getTileEntity(pos.offset(dummyDir)); if(tileEntityModWorkbench instanceof TileEntityModWorkbench) return tileEntityModWorkbench; diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityTurntable.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityTurntable.java index e5f339307c..55612e2dbe 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityTurntable.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityTurntable.java @@ -33,6 +33,7 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) redstone = nbt.getBoolean("redstone"); invert = nbt.getBoolean("invert"); } + @Override public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { @@ -51,7 +52,7 @@ public void onNeighborBlockChange(BlockPos otherPos) if(this.redstone) { BlockPos target = pos.offset(facing); - RotationUtil.rotateBlock(this.world, target, invert?facing:facing.getOpposite()); + RotationUtil.rotateBlock(this.world, target, invert?facing: facing.getOpposite()); } } } @@ -61,26 +62,31 @@ public EnumFacing getFacing() { return facing; } + @Override public void setFacing(EnumFacing facing) { this.facing = facing; } + @Override public int getFacingLimitation() { return 1; } + @Override public boolean mirrorFacingOnPlacement(EntityLivingBase placer) { return placer.isSneaking(); } + @Override public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) { return !entity.isSneaking(); } + @Override public boolean canRotate(EnumFacing axis) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWallmount.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWallmount.java index 699cbd285a..60a960141b 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWallmount.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWallmount.java @@ -44,11 +44,13 @@ public String[] getIntPropertyNames() { return new String[]{"orientation"}; } + @Override public PropertyInteger getIntProperty(String name) { return IEProperties.INT_4; } + @Override public int getIntPropertyValue(String name) { @@ -66,32 +68,37 @@ public EnumFacing getFacing() { return facing; } + @Override public void setFacing(EnumFacing facing) { this.facing = facing; } + @Override public int getFacingLimitation() { return 2; } + @Override public boolean mirrorFacingOnPlacement(EntityLivingBase placer) { return false; } + @Override public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) { return !entity.isSneaking(); } + @Override public boolean canRotate(EnumFacing axis) { return true; } - + @Override public boolean hammerUseSide(EnumFacing side, EntityPlayer player, float hitX, float hitY, float hitZ) { @@ -117,20 +124,20 @@ public void onDirectionalPlacement(EnumFacing side, float hitX, float hitY, floa orientation = 3; else if(side==EnumFacing.DOWN) orientation = 2; - else if(hitY<.5) + else if(hitY < .5) orientation = 1; } @Override public float[] getBlockBounds() { - EnumFacing towards = orientation>1?facing.getOpposite():facing; - float minX = towards==EnumFacing.WEST?0:.3125f; + EnumFacing towards = orientation > 1?facing.getOpposite(): facing; + float minX = towards==EnumFacing.WEST?0: .3125f; float minY = orientation==0?.375f: orientation==2?.3125f: 0; - float minZ = towards==EnumFacing.NORTH?0:.3125f; - float maxX = towards==EnumFacing.EAST?1:.6875f; + float minZ = towards==EnumFacing.NORTH?0: .3125f; + float maxX = towards==EnumFacing.EAST?1: .6875f; float maxY = orientation==1?.625f: orientation==3?.6875f: 1; - float maxZ = towards==EnumFacing.SOUTH?1:.6875f; - return new float[]{minX,minY,minZ, maxX,maxY,maxZ}; + float maxZ = towards==EnumFacing.SOUTH?1: .6875f; + return new float[]{minX, minY, minZ, maxX, maxY, maxZ}; } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWatermill.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWatermill.java index 50b17f0b39..1e8dfd9aa1 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWatermill.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWatermill.java @@ -10,7 +10,6 @@ import blusunrize.immersiveengineering.api.ApiUtils; import blusunrize.immersiveengineering.api.energy.IRotationAcceptor; -import blusunrize.immersiveengineering.common.Config.IEConfig; import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile; import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IHasDummyBlocks; import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IHasObjProperty; @@ -35,8 +34,8 @@ public class TileEntityWatermill extends TileEntityIEBase implements ITickable, IDirectionalTile, IHasDummyBlocks, IHasObjProperty { public EnumFacing facing = EnumFacing.NORTH; - public int[] offset={0,0}; - public float rotation=0; + public int[] offset = {0, 0}; + public float rotation = 0; private Vec3d rotationVec = null; public boolean canTurn = false; public boolean multiblock = false; @@ -58,15 +57,15 @@ public void update() return; if(isBlocked()) { - canTurn=false; + canTurn = false; return; } else - canTurn = multiblock||getRotationVec().lengthVector() != 0; + canTurn = multiblock||getRotationVec().lengthVector()!=0; if(world.getTotalWorldTime()%64==((getPos().getX()^getPos().getZ())&63)) { - rotationVec=null; + rotationVec = null; } prevRotation = rotation; @@ -74,21 +73,21 @@ public void update() if(!multiblock&&acc instanceof IRotationAcceptor) { double power = getPower(); - int l=1; + int l = 1; TileEntity tileEntity = Utils.getExistingTileEntity(world, getPos().offset(facing, l)); - while (l<3 - && canUse(tileEntity)) + while(l < 3 + &&canUse(tileEntity)) { power += ((TileEntityWatermill)tileEntity).getPower(); l++; tileEntity = Utils.getExistingTileEntity(world, getPos().offset(facing, l)); } - perTick = 1f/1440 * power/l; + perTick = 1f/1440*power/l; canTurn = perTick!=0; rotation += perTick; rotation %= 1; - for(int l2=1; l2-2&&hh<2)||(ww>-2&&ww<2)) + for(int hh = -2; hh <= 2; hh++) + for(int ww = -2; ww <= 2; ww++) + if((hh > -2&&hh < 2)||(ww > -2&&ww < 2)) { - BlockPos pos2 = pos.add(facing.getAxis()==Axis.Z?ww:0, hh, facing.getAxis()==Axis.Z?0:ww); + BlockPos pos2 = pos.add(facing.getAxis()==Axis.Z?ww: 0, hh, facing.getAxis()==Axis.Z?0: ww); world.setBlockState(pos2, state); TileEntityWatermill dummy = (TileEntityWatermill)world.getTileEntity(pos2); dummy.facing = facing; - dummy.offset = new int[]{ww,hh}; + dummy.offset = new int[]{ww, hh}; } } + @Override public void breakDummies(BlockPos pos, IBlockState state) { - if (!formed) + if(!formed) return; - BlockPos initPos = pos.add(facing.getAxis()==Axis.Z?-offset[0]:0, -offset[1], facing.getAxis()==Axis.X?-offset[0]:0); - for(int hh=-2; hh<=2; hh++) - for(int ww=-2; ww<=2; ww++) - if((hh>-2&&hh<2)||(ww>-2&&ww<2)) + BlockPos initPos = pos.add(facing.getAxis()==Axis.Z?-offset[0]: 0, -offset[1], facing.getAxis()==Axis.X?-offset[0]: 0); + for(int hh = -2; hh <= 2; hh++) + for(int ww = -2; ww <= 2; ww++) + if((hh > -2&&hh < 2)||(ww > -2&&ww < 2)) { - BlockPos pos2 = initPos.add(facing.getAxis()==Axis.Z?ww:0, hh, facing.getAxis()==Axis.X?ww:0); + BlockPos pos2 = initPos.add(facing.getAxis()==Axis.Z?ww: 0, hh, facing.getAxis()==Axis.X?ww: 0); TileEntity te = world.getTileEntity(pos2); if(te instanceof TileEntityWatermill) { - ((TileEntityWatermill) te).formed = false; + ((TileEntityWatermill)te).formed = false; world.setBlockToAir(pos2); } } } static ArrayList emptyDisplayList = new ArrayList(); + @Override public ArrayList compileDisplayList() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWindmill.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWindmill.java index 50e9e3440b..999646b8c6 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWindmill.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWindmill.java @@ -9,7 +9,6 @@ package blusunrize.immersiveengineering.common.blocks.wooden; import blusunrize.immersiveengineering.api.energy.IRotationAcceptor; -import blusunrize.immersiveengineering.common.Config.IEConfig; import blusunrize.immersiveengineering.common.IEContent; import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile; import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IHasObjProperty; @@ -39,9 +38,9 @@ public class TileEntityWindmill extends TileEntityIEBase implements ITickable, IDirectionalTile, ITileDrop, IPlayerInteraction, IHasObjProperty { public EnumFacing facing = EnumFacing.NORTH; - public float prevRotation=0; - public float rotation=0; - public float turnSpeed=0; + public float prevRotation = 0; + public float rotation = 0; + public float turnSpeed = 0; public float perTick = 0; public int sails = 0; @@ -74,13 +73,13 @@ public void update() // mod *= 1.25; // else if(getPos().getY()<70) // mod *= .33; - mod*=getSpeedModifier(); + mod *= getSpeedModifier(); - prevRotation = (float) (turnSpeed*mod); + prevRotation = (float)(turnSpeed*mod); rotation += turnSpeed*mod; rotation %= 1; - perTick = (float) (turnSpeed*mod); + perTick = (float)(turnSpeed*mod); if(!world.isRemote) { @@ -88,11 +87,12 @@ public void update() if(tileEntity instanceof IRotationAcceptor) { IRotationAcceptor dynamo = (IRotationAcceptor)tileEntity; - double power = turnSpeed*mod * 800; + double power = turnSpeed*mod*800; dynamo.inputRotation(Math.abs(power), facing); } } } + protected float getSpeedModifier() { return .5f+sails*.125f; @@ -100,39 +100,39 @@ protected float getSpeedModifier() public boolean checkArea() { - if (facing.getAxis()==EnumFacing.Axis.Y) + if(facing.getAxis()==EnumFacing.Axis.Y) return false; - turnSpeed=0; - for(int hh=-4;hh<=4;hh++) + turnSpeed = 0; + for(int hh = -4; hh <= 4; hh++) { - int r=Math.abs(hh)==4?1: Math.abs(hh)==3?2: Math.abs(hh)==2?3: 4; - for(int ww=-r;ww<=r;ww++) - if((hh!=0||ww!=0)&&!world.isAirBlock(getPos().add((facing.getAxis()==Axis.Z?ww:0),hh,(facing.getAxis()==Axis.Z?0:ww)))) + int r = Math.abs(hh)==4?1: Math.abs(hh)==3?2: Math.abs(hh)==2?3: 4; + for(int ww = -r; ww <= r; ww++) + if((hh!=0||ww!=0)&&!world.isAirBlock(getPos().add((facing.getAxis()==Axis.Z?ww: 0), hh, (facing.getAxis()==Axis.Z?0: ww)))) return false; } int blocked = 0; - for(int hh=-4;hh<=4;hh++) + for(int hh = -4; hh <= 4; hh++) { - int r=Math.abs(hh)==4?1: Math.abs(hh)==3?2: Math.abs(hh)==2?3: 4; - for(int ww=-r;ww<=r;ww++) + int r = Math.abs(hh)==4?1: Math.abs(hh)==3?2: Math.abs(hh)==2?3: 4; + for(int ww = -r; ww <= r; ww++) { - for(int dd=1;dd<8;dd++) + for(int dd = 1; dd < 8; dd++) { BlockPos pos = getPos().add(0, hh, 0).offset(facing.getOpposite(), dd).offset(facing.rotateY(), ww); - if(!world.isBlockLoaded(pos) || world.isAirBlock(pos)) - turnSpeed ++; + if(!world.isBlockLoaded(pos)||world.isAirBlock(pos)) + turnSpeed++; else if(world.getTileEntity(pos) instanceof TileEntityWindmill) { - blocked+=20; - turnSpeed-=179; + blocked += 20; + turnSpeed -= 179; } else blocked++; } } - if(blocked>100) + if(blocked > 100) return false; } @@ -148,6 +148,7 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) rotation = nbt.getFloat("rotation"); turnSpeed = nbt.getFloat("turnSpeed"); } + @Override public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { @@ -160,12 +161,13 @@ public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) @SideOnly(Side.CLIENT) private AxisAlignedBB renderAABB; + @SideOnly(Side.CLIENT) @Override public AxisAlignedBB getRenderBoundingBox() { if(renderAABB==null) - renderAABB = new AxisAlignedBB(getPos().getX()-(facing.getAxis()==Axis.Z?6:0),getPos().getY()-6,getPos().getZ()-(facing.getAxis()==Axis.Z?0:6), getPos().getX()+(facing.getAxis()==Axis.Z?7:0),getPos().getY()+7,getPos().getZ()+(facing.getAxis()==Axis.Z?0:7)); + renderAABB = new AxisAlignedBB(getPos().getX()-(facing.getAxis()==Axis.Z?6: 0), getPos().getY()-6, getPos().getZ()-(facing.getAxis()==Axis.Z?0: 6), getPos().getX()+(facing.getAxis()==Axis.Z?7: 0), getPos().getY()+7, getPos().getZ()+(facing.getAxis()==Axis.Z?0: 7)); return renderAABB; } @@ -174,26 +176,31 @@ public EnumFacing getFacing() { return facing; } + @Override public void setFacing(EnumFacing facing) { this.facing = facing; } + @Override public int getFacingLimitation() { return 6; } + @Override public boolean mirrorFacingOnPlacement(EntityLivingBase placer) { return false; } + @Override public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) { return false; } + @Override public boolean canRotate(EnumFacing axis) { @@ -201,6 +208,7 @@ public boolean canRotate(EnumFacing axis) } static ArrayList emptyDisplayList = new ArrayList(); + @Override public ArrayList compileDisplayList() { @@ -210,7 +218,7 @@ public ArrayList compileDisplayList() @Override public boolean interact(EnumFacing side, EntityPlayer player, EnumHand hand, ItemStack heldItem, float hitX, float hitY, float hitZ) { - if(sails<8 && OreDictionary.itemMatches(new ItemStack(IEContent.itemMaterial,1,12), heldItem, false)) + if(sails < 8&&OreDictionary.itemMatches(new ItemStack(IEContent.itemMaterial, 1, 12), heldItem, false)) { this.sails++; heldItem.shrink(1); @@ -222,11 +230,12 @@ public boolean interact(EnumFacing side, EntityPlayer player, EnumHand hand, Ite @Override public ItemStack getTileDrop(EntityPlayer player, IBlockState state) { - ItemStack stack = new ItemStack(state.getBlock(),1,state.getBlock().getMetaFromState(state)); - if(sails>0) + ItemStack stack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)); + if(sails > 0) ItemNBTHelper.setInt(stack, "sails", sails); return stack; } + @Override public void readOnPlacement(EntityLivingBase placer, ItemStack stack) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWoodenBarrel.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWoodenBarrel.java index b90347b50d..2d3a7a796e 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWoodenBarrel.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWoodenBarrel.java @@ -41,7 +41,7 @@ public class TileEntityWoodenBarrel extends TileEntityIEBase implements ITickable, IBlockOverlayText, IConfigurableSides, IPlayerInteraction, ITileDrop, IComparatorOverride { - public int[] sideConfig = {1,0}; + public int[] sideConfig = {1, 0}; public FluidTank tank = new FluidTank(12000); public static final int IGNITION_TEMPERATURE = 573; @@ -52,13 +52,13 @@ public void update() return; boolean update = false; - for(int i=0; i<2; i++) - if(tank.getFluidAmount()>0 && sideConfig[i]==1) + for(int i = 0; i < 2; i++) + if(tank.getFluidAmount() > 0&&sideConfig[i]==1) { EnumFacing f = EnumFacing.getFront(i); - int out = Math.min(40,tank.getFluidAmount()); + int out = Math.min(40, tank.getFluidAmount()); TileEntity te = world.getTileEntity(getPos().offset(f)); - if(te!=null && te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, f.getOpposite())) + if(te!=null&&te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, f.getOpposite())) { IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, f.getOpposite()); int accepted = handler.fill(Utils.copyFluidStackWithAmount(tank.getFluid(), out, false), false); @@ -89,19 +89,20 @@ public String[] getOverlayText(EntityPlayer player, RayTraceResult mop, boolean s = I18n.format(Lib.GUI+"empty"); return new String[]{s}; } - if(hammer && IEConfig.colourblindSupport && mop.sideHit.getAxis()==Axis.Y) + if(hammer&&IEConfig.colourblindSupport&&mop.sideHit.getAxis()==Axis.Y) { int i = sideConfig[Math.min(sideConfig.length-1, mop.sideHit.ordinal())]; int j = sideConfig[Math.min(sideConfig.length-1, mop.sideHit.getOpposite().ordinal())]; return new String[]{ I18n.format(Lib.DESC_INFO+"blockSide.facing") - +": "+ I18n.format(Lib.DESC_INFO+"blockSide.connectFluid."+i), + +": "+I18n.format(Lib.DESC_INFO+"blockSide.connectFluid."+i), I18n.format(Lib.DESC_INFO+"blockSide.opposite") - +": "+ I18n.format(Lib.DESC_INFO+"blockSide.connectFluid."+j) + +": "+I18n.format(Lib.DESC_INFO+"blockSide.connectFluid."+j) }; } return null; } + @Override public boolean useNixieFont(EntityPlayer player, RayTraceResult mop) { @@ -112,10 +113,11 @@ public boolean useNixieFont(EntityPlayer player, RayTraceResult mop) public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) { sideConfig = nbt.getIntArray("sideConfig"); - if(sideConfig==null || sideConfig.length<2) - sideConfig = new int[]{-1,0}; + if(sideConfig==null||sideConfig.length < 2) + sideConfig = new int[]{-1, 0}; this.readTank(nbt); } + public void readTank(NBTTagCompound nbt) { tank.readFromNBT(nbt.getCompoundTag("tank")); @@ -127,28 +129,31 @@ public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) nbt.setIntArray("sideConfig", sideConfig); this.writeTank(nbt, false); } + public void writeTank(NBTTagCompound nbt, boolean toItem) { - boolean write = tank.getFluidAmount()>0; + boolean write = tank.getFluidAmount() > 0; NBTTagCompound tankTag = tank.writeToNBT(new NBTTagCompound()); - if(!toItem || write) + if(!toItem||write) nbt.setTag("tank", tankTag); } - SidedFluidHandler[] sidedFluidHandler = {new SidedFluidHandler(this, EnumFacing.DOWN),new SidedFluidHandler(this, EnumFacing.UP)}; + SidedFluidHandler[] sidedFluidHandler = {new SidedFluidHandler(this, EnumFacing.DOWN), new SidedFluidHandler(this, EnumFacing.UP)}; SidedFluidHandler nullsideFluidHandler = new SidedFluidHandler(this, null); + @Override public boolean hasCapability(Capability capability, @Nullable EnumFacing facing) { - if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && (facing == null || facing.getAxis() == Axis.Y)) + if(capability==CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY&&(facing==null||facing.getAxis()==Axis.Y)) return true; return super.hasCapability(capability, facing); } + @Override public T getCapability(Capability capability, @Nullable EnumFacing facing) { - if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && (facing == null || facing.getAxis() == Axis.Y)) - return (T)(facing==null?nullsideFluidHandler:sidedFluidHandler[facing.ordinal()]); + if(capability==CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY&&(facing==null||facing.getAxis()==Axis.Y)) + return (T)(facing==null?nullsideFluidHandler: sidedFluidHandler[facing.ordinal()]); return super.getCapability(capability, facing); } @@ -156,6 +161,7 @@ static class SidedFluidHandler implements IFluidHandler { TileEntityWoodenBarrel barrel; EnumFacing facing; + SidedFluidHandler(TileEntityWoodenBarrel barrel, EnumFacing facing) { this.barrel = barrel; @@ -165,37 +171,40 @@ static class SidedFluidHandler implements IFluidHandler @Override public int fill(FluidStack resource, boolean doFill) { - if(resource == null || (facing!=null&&barrel.sideConfig[facing.ordinal()]!=0) || !barrel.isFluidValid(resource)) + if(resource==null||(facing!=null&&barrel.sideConfig[facing.ordinal()]!=0)||!barrel.isFluidValid(resource)) return 0; int i = barrel.tank.fill(resource, doFill); - if(i>0) + if(i > 0) { barrel.markDirty(); barrel.markContainingBlockForUpdate(null); } return i; } + @Override public FluidStack drain(FluidStack resource, boolean doDrain) { - if(resource == null) + if(resource==null) return null; return this.drain(resource.amount, doDrain); } + @Override public FluidStack drain(int maxDrain, boolean doDrain) { if(facing!=null&&barrel.sideConfig[facing.ordinal()]!=1) return null; FluidStack f = barrel.tank.drain(maxDrain, doDrain); - if(f!=null && f.amount>0) + if(f!=null&&f.amount > 0) { barrel.markDirty(); barrel.markContainingBlockForUpdate(null); } return f; } + @Override public IFluidTankProperties[] getTankProperties() { @@ -205,29 +214,31 @@ public IFluidTankProperties[] getTankProperties() public boolean isFluidValid(FluidStack fluid) { - return fluid!=null && fluid.getFluid()!=null && fluid.getFluid().getTemperature(fluid)1) + if(side > 1) return SideConfig.NONE; return SideConfig.values()[this.sideConfig[side]+1]; } + @Override public boolean toggleSide(int side, EntityPlayer p) { if(side!=0&&side!=1) - return false ; + return false; sideConfig[side]++; - if(sideConfig[side]>1) - sideConfig[side]=-1; + if(sideConfig[side] > 1) + sideConfig[side] = -1; this.markDirty(); this.markContainingBlockForUpdate(null); world.addBlockEvent(getPos(), this.getBlockType(), 0, 0); return true; } + @Override public boolean receiveClientEvent(int id, int arg) { @@ -245,12 +256,12 @@ public boolean interact(EnumFacing side, EntityPlayer player, EnumHand hand, Ite FluidStack f = FluidUtil.getFluidContained(heldItem); boolean metal = this instanceof TileEntityMetalBarrel; if(f!=null) - if(!metal && f.getFluid().isGaseous(f)) + if(!metal&&f.getFluid().isGaseous(f)) { ChatUtils.sendServerNoSpamMessages(player, new TextComponentTranslation(Lib.CHAT_INFO+"noGasAllowed")); return true; } - else if(!metal && f.getFluid().getTemperature(f)>=TileEntityWoodenBarrel.IGNITION_TEMPERATURE) + else if(!metal&&f.getFluid().getTemperature(f) >= TileEntityWoodenBarrel.IGNITION_TEMPERATURE) { ChatUtils.sendServerNoSpamMessages(player, new TextComponentTranslation(Lib.CHAT_INFO+"tooHot")); return true; @@ -275,6 +286,7 @@ public ItemStack getTileDrop(EntityPlayer player, IBlockState state) stack.setTagCompound(tag); return stack; } + @Override public void readOnPlacement(EntityLivingBase placer, ItemStack stack) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWoodenCrate.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWoodenCrate.java index 7bd84187b8..b8961ddae4 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWoodenCrate.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWoodenCrate.java @@ -67,26 +67,28 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) inventory = Utils.readInventory(nbt.getTagList("inventory", 10), 27); } } + @Override public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { if(this.name!=null) nbt.setString("name", this.name); - if(this.enchantments!=null && this.enchantments.tagCount()>0) + if(this.enchantments!=null&&this.enchantments.tagCount() > 0) nbt.setTag("enchantments", this.enchantments); if(!descPacket) { if(lootTable!=null) - nbt.setString("lootTable",lootTable.toString()); + nbt.setString("lootTable", lootTable.toString()); else writeInv(nbt, false); } } + public void writeInv(NBTTagCompound nbt, boolean toItem) { boolean write = false; NBTTagList invList = new NBTTagList(); - for(int i=0; i list = loottable.generateLootForPools(rand, context); List listSlots = Lists.newArrayList(); - for(int i=0; i getInventory() { return inventory; } + @Override public boolean isStackValid(int slot, ItemStack stack) { return IEApi.isAllowedInCrate(stack); } + @Override public int getSlotLimit(int slot) { return 64; } + @Override public void doGraphicalUpdates(int slot) { @@ -185,10 +193,11 @@ public ItemStack getTileDrop(EntityPlayer player, IBlockState state) stack.setTagCompound(tag); if(this.name!=null) stack.setStackDisplayName(this.name); - if(enchantments!=null && enchantments.tagCount()>0) + if(enchantments!=null&&enchantments.tagCount() > 0) ItemNBTHelper.getTag(stack).setTag("ench", enchantments); return stack; } + @Override public void readOnPlacement(EntityLivingBase placer, ItemStack stack) { @@ -200,6 +209,7 @@ public void readOnPlacement(EntityLivingBase placer, ItemStack stack) enchantments = stack.getEnchantmentTagList(); } } + @Override public boolean preventInventoryDrop() { @@ -219,7 +229,9 @@ public boolean hasCapability(Capability capability, EnumFacing facing) return true; return super.hasCapability(capability, facing); } - IItemHandler insertionHandler = new IEInventoryHandler(27,this); + + IItemHandler insertionHandler = new IEInventoryHandler(27, this); + @Override public T getCapability(Capability capability, EnumFacing facing) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWoodenPost.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWoodenPost.java index ca33557d9a..42a83cc6d1 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWoodenPost.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWoodenPost.java @@ -44,6 +44,7 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) { dummy = nbt.getByte("dummy"); } + @Override public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) { @@ -52,14 +53,16 @@ public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) @SideOnly(Side.CLIENT) private AxisAlignedBB renderAABB; + @SideOnly(Side.CLIENT) @Override public AxisAlignedBB getRenderBoundingBox() { - return new AxisAlignedBB(getPos().add(-1,0,-1),getPos().add(1,4,1)); + return new AxisAlignedBB(getPos().add(-1, 0, -1), getPos().add(1, 4, 1)); } static ArrayList emptyDisplayList = new ArrayList(); + @Override public ArrayList compileDisplayList() { @@ -68,9 +71,9 @@ public ArrayList compileDisplayList() ArrayList list = new ArrayList(); list.add("base"); TileEntity te; - for(int i=0; i<=2; i++) + for(int i = 0; i <= 2; i++) { - te = world.getTileEntity(getPos().add(0,1+i,0)); + te = world.getTileEntity(getPos().add(0, 1+i, 0)); if(te instanceof TileEntityWoodenPost)//Stacked pieces { for(EnumFacing f : EnumFacing.HORIZONTALS) @@ -78,7 +81,7 @@ public ArrayList compileDisplayList() { if(i==2)//Arms { - TileEntityWoodenPost arm = (TileEntityWoodenPost)world.getTileEntity(pos.add(0,1+i,0).offset(f)); + TileEntityWoodenPost arm = (TileEntityWoodenPost)world.getTileEntity(pos.add(0, 1+i, 0).offset(f)); boolean down = arm.hasConnection(EnumFacing.DOWN); if(down) list.add("arm_"+f.getName2()+"_down"); @@ -97,16 +100,16 @@ public ArrayList compileDisplayList() public BlockFaceShape getFaceShape(EnumFacing side) { if(dummy==0) - return side==EnumFacing.DOWN?BlockFaceShape.CENTER_BIG:BlockFaceShape.UNDEFINED; - else if(dummy>=3) - return (side==EnumFacing.UP||(dummy>3&&side==EnumFacing.DOWN))?BlockFaceShape.CENTER_BIG:BlockFaceShape.UNDEFINED; + return side==EnumFacing.DOWN?BlockFaceShape.CENTER_BIG: BlockFaceShape.UNDEFINED; + else if(dummy >= 3) + return (side==EnumFacing.UP||(dummy > 3&&side==EnumFacing.DOWN))?BlockFaceShape.CENTER_BIG: BlockFaceShape.UNDEFINED; return BlockFaceShape.CENTER; } public boolean hasConnection(EnumFacing dir) { BlockPos pos = getPos().offset(dir); - if(dummy>0&&dummy<3) + if(dummy > 0&&dummy < 3) { IBlockState state = world.getBlockState(pos); for(Enum meta : postMetaProperties) @@ -118,20 +121,20 @@ public boolean hasConnection(EnumFacing dir) double minZ = boundingBox.minZ; double maxZ = boundingBox.maxZ; boolean connect = dir==EnumFacing.NORTH?maxZ==1: dir==EnumFacing.SOUTH?minZ==0: dir==EnumFacing.WEST?maxX==1: minX==0; - return connect && ((dir.getAxis()==Axis.Z && minX>0&&maxX<1)||(dir.getAxis()==Axis.X && minZ>0&&maxZ<1)); + return connect&&((dir.getAxis()==Axis.Z&&minX > 0&&maxX < 1)||(dir.getAxis()==Axis.X&&minZ > 0&&maxZ < 1)); } else if(dummy==3) { TileEntity te = world.getTileEntity(pos); - return (te instanceof TileEntityWoodenPost && ((TileEntityWoodenPost)te).dummy-3==dir.ordinal()); + return (te instanceof TileEntityWoodenPost&&((TileEntityWoodenPost)te).dummy-3==dir.ordinal()); } - else if(dummy>3) + else if(dummy > 3) { if(world.isAirBlock(pos)) return false; IBlockState state = world.getBlockState(pos); AxisAlignedBB boundingBox = state.getBoundingBox(world, pos); - return dir==EnumFacing.UP?boundingBox.minY==0: dir == EnumFacing.DOWN && boundingBox.maxY == 1; + return dir==EnumFacing.UP?boundingBox.minY==0: dir==EnumFacing.DOWN&&boundingBox.maxY==1; } return false; } @@ -140,22 +143,22 @@ else if(dummy>3) public float[] getBlockBounds() { if(dummy==0) - return new float[]{.25f,0,.25f, .75f,1,.75f}; - if(dummy<=2) - return new float[]{hasConnection(EnumFacing.WEST)?0:.375f,0,hasConnection(EnumFacing.NORTH)?0:.375f, hasConnection(EnumFacing.EAST)?1:.625f,1,hasConnection(EnumFacing.SOUTH)?1:.625f}; + return new float[]{.25f, 0, .25f, .75f, 1, .75f}; + if(dummy <= 2) + return new float[]{hasConnection(EnumFacing.WEST)?0: .375f, 0, hasConnection(EnumFacing.NORTH)?0: .375f, hasConnection(EnumFacing.EAST)?1: .625f, 1, hasConnection(EnumFacing.SOUTH)?1: .625f}; if(dummy==3) - return new float[]{hasConnection(EnumFacing.WEST)?0:.3125f,0,hasConnection(EnumFacing.NORTH)?0:.3125f, hasConnection(EnumFacing.EAST)?1:.6875f,1,hasConnection(EnumFacing.SOUTH)?1:.6875f}; + return new float[]{hasConnection(EnumFacing.WEST)?0: .3125f, 0, hasConnection(EnumFacing.NORTH)?0: .3125f, hasConnection(EnumFacing.EAST)?1: .6875f, 1, hasConnection(EnumFacing.SOUTH)?1: .6875f}; - float down = hasConnection(EnumFacing.DOWN)?0:.4375f; - float up = down>0?1:.5625f; + float down = hasConnection(EnumFacing.DOWN)?0: .4375f; + float up = down > 0?1: .5625f; if(dummy-3==2) - return new float[]{.3125f,down,.3125f, .6875f,up,1}; + return new float[]{.3125f, down, .3125f, .6875f, up, 1}; if(dummy-3==3) - return new float[]{.3125f,down,0, .6875f,up,.6875f}; + return new float[]{.3125f, down, 0, .6875f, up, .6875f}; if(dummy-3==4) - return new float[]{.3125f,down,.3125f, 1,up,.6875f}; + return new float[]{.3125f, down, .3125f, 1, up, .6875f}; if(dummy-3==5) - return new float[]{0,down,.3125f, .6875f,up,.6875f}; + return new float[]{0, down, .3125f, .6875f, up, .6875f}; return null; } @@ -164,32 +167,34 @@ public boolean isDummy() { return dummy!=0; } + @Override public void placeDummies(BlockPos pos, IBlockState state, EnumFacing side, float hitX, float hitY, float hitZ) { - for(int i=1; i<=3; i++) + for(int i = 1; i <= 3; i++) { - world.setBlockState(pos.add(0,i,0), state); - ((TileEntityWoodenPost)world.getTileEntity(pos.add(0,i,0))).dummy = (byte)i; + world.setBlockState(pos.add(0, i, 0), state); + ((TileEntityWoodenPost)world.getTileEntity(pos.add(0, i, 0))).dummy = (byte)i; world.addBlockEvent(pos.add(0, i, 0), getBlockType(), 255, 0); } } + @Override public void breakDummies(BlockPos pos, IBlockState state) { - if(dummy<=3) - for(int i=0; i<=3; i++) + if(dummy <= 3) + for(int i = 0; i <= 3; i++) { - if(world.getTileEntity(getPos().add(0,-dummy,0).add(0,i,0)) instanceof TileEntityWoodenPost) - world.setBlockToAir(getPos().add(0,-dummy,0).add(0,i,0)); + if(world.getTileEntity(getPos().add(0, -dummy, 0).add(0, i, 0)) instanceof TileEntityWoodenPost) + world.setBlockToAir(getPos().add(0, -dummy, 0).add(0, i, 0)); if(i==3) { TileEntity te; for(EnumFacing facing : EnumFacing.HORIZONTALS) { - te = world.getTileEntity(getPos().add(0,-dummy,0).add(0,i,0).offset(facing)); - if(te instanceof TileEntityWoodenPost && ((TileEntityWoodenPost) te).dummy==(3+facing.ordinal())) - world.setBlockToAir(getPos().add(0,-dummy,0).add(0,i,0).offset(facing)); + te = world.getTileEntity(getPos().add(0, -dummy, 0).add(0, i, 0).offset(facing)); + if(te instanceof TileEntityWoodenPost&&((TileEntityWoodenPost)te).dummy==(3+facing.ordinal())) + world.setBlockToAir(getPos().add(0, -dummy, 0).add(0, i, 0).offset(facing)); } } } @@ -198,7 +203,7 @@ public void breakDummies(BlockPos pos, IBlockState state) @Override public boolean hammerUseSide(EnumFacing side, EntityPlayer player, float hitX, float hitY, float hitZ) { - if(this.dummy==3 && side.getAxis()!=Axis.Y) + if(this.dummy==3&&side.getAxis()!=Axis.Y) { BlockPos offsetPos = getPos().offset(side); //No Arms if space is blocked @@ -206,22 +211,22 @@ public boolean hammerUseSide(EnumFacing side, EntityPlayer player, float hitX, f return false; //No Arms if perpendicular arms exist TileEntity perpendicular = world.getTileEntity(getPos().offset(side.rotateY())); - if(perpendicular instanceof TileEntityWoodenPost && ((TileEntityWoodenPost)perpendicular).dummy-3==side.rotateY().ordinal()) + if(perpendicular instanceof TileEntityWoodenPost&&((TileEntityWoodenPost)perpendicular).dummy-3==side.rotateY().ordinal()) return false; perpendicular = world.getTileEntity(getPos().offset(side.rotateYCCW())); - if(perpendicular instanceof TileEntityWoodenPost && ((TileEntityWoodenPost)perpendicular).dummy-3==side.rotateYCCW().ordinal()) + if(perpendicular instanceof TileEntityWoodenPost&&((TileEntityWoodenPost)perpendicular).dummy-3==side.rotateYCCW().ordinal()) return false; world.setBlockState(offsetPos, world.getBlockState(getPos())); ((TileEntityWoodenPost)world.getTileEntity(offsetPos)).dummy = (byte)(3+side.ordinal()); this.markBlockForUpdate(offsetPos, null); - this.markBlockForUpdate(getPos().add(0,-3,0), null); + this.markBlockForUpdate(getPos().add(0, -3, 0), null); } - else if(this.dummy>3) + else if(this.dummy > 3) { EnumFacing f = EnumFacing.getFront(dummy-3).getOpposite(); this.world.setBlockToAir(getPos()); - this.markBlockForUpdate(getPos().offset(f).add(0,-3,0), null); + this.markBlockForUpdate(getPos().offset(f).add(0, -3, 0), null); } return false; } @@ -229,6 +234,6 @@ else if(this.dummy>3) @Override public boolean canConnectTransformer(IBlockAccess world, BlockPos pos) { - return this.dummy > 0 && this.dummy <= 3; + return this.dummy > 0&&this.dummy <= 3; } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/package-info.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/package-info.java index d98bb3ab71..d83d4dff15 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/package-info.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/package-info.java @@ -3,4 +3,5 @@ package blusunrize.immersiveengineering.common.blocks.wooden; import mcp.MethodsReturnNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/crafting/ArcRecyclingRecipe.java b/src/main/java/blusunrize/immersiveengineering/common/crafting/ArcRecyclingRecipe.java index 5de3cc694c..bbd1985031 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/crafting/ArcRecyclingRecipe.java +++ b/src/main/java/blusunrize/immersiveengineering/common/crafting/ArcRecyclingRecipe.java @@ -20,21 +20,22 @@ public class ArcRecyclingRecipe extends ArcFurnaceRecipe { - HashMap outputs; - public ArcRecyclingRecipe(HashMap outputs, Object input, int time, int energyPerTick) + HashMap outputs; + + public ArcRecyclingRecipe(HashMap outputs, Object input, int time, int energyPerTick) { - super(null,input,ItemStack.EMPTY, time, energyPerTick); + super(null, input, ItemStack.EMPTY, time, energyPerTick); this.outputs = outputs; this.setSpecialRecipeType("Recycling"); this.outputList = NonNullList.create(); - for(Entry e : outputs.entrySet()) + for(Entry e : outputs.entrySet()) { double scaledOut = e.getValue(); //Noone likes nuggets anyway >_> - if(scaledOut>=1) - outputList.add(Utils.copyStackWithAmount(e.getKey(),(int)scaledOut)); + if(scaledOut >= 1) + outputList.add(Utils.copyStackWithAmount(e.getKey(), (int)scaledOut)); int nuggetOut = (int)((scaledOut-(int)scaledOut)*9); - if(nuggetOut>0) + if(nuggetOut > 0) { String[] type = ApiUtils.getMetalComponentTypeAndMetal(e.getKey(), "ingot"); if(type!=null) @@ -51,16 +52,16 @@ public NonNullList getOutputs(ItemStack input, NonNullList { if(outputs==null) return NonNullList.create(); - float mod = !input.isItemStackDamageable()?1:(input.getMaxDamage()-input.getItemDamage())/(float)input.getMaxDamage(); + float mod = !input.isItemStackDamageable()?1: (input.getMaxDamage()-input.getItemDamage())/(float)input.getMaxDamage(); NonNullList outs = NonNullList.create(); - for(Entry e : outputs.entrySet()) + for(Entry e : outputs.entrySet()) { double scaledOut = mod*e.getValue(); //Noone likes nuggets anyway >_> - if(scaledOut>=1) - outs.add(Utils.copyStackWithAmount(e.getKey(),(int)scaledOut)); + if(scaledOut >= 1) + outs.add(Utils.copyStackWithAmount(e.getKey(), (int)scaledOut)); int nuggetOut = (int)((scaledOut-(int)scaledOut)*9); - if(nuggetOut>0) + if(nuggetOut > 0) { String[] type = ApiUtils.getMetalComponentTypeAndMetal(e.getKey(), "ingot"); if(type!=null) @@ -72,10 +73,10 @@ public NonNullList getOutputs(ItemStack input, NonNullList } return outs; } - + @Override public boolean matches(ItemStack input, NonNullList additives) { - return !input.isEmpty() && this.input.matchesItemStack(input); + return !input.isEmpty()&&this.input.matchesItemStack(input); } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/crafting/ArcRecyclingThreadHandler.java b/src/main/java/blusunrize/immersiveengineering/common/crafting/ArcRecyclingThreadHandler.java index 4a2088f749..82207b1bdd 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/crafting/ArcRecyclingThreadHandler.java +++ b/src/main/java/blusunrize/immersiveengineering/common/crafting/ArcRecyclingThreadHandler.java @@ -30,10 +30,12 @@ public class ArcRecyclingThreadHandler extends Thread static boolean hasProfiled = false; public static List recipesToAdd = null; private List recipeList = null; + private ArcRecyclingThreadHandler(List r) { recipeList = r; } + public static void doRecipeProfiling() { Iterator prevRecipeIt = ArcFurnaceRecipe.recipeList.iterator(); @@ -53,27 +55,30 @@ public static void doRecipeProfiling() recipesToAdd = null; new ArcRecyclingThreadHandler(ForgeRegistries.RECIPES.getValues()).start(); } + @Override - public void run() { + public void run() + { int threadAmount = Runtime.getRuntime().availableProcessors(); IELogger.info("Starting recipe profiler for Arc Recycling, using "+threadAmount+" Threads"); long timestamp = System.currentTimeMillis(); RegistryIterationThread[] threads = new RegistryIterationThread[threadAmount]; boolean divisable = recipeList.size()%threadAmount==0; - int limit = divisable?(recipeList.size()/threadAmount) : (recipeList.size()/(threadAmount-1)); - int leftOver = divisable?limit:(recipeList.size()-(threadAmount-1)*limit); + int limit = divisable?(recipeList.size()/threadAmount): (recipeList.size()/(threadAmount-1)); + int leftOver = divisable?limit: (recipeList.size()-(threadAmount-1)*limit); for(int i = 0; i < threadAmount; i++) - threads[i] = new RegistryIterationThread(recipeList, limit*i, i==(threadAmount-1)?leftOver:limit); + threads[i] = new RegistryIterationThread(recipeList, limit*i, i==(threadAmount-1)?leftOver: limit); //iterate over each thread individually ArrayList validated = new ArrayList(); ArrayListMultimap nonValidated = ArrayListMultimap.create(); int invalidCount = 0; - for(int i=0; i newlyValid = new ArrayList(); - for(RecyclingCalculation valid : validated) + for(RecyclingCalculation valid : validated) { - Iterator> itNonValid = nonValidated.entries().iterator(); + Iterator> itNonValid = nonValidated.entries().iterator(); while(itNonValid.hasNext()) { - Map.Entry e = itNonValid.next(); + Map.Entry e = itNonValid.next(); if(OreDictionary.itemMatches(e.getKey(), valid.stack, false)) { RecyclingCalculation nonValid = e.getValue(); @@ -114,11 +118,11 @@ public void run() { //HashSet to avoid duplicates HashSet finishedRecycles = new HashSet(); List ret = new ArrayList<>(); - for(RecyclingCalculation valid : validated) - if(finishedRecycles.add(valid.stack.toString()) && !valid.outputs.isEmpty()) + for(RecyclingCalculation valid : validated) + if(finishedRecycles.add(valid.stack.toString())&&!valid.outputs.isEmpty()) ret.add(new ArcRecyclingRecipe(valid.outputs, valid.stack, 100, 512)); - for(RecyclingCalculation invalid : Sets.newHashSet(nonValidated.values())) - if(finishedRecycles.add(invalid.stack.toString()) && !invalid.outputs.isEmpty()) + for(RecyclingCalculation invalid : Sets.newHashSet(nonValidated.values())) + if(finishedRecycles.add(invalid.stack.toString())&&!invalid.outputs.isEmpty()) { // IELogger.info("Couldn't fully analyze "+invalid.stack+", missing knowledge for "+invalid.queriedSubcomponents); ret.add(new ArcRecyclingRecipe(invalid.outputs, invalid.stack, 100, 512)); @@ -127,6 +131,7 @@ public void run() { recipesToAdd = ret; hasProfiled = true; } + public static class RegistryIterationThread extends Thread { final List recipeList; @@ -147,10 +152,10 @@ public RegistryIterationThread(List recipeList, int baseOffset, int pas @Override public void run() { - for(int pass=0; pass missingSub = new ArrayList(); - HashMap outputs = new HashMap(); + HashMap outputs = new HashMap(); for(Ingredient in : inputs) if(in!=null) { @@ -195,12 +200,12 @@ public static RecyclingCalculation getRecycleCalculation(ItemStack stack, IRecip missingSub.add(inputStack); continue; } - if(brokenDown[0]!=null && brokenDown[0] instanceof ItemStack && brokenDown[1]!=null && (Double)brokenDown[1] > 0) + if(brokenDown[0]!=null&&brokenDown[0] instanceof ItemStack&&brokenDown[1]!=null&&(Double)brokenDown[1] > 0) { boolean invalidOutput = false; for(Object invalid : ArcFurnaceRecipe.invalidRecyclingOutput) if(Utils.stackMatchesObject((ItemStack)brokenDown[0], invalid)) - invalidOutput=true; + invalidOutput = true; if(!invalidOutput) { boolean b = false; @@ -208,28 +213,30 @@ public static RecyclingCalculation getRecycleCalculation(ItemStack stack, IRecip if(OreDictionary.itemMatches((ItemStack)brokenDown[0], storedOut, false)) { outputs.put(storedOut, outputs.get(storedOut)+(Double)brokenDown[1]/inputSize); - b=true; + b = true; } if(!b) - outputs.put(Utils.copyStackWithAmount((ItemStack)brokenDown[0],1), (Double)brokenDown[1]/inputSize); + outputs.put(Utils.copyStackWithAmount((ItemStack)brokenDown[0], 1), (Double)brokenDown[1]/inputSize); } } } - if(!outputs.isEmpty() || !missingSub.isEmpty()) + if(!outputs.isEmpty()||!missingSub.isEmpty()) { - RecyclingCalculation calc = new RecyclingCalculation(recipe, Utils.copyStackWithAmount(stack,1), outputs); + RecyclingCalculation calc = new RecyclingCalculation(recipe, Utils.copyStackWithAmount(stack, 1), outputs); calc.queriedSubcomponents.addAll(missingSub); return calc; } } return null; } + public static class RecyclingCalculation { IRecipe recipe; ItemStack stack; HashMap outputs; ArrayList queriedSubcomponents = new ArrayList(); + public RecyclingCalculation(IRecipe recipe, ItemStack stack, HashMap outputs) { this.recipe = recipe; @@ -239,8 +246,9 @@ public RecyclingCalculation(IRecipe recipe, ItemStack stack, HashMap e : calc.outputs.entrySet()) + for(Map.Entry e : calc.outputs.entrySet()) { boolean b = true; for(ItemStack key : outputs.keySet()) diff --git a/src/main/java/blusunrize/immersiveengineering/common/crafting/ConditionFactoryIEConfig.java b/src/main/java/blusunrize/immersiveengineering/common/crafting/ConditionFactoryIEConfig.java index c797de10b8..5fc7bb701e 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/crafting/ConditionFactoryIEConfig.java +++ b/src/main/java/blusunrize/immersiveengineering/common/crafting/ConditionFactoryIEConfig.java @@ -25,8 +25,8 @@ public class ConditionFactoryIEConfig implements IConditionFactory @Override public BooleanSupplier parse(JsonContext context, JsonObject json) { - String key = JsonUtils.getString(json , "key"); - boolean value = JsonUtils.getBoolean(json , "value", true); - return () -> Config.manual_bool.get(key) == value; + String key = JsonUtils.getString(json, "key"); + boolean value = JsonUtils.getBoolean(json, "value", true); + return () -> Config.manual_bool.get(key)==value; } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/crafting/ConditionFactoryOreExists.java b/src/main/java/blusunrize/immersiveengineering/common/crafting/ConditionFactoryOreExists.java index 4eb9dc13cd..bf489cf1dc 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/crafting/ConditionFactoryOreExists.java +++ b/src/main/java/blusunrize/immersiveengineering/common/crafting/ConditionFactoryOreExists.java @@ -25,8 +25,8 @@ public class ConditionFactoryOreExists implements IConditionFactory @Override public BooleanSupplier parse(JsonContext context, JsonObject json) { - String key = JsonUtils.getString(json , "ore"); - boolean value = JsonUtils.getBoolean(json , "value", true); - return () -> ApiUtils.isExistingOreName(key) == value; + String key = JsonUtils.getString(json, "ore"); + boolean value = JsonUtils.getBoolean(json, "value", true); + return () -> ApiUtils.isExistingOreName(key)==value; } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/crafting/IngredientFactoryStackableNBT.java b/src/main/java/blusunrize/immersiveengineering/common/crafting/IngredientFactoryStackableNBT.java index 2fb0ffa772..bdf6e9f1e9 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/crafting/IngredientFactoryStackableNBT.java +++ b/src/main/java/blusunrize/immersiveengineering/common/crafting/IngredientFactoryStackableNBT.java @@ -34,6 +34,7 @@ public static class IngredientStackableNBT extends Ingredient { @Nonnull private final ItemStack stack; + public IngredientStackableNBT(@Nonnull ItemStack match) { super(match); @@ -43,7 +44,7 @@ public IngredientStackableNBT(@Nonnull ItemStack match) @Override public boolean apply(@Nullable ItemStack input) { - if (input==null||!super.apply(input)) + if(input==null||!super.apply(input)) return false; Optional tag1 = Optional.ofNullable(stack.getTagCompound()); Optional tag2 = Optional.ofNullable(input.getTagCompound()); diff --git a/src/main/java/blusunrize/immersiveengineering/common/crafting/IngredientFluidStack.java b/src/main/java/blusunrize/immersiveengineering/common/crafting/IngredientFluidStack.java index 6f08613a80..bf72092e20 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/crafting/IngredientFluidStack.java +++ b/src/main/java/blusunrize/immersiveengineering/common/crafting/IngredientFluidStack.java @@ -28,6 +28,7 @@ public IngredientFluidStack(FluidStack fluid) super(0); this.fluid = fluid; } + public IngredientFluidStack(Fluid fluid, int amount) { this(new FluidStack(fluid, amount)); @@ -39,6 +40,7 @@ public FluidStack getFluid() } ItemStack[] cachedStacks; + @Override public ItemStack[] getMatchingStacks() { @@ -52,14 +54,14 @@ public ItemStack[] getMatchingStacks() @Override public boolean apply(@Nullable ItemStack stack) { - if (stack == null) + if(stack==null) { return false; } else { FluidStack fs = FluidUtil.getFluidContained(stack); - return fs == null && this.fluid == null || fs != null && fs.containsFluid(fluid); + return fs==null&&this.fluid==null||fs!=null&&fs.containsFluid(fluid); } } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/crafting/IngredientIngrStack.java b/src/main/java/blusunrize/immersiveengineering/common/crafting/IngredientIngrStack.java index d630e4aa0a..5d1efc32b4 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/crafting/IngredientIngrStack.java +++ b/src/main/java/blusunrize/immersiveengineering/common/crafting/IngredientIngrStack.java @@ -46,7 +46,7 @@ public IngredientIngrStack(IngredientStack ingredientStack) public ItemStack[] getMatchingStacks() { List list = null; - if(array==null || this.array.length!=(list=this.ingredientStack.getSizedStackList()).size()) + if(array==null||this.array.length!=(list = this.ingredientStack.getSizedStackList()).size()) { if(list==null) list = this.ingredientStack.getSizedStackList(); @@ -54,7 +54,7 @@ public ItemStack[] getMatchingStacks() List list2 = new ArrayList<>(list.size()); for(ItemStack stack : list) { - if(stack.getMetadata() == OreDictionary.WILDCARD_VALUE) + if(stack.getMetadata()==OreDictionary.WILDCARD_VALUE) { NonNullList lst = NonNullList.create(); stack.getItem().getSubItems(CreativeTabs.SEARCH, lst); @@ -75,7 +75,7 @@ public ItemStack[] getMatchingStacks() public IntList getValidItemStacksPacked() { List list = null; - if(this.itemIds==null || this.itemIds.size()!=(list=this.ingredientStack.getSizedStackList()).size()) + if(this.itemIds==null||this.itemIds.size()!=(list = this.ingredientStack.getSizedStackList()).size()) { if(list==null) list = this.ingredientStack.getSizedStackList(); @@ -83,7 +83,7 @@ public IntList getValidItemStacksPacked() this.itemIds = new IntArrayList(list.size()); for(ItemStack stack : list) { - if(stack.getMetadata() == OreDictionary.WILDCARD_VALUE) + if(stack.getMetadata()==OreDictionary.WILDCARD_VALUE) { NonNullList lst = NonNullList.create(); stack.getItem().getSubItems(CreativeTabs.SEARCH, lst); @@ -103,7 +103,7 @@ public IntList getValidItemStacksPacked() @Override public boolean apply(@Nullable ItemStack input) { - if(input == null) + if(input==null) return false; return this.ingredientStack.matchesItemStack(input); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/crafting/IngredientMultiOre.java b/src/main/java/blusunrize/immersiveengineering/common/crafting/IngredientMultiOre.java index e083ba6ee0..9be991610d 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/crafting/IngredientMultiOre.java +++ b/src/main/java/blusunrize/immersiveengineering/common/crafting/IngredientMultiOre.java @@ -36,13 +36,13 @@ public IngredientMultiOre(String... ores) { super(0); this.ores = new NonNullList[ores.length]; - for(int i=0; i list : ores) i += list.size(); return i; @@ -52,13 +52,13 @@ private int totalSize() @Nonnull public ItemStack[] getMatchingStacks() { - if(array==null || this.array.length!=totalSize()) + if(array==null||this.array.length!=totalSize()) { NonNullList lst = NonNullList.create(); for(NonNullList list : ores) for(ItemStack stack : list) { - if(stack.getMetadata() == OreDictionary.WILDCARD_VALUE) + if(stack.getMetadata()==OreDictionary.WILDCARD_VALUE) stack.getItem().getSubItems(CreativeTabs.SEARCH, lst); else lst.add(stack); @@ -73,14 +73,14 @@ public ItemStack[] getMatchingStacks() @SideOnly(Side.CLIENT) public IntList getValidItemStacksPacked() { - if(this.itemIds==null || this.itemIds.size()!=totalSize()) + if(this.itemIds==null||this.itemIds.size()!=totalSize()) { this.itemIds = new IntArrayList(totalSize()); for(NonNullList list : ores) for(ItemStack stack : list) { - if(stack.getMetadata() == OreDictionary.WILDCARD_VALUE) + if(stack.getMetadata()==OreDictionary.WILDCARD_VALUE) { NonNullList lst = NonNullList.create(); stack.getItem().getSubItems(CreativeTabs.SEARCH, lst); @@ -102,7 +102,7 @@ public IntList getValidItemStacksPacked() @Override public boolean apply(@Nullable ItemStack input) { - if(input == null) + if(input==null) return false; for(NonNullList list : ores) diff --git a/src/main/java/blusunrize/immersiveengineering/common/crafting/MetalPressPackingRecipe.java b/src/main/java/blusunrize/immersiveengineering/common/crafting/MetalPressPackingRecipe.java index 8894454b74..ee96f539b8 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/crafting/MetalPressPackingRecipe.java +++ b/src/main/java/blusunrize/immersiveengineering/common/crafting/MetalPressPackingRecipe.java @@ -57,8 +57,9 @@ public boolean listInJEI() @Override public boolean matches(ItemStack mold, ItemStack input) { - return input.getCount()>=this.totalAmount && getOutputCached(input)!=null; + return input.getCount() >= this.totalAmount&&getOutputCached(input)!=null; } + @Override public MetalPressRecipe getActualRecipe(ItemStack mold, ItemStack input) { @@ -68,11 +69,13 @@ public MetalPressRecipe getActualRecipe(ItemStack mold, ItemStack input) public static class PackedDelegate extends MetalPressRecipe { private final ComparableItemStack mapKey; + public PackedDelegate(ComparableItemStack mapKey, ItemStack output, Object input, ComparableItemStack mold, int energy) { super(output, input, mold, energy); this.mapKey = mapKey; } + @Override public boolean listInJEI() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/crafting/MetalPressUnpackingRecipe.java b/src/main/java/blusunrize/immersiveengineering/common/crafting/MetalPressUnpackingRecipe.java index 93ad99acb6..03b1829daf 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/crafting/MetalPressUnpackingRecipe.java +++ b/src/main/java/blusunrize/immersiveengineering/common/crafting/MetalPressUnpackingRecipe.java @@ -52,6 +52,7 @@ public boolean matches(ItemStack mold, ItemStack input) { return getOutputCached(input)!=null; } + @Override public MetalPressRecipe getActualRecipe(ItemStack mold, ItemStack input) { @@ -61,11 +62,13 @@ public MetalPressRecipe getActualRecipe(ItemStack mold, ItemStack input) public static class PackedDelegate extends MetalPressRecipe { private final ComparableItemStack mapKey; + public PackedDelegate(ComparableItemStack mapKey, ItemStack output, Object input, ComparableItemStack mold, int energy) { super(output, input, mold, energy); this.mapKey = mapKey; } + @Override public boolean listInJEI() { @@ -92,17 +95,17 @@ private PackedDelegate getOutputCached(ItemStack input) return this.cache.get(comp); comp.copy(); - ItemStack out = MetalPressPackingRecipe.getPackedOutput(1,1, input); + ItemStack out = MetalPressPackingRecipe.getPackedOutput(1, 1, input); int count = out.getCount(); - if(count!=4 && count!=9) + if(count!=4&&count!=9) { this.cache.put(comp, null); return null; } - ItemStack rePacked = MetalPressPackingRecipe.getPackedOutput(count==4?2:3, count, out); - if(rePacked.isEmpty() || !OreDictionary.itemMatches(input, rePacked, true)) + ItemStack rePacked = MetalPressPackingRecipe.getPackedOutput(count==4?2: 3, count, out); + if(rePacked.isEmpty()||!OreDictionary.itemMatches(input, rePacked, true)) { this.cache.put(comp, null); return null; diff --git a/src/main/java/blusunrize/immersiveengineering/common/crafting/MixerRecipePotion.java b/src/main/java/blusunrize/immersiveengineering/common/crafting/MixerRecipePotion.java index 888b00da94..513b935269 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/crafting/MixerRecipePotion.java +++ b/src/main/java/blusunrize/immersiveengineering/common/crafting/MixerRecipePotion.java @@ -25,17 +25,18 @@ public class MixerRecipePotion extends MixerRecipe { public final PotionType inputPotionType; + public MixerRecipePotion(PotionType inputType) { - super(new FluidStack(IEContent.fluidPotion,1000), getFluidStackForType(inputType,1000), new Object[0], 6400); + super(new FluidStack(IEContent.fluidPotion, 1000), getFluidStackForType(inputType, 1000), new Object[0], 6400); this.inputPotionType = inputType; } public static FluidStack getFluidStackForType(PotionType type, int amount) { - if(type==PotionTypes.WATER || type==null) - return new FluidStack(FluidRegistry.WATER,amount); - FluidStack stack = new FluidStack(IEContent.fluidPotion,amount); + if(type==PotionTypes.WATER||type==null) + return new FluidStack(FluidRegistry.WATER, amount); + FluidStack stack = new FluidStack(IEContent.fluidPotion, amount); stack.tag = new NBTTagCompound(); stack.tag.setString("Potion", PotionType.REGISTRY.getNameForObject(type).toString()); return stack; @@ -56,7 +57,7 @@ public FluidStack getFluidOutput(FluidStack input, NonNullList compon @Override public boolean matches(FluidStack fluid, NonNullList components) { - if(fluid!=null && fluid.containsFluid(this.fluidInput)) + if(fluid!=null&&fluid.containsFluid(this.fluidInput)) for(PotionHelper.MixPredicate mixPredicate : PotionHelper.POTION_TYPE_CONVERSIONS) if(mixPredicate.input==this.inputPotionType) for(ItemStack stack : components) @@ -68,8 +69,8 @@ public boolean matches(FluidStack fluid, NonNullList components) @Override public int[] getUsedSlots(FluidStack fluid, NonNullList components) { - for(int i = 0; i< components.size(); i++) - if(!components.get(i).isEmpty() && PotionHelper.isReagent(components.get(i))) + for(int i = 0; i < components.size(); i++) + if(!components.get(i).isEmpty()&&PotionHelper.isReagent(components.get(i))) return new int[]{i}; return new int[0]; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeBannerAdvanced.java b/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeBannerAdvanced.java index 9891200e1f..9e2adf8f15 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeBannerAdvanced.java +++ b/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeBannerAdvanced.java @@ -28,11 +28,11 @@ public class RecipeBannerAdvanced extends RecipesBanners.RecipeAddPattern public static void addAdvancedPatternRecipe(BannerPattern pattern, IngredientStack stack, int... offset) { - if(offset!=null && offset.length>0) + if(offset!=null&&offset.length > 0) { int[] slotOffset = new int[2]; slotOffset[0] = offset[0]; - if(offset.length>1) + if(offset.length > 1) slotOffset[1] = offset[1]; advancedPatterns.put(pattern, new RecipeReference(stack, slotOffset)); } @@ -58,10 +58,10 @@ protected BannerPattern matchPatterns(InventoryCrafting invCrafting) boolean hasIngr = false; boolean hasColour = false; - for(int i=0; i0)//banner needs to be left, but ingr is in leftmost column - ||(i%w==w-1 && ref.offsetToBanner[0]<0)//banner needs to be right but ingr is in rightmost column - ||(i/h==0 && ref.offsetToBanner[1]>0)//banner needs to be above but ingr is in topmost row - ||(i/h==h-1 && ref.offsetToBanner[1]<0)//banner needs to be below but ingr is in bottommost row - ||(bannerSlot<0||bannerSlot>=invCrafting.getSizeInventory()))//bannerslot is outside grid + if((i%w==0&&ref.offsetToBanner[0] > 0)//banner needs to be left, but ingr is in leftmost column + ||(i%w==w-1&&ref.offsetToBanner[0] < 0)//banner needs to be right but ingr is in rightmost column + ||(i/h==0&&ref.offsetToBanner[1] > 0)//banner needs to be above but ingr is in topmost row + ||(i/h==h-1&&ref.offsetToBanner[1] < 0)//banner needs to be below but ingr is in bottommost row + ||(bannerSlot < 0||bannerSlot >= invCrafting.getSizeInventory()))//bannerslot is outside grid { matchesPattern = false; break; } ItemStack bannerCheck = invCrafting.getStackInSlot(bannerSlot); - if(bannerCheck.isEmpty() || bannerCheck.getItem()!=Items.BANNER) + if(bannerCheck.isEmpty()||bannerCheck.getItem()!=Items.BANNER) { matchesPattern = false; break; @@ -121,6 +121,7 @@ public RecipeReference(IngredientStack ingredient) { this.ingredient = ingredient; } + public RecipeReference(IngredientStack ingredient, int[] offsetToBanner) { this.ingredient = ingredient; diff --git a/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeEarmuffs.java b/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeEarmuffs.java index 5eb54b29f1..d2a82115c2 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeEarmuffs.java +++ b/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeEarmuffs.java @@ -35,20 +35,20 @@ public boolean matches(InventoryCrafting inv, World world) ItemStack earmuffs = ItemStack.EMPTY; ItemStack armor = ItemStack.EMPTY; List list = Lists.newArrayList(); - for(int i=0;i> 16 & 255) / 255.0F; - float g = (float)(colour >> 8 & 255) / 255.0F; - float b = (float)(colour & 255) / 255.0F; - j = (int)((float)j + Math.max(r, Math.max(g, b)) * 255.0F); - colourArray[0] = (int)((float)colourArray[0] + r * 255.0F); - colourArray[1] = (int)((float)colourArray[1] + g * 255.0F); - colourArray[2] = (int)((float)colourArray[2] + b * 255.0F); + float r = (float)(colour >> 16&255)/255.0F; + float g = (float)(colour >> 8&255)/255.0F; + float b = (float)(colour&255)/255.0F; + j = (int)((float)j+Math.max(r, Math.max(g, b))*255.0F); + colourArray[0] = (int)((float)colourArray[0]+r*255.0F); + colourArray[1] = (int)((float)colourArray[1]+g*255.0F); + colourArray[2] = (int)((float)colourArray[2]+b*255.0F); ++totalColourSets; } else if(Utils.isDye(stackInSlot)) { float[] afloat = EntitySheep.getDyeRgb(EnumDyeColor.byDyeDamage(Utils.getDye(stackInSlot))); - int r = (int)(afloat[0] * 255.0F); - int g = (int)(afloat[1] * 255.0F); - int b = (int)(afloat[2] * 255.0F); + int r = (int)(afloat[0]*255.0F); + int g = (int)(afloat[1]*255.0F); + int b = (int)(afloat[2]*255.0F); j += Math.max(r, Math.max(g, b)); colourArray[0] += r; colourArray[1] += g; colourArray[2] += b; ++totalColourSets; } - else if(armor.isEmpty() && stackInSlot.getItem() instanceof ItemArmor && ((ItemArmor)stackInSlot.getItem()).armorType==EntityEquipmentSlot.HEAD && !IEContent.itemEarmuffs.equals(stackInSlot.getItem())) + else if(armor.isEmpty()&&stackInSlot.getItem() instanceof ItemArmor&&((ItemArmor)stackInSlot.getItem()).armorType==EntityEquipmentSlot.HEAD&&!IEContent.itemEarmuffs.equals(stackInSlot.getItem())) armor = stackInSlot; } if(!earmuffs.isEmpty()) { - if(totalColourSets>1) + if(totalColourSets > 1) { - int r = colourArray[0] / totalColourSets; - int g = colourArray[1] / totalColourSets; - int b = colourArray[2] / totalColourSets; - float colourMod = (float)j / (float)totalColourSets; + int r = colourArray[0]/totalColourSets; + int g = colourArray[1]/totalColourSets; + int b = colourArray[2]/totalColourSets; + float colourMod = (float)j/(float)totalColourSets; float highestColour = (float)Math.max(r, Math.max(g, b)); - r = (int)((float)r * colourMod / highestColour); - g = (int)((float)g * colourMod / highestColour); - b = (int)((float)b * colourMod / highestColour); - int newColour = (r << 8) + g; - newColour = (newColour << 8) + b; + r = (int)((float)r*colourMod/highestColour); + g = (int)((float)g*colourMod/highestColour); + b = (int)((float)b*colourMod/highestColour); + int newColour = (r<<8)+g; + newColour = (newColour<<8)+b; ItemNBTHelper.setInt(earmuffs, Lib.NBT_EarmuffColour, newColour); } ItemStack output; @@ -120,7 +120,7 @@ else if(armor.isEmpty() && stackInSlot.getItem() instanceof ItemArmor && ((ItemA output = earmuffs.copy(); return output; } - else if(!armor.isEmpty() && ItemNBTHelper.hasKey(armor, Lib.NBT_Earmuffs)) + else if(!armor.isEmpty()&&ItemNBTHelper.hasKey(armor, Lib.NBT_Earmuffs)) { ItemStack output = armor.copy(); ItemNBTHelper.remove(output, Lib.NBT_Earmuffs); @@ -132,23 +132,23 @@ else if(!armor.isEmpty() && ItemNBTHelper.hasKey(armor, Lib.NBT_Earmuffs)) @Override public boolean canFit(int width, int height) { - return width>=2 && height>=2; + return width >= 2&&height >= 2; } @Override public ItemStack getRecipeOutput() { - return new ItemStack(IEContent.itemBullet,1,10); + return new ItemStack(IEContent.itemBullet, 1, 10); } @Override public NonNullList getRemainingItems(InventoryCrafting inv) { NonNullList remaining = ForgeHooks.defaultRecipeGetRemainingItems(inv); - for(int i=0;i list = Lists.newArrayList(); - for(int i=0;i> 16 & 255) / 255.0F; - float g = (float)(colour >> 8 & 255) / 255.0F; - float b = (float)(colour & 255) / 255.0F; - j = (int)((float)j + Math.max(r, Math.max(g, b)) * 255.0F); - colourArray[0] = (int)((float)colourArray[0] + r * 255.0F); - colourArray[1] = (int)((float)colourArray[1] + g * 255.0F); - colourArray[2] = (int)((float)colourArray[2] + b * 255.0F); + float r = (float)(colour >> 16&255)/255.0F; + float g = (float)(colour >> 8&255)/255.0F; + float b = (float)(colour&255)/255.0F; + j = (int)((float)j+Math.max(r, Math.max(g, b))*255.0F); + colourArray[0] = (int)((float)colourArray[0]+r*255.0F); + colourArray[1] = (int)((float)colourArray[1]+g*255.0F); + colourArray[2] = (int)((float)colourArray[2]+b*255.0F); ++totalColourSets; } else if(Utils.isDye(stackInSlot)) { float[] afloat = EntitySheep.getDyeRgb(EnumDyeColor.byDyeDamage(Utils.getDye(stackInSlot))); - int r = (int)(afloat[0] * 255.0F); - int g = (int)(afloat[1] * 255.0F); - int b = (int)(afloat[2] * 255.0F); + int r = (int)(afloat[0]*255.0F); + int g = (int)(afloat[1]*255.0F); + int b = (int)(afloat[2]*255.0F); j += Math.max(r, Math.max(g, b)); colourArray[0] += r; colourArray[1] += g; @@ -90,16 +90,16 @@ else if(Utils.isDye(stackInSlot)) { ItemStack newBullet = Utils.copyStackWithAmount(bullet, 1); - int r = colourArray[0] / totalColourSets; - int g = colourArray[1] / totalColourSets; - int b = colourArray[2] / totalColourSets; - float colourMod = (float)j / (float)totalColourSets; + int r = colourArray[0]/totalColourSets; + int g = colourArray[1]/totalColourSets; + int b = colourArray[2]/totalColourSets; + float colourMod = (float)j/(float)totalColourSets; float highestColour = (float)Math.max(r, Math.max(g, b)); - r = (int)((float)r * colourMod / highestColour); - g = (int)((float)g * colourMod / highestColour); - b = (int)((float)b * colourMod / highestColour); - int newColour = (r << 8) + g; - newColour = (newColour << 8) + b; + r = (int)((float)r*colourMod/highestColour); + g = (int)((float)g*colourMod/highestColour); + b = (int)((float)b*colourMod/highestColour); + int newColour = (r<<8)+g; + newColour = (newColour<<8)+b; ItemNBTHelper.setInt(newBullet, "flareColour", newColour); return newBullet; } @@ -109,7 +109,7 @@ else if(Utils.isDye(stackInSlot)) @Override public boolean canFit(int width, int height) { - return width>=2 && height>=2; + return width >= 2&&height >= 2; } @Override diff --git a/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeIEItemRepair.java b/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeIEItemRepair.java index 57207eb411..dfd9f8fcf4 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeIEItemRepair.java +++ b/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeIEItemRepair.java @@ -9,7 +9,6 @@ package blusunrize.immersiveengineering.common.crafting; import blusunrize.immersiveengineering.api.Lib; -import blusunrize.immersiveengineering.common.items.IEItemInterfaces; import blusunrize.immersiveengineering.common.items.IEItemInterfaces.IItemDamageableIE; import blusunrize.immersiveengineering.common.util.ItemNBTHelper; import net.minecraft.inventory.InventoryCrafting; @@ -41,20 +40,20 @@ public boolean matches(InventoryCrafting inv, World worldIn) public ItemStack getCraftingResult(InventoryCrafting inv) { int[] relevant = getRelevantStacks(inv); - if (relevant == null) + if(relevant==null) return ItemStack.EMPTY; ItemStack first = inv.getStackInSlot(relevant[0]); ItemStack second = inv.getStackInSlot(relevant[1]); - IItemDamageableIE firstDamage = (IItemDamageableIE) first.getItem(); - IItemDamageableIE secondDamage = (IItemDamageableIE) second.getItem(); + IItemDamageableIE firstDamage = (IItemDamageableIE)first.getItem(); + IItemDamageableIE secondDamage = (IItemDamageableIE)second.getItem(); - int j = firstDamage.getMaxDamageIE(first) - firstDamage.getItemDamageIE(first); - int k = firstDamage.getMaxDamageIE(first) - secondDamage.getItemDamageIE(second); - int l = j + k + firstDamage.getMaxDamageIE(first) * 5 / 100; - int i1 = firstDamage.getMaxDamageIE(first) - l; + int j = firstDamage.getMaxDamageIE(first)-firstDamage.getItemDamageIE(first); + int k = firstDamage.getMaxDamageIE(first)-secondDamage.getItemDamageIE(second); + int l = j+k+firstDamage.getMaxDamageIE(first)*5/100; + int i1 = firstDamage.getMaxDamageIE(first)-l; - if (i1 < 0) + if(i1 < 0) i1 = 0; ItemStack ret = new ItemStack(first.getItem(), 1, first.getMetadata()); @@ -68,7 +67,7 @@ public NonNullList getRemainingItems(InventoryCrafting inv) { NonNullList ret = super.getRemainingItems(inv); int[] relevantStacks = getRelevantStacks(inv); - if (relevantStacks!=null) + if(relevantStacks!=null) { ret.set(relevantStacks[0], ItemStack.EMPTY); ret.set(relevantStacks[1], ItemStack.EMPTY); @@ -81,22 +80,22 @@ private int[] getRelevantStacks(InventoryCrafting inv) { int[] ret = new int[2]; int indexInRet = 0; - for (int i = 0; i < inv.getSizeInventory(); ++i) + for(int i = 0; i < inv.getSizeInventory(); ++i) { ItemStack curr = inv.getStackInSlot(i); - if (tool.apply(curr) && curr.getItem() instanceof IItemDamageableIE) + if(tool.apply(curr)&&curr.getItem() instanceof IItemDamageableIE) { - if (indexInRet>1) + if(indexInRet > 1) return null; ret[indexInRet] = i; indexInRet++; } - else if (!curr.isEmpty()) + else if(!curr.isEmpty()) return null; } - return indexInRet==2?ret:null; + return indexInRet==2?ret: null; } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeJerrycan.java b/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeJerrycan.java index a8e489bf2b..943313405f 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeJerrycan.java +++ b/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeJerrycan.java @@ -33,11 +33,11 @@ public boolean matches(@Nonnull InventoryCrafting inv, World world) ItemStack jerrycan = ItemStack.EMPTY; ItemStack container = ItemStack.EMPTY; int[] slots = getRelevantSlots(inv); - if (slots[0]>=0) + if(slots[0] >= 0) jerrycan = inv.getStackInSlot(slots[0]); - if (slots[1]>=0) + if(slots[1] >= 0) container = inv.getStackInSlot(slots[1]); - if(!jerrycan.isEmpty() && !container.isEmpty()) + if(!jerrycan.isEmpty()&&!container.isEmpty()) { IFluidHandler handler = FluidUtil.getFluidHandler(container); FluidStack fs = handler.drain(Integer.MAX_VALUE, false); @@ -54,19 +54,19 @@ public ItemStack getCraftingResult(@Nonnull InventoryCrafting inv) ItemStack container = ItemStack.EMPTY; FluidStack fs = null; int[] slots = getRelevantSlots(inv); - if (slots[0]>=0) + if(slots[0] >= 0) { jerrycan = inv.getStackInSlot(slots[0]); fs = FluidUtil.getFluidContained(jerrycan); } - if (slots[1]>=0) + if(slots[1] >= 0) container = inv.getStackInSlot(slots[1]); - if(fs!=null && !container.isEmpty()) + if(fs!=null&&!container.isEmpty()) { ItemStack newContainer = Utils.copyStackWithAmount(container, 1); IFluidHandlerItem handler = FluidUtil.getFluidHandler(newContainer); int accepted = handler.fill(fs, false); - if(accepted>0) + if(accepted > 0) { handler.fill(fs, true); newContainer = handler.getContainer();// Because buckets are silly @@ -81,13 +81,13 @@ public ItemStack getCraftingResult(@Nonnull InventoryCrafting inv) private int[] getRelevantSlots(InventoryCrafting inv) { int[] ret = {-1, -1}; - for(int i=0;i=2 && height>=2; + return width >= 2&&height >= 2; } @Nonnull @@ -117,7 +117,7 @@ public NonNullList getRemainingItems(InventoryCrafting inv) { NonNullList remaining = ForgeHooks.defaultRecipeGetRemainingItems(inv); int[] inputs = getRelevantSlots(inv); - if (inputs[1]>=0) + if(inputs[1] >= 0) remaining.set(inputs[1], ItemStack.EMPTY); return remaining; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipePotionBullets.java b/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipePotionBullets.java index 5dc2c7b9a0..1fadf5b814 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipePotionBullets.java +++ b/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipePotionBullets.java @@ -27,18 +27,18 @@ public boolean matches(InventoryCrafting inv, World world) { ItemStack bullet = ItemStack.EMPTY; ItemStack potion = ItemStack.EMPTY; - for(int i=0;i=2 && height>=2; + return width >= 2&&height >= 2; } @Override @@ -72,9 +72,9 @@ public ItemStack getRecipeOutput() return BulletHandler.getBulletStack("potion"); } - @Override - public NonNullList getRemainingItems(InventoryCrafting inv) - { - return ForgeHooks.defaultRecipeGetRemainingItems(inv); - } + @Override + public NonNullList getRemainingItems(InventoryCrafting inv) + { + return ForgeHooks.defaultRecipeGetRemainingItems(inv); + } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipePowerpack.java b/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipePowerpack.java index 7f327c2ba3..647ff9256f 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipePowerpack.java +++ b/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipePowerpack.java @@ -28,18 +28,18 @@ public boolean matches(InventoryCrafting inv, World world) { ItemStack powerpack = ItemStack.EMPTY; ItemStack armor = ItemStack.EMPTY; - for(int i=0;i=2 && height>=2; + return width >= 2&&height >= 2; } @Override public ItemStack getRecipeOutput() { - return new ItemStack(IEContent.itemPowerpack,1,0); + return new ItemStack(IEContent.itemPowerpack, 1, 0); } @Override public NonNullList getRemainingItems(InventoryCrafting inv) { NonNullList remaining = ForgeHooks.defaultRecipeGetRemainingItems(inv); - for(int i=0;i getRemainingItems(InventoryCrafting inv) private boolean isValidArmor(ItemStack stack) { - if(!(stack.getItem() instanceof ItemArmor) || ((ItemArmor)stack.getItem()).armorType!=EntityEquipmentSlot.CHEST) + if(!(stack.getItem() instanceof ItemArmor)||((ItemArmor)stack.getItem()).armorType!=EntityEquipmentSlot.CHEST) return false; - if (stack.getItem()==IEContent.itemPowerpack) + if(stack.getItem()==IEContent.itemPowerpack) return false; String regName = stack.getItem().getRegistryName().toString(); for(String s : Config.IEConfig.Tools.powerpack_whitelist) diff --git a/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeRGBColouration.java b/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeRGBColouration.java index 055d43a1a6..95de85f59a 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeRGBColouration.java +++ b/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeRGBColouration.java @@ -42,12 +42,12 @@ public boolean matches(InventoryCrafting inv, World world) { ItemStack itemToColour = ItemStack.EMPTY; List list = Lists.newArrayList(); - for(int i=0;i> 16 & 255) / 255.0F; - float g = (float)(colour >> 8 & 255) / 255.0F; - float b = (float)(colour & 255) / 255.0F; - j = (int)((float)j + Math.max(r, Math.max(g, b)) * 255.0F); - colourArray[0] = (int)((float)colourArray[0] + r * 255.0F); - colourArray[1] = (int)((float)colourArray[1] + g * 255.0F); - colourArray[2] = (int)((float)colourArray[2] + b * 255.0F); + float r = (float)(colour >> 16&255)/255.0F; + float g = (float)(colour >> 8&255)/255.0F; + float b = (float)(colour&255)/255.0F; + j = (int)((float)j+Math.max(r, Math.max(g, b))*255.0F); + colourArray[0] = (int)((float)colourArray[0]+r*255.0F); + colourArray[1] = (int)((float)colourArray[1]+g*255.0F); + colourArray[2] = (int)((float)colourArray[2]+b*255.0F); ++totalColourSets; } else if(Utils.isDye(stackInSlot)) { float[] afloat = EntitySheep.getDyeRgb(EnumDyeColor.byDyeDamage(Utils.getDye(stackInSlot))); - int r = (int)(afloat[0] * 255.0F); - int g = (int)(afloat[1] * 255.0F); - int b = (int)(afloat[2] * 255.0F); + int r = (int)(afloat[0]*255.0F); + int g = (int)(afloat[1]*255.0F); + int b = (int)(afloat[2]*255.0F); j += Math.max(r, Math.max(g, b)); colourArray[0] += r; colourArray[1] += g; @@ -98,16 +98,16 @@ else if(Utils.isDye(stackInSlot)) if(!itemToColour.isEmpty()) { ItemStack newItem = Utils.copyStackWithAmount(itemToColour, 1); - int r = colourArray[0] / totalColourSets; - int g = colourArray[1] / totalColourSets; - int b = colourArray[2] / totalColourSets; - float colourMod = (float)j / (float)totalColourSets; + int r = colourArray[0]/totalColourSets; + int g = colourArray[1]/totalColourSets; + int b = colourArray[2]/totalColourSets; + float colourMod = (float)j/(float)totalColourSets; float highestColour = (float)Math.max(r, Math.max(g, b)); - r = (int)((float)r * colourMod / highestColour); - g = (int)((float)g * colourMod / highestColour); - b = (int)((float)b * colourMod / highestColour); - int newColour = (r << 8) + g; - newColour = (newColour << 8) + b; + r = (int)((float)r*colourMod/highestColour); + g = (int)((float)g*colourMod/highestColour); + b = (int)((float)b*colourMod/highestColour); + int newColour = (r<<8)+g; + newColour = (newColour<<8)+b; colourSetter.accept(newItem, newColour); return newItem; } @@ -117,7 +117,7 @@ else if(Utils.isDye(stackInSlot)) @Override public boolean canFit(int width, int height) { - return width>=2 && height>=2; + return width >= 2&&height >= 2; } @Override diff --git a/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeRevolver.java b/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeRevolver.java index 0e56462322..5f65c650f1 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeRevolver.java +++ b/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeRevolver.java @@ -23,12 +23,12 @@ public class RecipeRevolver extends net.minecraftforge.registries.IForgeRegistry public boolean matches(InventoryCrafting inv, World world) { ItemStack revolver = ItemStack.EMPTY; - for(int i=0;i=2 && height>=2; + return width >= 2&&height >= 2; } @Override @@ -67,9 +67,9 @@ public ItemStack getRecipeOutput() return ItemStack.EMPTY; } - @Override - public NonNullList getRemainingItems(InventoryCrafting inv) - { - return ForgeHooks.defaultRecipeGetRemainingItems(inv); - } + @Override + public NonNullList getRemainingItems(InventoryCrafting inv) + { + return ForgeHooks.defaultRecipeGetRemainingItems(inv); + } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeShaderBags.java b/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeShaderBags.java index d2a91c5438..c2df35f6c9 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeShaderBags.java +++ b/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeShaderBags.java @@ -25,13 +25,13 @@ public class RecipeShaderBags extends net.minecraftforge.registries.IForgeRegist public boolean matches(InventoryCrafting inv, World world) { ItemStack stack = ItemStack.EMPTY; - for(int i=0;i=2 && height>=2; + return width >= 2&&height >= 2; } @Override public ItemStack getRecipeOutput() { - return new ItemStack(IEContent.itemShaderBag,2); + return new ItemStack(IEContent.itemShaderBag, 2); } - @Override - public NonNullList getRemainingItems(InventoryCrafting inv) - { - return ForgeHooks.defaultRecipeGetRemainingItems(inv); - } + @Override + public NonNullList getRemainingItems(InventoryCrafting inv) + { + return ForgeHooks.defaultRecipeGetRemainingItems(inv); + } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeShapedIngredient.java b/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeShapedIngredient.java index 26980835d4..d50ce17682 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeShapedIngredient.java +++ b/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeShapedIngredient.java @@ -33,10 +33,12 @@ public class RecipeShapedIngredient extends ShapedOreRecipe int[] nbtCopyTargetSlot = null; Pattern nbtCopyPredicate = null; int lastMatch = 0; + public RecipeShapedIngredient(ResourceLocation group, ItemStack result, Object... recipe) { super(group, result, wrapIngredients(recipe)); } + public RecipeShapedIngredient(ResourceLocation group, ItemStack result, ShapedPrimer primer) { super(group, result, primer); @@ -45,7 +47,7 @@ public RecipeShapedIngredient(ResourceLocation group, ItemStack result, ShapedPr private static Object[] wrapIngredients(Object... recipe) { Object[] out = new Object[recipe.length]; - for(int i=0; i in for(int x = 0; x < inv.getWidth(); x++) for(int y = 0; y < inv.getHeight(); y++) { - int subX = x - startX; - int subY = y - startY; + int subX = x-startX; + int subY = y-startY; Ingredient target = Ingredient.EMPTY; if(!rotate) { - if(subX >= 0 && subY >= 0 && subX < width && subY < height) + if(subX >= 0&&subY >= 0&&subX < width&&subY < height) if(mirror) - target = ingredients.get(width - subX - 1 + subY * width); + target = ingredients.get(width-subX-1+subY*width); else - target = ingredients.get(subX + subY * width); - } else + target = ingredients.get(subX+subY*width); + } + else { - if(subX >= 0 && subY >= 0 && subX < height && subY < width) + if(subX >= 0&&subY >= 0&&subX < height&&subY < width) if(mirror) - target = ingredients.get(height - subX - 1 + subY * width); + target = ingredients.get(height-subX-1+subY*width); else - target = ingredients.get(subY + subX * height); + target = ingredients.get(subY+subX*height); } ItemStack slot = inv.getStackInRowAndColumn(x, y); diff --git a/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeShapelessIngredient.java b/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeShapelessIngredient.java index 563c1af3ee..02ba978aed 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeShapelessIngredient.java +++ b/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeShapelessIngredient.java @@ -30,14 +30,16 @@ public RecipeShapelessIngredient(ResourceLocation group, ItemStack result, Objec { super(group, result, wrapIngredients(recipe)); } + public RecipeShapelessIngredient(ResourceLocation group, ItemStack result, NonNullList input) { super(group, input, result); } + private static Object[] wrapIngredients(Object... recipe) { Object[] out = new Object[recipe.length]; - for(int i=0; i= 0 && nbtCopyTargetSlot < getIngredients().size()) + if(nbtCopyTargetSlot >= 0&&nbtCopyTargetSlot < getIngredients().size()) for(int i = 0; i < matrix.getSizeInventory(); i++) { ItemStack slot = matrix.getStackInSlot(i); if(getIngredients().get(nbtCopyTargetSlot).apply(slot)) { ItemStack out = output.copy(); - if(!matrix.getStackInSlot(nbtCopyTargetSlot).isEmpty() && matrix.getStackInSlot(nbtCopyTargetSlot).hasTagCompound()) + if(!matrix.getStackInSlot(nbtCopyTargetSlot).isEmpty()&&matrix.getStackInSlot(nbtCopyTargetSlot).hasTagCompound()) out.setTagCompound(matrix.getStackInSlot(nbtCopyTargetSlot).getTagCompound().copy()); return out; } @@ -78,29 +80,29 @@ public ItemStack getCraftingResult(InventoryCrafting matrix) @Override public NonNullList getRemainingItems(InventoryCrafting inv) { - NonNullList remains = super.getRemainingItems(inv); + NonNullList remains = super.getRemainingItems(inv); for(int i = 0; i < remains.size(); i++) { ItemStack s = inv.getStackInSlot(i); ItemStack remain = remains.get(i); - if(toolDamageSlot >= 0 && toolDamageSlot < getIngredients().size()) + if(toolDamageSlot >= 0&&toolDamageSlot < getIngredients().size()) { ItemStack tool = ItemStack.EMPTY; - if(remain.isEmpty() && !s.isEmpty() && getIngredients().get(toolDamageSlot).apply(s)) + if(remain.isEmpty()&&!s.isEmpty()&&getIngredients().get(toolDamageSlot).apply(s)) tool = s.copy(); - else if(!remain.isEmpty() && getIngredients().get(toolDamageSlot).apply(remain)) + else if(!remain.isEmpty()&&getIngredients().get(toolDamageSlot).apply(remain)) tool = remain; - if(!tool.isEmpty() && tool.isItemStackDamageable()) + if(!tool.isEmpty()&&tool.isItemStackDamageable()) { - tool.setItemDamage(tool.getItemDamage() + 1); + tool.setItemDamage(tool.getItemDamage()+1); if(tool.getItemDamage() > tool.getMaxDamage()) tool = ItemStack.EMPTY; remains.set(i, tool); } } - if(!s.isEmpty() && remain.isEmpty() && s.getItem() instanceof UniversalBucket) + if(!s.isEmpty()&&remain.isEmpty()&&s.getItem() instanceof UniversalBucket) { - ItemStack empty = ((UniversalBucket) s.getItem()).getEmpty(); + ItemStack empty = ((UniversalBucket)s.getItem()).getEmpty(); if(!empty.isEmpty()) remains.set(i, empty.copy()); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeSpeeloader.java b/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeSpeeloader.java index 1c6c5d15de..6b9c40f2c6 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeSpeeloader.java +++ b/src/main/java/blusunrize/immersiveengineering/common/crafting/RecipeSpeeloader.java @@ -30,14 +30,14 @@ public ItemStack getCraftingResult(InventoryCrafting matrix) { ItemStack speedloader = matrix.getStackInSlot(4); - if(!speedloader.isEmpty() && speedloader.getItem() instanceof ItemSpeedloader && ((ItemSpeedloader)speedloader.getItem()).isEmpty(speedloader)) + if(!speedloader.isEmpty()&&speedloader.getItem() instanceof ItemSpeedloader&&((ItemSpeedloader)speedloader.getItem()).isEmpty(speedloader)) { ItemStack out = speedloader.copy(); NonNullList fill = NonNullList.withSize(8, ItemStack.EMPTY); for(int i = 0; i < 8; i++) { int j = i >= 4?i+1: i; - fill.set(i, Utils.copyStackWithAmount(matrix.getStackInSlot(j),1)); + fill.set(i, Utils.copyStackWithAmount(matrix.getStackInSlot(j), 1)); } ((ItemSpeedloader)out.getItem()).setContainedItems(out, fill); return out; diff --git a/src/main/java/blusunrize/immersiveengineering/common/datafixers/AssemblerPatternWalker.java b/src/main/java/blusunrize/immersiveengineering/common/datafixers/AssemblerPatternWalker.java index 09a110ef0e..e5c22fa2ed 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/datafixers/AssemblerPatternWalker.java +++ b/src/main/java/blusunrize/immersiveengineering/common/datafixers/AssemblerPatternWalker.java @@ -29,10 +29,10 @@ public AssemblerPatternWalker() @Override public NBTTagCompound filteredProcess(@Nonnull IDataFixer fixer, @Nonnull NBTTagCompound compound, int versionIn) { - for (int pattern = 0;pattern<3;pattern++) + for(int pattern = 0; pattern < 3; pattern++) { NBTTagList patternNBT = compound.getTagList("pattern"+pattern, Constants.NBT.TAG_COMPOUND); - for (int slot = 0;slot cl:IEContent.registeredIETiles) + for(Class cl : IEContent.registeredIETiles) { - if (TileEntityMultiblockMetal.class.isAssignableFrom(cl)) + if(TileEntityMultiblockMetal.class.isAssignableFrom(cl)) { Object te = cl.newInstance(); - if ((boolean)isInWorld.invoke(te)) + if((boolean)isInWorld.invoke(te)) fixer.registerVanillaWalker(BLOCK_ENTITY, new MultiblockProcessWalker(cl)); } - if (IIEInventory.class.isAssignableFrom(cl) && !specialCases.contains(cl)) + if(IIEInventory.class.isAssignableFrom(cl)&&!specialCases.contains(cl)) fixer.registerVanillaWalker(BLOCK_ENTITY, new ItemStackDataLists(cl, "inventory")); } - } - catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) + } catch(NoSuchMethodException|IllegalAccessException|InstantiationException|InvocationTargetException e) { throw new RuntimeException(e); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/datafixers/IEItemFixWalker.java b/src/main/java/blusunrize/immersiveengineering/common/datafixers/IEItemFixWalker.java index 3d6ad2d762..dd8a27a722 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/datafixers/IEItemFixWalker.java +++ b/src/main/java/blusunrize/immersiveengineering/common/datafixers/IEItemFixWalker.java @@ -10,7 +10,6 @@ import blusunrize.immersiveengineering.common.IEContent; import blusunrize.immersiveengineering.common.blocks.wooden.BlockTypes_WoodenDevice0; -import blusunrize.immersiveengineering.common.util.IELogger; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.datafix.DataFixesManager; import net.minecraft.util.datafix.IDataFixer; @@ -33,16 +32,16 @@ public IEItemFixWalker() public NBTTagCompound process(@Nonnull IDataFixer fixer, @Nonnull NBTTagCompound compound, int versionIn) { String type = compound.getString("id"); - if (type.equals(CRATE_ID)) + if(type.equals(CRATE_ID)) { int meta = compound.getInteger("Damage"); - if (meta==BlockTypes_WoodenDevice0.CRATE.getMeta()||meta==BlockTypes_WoodenDevice0.REINFORCED_CRATE.getMeta()) + if(meta==BlockTypes_WoodenDevice0.CRATE.getMeta()||meta==BlockTypes_WoodenDevice0.REINFORCED_CRATE.getMeta()) { NBTTagCompound stackTag = compound.getCompoundTag("tag"); DataFixesManager.processInventory(fixer, stackTag, versionIn, "inventory"); } } - else if (type.equals(TOOLBOX_ID)) + else if(type.equals(TOOLBOX_ID)) { NBTTagCompound stackTag = compound.getCompoundTag("ForgeCaps").getCompoundTag("Parent"); DataFixesManager.processInventory(fixer, stackTag, versionIn, "Items"); diff --git a/src/main/java/blusunrize/immersiveengineering/common/datafixers/MultiblockProcessWalker.java b/src/main/java/blusunrize/immersiveengineering/common/datafixers/MultiblockProcessWalker.java index 1464c006cd..9432bf7424 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/datafixers/MultiblockProcessWalker.java +++ b/src/main/java/blusunrize/immersiveengineering/common/datafixers/MultiblockProcessWalker.java @@ -13,7 +13,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.datafix.DataFixesManager; import net.minecraft.util.datafix.IDataFixer; -import net.minecraft.util.datafix.IDataWalker; import net.minecraft.util.datafix.walkers.Filtered; import net.minecraftforge.common.util.Constants; @@ -34,10 +33,10 @@ public MultiblockProcessWalker(Class p_i47309_1_) public NBTTagCompound filteredProcess(@Nonnull IDataFixer fixer, @Nonnull NBTTagCompound compound, int versionIn) { NBTTagList queue = compound.getTagList("processQueue", Constants.NBT.TAG_COMPOUND); - for (int i = 0;i1000; + boolean fire = fluid.getTemperature(fluidStack) > 1000; if(effect!=null) { ItemStack thrower = ItemStack.EMPTY; @@ -132,12 +138,12 @@ public void onImpact(RayTraceResult mop) if(shooter!=null) thrower = shooter.getHeldItem(EnumHand.MAIN_HAND); - if(mop.typeOfHit== Type.ENTITY&&mop.entityHit instanceof EntityLivingBase) + if(mop.typeOfHit==Type.ENTITY&&mop.entityHit instanceof EntityLivingBase) effect.applyToEntity((EntityLivingBase)mop.entityHit, shooter, thrower, fluidStack); - else if(mop.typeOfHit== Type.BLOCK) + else if(mop.typeOfHit==Type.BLOCK) effect.applyToBlock(world, mop, shooter, thrower, fluidStack); } - else if(mop.entityHit!=null && fluid.getTemperature(fluidStack)>500) + else if(mop.entityHit!=null&&fluid.getTemperature(fluidStack) > 500) { int tempDiff = fluid.getTemperature(fluidStack)-300; int damage = Math.abs(tempDiff)/500; @@ -147,7 +153,7 @@ else if(mop.entityHit!=null && fluid.getTemperature(fluidStack)>500) if(mop.entityHit!=null) { int f = this.isBurning()?this.fire: fire?3: 0; - if(f>0) + if(f > 0) { mop.entityHit.setFire(f); if(mop.entityHit.attackEntityFrom(DamageSource.IN_FIRE, 2)) @@ -164,9 +170,9 @@ public Light provideLight() FluidStack fluidStack = getFluid(); if(fluidStack!=null) { - int light = this.isBurning()?15:fluidStack.getFluid().getLuminosity(fluidStack); - if(light>0) - return Light.builder().pos(this).radius(.05f*light).color(1,1,1).build(); + int light = this.isBurning()?15: fluidStack.getFluid().getLuminosity(fluidStack); + if(light > 0) + return Light.builder().pos(this).radius(.05f*light).color(1, 1, 1).build(); } return null; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/entities/EntityFluorescentTube.java b/src/main/java/blusunrize/immersiveengineering/common/entities/EntityFluorescentTube.java index 58806b0e27..ac1859dc8c 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/entities/EntityFluorescentTube.java +++ b/src/main/java/blusunrize/immersiveengineering/common/entities/EntityFluorescentTube.java @@ -37,7 +37,7 @@ public class EntityFluorescentTube extends Entity implements ITeslaEntity private static final DataParameter dataMarker_g = EntityDataManager.createKey(EntityFluorescentTube.class, DataSerializers.FLOAT); private static final DataParameter dataMarker_b = EntityDataManager.createKey(EntityFluorescentTube.class, DataSerializers.FLOAT); private static final DataParameter dataMarker_angleHorizontal = EntityDataManager.createKey(EntityFluorescentTube.class, DataSerializers.FLOAT); - + private int timer = 0; public boolean active = false; public float[] rgb = new float[4]; @@ -51,6 +51,7 @@ public EntityFluorescentTube(World world, ItemStack tube, float angleVert) rotationYaw = angleVert; rgb = ItemFluorescentTube.getRGB(tube); } + public EntityFluorescentTube(World world) { super(world); @@ -72,13 +73,13 @@ public void onUpdate() this.motionY *= 0.9800000190734863D; this.motionZ *= 0.9800000190734863D; - if (this.onGround) + if(this.onGround) { this.motionX *= 0.699999988079071D; this.motionZ *= 0.699999988079071D; this.motionY *= -0.5D; } - if (firstTick&&!world.isRemote&&rgb!=null) + if(firstTick&&!world.isRemote&&rgb!=null) { dataManager.set(dataMarker_r, rgb[0]); dataManager.set(dataMarker_g, rgb[1]); @@ -87,13 +88,13 @@ public void onUpdate() firstTick = false; } // tube logic - if (timer>0&&!world.isRemote) + if(timer > 0&&!world.isRemote) { timer--; - if (timer<=0) + if(timer <= 0) dataManager.set(dataMarker_active, false); } - if (world.isRemote) + if(world.isRemote) { active = dataManager.get(dataMarker_active); rgb = new float[]{dataManager.get(dataMarker_r), @@ -102,6 +103,7 @@ public void onUpdate() angleHorizontal = dataManager.get(dataMarker_angleHorizontal); } } + @Override protected void entityInit() { @@ -135,7 +137,7 @@ public void writeEntityToNBT(NBTTagCompound nbt) @Override public boolean attackEntityFrom(DamageSource source, float amount) { - if (!isDead&&!world.isRemote) + if(!isDead&&!world.isRemote) { ItemStack tube = new ItemStack(IEContent.itemFluorescentTube); ItemFluorescentTube.setRGB(tube, rgb); @@ -151,27 +153,30 @@ public boolean canBeCollidedWith() { return !isDead; } + @Override public AxisAlignedBB getEntityBoundingBox() { return super.getEntityBoundingBox(); } + @Override public void onHit(TileEntity te, boolean lowPower) { - if(te instanceof TileEntityTeslaCoil && ((TileEntityTeslaCoil)te).energyStorage.extractEnergy(1, false) > 0) + if(te instanceof TileEntityTeslaCoil&&((TileEntityTeslaCoil)te).energyStorage.extractEnergy(1, false) > 0) { timer = 35; dataManager.set(dataMarker_active, true); } } + @Override public EnumActionResult applyPlayerInteraction(EntityPlayer player, Vec3d targetVec3, EnumHand hand) { if(Utils.isHammer(player.getHeldItem(hand))) { - angleHorizontal+=(player.isSneaking()?10:1); - angleHorizontal%=360; + angleHorizontal += (player.isSneaking()?10: 1); + angleHorizontal %= 360; dataManager.set(dataMarker_angleHorizontal, angleHorizontal); return EnumActionResult.SUCCESS; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/entities/EntityIEExplosive.java b/src/main/java/blusunrize/immersiveengineering/common/entities/EntityIEExplosive.java index 03a21b5369..285cbad953 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/entities/EntityIEExplosive.java +++ b/src/main/java/blusunrize/immersiveengineering/common/entities/EntityIEExplosive.java @@ -43,6 +43,7 @@ public EntityIEExplosive(World world) { super(world); } + public EntityIEExplosive(World world, double x, double y, double z, EntityLivingBase igniter, IBlockState blockstate, float explosionPower) { super(world, x, y, z, igniter); @@ -51,6 +52,7 @@ public EntityIEExplosive(World world, double x, double y, double z, EntityLiving this.explosionDropChance = 1/explosionPower; this.setBlockSynced(); } + public EntityIEExplosive(World world, BlockPos pos, EntityLivingBase igniter, IBlockState blockstate, float explosionPower) { this(world, pos.getX()+.5, pos.getY()+.5, pos.getZ()+.5, igniter, blockstate, explosionPower); @@ -61,11 +63,13 @@ public EntityIEExplosive setSmoking(boolean smoke) this.explosionSmoke = smoke; return this; } + public EntityIEExplosive setFlaming(boolean fire) { this.explosionFire = fire; return this; } + public EntityIEExplosive setDropChance(float chance) { this.explosionDropChance = chance; @@ -88,6 +92,7 @@ public void setBlockSynced() this.dataManager.set(dataMarker_fuse, this.getFuse()); } } + public void getBlockSynced() { this.block = this.dataManager.get(dataMarker_block).orNull(); @@ -97,10 +102,10 @@ public void getBlockSynced() @Override public String getName() { - if(this.block!=null && name==null) + if(this.block!=null&&name==null) { - ItemStack s = new ItemStack(this.block.getBlock(),1,this.block.getBlock().getMetaFromState(this.block)); - if(!s.isEmpty() && s.getItem()!= Items.AIR) + ItemStack s = new ItemStack(this.block.getBlock(), 1, this.block.getBlock().getMetaFromState(this.block)); + if(!s.isEmpty()&&s.getItem()!=Items.AIR) name = s.getDisplayName(); } if(name!=null) @@ -116,8 +121,9 @@ protected void writeEntityToNBT(NBTTagCompound tagCompound) tagCompound.setBoolean("explosionSmoke", explosionSmoke); tagCompound.setBoolean("explosionFire", explosionFire); if(this.block!=null) - tagCompound.setInteger("block",Block.getStateId(this.block)); + tagCompound.setInteger("block", Block.getStateId(this.block)); } + @Override protected void readEntityFromNBT(NBTTagCompound tagCompound) { @@ -133,7 +139,7 @@ protected void readEntityFromNBT(NBTTagCompound tagCompound) @Override public void onUpdate() { - if(world.isRemote && this.block==null) + if(world.isRemote&&this.block==null) this.getBlockSynced(); this.prevPosX = this.posX; @@ -153,13 +159,13 @@ public void onUpdate() } int newFuse = this.getFuse()-1; this.setFuse(newFuse); - if(newFuse--<=0) + if(newFuse-- <= 0) { this.setDead(); if(!this.world.isRemote) { - Explosion explosion = new IEExplosion(world, this, posX,posY+(height/16f),posZ, explosionPower, explosionFire, explosionSmoke).setDropChance(explosionDropChance); + Explosion explosion = new IEExplosion(world, this, posX, posY+(height/16f), posZ, explosionPower, explosionFire, explosionSmoke).setDropChance(explosionDropChance); if(!ForgeEventFactory.onExplosionStart(world, explosion)) { explosion.doExplosionA(); @@ -170,7 +176,7 @@ public void onUpdate() else { this.handleWaterMovement(); - this.world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); + this.world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, this.posX, this.posY+0.5D, this.posZ, 0.0D, 0.0D, 0.0D); } } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/entities/EntityIEProjectile.java b/src/main/java/blusunrize/immersiveengineering/common/entities/EntityIEProjectile.java index 85e822d47d..58d25763ba 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/entities/EntityIEProjectile.java +++ b/src/main/java/blusunrize/immersiveengineering/common/entities/EntityIEProjectile.java @@ -40,15 +40,16 @@ public abstract class EntityIEProjectile extends EntityArrow//Yes I have to exte public int ticksInGround; public int ticksInAir; - private int tickLimit=40; + private int tickLimit = 40; private static final DataParameter dataMarker_shooter = EntityDataManager.createKey(EntityIEProjectile.class, DataSerializers.STRING); public EntityIEProjectile(World world) { super(world); - this.setSize(.125f,.125f); + this.setSize(.125f, .125f); this.pickupStatus = PickupStatus.DISALLOWED; } + public EntityIEProjectile(World world, double x, double y, double z, double ax, double ay, double az) { super(world); @@ -57,6 +58,7 @@ public EntityIEProjectile(World world, double x, double y, double z, double ax, this.setPosition(x, y, z); this.pickupStatus = PickupStatus.DISALLOWED; } + public EntityIEProjectile(World world, EntityLivingBase living, double ax, double ay, double az) { super(world); @@ -91,20 +93,22 @@ protected void entityInit() public void setTickLimit(int limit) { - this.tickLimit=limit; + this.tickLimit = limit; } public void setShooterSynced() { this.dataManager.set(dataMarker_shooter, this.shootingEntity.getName()); } + public EntityLivingBase getShooterSynced() { String s = this.dataManager.get(dataMarker_shooter); - if(s != null) + if(s!=null) return this.world.getPlayerEntityByName(s); return null; } + public Entity getShooter() { return shootingEntity; @@ -119,7 +123,7 @@ protected ItemStack getArrowStack() @Override public void onUpdate() { - if(this.getShooter() == null && this.world.isRemote) + if(this.getShooter()==null&&this.world.isRemote) this.shootingEntity = getShooterSynced(); this.onEntityUpdate(); @@ -128,28 +132,28 @@ public void onUpdate() IBlockState iblockstate = this.world.getBlockState(blockpos); Block block = iblockstate.getBlock(); - if(iblockstate.getMaterial() != Material.AIR) + if(iblockstate.getMaterial()!=Material.AIR) { AxisAlignedBB axisalignedbb = block.getCollisionBoundingBox(iblockstate, this.world, blockpos); - if(axisalignedbb != null && axisalignedbb.contains(new Vec3d(this.posX, this.posY, this.posZ))) + if(axisalignedbb!=null&&axisalignedbb.contains(new Vec3d(this.posX, this.posY, this.posZ))) this.inGround = true; } if(this.inGround) { int j = block.getMetaFromState(iblockstate); - if(block==this.inBlock && j==this.inMeta) + if(block==this.inBlock&&j==this.inMeta) { ++this.ticksInGround; - if (this.ticksInGround>=getMaxTicksInGround()) + if(this.ticksInGround >= getMaxTicksInGround()) this.setDead(); } else { this.inGround = false; - this.motionX *= (double)(this.rand.nextFloat() * 0.2F); - this.motionY *= (double)(this.rand.nextFloat() * 0.2F); - this.motionZ *= (double)(this.rand.nextFloat() * 0.2F); + this.motionX *= (double)(this.rand.nextFloat()*0.2F); + this.motionY *= (double)(this.rand.nextFloat()*0.2F); + this.motionZ *= (double)(this.rand.nextFloat()*0.2F); this.ticksInGround = 0; this.ticksInAir = 0; } @@ -158,41 +162,41 @@ public void onUpdate() { ++this.ticksInAir; - if(ticksInAir>=tickLimit) + if(ticksInAir >= tickLimit) { this.setDead(); return; } Vec3d currentPos = new Vec3d(this.posX, this.posY, this.posZ); - Vec3d nextPos = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); - RayTraceResult mop = this.world.rayTraceBlocks(currentPos, nextPos, false,true,false); + Vec3d nextPos = new Vec3d(this.posX+this.motionX, this.posY+this.motionY, this.posZ+this.motionZ); + RayTraceResult mop = this.world.rayTraceBlocks(currentPos, nextPos, false, true, false); currentPos = new Vec3d(this.posX, this.posY, this.posZ); - if(mop != null) + if(mop!=null) nextPos = new Vec3d(mop.hitVec.x, mop.hitVec.y, mop.hitVec.z); else - nextPos = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + nextPos = new Vec3d(this.posX+this.motionX, this.posY+this.motionY, this.posZ+this.motionZ); - if(mop==null || mop.entityHit==null) + if(mop==null||mop.entityHit==null) { Entity entity = null; - List list = this.world.getEntitiesInAABBexcluding(this, this.getEntityBoundingBox().expand(this.motionX, this.motionY, this.motionZ).grow(1), (e)->e.canBeCollidedWith()); + List list = this.world.getEntitiesInAABBexcluding(this, this.getEntityBoundingBox().expand(this.motionX, this.motionY, this.motionZ).grow(1), (e) -> e.canBeCollidedWith()); double d0 = 0.0D; - for (int i = 0; i < list.size(); ++i) + for(int i = 0; i < list.size(); ++i) { Entity entity1 = (Entity)list.get(i); - if(entity1.canBeCollidedWith() && (!entity1.isEntityEqual(this.shootingEntity) || this.ticksInAir>5)) + if(entity1.canBeCollidedWith()&&(!entity1.isEntityEqual(this.shootingEntity)||this.ticksInAir > 5)) { float f = 0.3F; AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().grow((double)f, (double)f, (double)f); RayTraceResult movingobjectposition1 = axisalignedbb.calculateIntercept(currentPos, nextPos); - if (movingobjectposition1 != null) + if(movingobjectposition1!=null) { double d1 = currentPos.distanceTo(movingobjectposition1.hitVec); - if (d1 < d0 || d0 == 0.0D) + if(d1 < d0||d0==0.0D) { entity = entity1; d0 = d1; @@ -206,18 +210,18 @@ public void onUpdate() if(mop!=null) { - if(!this.isBurning() && this.canIgnite() && mop.entityHit!=null && mop.entityHit.isBurning()) + if(!this.isBurning()&&this.canIgnite()&&mop.entityHit!=null&&mop.entityHit.isBurning()) this.setFire(3); if(mop.entityHit!=null) { boolean allowHit = true; - if(this.shootingEntity instanceof EntityPlayer && mop.entityHit instanceof EntityPlayer) + if(this.shootingEntity instanceof EntityPlayer&&mop.entityHit instanceof EntityPlayer) allowHit = ((EntityPlayer)this.shootingEntity).canAttackPlayer((EntityPlayer)mop.entityHit); if(allowHit) this.onImpact(mop); this.setDead(); } - else if(mop.typeOfHit== RayTraceResult.Type.BLOCK) + else if(mop.typeOfHit==RayTraceResult.Type.BLOCK) { this.onImpact(mop); this.blockX = mop.getBlockPos().getX(); @@ -226,20 +230,20 @@ else if(mop.typeOfHit== RayTraceResult.Type.BLOCK) IBlockState state = this.world.getBlockState(mop.getBlockPos()); this.inBlock = state.getBlock(); this.inMeta = inBlock.getMetaFromState(state); - this.motionX = mop.hitVec.x - this.posX; - this.motionY = mop.hitVec.y - this.posY; - this.motionZ = mop.hitVec.z - this.posZ; - float f2 = MathHelper.sqrt(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); - this.posX -= this.motionX / (double)f2 * 0.05000000074505806D; - this.posY -= this.motionY / (double)f2 * 0.05000000074505806D; - this.posZ -= this.motionZ / (double)f2 * 0.05000000074505806D; + this.motionX = mop.hitVec.x-this.posX; + this.motionY = mop.hitVec.y-this.posY; + this.motionZ = mop.hitVec.z-this.posZ; + float f2 = MathHelper.sqrt(this.motionX*this.motionX+this.motionY*this.motionY+this.motionZ*this.motionZ); + this.posX -= this.motionX/(double)f2*0.05000000074505806D; + this.posY -= this.motionY/(double)f2*0.05000000074505806D; + this.posZ -= this.motionZ/(double)f2*0.05000000074505806D; // this.posX = movingobjectposition.hitVec.xCoord; // this.posY = movingobjectposition.hitVec.yCoord; // this.posZ = movingobjectposition.hitVec.zCoord; // this.setPosition(this.posX, this.posY, this.posZ); this.inGround = true; - if(this.inBlock.getMaterial(state) != Material.AIR) + if(this.inBlock.getMaterial(state)!=Material.AIR) this.inBlock.onEntityCollidedWithBlock(this.world, mop.getBlockPos(), state, this); // return; } @@ -249,18 +253,19 @@ else if(mop.typeOfHit== RayTraceResult.Type.BLOCK) this.posY += this.motionY; this.posZ += this.motionZ; - float motion = MathHelper.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); - this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); + float motion = MathHelper.sqrt(this.motionX*this.motionX+this.motionZ*this.motionZ); + this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ)*180.0D/Math.PI); - for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)motion) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F); - while (this.rotationPitch - this.prevRotationPitch >= 180.0F) + for(this.rotationPitch = (float)(Math.atan2(this.motionY, (double)motion)*180.0D/Math.PI); this.rotationPitch-this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) + ; + while(this.rotationPitch-this.prevRotationPitch >= 180.0F) this.prevRotationPitch += 360.0F; - while (this.rotationYaw - this.prevRotationYaw < -180.0F) + while(this.rotationYaw-this.prevRotationYaw < -180.0F) this.prevRotationYaw -= 360.0F; - while (this.rotationYaw - this.prevRotationYaw >= 180.0F) + while(this.rotationYaw-this.prevRotationYaw >= 180.0F) this.prevRotationYaw += 360.0F; - this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; - this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; + this.rotationPitch = this.prevRotationPitch+(this.rotationPitch-this.prevRotationPitch)*0.2F; + this.rotationYaw = this.prevRotationYaw+(this.rotationYaw-this.prevRotationYaw)*0.2F; float movementDecay = getMotionDecayFactor(); @@ -270,7 +275,7 @@ else if(mop.typeOfHit== RayTraceResult.Type.BLOCK) for(int j = 0; j < 4; ++j) { float f3 = 0.25F; - this.world.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX - this.motionX * (double)f3, this.posY - this.motionY * (double)f3, this.posZ - this.motionZ * (double)f3, this.motionX, this.motionY, this.motionZ); + this.world.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX-this.motionX*(double)f3, this.posY-this.motionY*(double)f3, this.posZ-this.motionZ*(double)f3, this.motionX, this.motionY, this.motionZ); } movementDecay *= 0.8F; } @@ -293,9 +298,9 @@ public void onCollideWithPlayer(EntityPlayer p_70100_1_) @Override public boolean isInRangeToRenderDist(double p_70112_1_) { - double d1 = this.getEntityBoundingBox().getAverageEdgeLength() * 4.0D; + double d1 = this.getEntityBoundingBox().getAverageEdgeLength()*4.0D; d1 *= 64.0D; - return p_70112_1_ < d1 * d1; + return p_70112_1_ < d1*d1; } public double getGravity() @@ -329,7 +334,7 @@ public void writeEntityToNBT(NBTTagCompound nbt) nbt.setShort("zTile", (short)this.blockZ); nbt.setByte("inTile", (byte)Block.getIdFromBlock(this.inBlock)); nbt.setByte("inMeta", (byte)this.inMeta); - nbt.setByte("inGround", (byte)(this.inGround ? 1 : 0)); + nbt.setByte("inGround", (byte)(this.inGround?1: 0)); if(this.shootingEntity!=null) nbt.setString("shootingEntity", this.shootingEntity.getName()); @@ -342,8 +347,8 @@ public void readEntityFromNBT(NBTTagCompound nbt) this.blockX = nbt.getShort("xTile"); this.blockY = nbt.getShort("yTile"); this.blockZ = nbt.getShort("zTile"); - this.inBlock = Block.getBlockById(nbt.getByte("inTile") & 255); - this.inGround = nbt.getByte("inGround") == 1; + this.inBlock = Block.getBlockById(nbt.getByte("inTile")&255); + this.inGround = nbt.getByte("inGround")==1; if(this.world!=null) this.shootingEntity = this.world.getPlayerEntityByName(nbt.getString("shootingEntity")); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/entities/EntityRailgunShot.java b/src/main/java/blusunrize/immersiveengineering/common/entities/EntityRailgunShot.java index fe7605da22..b436c959d8 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/entities/EntityRailgunShot.java +++ b/src/main/java/blusunrize/immersiveengineering/common/entities/EntityRailgunShot.java @@ -33,14 +33,16 @@ public EntityRailgunShot(World world) this.setSize(.5f, .5f); this.pickupStatus = PickupStatus.ALLOWED; } + public EntityRailgunShot(World world, double x, double y, double z, double ax, double ay, double az, ItemStack ammo) { - super(world, x,y,z, ax,ay,az); + super(world, x, y, z, ax, ay, az); this.setSize(.5f, .5f); this.ammo = ammo; this.setAmmoSynced(); this.pickupStatus = PickupStatus.ALLOWED; } + public EntityRailgunShot(World world, EntityLivingBase living, double ax, double ay, double az, ItemStack ammo) { super(world, living, ax, ay, az); @@ -49,6 +51,7 @@ public EntityRailgunShot(World world, EntityLivingBase living, double ax, double this.setAmmoSynced(); this.pickupStatus = PickupStatus.ALLOWED; } + @Override protected void entityInit() { @@ -67,17 +70,20 @@ public void setAmmoSynced() if(!this.getAmmo().isEmpty()) this.dataManager.set(dataMarker_ammo, getAmmo()); } + public ItemStack getAmmoSynced() { return this.dataManager.get(dataMarker_ammo); } + public ItemStack getAmmo() { return ammo; } + public RailgunProjectileProperties getAmmoProperties() { - if(ammoProperties==null && !ammo.isEmpty()) + if(ammoProperties==null&&!ammo.isEmpty()) ammoProperties = RailgunHandler.getProjectileProperties(ammo); return ammoProperties; } @@ -85,7 +91,7 @@ public RailgunProjectileProperties getAmmoProperties() @Override public double getGravity() { - return .005*(getAmmoProperties()!=null?getAmmoProperties().gravity:1); + return .005*(getAmmoProperties()!=null?getAmmoProperties().gravity: 1); } @Override @@ -102,7 +108,7 @@ public void onEntityUpdate() // ((WorldServer)world).func_147487_a("flame", posX,posY,posZ, 0, 0,0,0, 1); // else // world.spawnParticle("smoke", posX, posY, posZ, 0, 0, 0); - if(this.getAmmo().isEmpty() && this.world.isRemote) + if(this.getAmmo().isEmpty()&&this.world.isRemote) this.ammo = getAmmoSynced(); super.onEntityUpdate(); } @@ -110,7 +116,7 @@ public void onEntityUpdate() @Override public void onImpact(RayTraceResult mop) { - if(!this.world.isRemote && !getAmmo().isEmpty()) + if(!this.world.isRemote&&!getAmmo().isEmpty()) { if(mop.entityHit!=null) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/entities/EntityRevolvershot.java b/src/main/java/blusunrize/immersiveengineering/common/entities/EntityRevolvershot.java index e96df7666b..002a830e15 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/entities/EntityRevolvershot.java +++ b/src/main/java/blusunrize/immersiveengineering/common/entities/EntityRevolvershot.java @@ -55,7 +55,7 @@ public class EntityRevolvershot extends Entity private float movementDecay = 0; private float gravity = 0; - private int tickLimit=40; + private int tickLimit = 40; String bulletType; public boolean bulletElectro = false; public ItemStack bulletPotion = ItemStack.EMPTY; @@ -65,7 +65,7 @@ public class EntityRevolvershot extends Entity public EntityRevolvershot(World world) { super(world); - this.setSize(.125f,.125f); + this.setSize(.125f, .125f); } public EntityRevolvershot(World world, double x, double y, double z, double ax, double ay, double az, IBullet type) @@ -79,8 +79,9 @@ public EntityRevolvershot(World world, double x, double y, double z, double ax, public EntityRevolvershot(World world, EntityLivingBase living, double ax, double ay, double az, IBullet type, ItemStack stack) { - this(world, living, ax, ay, az, BulletHandler.findRegistryName(type),stack); + this(world, living, ax, ay, az, BulletHandler.findRegistryName(type), stack); } + public EntityRevolvershot(World world, EntityLivingBase living, double ax, double ay, double az, String type, ItemStack stack) { super(world); @@ -96,17 +97,17 @@ public EntityRevolvershot(World world, EntityLivingBase living, double ax, doubl public void setTickLimit(int limit) { - this.tickLimit=limit; + this.tickLimit = limit; } public void setMovementDecay(float f) { - this.movementDecay=f; + this.movementDecay = f; } public void setGravity(float f) { - this.gravity=f; + this.gravity = f; } @@ -114,9 +115,9 @@ public void setGravity(float f) @Override public boolean isInRangeToRenderDist(double p_70112_1_) { - double d1 = this.getEntityBoundingBox().getAverageEdgeLength() * 4.0D; + double d1 = this.getEntityBoundingBox().getAverageEdgeLength()*4.0D; d1 *= 64.0D; - return p_70112_1_ < d1 * d1; + return p_70112_1_ < d1*d1; } @Override @@ -129,10 +130,12 @@ public void setShooterSynced() { this.dataManager.set(dataMarker_shooter, this.shootingEntity.getName()); } + public EntityLivingBase getShooterSynced() { return this.world.getPlayerEntityByName(this.dataManager.get(dataMarker_shooter)); } + public Entity getShooter() { return shootingEntity; @@ -141,10 +144,10 @@ public Entity getShooter() @Override public void onUpdate() { - if(this.getShooter() == null && this.world.isRemote) + if(this.getShooter()==null&&this.world.isRemote) this.shootingEntity = getShooterSynced(); - if(!this.world.isRemote && (this.shootingEntity != null && this.shootingEntity.isDead)) + if(!this.world.isRemote&&(this.shootingEntity!=null&&this.shootingEntity.isDead)) this.setDead(); else { @@ -152,11 +155,11 @@ public void onUpdate() IBlockState iblockstate = this.world.getBlockState(blockpos); Block block = iblockstate.getBlock(); - if(iblockstate.getMaterial() != Material.AIR) + if(iblockstate.getMaterial()!=Material.AIR) { AxisAlignedBB axisalignedbb = iblockstate.getCollisionBoundingBox(this.world, blockpos); - if (axisalignedbb != null && axisalignedbb.contains(new Vec3d(this.posX, this.posY, this.posZ))) + if(axisalignedbb!=null&&axisalignedbb.contains(new Vec3d(this.posX, this.posY, this.posZ))) { this.inGround = true; } @@ -168,11 +171,11 @@ public void onUpdate() { int j = block.getMetaFromState(iblockstate); - if(block==this.inTile && j==this.inData) + if(block==this.inTile&&j==this.inData) { ++this.ticksInGround; - if (this.ticksInGround >= 1200) + if(this.ticksInGround >= 1200) { this.setDead(); } @@ -180,9 +183,9 @@ public void onUpdate() else { this.inGround = false; - this.motionX *= (double)(this.rand.nextFloat() * 0.2F); - this.motionY *= (double)(this.rand.nextFloat() * 0.2F); - this.motionZ *= (double)(this.rand.nextFloat() * 0.2F); + this.motionX *= (double)(this.rand.nextFloat()*0.2F); + this.motionY *= (double)(this.rand.nextFloat()*0.2F); + this.motionZ *= (double)(this.rand.nextFloat()*0.2F); this.ticksInGround = 0; this.ticksInAir = 0; } @@ -190,7 +193,7 @@ public void onUpdate() else ++this.ticksInAir; - if(ticksInAir>=tickLimit) + if(ticksInAir >= tickLimit) { this.onExpire(); this.setDead(); @@ -198,31 +201,31 @@ public void onUpdate() } Vec3d vec3 = new Vec3d(this.posX, this.posY, this.posZ); - Vec3d vec31 = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + Vec3d vec31 = new Vec3d(this.posX+this.motionX, this.posY+this.motionY, this.posZ+this.motionZ); RayTraceResult movingobjectposition = this.world.rayTraceBlocks(vec3, vec31); vec3 = new Vec3d(this.posX, this.posY, this.posZ); - vec31 = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + vec31 = new Vec3d(this.posX+this.motionX, this.posY+this.motionY, this.posZ+this.motionZ); - if (movingobjectposition != null) + if(movingobjectposition!=null) vec31 = new Vec3d(movingobjectposition.hitVec.x, movingobjectposition.hitVec.y, movingobjectposition.hitVec.z); Entity entity = null; List list = this.world.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().offset(this.motionX, this.motionY, this.motionZ).grow(1.0D)); double d0 = 0.0D; - for (int i = 0; i < list.size(); ++i) + for(int i = 0; i < list.size(); ++i) { Entity entity1 = list.get(i); - if (entity1.canBeCollidedWith() && (!entity1.isEntityEqual(this.shootingEntity))) + if(entity1.canBeCollidedWith()&&(!entity1.isEntityEqual(this.shootingEntity))) { float f = 0.3F; AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().grow(f); RayTraceResult movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31); - if (movingobjectposition1 != null) + if(movingobjectposition1!=null) { double d1 = vec3.distanceTo(movingobjectposition1.hitVec); - if (d1 < d0 || d0 == 0.0D) + if(d1 < d0||d0==0.0D) { entity = entity1; d0 = d1; @@ -231,36 +234,37 @@ public void onUpdate() } } - if (entity != null) + if(entity!=null) movingobjectposition = new RayTraceResult(entity); - if (movingobjectposition != null) + if(movingobjectposition!=null) this.onImpact(movingobjectposition); this.posX += this.motionX; this.posY += this.motionY; this.posZ += this.motionZ; - float f1 = MathHelper.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); - this.rotationYaw = (float)(Math.atan2(this.motionZ, this.motionX) * 180.0D / Math.PI) + 90.0F; + float f1 = MathHelper.sqrt(this.motionX*this.motionX+this.motionZ*this.motionZ); + this.rotationYaw = (float)(Math.atan2(this.motionZ, this.motionX)*180.0D/Math.PI)+90.0F; - for (this.rotationPitch = (float)(Math.atan2((double)f1, this.motionY) * 180.0D / Math.PI) - 90.0F; this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F); + for(this.rotationPitch = (float)(Math.atan2((double)f1, this.motionY)*180.0D/Math.PI)-90.0F; this.rotationPitch-this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) + ; - while (this.rotationPitch - this.prevRotationPitch >= 180.0F) + while(this.rotationPitch-this.prevRotationPitch >= 180.0F) this.prevRotationPitch += 360.0F; - while (this.rotationYaw - this.prevRotationYaw < -180.0F) + while(this.rotationYaw-this.prevRotationYaw < -180.0F) this.prevRotationYaw -= 360.0F; - while (this.rotationYaw - this.prevRotationYaw >= 180.0F) + while(this.rotationYaw-this.prevRotationYaw >= 180.0F) this.prevRotationYaw += 360.0F; - this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; - this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; + this.rotationPitch = this.prevRotationPitch+(this.rotationPitch-this.prevRotationPitch)*0.2F; + this.rotationYaw = this.prevRotationYaw+(this.rotationYaw-this.prevRotationYaw)*0.2F; float decay = movementDecay; if(this.isInWater()) { float f3 = 0.25F; for(int j = 0; j < 4; ++j) - this.world.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX - this.motionX * (double)f3, this.posY - this.motionY * (double)f3, this.posZ - this.motionZ * (double)f3, this.motionX, this.motionY, this.motionZ); + this.world.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX-this.motionX*(double)f3, this.posY-this.motionY*(double)f3, this.posZ-this.motionZ*(double)f3, this.motionX, this.motionY, this.motionZ); decay *= .6; } @@ -283,18 +287,18 @@ protected void onImpact(RayTraceResult mop) { boolean headshot = false; if(mop.entityHit instanceof EntityLivingBase) - headshot = Utils.isVecInEntityHead((EntityLivingBase) mop.entityHit, new Vec3d(posX, posY, posZ)); + headshot = Utils.isVecInEntityHead((EntityLivingBase)mop.entityHit, new Vec3d(posX, posY, posZ)); - if(this.bulletType != null) + if(this.bulletType!=null) { IBullet bullet = BulletHandler.getBullet(bulletType); - if(bullet != null) + if(bullet!=null) bullet.onHitTarget(world, mop, this.shootingEntity, this, headshot); - if(headshot && mop.entityHit instanceof EntityAgeable && ((EntityAgeable)mop.entityHit).isChild() && ((EntityLivingBase)mop.entityHit).getHealth()<=0) + if(headshot&&mop.entityHit instanceof EntityAgeable&&((EntityAgeable)mop.entityHit).isChild()&&((EntityLivingBase)mop.entityHit).getHealth() <= 0) { if(this.shootingEntity instanceof EntityPlayer) Utils.unlockIEAdvancement((EntityPlayer)this.shootingEntity, "main/secret_birthdayparty"); - world.playSound(null, posX,posY,posZ, IESounds.birthdayParty, SoundCategory.PLAYERS, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + world.playSound(null, posX, posY, posZ, IESounds.birthdayParty, SoundCategory.PLAYERS, 1.0F, 1.2F/(this.rand.nextFloat()*0.2F+0.9F)); ImmersiveEngineering.packetHandler.sendToDimension(new MessageBirthdayParty((EntityLivingBase)mop.entityHit), world.provider.getDimension()); } } @@ -310,22 +314,22 @@ protected void onImpact(RayTraceResult mop) public void secondaryImpact(RayTraceResult mop) { - if(bulletElectro && mop.entityHit instanceof EntityLivingBase) + if(bulletElectro&&mop.entityHit instanceof EntityLivingBase) { IBullet bullet = BulletHandler.getBullet(bulletType); - float percentualDrain = .15f/(bullet==null?1:bullet.getProjectileCount(shootingEntity instanceof EntityPlayer?(EntityPlayer)this.shootingEntity:null)); - ((EntityLivingBase)mop.entityHit).addPotionEffect(new PotionEffect(MobEffects.SLOWNESS,15,4)); + float percentualDrain = .15f/(bullet==null?1: bullet.getProjectileCount(shootingEntity instanceof EntityPlayer?(EntityPlayer)this.shootingEntity: null)); + ((EntityLivingBase)mop.entityHit).addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 15, 4)); for(EntityEquipmentSlot slot : EntityEquipmentSlot.values()) { ItemStack stack = ((EntityLivingBase)mop.entityHit).getItemStackFromSlot(slot); - if(EnergyHelper.isFluxItem(stack) && EnergyHelper.getEnergyStored(stack)>0) + if(EnergyHelper.isFluxItem(stack)&&EnergyHelper.getEnergyStored(stack) > 0) { - int drain = (int)Math.max(EnergyHelper.getEnergyStored(stack),EnergyHelper.getMaxEnergyStored(stack)*percentualDrain); + int drain = (int)Math.max(EnergyHelper.getEnergyStored(stack), EnergyHelper.getMaxEnergyStored(stack)*percentualDrain); int hasDrained = 0; - while(hasDrained>16&255)/255f; - float g = (getColour()>>8&255)/255f; + float r = (getColour() >> 16&255)/255f; + float g = (getColour() >> 8&255)/255f; float b = (getColour()&255)/255f; - ImmersiveEngineering.proxy.spawnRedstoneFX(world, posX,posY,posZ, 0,0,0, 1, r,g,b); - if(ticksExisted>40) - for(int i=0; i<20; i++) + ImmersiveEngineering.proxy.spawnRedstoneFX(world, posX, posY, posZ, 0, 0, 0, 1, r, g, b); + if(ticksExisted > 40) + for(int i = 0; i < 20; i++) { - Vec3d v = new Vec3d(Utils.RAND.nextDouble()-.5,Utils.RAND.nextDouble()-.5,Utils.RAND.nextDouble()-.5); - ImmersiveEngineering.proxy.spawnRedstoneFX(world, posX+v.x,posY+v.y,posZ+v.z, v.x/10,v.y/10,v.z/10, 1, r,g,b); + Vec3d v = new Vec3d(Utils.RAND.nextDouble()-.5, Utils.RAND.nextDouble()-.5, Utils.RAND.nextDouble()-.5); + ImmersiveEngineering.proxy.spawnRedstoneFX(world, posX+v.x, posY+v.y, posZ+v.z, v.x/10, v.y/10, v.z/10, 1, r, g, b); } } if(ticksExisted==40) @@ -99,17 +101,17 @@ public void onUpdate() motionX = 0; motionY = -.1; motionZ = 0; - float r = (getColour()>>16&255)/255f; - float g = (getColour()>>8&255)/255f; + float r = (getColour() >> 16&255)/255f; + float g = (getColour() >> 8&255)/255f; float b = (getColour()&255)/255f; - for(int i=0; i<80; i++) + for(int i = 0; i < 80; i++) { - Vec3d v = new Vec3d((Utils.RAND.nextDouble()-.5)*i>40?2:1,(Utils.RAND.nextDouble()-.5)*i>40?2:1,(Utils.RAND.nextDouble()-.5)*i>40?2:1); - ImmersiveEngineering.proxy.spawnRedstoneFX(world, posX+v.x,posY+v.y,posZ+v.z, v.x/10,v.y/10,v.z/10, 1, r,g,b); + Vec3d v = new Vec3d((Utils.RAND.nextDouble()-.5)*i > 40?2: 1, (Utils.RAND.nextDouble()-.5)*i > 40?2: 1, (Utils.RAND.nextDouble()-.5)*i > 40?2: 1); + ImmersiveEngineering.proxy.spawnRedstoneFX(world, posX+v.x, posY+v.y, posZ+v.z, v.x/10, v.y/10, v.z/10, 1, r, g, b); } lightPos = this.getPosition(); - for(int i=0; i<128; i++) + for(int i = 0; i < 128; i++) if(world.isAirBlock(lightPos)) lightPos = lightPos.down(); else @@ -123,10 +125,10 @@ public void onUpdate() @Override protected void onImpact(RayTraceResult mop) { - if(ticksExisted<=40) + if(ticksExisted <= 40) { if(!this.world.isRemote) - if(mop.entityHit != null) + if(mop.entityHit!=null) { if(!mop.entityHit.isImmuneToFire()) mop.entityHit.setFire(8); @@ -137,26 +139,26 @@ else if(mop.getBlockPos()!=null) if(this.world.isAirBlock(pos)) this.world.setBlockState(pos, Blocks.FIRE.getDefaultState()); } - float r = (getColour()>>16&255)/255f; - float g = (getColour()>>8&255)/255f; + float r = (getColour() >> 16&255)/255f; + float g = (getColour() >> 8&255)/255f; float b = (getColour()&255)/255f; - for(int i=0; i<80; i++) + for(int i = 0; i < 80; i++) { - Vec3d v = new Vec3d((Utils.RAND.nextDouble()-.5)*i>40?2:1,(Utils.RAND.nextDouble()-.5)*i>40?2:1,(Utils.RAND.nextDouble()-.5)*i>40?2:1); - ImmersiveEngineering.proxy.spawnRedstoneFX(world, posX+v.x,posY+v.y,posZ+v.z, v.x/10,v.y/10,v.z/10, 1, r,g,b); + Vec3d v = new Vec3d((Utils.RAND.nextDouble()-.5)*i > 40?2: 1, (Utils.RAND.nextDouble()-.5)*i > 40?2: 1, (Utils.RAND.nextDouble()-.5)*i > 40?2: 1); + ImmersiveEngineering.proxy.spawnRedstoneFX(world, posX+v.x, posY+v.y, posZ+v.z, v.x/10, v.y/10, v.z/10, 1, r, g, b); } } this.setDead(); } @Nullable - @Optional.Method(modid="albedo") + @Optional.Method(modid = "albedo") @SideOnly(Side.CLIENT) @Override public Light provideLight() { - float r = (getColour()>>16&255)/255f; - float g = (getColour()>>8&255)/255f; + float r = (getColour() >> 16&255)/255f; + float g = (getColour() >> 8&255)/255f; float b = (getColour()&255)/255f; if(lightPos!=null) return Light.builder().pos(lightPos).radius(16).color(r, g, b).build(); diff --git a/src/main/java/blusunrize/immersiveengineering/common/entities/EntityRevolvershotHoming.java b/src/main/java/blusunrize/immersiveengineering/common/entities/EntityRevolvershotHoming.java index bc0397f530..14a92ad8d9 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/entities/EntityRevolvershotHoming.java +++ b/src/main/java/blusunrize/immersiveengineering/common/entities/EntityRevolvershotHoming.java @@ -20,6 +20,7 @@ public class EntityRevolvershotHoming extends EntityRevolvershot public int trackCountdown = 5; public double redirectionSpeed = .25; public EntityLivingBase targetOverride; + public EntityRevolvershotHoming(World world) { super(world); @@ -40,15 +41,15 @@ public void onUpdate() { super.onUpdate(); - if(!world.isRemote && this.ticksExisted>trackCountdown) + if(!world.isRemote&&this.ticksExisted > trackCountdown) { EntityLivingBase target = getTarget(); if(target!=null) { Vec3d newMotion = new Vec3d( - motionX*(1-redirectionSpeed)+ (target.posX-this.posX)*redirectionSpeed, - motionY*(1-redirectionSpeed)+ ((target.posY+target.height/2)-this.posY)*redirectionSpeed, - motionZ*(1-redirectionSpeed)+ (target.posZ-this.posZ)*redirectionSpeed).normalize(); + motionX*(1-redirectionSpeed)+(target.posX-this.posX)*redirectionSpeed, + motionY*(1-redirectionSpeed)+((target.posY+target.height/2)-this.posY)*redirectionSpeed, + motionZ*(1-redirectionSpeed)+(target.posZ-this.posZ)*redirectionSpeed).normalize(); this.motionX = newMotion.x; this.motionY = newMotion.y; @@ -59,14 +60,14 @@ public void onUpdate() public EntityLivingBase getTarget() { - if(targetOverride!=null && !targetOverride.isDead) + if(targetOverride!=null&&!targetOverride.isDead) return targetOverride; double r = 20D; - AxisAlignedBB aabb = new AxisAlignedBB(posX-r,posY-r,posZ-r, posX+r,posY+r,posZ+r); + AxisAlignedBB aabb = new AxisAlignedBB(posX-r, posY-r, posZ-r, posX+r, posY+r, posZ+r); EntityLivingBase target = null; - for(Object o: world.getEntitiesWithinAABB(EntityLivingBase.class, aabb)) - if(o instanceof EntityLivingBase && !o.equals(this.shootingEntity)) - if(target==null || ((EntityLivingBase)o).getDistanceSq(this)= 180.0F) + while(this.rotationPitch-this.prevRotationPitch >= 180.0F) this.prevRotationPitch += 360.0F; - while (this.rotationYaw - this.prevRotationYaw < -180.0F) + while(this.rotationYaw-this.prevRotationYaw < -180.0F) this.prevRotationYaw -= 360.0F; - while (this.rotationYaw - this.prevRotationYaw >= 180.0F) + while(this.rotationYaw-this.prevRotationYaw >= 180.0F) this.prevRotationYaw += 360.0F; } + @Override - protected void entityInit() {} + protected void entityInit() + { + } @SideOnly(Side.CLIENT) @Override public boolean isInRangeToRenderDist(double p_70112_1_) { - double d1 = this.getEntityBoundingBox().getAverageEdgeLength() * 4.0D; + double d1 = this.getEntityBoundingBox().getAverageEdgeLength()*4.0D; d1 *= 64.0D; - return p_70112_1_ < d1 * d1; + return p_70112_1_ < d1*d1; } @@ -97,7 +103,7 @@ public void onUpdate() // if(this.getControllingPassenger() instanceof EntityPlayer) // player = ((EntityPlayer)this.getControllingPassenger()); List list = this.getPassengers(); - if(!list.isEmpty() && list.get(0) instanceof EntityPlayer) + if(!list.isEmpty()&&list.get(0) instanceof EntityPlayer) player = (EntityPlayer)list.get(0); if(this.ticksExisted==1&&!world.isRemote) @@ -111,23 +117,23 @@ public void onUpdate() // this.setDead(); // if(world.isRemote) // return; - if(subPoints!=null && targetPoint5) + else if(gDist > 5) { setDead(); return; @@ -164,27 +170,28 @@ else if(gDist>5) this.posX += this.motionX; this.posY += this.motionY; this.posZ += this.motionZ; - float f1 = MathHelper.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); - this.rotationYaw = (float)(Math.atan2(this.motionZ, this.motionX) * 180.0D / Math.PI) + 90.0F; + float f1 = MathHelper.sqrt(this.motionX*this.motionX+this.motionZ*this.motionZ); + this.rotationYaw = (float)(Math.atan2(this.motionZ, this.motionX)*180.0D/Math.PI)+90.0F; - for (this.rotationPitch = (float)(Math.atan2((double)f1, this.motionY) * 180.0D / Math.PI) - 90.0F; this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F); + for(this.rotationPitch = (float)(Math.atan2((double)f1, this.motionY)*180.0D/Math.PI)-90.0F; this.rotationPitch-this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) + ; - while (this.rotationPitch - this.prevRotationPitch >= 180.0F) + while(this.rotationPitch-this.prevRotationPitch >= 180.0F) this.prevRotationPitch += 360.0F; - while (this.rotationYaw - this.prevRotationYaw < -180.0F) + while(this.rotationYaw-this.prevRotationYaw < -180.0F) this.prevRotationYaw -= 360.0F; - while (this.rotationYaw - this.prevRotationYaw >= 180.0F) + while(this.rotationYaw-this.prevRotationYaw >= 180.0F) this.prevRotationYaw += 360.0F; - this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; - this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; + this.rotationPitch = this.prevRotationPitch+(this.rotationPitch-this.prevRotationPitch)*0.2F; + this.rotationYaw = this.prevRotationYaw+(this.rotationYaw-this.prevRotationYaw)*0.2F; - if (this.isInWater()) + if(this.isInWater()) { - for (int j = 0; j < 4; ++j) + for(int j = 0; j < 4; ++j) { float f3 = 0.25F; - this.world.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX - this.motionX * (double)f3, this.posY - this.motionY * (double)f3, this.posZ - this.motionZ * (double)f3, this.motionX, this.motionY, this.motionZ); + this.world.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX-this.motionX*(double)f3, this.posY-this.motionY*(double)f3, this.posZ-this.motionZ*(double)f3, this.motionX, this.motionY, this.motionZ); } } @@ -193,10 +200,10 @@ else if(gDist>5) double dx = this.posX-this.prevPosX; double dy = this.posY-this.prevPosY; double dz = this.posZ-this.prevPosZ; - int distTrvl = Math.round(MathHelper.sqrt(dx*dx + dy*dy + dz*dz) * 100.0F); + int distTrvl = Math.round(MathHelper.sqrt(dx*dx+dy*dy+dz*dz)*100.0F); // if(distTrvl>0) // player.addStat(IEAchievements.statDistanceSkyhook, distTrvl); - if (!world.isRemote&&SkylineHelper.isInBlock(player, world)) + if(!world.isRemote&&SkylineHelper.isInBlock(player, world)) { // setDead(); // player.setPosition(posX-3*dx, posY-3*dy+getMountedYOffset(),posZ-3*dz); @@ -216,22 +223,22 @@ public void reachedTarget(TileEntity end) this.setDead(); IELogger.debug("last tick at "+System.currentTimeMillis()); List list = this.getPassengers(); - if(list.isEmpty() || !(list.get(0) instanceof EntityPlayer)) + if(list.isEmpty()||!(list.get(0) instanceof EntityPlayer)) return; // if(!(this.getControllingPassenger() instanceof EntityPlayer)) // return; // EntityPlayer player = (EntityPlayer)this.getControllingPassenger(); EntityPlayer player = (EntityPlayer)list.get(0); ItemStack hook = player.getActiveItemStack(); - if(hook.isEmpty() || !(hook.getItem() instanceof ItemSkyhook)) + if(hook.isEmpty()||!(hook.getItem() instanceof ItemSkyhook)) return; Optional line = Optional.empty(); Set possible = ImmersiveNetHandler.INSTANCE.getConnections(world, connection.end); - if (possible!=null) + if(possible!=null) { Vec3d look = player.getLookVec(); - line = possible.stream().filter(c->!c.hasSameConnectors(connection)) - .max(Comparator.comparingDouble(c-> { + line = possible.stream().filter(c -> !c.hasSameConnectors(connection)) + .max(Comparator.comparingDouble(c -> { Vec3d[] vertices = c.getSubVertices(world); Vec3d across = vertices[vertices.length-1].subtract(vertices[0]).normalize(); return across.dotProduct(look); @@ -276,11 +283,11 @@ public Vec3d getLookVec() // if (1 == 1.0F) // { - f1 = MathHelper.cos(-this.rotationYaw * 0.017453292F - (float)Math.PI); - f2 = MathHelper.sin(-this.rotationYaw * 0.017453292F - (float)Math.PI); - f3 = -MathHelper.cos(-this.rotationPitch * 0.017453292F); - f4 = MathHelper.sin(-this.rotationPitch * 0.017453292F); - return new Vec3d((double)(f2 * f3), (double)f4, (double)(f1 * f3)); + f1 = MathHelper.cos(-this.rotationYaw*0.017453292F-(float)Math.PI); + f2 = MathHelper.sin(-this.rotationYaw*0.017453292F-(float)Math.PI); + f3 = -MathHelper.cos(-this.rotationPitch*0.017453292F); + f4 = MathHelper.sin(-this.rotationPitch*0.017453292F); + return new Vec3d((double)(f2*f3), (double)f4, (double)(f1*f3)); // } // else // { @@ -302,6 +309,7 @@ public Entity getControllingPassenger() // List list = this.getPassengers(); // return list.isEmpty() ? null : (Entity)list.get(0); } + @Override public boolean shouldRiderSit() { @@ -311,13 +319,15 @@ public boolean shouldRiderSit() @Override public boolean isInvisible() { - return true; + return true; } + @Override public boolean canRenderOnFire() { - return false; + return false; } + @Override public boolean isPushedByWater() { @@ -345,22 +355,26 @@ public float getCollisionBorderSize() { return 0.0F; } + @Override public float getBrightness() { return 1.0F; } + @SideOnly(Side.CLIENT) @Override public int getBrightnessForRender() { return 15728880; } + @Override public boolean canBeCollidedWith() { return false; } + @Override public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/entities/EntityWolfpackShot.java b/src/main/java/blusunrize/immersiveengineering/common/entities/EntityWolfpackShot.java index ad07d43421..ff3abfd0bb 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/entities/EntityWolfpackShot.java +++ b/src/main/java/blusunrize/immersiveengineering/common/entities/EntityWolfpackShot.java @@ -42,10 +42,10 @@ public EntityWolfpackShot(World world, EntityLivingBase living, double ax, doubl @Override protected void onImpact(RayTraceResult mop) { - if(!this.world.isRemote && mop.entityHit != null) + if(!this.world.isRemote&&mop.entityHit!=null) { - if(mop.entityHit.hurtResistantTime>0) - mop.entityHit.hurtResistantTime=0; + if(mop.entityHit.hurtResistantTime > 0) + mop.entityHit.hurtResistantTime = 0; mop.entityHit.attackEntityFrom(IEDamageSources.causeWolfpackDamage(this, shootingEntity), IEConfig.Tools.bulletDamage_WolfpackPart); } this.setDead(); diff --git a/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerAlloySmelter.java b/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerAlloySmelter.java index 4a9c5db1e8..e92a063aeb 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerAlloySmelter.java +++ b/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerAlloySmelter.java @@ -22,13 +22,13 @@ public ContainerAlloySmelter(InventoryPlayer inventoryPlayer, TileEntityAlloySme this.addSlotToContainer(new Slot(this.inv, 0, 38, 17)); this.addSlotToContainer(new Slot(this.inv, 1, 66, 17)); this.addSlotToContainer(new SlotFurnaceFuel(this.inv, 2, 52, 53)); - this.addSlotToContainer(new IESlot.Output(this, this.inv, 3,120, 35)); - slotCount=4; + this.addSlotToContainer(new IESlot.Output(this, this.inv, 3, 120, 35)); + slotCount = 4; - for (int i = 0; i < 3; i++) - for (int j = 0; j < 9; j++) + for(int i = 0; i < 3; i++) + for(int j = 0; j < 9; j++) addSlotToContainer(new Slot(inventoryPlayer, j+i*9+9, 8+j*18, 84+i*18)); - for (int i = 0; i < 9; i++) + for(int i = 0; i < 9; i++) addSlotToContainer(new Slot(inventoryPlayer, i, 8+i*18, 142)); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerArcFurnace.java b/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerArcFurnace.java index 177ca6c577..98ad94f9ff 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerArcFurnace.java +++ b/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerArcFurnace.java @@ -19,25 +19,25 @@ public class ContainerArcFurnace extends ContainerIEBase public ContainerArcFurnace(InventoryPlayer inventoryPlayer, TileEntityArcFurnace tile) { super(inventoryPlayer, tile); - this.tile=tile; - for(int i=0; i<12; i++) - this.addSlotToContainer(new IESlot.ArcInput(this, this.inv, i, 10+i%3*21,34+i/3*18)); - for(int i=0; i<4; i++) - this.addSlotToContainer(new IESlot.ArcAdditive(this, this.inv, 12+i, 114+i%2*18,34+i/2*18)); - for(int i=0; i<6; i++) - this.addSlotToContainer(new IESlot.Output(this, this.inv, 16+i, 78+i%3*18,80+i/3*18)); - this.addSlotToContainer(new IESlot.Output(this, this.inv, 22, 132,98)); + this.tile = tile; + for(int i = 0; i < 12; i++) + this.addSlotToContainer(new IESlot.ArcInput(this, this.inv, i, 10+i%3*21, 34+i/3*18)); + for(int i = 0; i < 4; i++) + this.addSlotToContainer(new IESlot.ArcAdditive(this, this.inv, 12+i, 114+i%2*18, 34+i/2*18)); + for(int i = 0; i < 6; i++) + this.addSlotToContainer(new IESlot.Output(this, this.inv, 16+i, 78+i%3*18, 80+i/3*18)); + this.addSlotToContainer(new IESlot.Output(this, this.inv, 22, 132, 98)); - this.addSlotToContainer(new IESlot.ArcElectrode(this, this.inv, 23, 62,10)); - this.addSlotToContainer(new IESlot.ArcElectrode(this, this.inv, 24, 80,10)); - this.addSlotToContainer(new IESlot.ArcElectrode(this, this.inv, 25, 98,10)); + this.addSlotToContainer(new IESlot.ArcElectrode(this, this.inv, 23, 62, 10)); + this.addSlotToContainer(new IESlot.ArcElectrode(this, this.inv, 24, 80, 10)); + this.addSlotToContainer(new IESlot.ArcElectrode(this, this.inv, 25, 98, 10)); - slotCount=26; + slotCount = 26; - for (int i = 0; i < 3; i++) - for (int j = 0; j < 9; j++) + for(int i = 0; i < 3; i++) + for(int j = 0; j < 9; j++) addSlotToContainer(new Slot(inventoryPlayer, j+i*9+9, 8+j*18, 126+i*18)); - for (int i = 0; i < 9; i++) + for(int i = 0; i < 9; i++) addSlotToContainer(new Slot(inventoryPlayer, i, 8+i*18, 184)); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerAssembler.java b/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerAssembler.java index 552e2492f1..652eead191 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerAssembler.java +++ b/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerAssembler.java @@ -19,26 +19,26 @@ public class ContainerAssembler extends ContainerIEBase public ContainerAssembler(InventoryPlayer inventoryPlayer, TileEntityAssembler tile) { super(inventoryPlayer, tile); - this.tile=tile; - for(int i=0; i extends Container public ContainerIEBase(InventoryPlayer inventoryPlayer, T tile) { - this.tile=tile; + this.tile = tile; this.inv = new InventoryTile(tile); } @@ -39,7 +39,7 @@ public boolean canInteractWith(EntityPlayer player) @Override public ItemStack slotClick(int id, int button, ClickType clickType, EntityPlayer player) { - Slot slot = id<0?null: this.inventorySlots.get(id); + Slot slot = id < 0?null: this.inventorySlots.get(id); if(!(slot instanceof IESlot.Ghost)) return super.slotClick(id, button, clickType, player); //Spooky Ghost Slots!!!! @@ -48,33 +48,33 @@ public ItemStack slotClick(int id, int button, ClickType clickType, EntityPlayer if(!stackSlot.isEmpty()) stack = stackSlot.copy(); - if (button==2) + if(button==2) slot.putStack(ItemStack.EMPTY); else if(button==0||button==1) { InventoryPlayer playerInv = player.inventory; ItemStack stackHeld = playerInv.getItemStack(); - if (stackSlot.isEmpty()) + if(stackSlot.isEmpty()) { - if(!stackHeld.isEmpty() && slot.isItemValid(stackHeld)) + if(!stackHeld.isEmpty()&&slot.isItemValid(stackHeld)) { slot.putStack(Utils.copyStackWithAmount(stackHeld, 1)); } } - else if (stackHeld.isEmpty()) + else if(stackHeld.isEmpty()) { slot.putStack(ItemStack.EMPTY); } - else if (slot.isItemValid(stackHeld)) + else if(slot.isItemValid(stackHeld)) { slot.putStack(Utils.copyStackWithAmount(stackHeld, 1)); } } - else if (button == 5) + else if(button==5) { InventoryPlayer playerInv = player.inventory; ItemStack stackHeld = playerInv.getItemStack(); - if (!slot.getHasStack()) + if(!slot.getHasStack()) { slot.putStack(Utils.copyStackWithAmount(stackHeld, 1)); } @@ -88,22 +88,22 @@ public ItemStack transferStackInSlot(EntityPlayer player, int slot) ItemStack stack = ItemStack.EMPTY; Slot slotObject = inventorySlots.get(slot); - if(slotObject != null && slotObject.getHasStack()) + if(slotObject!=null&&slotObject.getHasStack()) { ItemStack stackInSlot = slotObject.getStack(); stack = stackInSlot.copy(); if(slot < slotCount) { - if(!this.mergeItemStack(stackInSlot, slotCount, (slotCount + 36), true)) + if(!this.mergeItemStack(stackInSlot, slotCount, (slotCount+36), true)) return ItemStack.EMPTY; } else { boolean b = false; - for(int i=0;i=startIndex)) + while(!stack.isEmpty()&&(!reverseDirection&&i < endIndex||reverseDirection&&i >= startIndex)) { Slot slot = this.inventorySlots.get(i); ItemStack stackInSlot = slot.getStack(); - if(!stackInSlot.isEmpty() && areItemStacksEqual(stack, stackInSlot)) + if(!stackInSlot.isEmpty()&&areItemStacksEqual(stack, stackInSlot)) { int j = stackInSlot.getCount()+stack.getCount(); int maxSize = Math.min(slot.getSlotStackLimit(), stack.getMaxStackSize()); - if(j<=maxSize) + if(j <= maxSize) { stack.setCount(0); stackInSlot.setCount(j); slot.onSlotChanged(); flag = true; } - else if(stackInSlot.getCount()=startIndex) + while(!reverseDirection&&i < endIndex||reverseDirection&&i >= startIndex) { Slot slot = this.inventorySlots.get(i); ItemStack stackInSlot = slot.getStack(); - if(stackInSlot.isEmpty() && slot.isItemValid(stack)) + if(stackInSlot.isEmpty()&&slot.isItemValid(stack)) { int maxSize = Math.min(slot.getSlotStackLimit(), stack.getMaxStackSize()); - if(stack.getCount()<=maxSize) + if(stack.getCount() <= maxSize) { slot.putStack(stack.copy()); slot.onSlotChanged(); @@ -206,7 +206,7 @@ else if(stackInSlot.getCount()1) + else if(slotCount > 1) { boolean b = true; - for(int i=1; i1) } } - if (stackInSlot.getCount() == 0) + if(stackInSlot.getCount()==0) slotObject.putStack(ItemStack.EMPTY); else slotObject.onSlotChanged(); - if (stackInSlot.getCount() == stack.getCount()) + if(stackInSlot.getCount()==stack.getCount()) return ItemStack.EMPTY; slotObject.onTake(player, stack); } @@ -158,7 +158,7 @@ public ItemStack slotClick(int id, int button, ClickType clickType, EntityPlayer { ItemStack ret = super.slotClick(id, button, clickType, player); tile.markContainingBlockForUpdate(null); - if (FMLCommonHandler.instance().getEffectiveSide().isServer()) + if(FMLCommonHandler.instance().getEffectiveSide().isServer()) detectAndSendChanges(); return ret; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerRefinery.java b/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerRefinery.java index 25801f6a73..4f5ce25337 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerRefinery.java +++ b/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerRefinery.java @@ -26,60 +26,60 @@ public ContainerRefinery(InventoryPlayer inventoryPlayer, TileEntityRefinery til super(inventoryPlayer, tile); final TileEntityRefinery tileF = tile; - this.addSlotToContainer(new IESlot.FluidContainer(this, this.inv, 0, 37,15, 2) + this.addSlotToContainer(new IESlot.FluidContainer(this, this.inv, 0, 37, 15, 2) { @Override public boolean isItemValid(ItemStack itemStack) { IFluidHandler h = itemStack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null); - if (h==null||h.getTankProperties().length==0) + if(h==null||h.getTankProperties().length==0) return false; FluidStack fs = h.getTankProperties()[0].getContents(); if(fs==null) return false; if(RefineryRecipe.findIncompleteRefineryRecipe(fs, null)==null) return false; - if(tileF.tanks[0].getFluidAmount()>0&&!fs.isFluidEqual(tileF.tanks[0].getFluid())) + if(tileF.tanks[0].getFluidAmount() > 0&&!fs.isFluidEqual(tileF.tanks[0].getFluid())) return false; - if(tileF.tanks[1].getFluidAmount()<=0) + if(tileF.tanks[1].getFluidAmount() <= 0) return true; List incomplete = RefineryRecipe.findIncompleteRefineryRecipe(fs, tileF.tanks[1].getFluid()); - return incomplete!=null && !incomplete.isEmpty(); + return incomplete!=null&&!incomplete.isEmpty(); } }); - this.addSlotToContainer(new IESlot.Output(this, this.inv, 1, 37,54)); + this.addSlotToContainer(new IESlot.Output(this, this.inv, 1, 37, 54)); - this.addSlotToContainer(new IESlot.FluidContainer(this, this.inv, 2, 85,15, 2) + this.addSlotToContainer(new IESlot.FluidContainer(this, this.inv, 2, 85, 15, 2) { @Override public boolean isItemValid(ItemStack itemStack) { IFluidHandler h = itemStack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null); - if (h==null||h.getTankProperties().length==0) + if(h==null||h.getTankProperties().length==0) return false; FluidStack fs = h.getTankProperties()[0].getContents(); if(fs==null) return false; if(RefineryRecipe.findIncompleteRefineryRecipe(fs, null)==null) return false; - if(tileF.tanks[1].getFluidAmount()>0&&!fs.isFluidEqual(tileF.tanks[1].getFluid())) + if(tileF.tanks[1].getFluidAmount() > 0&&!fs.isFluidEqual(tileF.tanks[1].getFluid())) return false; - if(tileF.tanks[0].getFluidAmount()<=0) + if(tileF.tanks[0].getFluidAmount() <= 0) return true; List incomplete = RefineryRecipe.findIncompleteRefineryRecipe(fs, tileF.tanks[0].getFluid()); - return incomplete!=null && !incomplete.isEmpty(); + return incomplete!=null&&!incomplete.isEmpty(); } }); - this.addSlotToContainer(new IESlot.Output(this, this.inv, 3, 85,54)); + this.addSlotToContainer(new IESlot.Output(this, this.inv, 3, 85, 54)); - this.addSlotToContainer(new IESlot.FluidContainer(this, this.inv, 4, 133,15, 0)); - this.addSlotToContainer(new IESlot.Output(this, this.inv, 5, 133,54)); - slotCount=6; + this.addSlotToContainer(new IESlot.FluidContainer(this, this.inv, 4, 133, 15, 0)); + this.addSlotToContainer(new IESlot.Output(this, this.inv, 5, 133, 54)); + slotCount = 6; - for (int i = 0; i < 3; i++) - for (int j = 0; j < 9; j++) + for(int i = 0; i < 3; i++) + for(int j = 0; j < 9; j++) addSlotToContainer(new Slot(inventoryPlayer, j+i*9+9, 8+j*18, 85+i*18)); - for (int i = 0; i < 9; i++) + for(int i = 0; i < 9; i++) addSlotToContainer(new Slot(inventoryPlayer, i, 8+i*18, 143)); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerRevolver.java b/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerRevolver.java index 2800667398..deac679038 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerRevolver.java +++ b/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerRevolver.java @@ -24,32 +24,32 @@ public class ContainerRevolver extends ContainerInternalStorageItem { public static int[][][] slotPositions = { { - { 48, 11}, - { 56, 30} + {48, 11}, + {56, 30} }, { - { 48, 11}, - { 68, 3}, - { 78, 22}, - { 88, 3}, - { 98, 22}, - {108, 3}, + {48, 11}, + {68, 3}, + {78, 22}, + {88, 3}, + {98, 22}, + {108, 3}, {118, 22}, - { 56, 30} + {56, 30} }, { - { 48, 3}, - { 67, 3}, - { 86, 3}, - {105, 3}, + {48, 3}, + {67, 3}, + {86, 3}, + {105, 3}, {124, 11}, {132, 30}, {124, 49}, {105, 57}, - { 86, 49}, - { 86, 30}, - { 67, 30}, - { 48, 30}, + {86, 49}, + {86, 30}, + {67, 30}, + {48, 30}, } }; @@ -69,57 +69,58 @@ int addSlots(InventoryPlayer iinventory) { int bullets0 = ((IBulletContainer)(heldItem).getItem()).getBulletCount(heldItem); - this.secondHand = this.equipmentSlot==EntityEquipmentSlot.MAINHAND?EntityEquipmentSlot.OFFHAND:EntityEquipmentSlot.MAINHAND; + this.secondHand = this.equipmentSlot==EntityEquipmentSlot.MAINHAND?EntityEquipmentSlot.OFFHAND: EntityEquipmentSlot.MAINHAND; this.secondRevolver = iinventory.player.getItemStackFromSlot(this.secondHand); - if(!secondRevolver.isEmpty() && secondRevolver.getItem() instanceof IBulletContainer) + if(!secondRevolver.isEmpty()&&secondRevolver.getItem() instanceof IBulletContainer) { int bullets1 = ((IBulletContainer)secondRevolver.getItem()).getBulletCount(secondRevolver); - this.offset = ((bullets0>=18?150:bullets0>8?136:74)+(bullets1>=18?150:bullets1>8?136:74)+4-176)/2; + this.offset = ((bullets0 >= 18?150: bullets0 > 8?136: 74)+(bullets1 >= 18?150: bullets1 > 8?136: 74)+4-176)/2; } else { this.secondRevolver = ItemStack.EMPTY; this.secondHand = null; - this.offset = ((bullets0>=18?150:bullets0>8?136:74)-176)/2; + this.offset = ((bullets0 >= 18?150: bullets0 > 8?136: 74)-176)/2; } } int total = 0; - int off = (offset<0?-offset:0); - for(int hand = 0; hand<(this.secondHand!=null?2:1); hand++) + int off = (offset < 0?-offset: 0); + for(int hand = 0; hand < (this.secondHand!=null?2: 1); hand++) { int i = 0; - ItemStack held = this.secondHand==null?heldItem: (hand==0)==(player.getPrimaryHand()==EnumHandSide.RIGHT)?secondRevolver:heldItem; + ItemStack held = this.secondHand==null?heldItem: (hand==0)==(player.getPrimaryHand()==EnumHandSide.RIGHT)?secondRevolver: heldItem; IItemHandler secondRevolverInventory = secondRevolver.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); - IItemHandler inv = this.secondHand==null?this.inv: (hand==0)==(player.getPrimaryHand()==EnumHandSide.RIGHT)?secondRevolverInventory:this.inv; + IItemHandler inv = this.secondHand==null?this.inv: (hand==0)==(player.getPrimaryHand()==EnumHandSide.RIGHT)?secondRevolverInventory: this.inv; int revolverSlots = ((IBulletContainer)(held).getItem()).getBulletCount(held); - if (inv instanceof IEItemStackHandler) - ((IEItemStackHandler) inv).setInventoryForUpdate(iinventory); + if(inv instanceof IEItemStackHandler) + ((IEItemStackHandler)inv).setInventoryForUpdate(iinventory); this.addSlotToContainer(new IESlot.Bullet(inv, i++, off+29, 3, 1)); int slots = revolverSlots >= 18?2: revolverSlots > 8?1: 0; for(int[] slot : slotPositions[slots]) this.addSlotToContainer(new IESlot.Bullet(inv, i++, off+slot[0], slot[1], 1)); - this.addSlotToContainer(new IESlot.Bullet(inv, i++,off+48, 49, 1)); - this.addSlotToContainer(new IESlot.Bullet(inv, i++,off+29, 57, 1)); - this.addSlotToContainer(new IESlot.Bullet(inv, i++,off+10, 49, 1)); - this.addSlotToContainer(new IESlot.Bullet(inv, i++,off+2, 30, 1)); - this.addSlotToContainer(new IESlot.Bullet(inv, i++,off+10, 11, 1)); - off += (revolverSlots>=18?150: revolverSlots>8?136: 74)+4; + this.addSlotToContainer(new IESlot.Bullet(inv, i++, off+48, 49, 1)); + this.addSlotToContainer(new IESlot.Bullet(inv, i++, off+29, 57, 1)); + this.addSlotToContainer(new IESlot.Bullet(inv, i++, off+10, 49, 1)); + this.addSlotToContainer(new IESlot.Bullet(inv, i++, off+2, 30, 1)); + this.addSlotToContainer(new IESlot.Bullet(inv, i++, off+10, 11, 1)); + off += (revolverSlots >= 18?150: revolverSlots > 8?136: 74)+4; total += i; } this.bindPlayerInventory(iinventory); return total; } + protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) { - int off = (offset>0?offset:0); - for (int i = 0; i < 3; i++) - for (int j = 0; j < 9; j++) + int off = (offset > 0?offset: 0); + for(int i = 0; i < 3; i++) + for(int j = 0; j < 9; j++) this.addSlotToContainer(new Slot(inventoryPlayer, j+i*9+9, off+8+j*18, 85+i*18)); - for (int i = 0; i < 9; i++) + for(int i = 0; i < 9; i++) this.addSlotToContainer(new Slot(inventoryPlayer, i, off+8+i*18, 143)); } @@ -149,12 +150,12 @@ public void onContainerClosed(EntityPlayer par1EntityPlayer) { super.onContainerClosed(par1EntityPlayer); - for(int hand = 0; hand<(this.secondHand!=null?2:1); hand++) + for(int hand = 0; hand < (this.secondHand!=null?2: 1); hand++) { IItemHandler secondRevolverInventory = secondRevolver.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); - IItemHandler inv = this.secondHand == null ? this.inv : (hand == 0) == (player.getPrimaryHand() == EnumHandSide.RIGHT) ? secondRevolverInventory : this.inv; - if (inv instanceof IEItemStackHandler) - ((IEItemStackHandler) inv).setInventoryForUpdate(null); + IItemHandler inv = this.secondHand==null?this.inv: (hand==0)==(player.getPrimaryHand()==EnumHandSide.RIGHT)?secondRevolverInventory: this.inv; + if(inv instanceof IEItemStackHandler) + ((IEItemStackHandler)inv).setInventoryForUpdate(null); } } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerSorter.java b/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerSorter.java index 23fff30a68..1f85a40d7c 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerSorter.java +++ b/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerSorter.java @@ -21,36 +21,37 @@ public class ContainerSorter extends Container { TileEntitySorter tile; int slotCount; + public ContainerSorter(InventoryPlayer inventoryPlayer, TileEntitySorter tile) { - this.tile=tile; - for(int side=0; side<6; side++) - for(int i=0; i4?(i-5)*18: i==3?0: 36); - int y = 22+ (side%2)*76 + (i<3?0: i>4?36: 18); + int x = 4+(side/2)*58+(i < 3?i*18: i > 4?(i-5)*18: i==3?0: 36); + int y = 22+(side%2)*76+(i < 3?0: i > 4?36: 18); int id = side*TileEntitySorter.filterSlotsPerSide+i; this.addSlotToContainer(new IESlot.Ghost(this, tile.filter, id, x, y)); } - slotCount=6*TileEntitySorter.filterSlotsPerSide; + slotCount = 6*TileEntitySorter.filterSlotsPerSide; - for (int i = 0; i < 3; i++) - for (int j = 0; j < 9; j++) + for(int i = 0; i < 3; i++) + for(int j = 0; j < 9; j++) addSlotToContainer(new Slot(inventoryPlayer, j+i*9+9, 8+j*18, 163+i*18)); - for (int i = 0; i < 9; i++) + for(int i = 0; i < 9; i++) addSlotToContainer(new Slot(inventoryPlayer, i, 8+i*18, 221)); } @Override public boolean canInteractWith(EntityPlayer player) { - return tile!=null && tile.getWorld().getTileEntity(tile.getPos())==tile && player.getDistanceSq(tile.getPos().getX()+.5, tile.getPos().getY()+.5, tile.getPos().getZ()+.5)<=64; + return tile!=null&&tile.getWorld().getTileEntity(tile.getPos())==tile&&player.getDistanceSq(tile.getPos().getX()+.5, tile.getPos().getY()+.5, tile.getPos().getZ()+.5) <= 64; } @Override public ItemStack slotClick(int id, int button, ClickType modifier, EntityPlayer player) { - Slot slot = id<0?null: this.inventorySlots.get(id); + Slot slot = id < 0?null: this.inventorySlots.get(id); if(!(slot instanceof IESlot.Ghost)) return super.slotClick(id, button, modifier, player); @@ -59,33 +60,33 @@ public ItemStack slotClick(int id, int button, ClickType modifier, EntityPlayer if(!stackSlot.isEmpty()) stack = stackSlot.copy(); - if (button==2) + if(button==2) slot.putStack(ItemStack.EMPTY); else if(button==0||button==1) { InventoryPlayer playerInv = player.inventory; ItemStack stackHeld = playerInv.getItemStack(); - if (stackSlot.isEmpty()) + if(stackSlot.isEmpty()) { - if(!stackHeld.isEmpty() && slot.isItemValid(stackHeld)) + if(!stackHeld.isEmpty()&&slot.isItemValid(stackHeld)) { slot.putStack(Utils.copyStackWithAmount(stackHeld, 1)); } } - else if (stackHeld.isEmpty()) + else if(stackHeld.isEmpty()) { slot.putStack(ItemStack.EMPTY); } - else if (slot.isItemValid(stackHeld)) + else if(slot.isItemValid(stackHeld)) { slot.putStack(Utils.copyStackWithAmount(stackHeld, 1)); } } - else if (button == 5) + else if(button==5) { InventoryPlayer playerInv = player.inventory; ItemStack stackHeld = playerInv.getItemStack(); - if (!slot.getHasStack()) + if(!slot.getHasStack()) { slot.putStack(Utils.copyStackWithAmount(stackHeld, 1)); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerSqueezer.java b/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerSqueezer.java index d8806672bd..b99acf3f5b 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerSqueezer.java +++ b/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerSqueezer.java @@ -18,17 +18,17 @@ public ContainerSqueezer(InventoryPlayer inventoryPlayer, TileEntitySqueezer til { super(inventoryPlayer, tile); - for(int i=0; i<8; i++) - this.addSlotToContainer(new Slot(this.inv, i, 8+(i%4)*18,35+(i/4)*18)); - this.addSlotToContainer(new IESlot.Output(this, this.inv, 8, 91,53)); - this.addSlotToContainer(new IESlot.FluidContainer(this, this.inv, 9, 134,17, 0)); - this.addSlotToContainer(new IESlot.Output(this, this.inv, 10, 134,53)); - slotCount=11; + for(int i = 0; i < 8; i++) + this.addSlotToContainer(new Slot(this.inv, i, 8+(i%4)*18, 35+(i/4)*18)); + this.addSlotToContainer(new IESlot.Output(this, this.inv, 8, 91, 53)); + this.addSlotToContainer(new IESlot.FluidContainer(this, this.inv, 9, 134, 17, 0)); + this.addSlotToContainer(new IESlot.Output(this, this.inv, 10, 134, 53)); + slotCount = 11; - for (int i = 0; i < 3; i++) - for (int j = 0; j < 9; j++) + for(int i = 0; i < 3; i++) + for(int j = 0; j < 9; j++) addSlotToContainer(new Slot(inventoryPlayer, j+i*9+9, 8+j*18, 85+i*18)); - for (int i = 0; i < 9; i++) + for(int i = 0; i < 9; i++) addSlotToContainer(new Slot(inventoryPlayer, i, 8+i*18, 143)); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerToolbox.java b/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerToolbox.java index 4540f45de9..a4c1bed2d5 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerToolbox.java +++ b/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerToolbox.java @@ -27,22 +27,22 @@ public ContainerToolbox(InventoryPlayer iinventory, World world, EntityEquipment @Override int addSlots(InventoryPlayer iinventory) { - int i=0; + int i = 0; this.addSlotToContainer(new IESlot.ContainerCallback(this, this.inv, i++, 48, 24)); this.addSlotToContainer(new IESlot.ContainerCallback(this, this.inv, i++, 30, 42)); this.addSlotToContainer(new IESlot.ContainerCallback(this, this.inv, i++, 48, 42)); this.addSlotToContainer(new IESlot.ContainerCallback(this, this.inv, i++, 75, 24)); this.addSlotToContainer(new IESlot.ContainerCallback(this, this.inv, i++, 93, 24)); - this.addSlotToContainer(new IESlot.ContainerCallback(this, this.inv, i++,111, 24)); + this.addSlotToContainer(new IESlot.ContainerCallback(this, this.inv, i++, 111, 24)); this.addSlotToContainer(new IESlot.ContainerCallback(this, this.inv, i++, 75, 42)); this.addSlotToContainer(new IESlot.ContainerCallback(this, this.inv, i++, 93, 42)); - this.addSlotToContainer(new IESlot.ContainerCallback(this, this.inv, i++,111, 42)); - this.addSlotToContainer(new IESlot.ContainerCallback(this, this.inv, i++,129, 42)); + this.addSlotToContainer(new IESlot.ContainerCallback(this, this.inv, i++, 111, 42)); + this.addSlotToContainer(new IESlot.ContainerCallback(this, this.inv, i++, 129, 42)); - for(int j=0; j<6; j++) + for(int j = 0; j < 6; j++) this.addSlotToContainer(new IESlot.ContainerCallback(this, this.inv, i++, 35+j*18, 77)); - for(int j=0; j<7; j++) + for(int j = 0; j < 7; j++) this.addSlotToContainer(new IESlot.ContainerCallback(this, this.inv, i++, 26+j*18, 112)); bindPlayerInventory(iinventory); @@ -56,27 +56,29 @@ public boolean canInsert(ItemStack stack, int slotNumer, Slot slotObject) return false; if(!IEApi.isAllowedInCrate(stack)) return false; - if(slotNumer<3) + if(slotNumer < 3) return ToolboxHandler.isFood(stack); - else if(slotNumer<10) + else if(slotNumer < 10) return ToolboxHandler.isTool(stack); - else if(slotNumer<16) + else if(slotNumer < 16) return ToolboxHandler.isWiring(stack, world); else return true; } + @Override public boolean canTake(ItemStack stack, int slotNumer, Slot slotObject) { return true; } - protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) { - for (int i = 0; i < 3; i++) - for (int j = 0; j < 9; j++) + protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) + { + for(int i = 0; i < 3; i++) + for(int j = 0; j < 9; j++) this.addSlotToContainer(new Slot(inventoryPlayer, j+i*9+9, 8+j*18, 157+i*18)); - for (int i = 0; i < 9; i++) + for(int i = 0; i < 9; i++) this.addSlotToContainer(new Slot(inventoryPlayer, i, 8+i*18, 215)); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerToolboxBlock.java b/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerToolboxBlock.java index 4db33dd289..90213ccb78 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerToolboxBlock.java +++ b/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerToolboxBlock.java @@ -23,34 +23,35 @@ public class ContainerToolboxBlock extends ContainerIEBase implements ICallbackContainer { IItemHandler inv; + public ContainerToolboxBlock(InventoryPlayer inventoryPlayer, TileEntityToolbox tile) { super(inventoryPlayer, tile); this.tile = tile; inv = new ItemStackHandler(tile.getInventory()); - if (inv instanceof IEItemStackHandler) - ((IEItemStackHandler) inv).setTile(tile); + if(inv instanceof IEItemStackHandler) + ((IEItemStackHandler)inv).setTile(tile); this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++, 48, 24)); this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++, 30, 42)); this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++, 48, 42)); this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++, 75, 24)); this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++, 93, 24)); - this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++,111, 24)); + this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++, 111, 24)); this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++, 75, 42)); this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++, 93, 42)); - this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++,111, 42)); - this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++,129, 42)); + this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++, 111, 42)); + this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++, 129, 42)); - for(int j=0; j<6; j++) + for(int j = 0; j < 6; j++) this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++, 35+j*18, 77)); - for(int j=0; j<7; j++) + for(int j = 0; j < 7; j++) this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++, 26+j*18, 112)); - for (int i = 0; i < 3; i++) - for (int j = 0; j < 9; j++) + for(int i = 0; i < 3; i++) + for(int j = 0; j < 9; j++) this.addSlotToContainer(new Slot(inventoryPlayer, j+i*9+9, 8+j*18, 157+i*18)); - for (int i = 0; i < 9; i++) + for(int i = 0; i < 9; i++) this.addSlotToContainer(new Slot(inventoryPlayer, i, 8+i*18, 215)); } @@ -61,15 +62,16 @@ public boolean canInsert(ItemStack stack, int slotNumer, Slot slotObject) return false; if(!IEApi.isAllowedInCrate(stack)) return false; - if(slotNumer<3) + if(slotNumer < 3) return ToolboxHandler.isFood(stack); - else if(slotNumer<10) + else if(slotNumer < 10) return ToolboxHandler.isTool(stack); - else if(slotNumer<16) + else if(slotNumer < 16) return ToolboxHandler.isWiring(stack, this.tile.getWorld()); else return true; } + @Override public boolean canTake(ItemStack stack, int slotNumer, Slot slotObject) { @@ -79,7 +81,7 @@ public boolean canTake(ItemStack stack, int slotNumer, Slot slotObject) @Override public void onContainerClosed(EntityPlayer playerIn) { - if (inv instanceof IEItemStackHandler) - ((IEItemStackHandler) inv).setTile(null); + if(inv instanceof IEItemStackHandler) + ((IEItemStackHandler)inv).setTile(null); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerTurret.java b/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerTurret.java index 2fc9d1ce99..61e4e0bf11 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerTurret.java +++ b/src/main/java/blusunrize/immersiveengineering/common/gui/ContainerTurret.java @@ -23,7 +23,7 @@ public class ContainerTurret extends ContainerIEBase public ContainerTurret(InventoryPlayer inventoryPlayer, TileEntityTurret tile) { super(inventoryPlayer, tile); - this.tile=tile; + this.tile = tile; if(tile instanceof TileEntityTurretGun) { @@ -36,17 +36,17 @@ public boolean isItemValid(ItemStack itemStack) return false; String key = ItemNBTHelper.getString(itemStack, "bullet"); IBullet bullet = BulletHandler.getBullet(key); - return bullet!=null && bullet.isValidForTurret(); + return bullet!=null&&bullet.isValidForTurret(); } }); this.addSlotToContainer(new IESlot.Output(this, this.inv, 1, 134, 49)); - slotCount=2; + slotCount = 2; } - for(int i=0; i<3; i++) - for(int j=0; j<9; j++) + for(int i = 0; i < 3; i++) + for(int j = 0; j < 9; j++) addSlotToContainer(new Slot(inventoryPlayer, j+i*9+9, 8+j*18, 109+i*18)); - for(int i=0; i<9; i++) + for(int i = 0; i < 9; i++) addSlotToContainer(new Slot(inventoryPlayer, i, 8+i*18, 167)); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/gui/IESlot.java b/src/main/java/blusunrize/immersiveengineering/common/gui/IESlot.java index ae84bc0e78..d15a2d3a2f 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/gui/IESlot.java +++ b/src/main/java/blusunrize/immersiveengineering/common/gui/IESlot.java @@ -17,7 +17,6 @@ import blusunrize.immersiveengineering.api.shader.IShaderItem; import blusunrize.immersiveengineering.api.tool.*; import blusunrize.immersiveengineering.common.IEContent; -import blusunrize.immersiveengineering.common.blocks.metal.TileEntityBelljar; import blusunrize.immersiveengineering.common.items.ItemBullet; import blusunrize.immersiveengineering.common.items.ItemEngineersBlueprint; import blusunrize.immersiveengineering.common.util.inventory.IEItemStackHandler; @@ -45,10 +44,11 @@ public abstract class IESlot extends Slot { final Container container; + public IESlot(Container container, IInventory inv, int id, int x, int y) { super(inv, id, x, y); - this.container=container; + this.container = container; } @Override @@ -63,62 +63,72 @@ public Output(Container container, IInventory inv, int id, int x, int y) { super(container, inv, id, x, y); } + @Override public boolean isItemValid(ItemStack itemStack) { return false; } } + public static class FluidContainer extends IESlot { int filter; //0 = any, 1 = empty, 2 = full + public FluidContainer(Container container, IInventory inv, int id, int x, int y, int filter) { super(container, inv, id, x, y); - this.filter=filter; + this.filter = filter; } + @Override public boolean isItemValid(ItemStack itemStack) { IFluidHandler handler = FluidUtil.getFluidHandler(itemStack); - if(handler == null || handler.getTankProperties() == null) + if(handler==null||handler.getTankProperties()==null) return false; IFluidTankProperties[] tank = handler.getTankProperties(); - if(tank == null || tank.length < 1 || tank[0] == null) + if(tank==null||tank.length < 1||tank[0]==null) return false; if(filter==1) - return tank[0].getContents() == null; + return tank[0].getContents()==null; else if(filter==2) - return tank[0].getContents() != null; + return tank[0].getContents()!=null; return true; } } + public static class BlastFuel extends IESlot { public BlastFuel(Container container, IInventory inv, int id, int x, int y) { super(container, inv, id, x, y); } + @Override public boolean isItemValid(ItemStack itemStack) { return BlastFurnaceRecipe.isValidBlastFuel(itemStack); } } + public static class Bullet extends SlotItemHandler { int limit; + public Bullet(IItemHandler inv, int id, int x, int y, int limit) { super(inv, id, x, y); - this.limit=limit; + this.limit = limit; } + @Override public boolean isItemValid(ItemStack itemStack) { - return !itemStack.isEmpty() && itemStack.getItem() instanceof ItemBullet; + return !itemStack.isEmpty()&&itemStack.getItem() instanceof ItemBullet; } + @Override public int getSlotStackLimit() { @@ -131,29 +141,34 @@ public int getItemStackLimit(@Nonnull ItemStack stack) return limit; } } + public static class DrillHead extends SlotItemHandler { public DrillHead(IItemHandler inv, int id, int x, int y) { super(inv, id, x, y); } + @Override public boolean isItemValid(ItemStack itemStack) { - return !itemStack.isEmpty() && itemStack.getItem() instanceof IDrillHead; + return !itemStack.isEmpty()&&itemStack.getItem() instanceof IDrillHead; } + @Override public int getSlotStackLimit() { return 1; } } + public static class Upgrades extends SlotItemHandler { ItemStack upgradeableTool; String type; boolean preventDoubles; Container container; + public Upgrades(Container container, IItemHandler inv, int id, int x, int y, String type, ItemStack upgradeableTool, boolean preventDoubles) { super(inv, id, x, y); @@ -162,15 +177,17 @@ public Upgrades(Container container, IItemHandler inv, int id, int x, int y, Str this.upgradeableTool = upgradeableTool; this.preventDoubles = preventDoubles; } + @Override public boolean isItemValid(ItemStack itemStack) { if(preventDoubles) for(Slot slot : container.inventorySlots) - if(slot instanceof Upgrades && ((Upgrades)slot).preventDoubles && OreDictionary.itemMatches(slot.getStack(), itemStack, true)) + if(slot instanceof Upgrades&&((Upgrades)slot).preventDoubles&&OreDictionary.itemMatches(slot.getStack(), itemStack, true)) return false; - return !itemStack.isEmpty() && itemStack.getItem() instanceof IUpgrade && ((IUpgrade)itemStack.getItem()).getUpgradeTypes(itemStack).contains(type) && ((IUpgrade)itemStack.getItem()).canApplyUpgrades(upgradeableTool, itemStack); + return !itemStack.isEmpty()&&itemStack.getItem() instanceof IUpgrade&&((IUpgrade)itemStack.getItem()).getUpgradeTypes(itemStack).contains(type)&&((IUpgrade)itemStack.getItem()).canApplyUpgrades(upgradeableTool, itemStack); } + @Override public int getSlotStackLimit() { @@ -183,9 +200,11 @@ public void onSlotChanged() ((IUpgradeableTool)upgradeableTool.getItem()).recalculateUpgrades(upgradeableTool); } } + public static class Shader extends IESlot { ItemStack tool; + public Shader(Container container, IInventory inv, int id, int x, int y, ItemStack tool) { super(container, inv, id, x, y); @@ -193,30 +212,35 @@ public Shader(Container container, IInventory inv, int id, int x, int y, ItemSta if(FMLCommonHandler.instance().getEffectiveSide()==Side.CLIENT) this.setBackgroundName("immersiveengineering:items/shader_slot"); } + @Override public boolean isItemValid(ItemStack itemStack) { - if(itemStack.isEmpty() || !(itemStack.getItem() instanceof IShaderItem) || tool.isEmpty() || !tool.hasCapability(CapabilityShader.SHADER_CAPABILITY,null)) + if(itemStack.isEmpty()||!(itemStack.getItem() instanceof IShaderItem)||tool.isEmpty()||!tool.hasCapability(CapabilityShader.SHADER_CAPABILITY, null)) return false; - ShaderWrapper wrapper = tool.getCapability(CapabilityShader.SHADER_CAPABILITY,null); + ShaderWrapper wrapper = tool.getCapability(CapabilityShader.SHADER_CAPABILITY, null); if(wrapper==null) return false; return ((IShaderItem)itemStack.getItem()).getShaderCase(itemStack, tool, wrapper.getShaderType())!=null; } + @Override public int getSlotStackLimit() { return 1; } } + public static class UpgradeableItem extends IESlot { int size; + public UpgradeableItem(Container container, IInventory inv, int id, int x, int y, int size) { super(container, inv, id, x, y); this.size = size; } + @Override public boolean isItemValid(ItemStack itemStack) { @@ -228,11 +252,13 @@ public boolean isItemValid(ItemStack itemStack) return ((IConfigurableTool)itemStack.getItem()).canConfigure(itemStack); return false; } + @Override public int getSlotStackLimit() { return size; } + @Override public void onSlotChanged() { @@ -240,39 +266,45 @@ public void onSlotChanged() if(container instanceof ContainerModWorkbench) ((ContainerModWorkbench)container).rebindSlots(); } + @Override public boolean canTakeStack(EntityPlayer player) { - return !(!this.getStack().isEmpty() && getStack().getItem() instanceof IUpgradeableTool && !((IUpgradeableTool) getStack().getItem()).canTakeFromWorkbench(getStack())); + return !(!this.getStack().isEmpty()&&getStack().getItem() instanceof IUpgradeableTool&&!((IUpgradeableTool)getStack().getItem()).canTakeFromWorkbench(getStack())); } + @Override public ItemStack onTake(EntityPlayer player, ItemStack stack) { ItemStack result = super.onTake(player, stack); - if (!stack.isEmpty() && stack.getItem() instanceof IUpgradeableTool) - ((IUpgradeableTool) stack.getItem()).removeFromWorkbench(player, stack); + if(!stack.isEmpty()&&stack.getItem() instanceof IUpgradeableTool) + ((IUpgradeableTool)stack.getItem()).removeFromWorkbench(player, stack); IItemHandler handler = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); - if (handler instanceof IEItemStackHandler) - ((IEItemStackHandler) handler).setTile(null); + if(handler instanceof IEItemStackHandler) + ((IEItemStackHandler)handler).setTile(null); return result; } } + public static class AutoBlueprint extends IESlot { public AutoBlueprint(Container container, IInventory inv, int id, int x, int y) { super(container, inv, id, x, y); } + @Override public boolean isItemValid(ItemStack itemStack) { - return !itemStack.isEmpty() && itemStack.getItem() instanceof ItemEngineersBlueprint; + return !itemStack.isEmpty()&&itemStack.getItem() instanceof ItemEngineersBlueprint; } + @Override public int getSlotStackLimit() { return 1; } + @Override public void onSlotChanged() { @@ -282,6 +314,7 @@ public void onSlotChanged() // ((ContainerAutoWorkbench)container).rebindSlots(); } } + public static class Ghost extends IESlot { public Ghost(Container container, IInventory inv, int id, int x, int y) @@ -294,28 +327,33 @@ public void putStack(ItemStack itemStack) { super.putStack(itemStack); } + @Override public boolean canTakeStack(EntityPlayer player) { return false; } + @Override public int getSlotStackLimit() { return 1; } } + public static class ItemDisplay extends IESlot { public ItemDisplay(Container container, IInventory inv, int id, int x, int y) { super(container, inv, id, x, y); } + @Override public boolean isItemValid(ItemStack itemStack) { return false; } + @Override public boolean canTakeStack(EntityPlayer player) { @@ -327,31 +365,36 @@ public static class BlueprintInput extends SlotItemHandler { ItemStack upgradeableTool; Container container; + public BlueprintInput(Container container, IItemHandler inv, int id, int x, int y, ItemStack upgradeableTool) { super(inv, id, x, y); this.upgradeableTool = upgradeableTool; } + @Override public void onSlotChanged() { - if(!upgradeableTool.isEmpty() && upgradeableTool.getItem() instanceof ItemEngineersBlueprint) + if(!upgradeableTool.isEmpty()&&upgradeableTool.getItem() instanceof ItemEngineersBlueprint) ((ItemEngineersBlueprint)upgradeableTool.getItem()).updateOutputs(upgradeableTool); if(container instanceof ContainerModWorkbench) ((ContainerModWorkbench)container).rebindSlots(); super.onSlotChanged(); } + @Override public int getSlotStackLimit() { return 64; } } + public static class BlueprintOutput extends SlotItemHandler { public BlueprintCraftingRecipe recipe; ItemStack upgradeableTool; Container container; + public BlueprintOutput(Container container, IItemHandler inv, int id, int x, int y, ItemStack upgradeableTool, BlueprintCraftingRecipe recipe) { super(inv, id, x, y); @@ -359,6 +402,7 @@ public BlueprintOutput(Container container, IItemHandler inv, int id, int x, int this.upgradeableTool = upgradeableTool; this.recipe = recipe; } + @Override public boolean isItemValid(ItemStack itemStack) { @@ -376,7 +420,7 @@ public boolean isEnabled() @Override public ItemStack onTake(EntityPlayer player, ItemStack stack) { - if(!upgradeableTool.isEmpty() && upgradeableTool.getItem() instanceof ItemEngineersBlueprint) + if(!upgradeableTool.isEmpty()&&upgradeableTool.getItem() instanceof ItemEngineersBlueprint) { ((ItemEngineersBlueprint)upgradeableTool.getItem()).reduceInputs(recipe, upgradeableTool, stack, this.container); ((ItemEngineersBlueprint)upgradeableTool.getItem()).updateOutputs(upgradeableTool); @@ -392,24 +436,28 @@ public ArcInput(Container container, IInventory inv, int id, int x, int y) { super(container, inv, id, x, y); } + @Override public boolean isItemValid(ItemStack itemStack) { - return !itemStack.isEmpty() && ArcFurnaceRecipe.isValidRecipeInput(itemStack); + return !itemStack.isEmpty()&&ArcFurnaceRecipe.isValidRecipeInput(itemStack); } } + public static class ArcAdditive extends IESlot { public ArcAdditive(Container container, IInventory inv, int id, int x, int y) { super(container, inv, id, x, y); } + @Override public boolean isItemValid(ItemStack itemStack) { - return !itemStack.isEmpty() && ArcFurnaceRecipe.isValidRecipeAdditive(itemStack); + return !itemStack.isEmpty()&&ArcFurnaceRecipe.isValidRecipeAdditive(itemStack); } } + public static class ArcElectrode extends IESlot { public ArcElectrode(Container container, IInventory inv, int id, int x, int y) @@ -422,16 +470,18 @@ public int getSlotStackLimit() { return 1; } + @Override public boolean isItemValid(ItemStack itemStack) { - return !itemStack.isEmpty() && IEContent.itemGraphiteElectrode.equals(itemStack.getItem()); + return !itemStack.isEmpty()&&IEContent.itemGraphiteElectrode.equals(itemStack.getItem()); } } public static class Belljar extends IESlot { int type = 0; + public Belljar(int type, Container container, IInventory inv, int id, int x, int y) { super(container, inv, id, x, y); @@ -441,28 +491,31 @@ public Belljar(int type, Container container, IInventory inv, int id, int x, int @Override public int getSlotStackLimit() { - return type<2?1:64; + return type < 2?1: 64; } + @Override public boolean isItemValid(ItemStack itemStack) { - if (itemStack.isEmpty()) + if(itemStack.isEmpty()) return false; - if (type == SLOT_SEED) - return BelljarHandler.getHandler(itemStack) != null; + if(type==SLOT_SEED) + return BelljarHandler.getHandler(itemStack)!=null; else - return type == SLOT_SOIL || BelljarHandler.getItemFertilizerHandler(itemStack) != null; + return type==SLOT_SOIL||BelljarHandler.getItemFertilizerHandler(itemStack)!=null; } } public static class ContainerCallback extends SlotItemHandler { Container container; + public ContainerCallback(Container container, IItemHandler inv, int id, int x, int y) { super(inv, id, x, y); this.container = container; } + @Override public boolean isItemValid(ItemStack itemStack) { @@ -470,6 +523,7 @@ public boolean isItemValid(ItemStack itemStack) return ((ICallbackContainer)this.container).canInsert(itemStack, slotNumber, this); return true; } + @Override public boolean canTakeStack(EntityPlayer player) { @@ -478,9 +532,11 @@ public boolean canTakeStack(EntityPlayer player) return true; } } + public interface ICallbackContainer { boolean canInsert(ItemStack stack, int slotNumer, Slot slotObject); + boolean canTake(ItemStack stack, int slotNumer, Slot slotObject); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/gui/InventoryShader.java b/src/main/java/blusunrize/immersiveengineering/common/gui/InventoryShader.java index b9033c6854..3f8703b7c3 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/gui/InventoryShader.java +++ b/src/main/java/blusunrize/immersiveengineering/common/gui/InventoryShader.java @@ -43,7 +43,8 @@ public int getSizeInventory() } @Override - public boolean isEmpty() { + public boolean isEmpty() + { return this.shader.isEmpty(); } @@ -71,7 +72,7 @@ public ItemStack decrStackSize(int i, int j) if(!this.shader.isEmpty()) { ItemStack itemstack; - if(shader.getCount()<=j) + if(shader.getCount() <= j) { itemstack = this.shader.copy(); this.shader = ItemStack.EMPTY; @@ -94,7 +95,7 @@ public ItemStack decrStackSize(int i, int j) public void setInventorySlotContents(int i, ItemStack stack) { this.shader = stack; - if(!stack.isEmpty() && stack.getCount() > this.getInventoryStackLimit()) + if(!stack.isEmpty()&&stack.getCount() > this.getInventoryStackLimit()) stack.setCount(this.getInventoryStackLimit()); this.container.onCraftMatrixChanged(this); } @@ -104,15 +105,17 @@ public String getName() { return "container."+name; } + @Override public boolean hasCustomName() { return false; } + @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()); } @Override @@ -129,18 +132,24 @@ public void markDirty() } @Override - public boolean isUsableByPlayer(EntityPlayer entityplayer) { + public boolean isUsableByPlayer(EntityPlayer entityplayer) + { return true; } @Override - public void openInventory(EntityPlayer player) {} + public void openInventory(EntityPlayer player) + { + } @Override - public void closeInventory(EntityPlayer player) {} + public void closeInventory(EntityPlayer player) + { + } @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { + public boolean isItemValidForSlot(int i, ItemStack itemstack) + { return true; } @@ -150,15 +159,18 @@ public int getField(int id) { return 0; } + @Override public void setField(int id, int value) { } + @Override public int getFieldCount() { return 0; } + @Override public void clear() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/gui/InventoryTile.java b/src/main/java/blusunrize/immersiveengineering/common/gui/InventoryTile.java index 8ab3ec1b05..210478cec3 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/gui/InventoryTile.java +++ b/src/main/java/blusunrize/immersiveengineering/common/gui/InventoryTile.java @@ -41,6 +41,7 @@ public boolean hasCustomName() { return false; } + @Override public ITextComponent getDisplayName() { @@ -54,9 +55,12 @@ public int getSizeInventory() } @Override - public boolean isEmpty() { - for (ItemStack stack : inv.getInventory()) { - if (!stack.isEmpty()) { + public boolean isEmpty() + { + for(ItemStack stack : inv.getInventory()) + { + if(!stack.isEmpty()) + { return false; } } @@ -74,7 +78,7 @@ public ItemStack decrStackSize(int index, int count) { ItemStack stack = inv.getInventory().get(index); if(!stack.isEmpty()) - if(stack.getCount()<=count) + if(stack.getCount() <= count) inv.getInventory().set(index, ItemStack.EMPTY); else { @@ -114,7 +118,7 @@ public void markDirty() @Override public boolean isUsableByPlayer(EntityPlayer player) { - return !tile.isInvalid() && tile.getDistanceSq(player.posX, player.posY, player.posZ)<64; + return !tile.isInvalid()&&tile.getDistanceSq(player.posX, player.posY, player.posZ) < 64; } @Override @@ -125,7 +129,7 @@ public void openInventory(EntityPlayer player) @Override public void closeInventory(EntityPlayer player) { - for(int i=0; i getTextures(ItemStack stack, String key); } - public interface IBulletContainer + public interface IBulletContainer { NonNullList getBullets(ItemStack container, boolean remote); + default NonNullList getBullets(ItemStack container) { return getBullets(container, FMLCommonHandler.instance().getEffectiveSide()==Side.CLIENT); } + int getBulletCount(ItemStack container); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemBullet.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemBullet.java index b1c2b61436..8d86fe88c8 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemBullet.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemBullet.java @@ -22,7 +22,6 @@ import blusunrize.immersiveengineering.common.util.IEDamageSources; import blusunrize.immersiveengineering.common.util.IESounds; import blusunrize.immersiveengineering.common.util.ItemNBTHelper; -import blusunrize.immersiveengineering.common.util.Utils; import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.util.ITooltipFlag; @@ -35,11 +34,13 @@ import net.minecraft.item.ItemPotion; import net.minecraft.item.ItemSplashPotion; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionType; import net.minecraft.potion.PotionUtils; -import net.minecraft.util.*; +import net.minecraft.util.DamageSource; +import net.minecraft.util.NonNullList; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.SoundEvent; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; @@ -184,18 +185,19 @@ public FontRenderer getFontRenderer(ItemStack stack) @Override public void addInformation(ItemStack stack, @Nullable World world, List list, ITooltipFlag flag) { - if(stack.getItemDamage() == 2) + if(stack.getItemDamage()==2) { String key = ItemNBTHelper.getString(stack, "bullet"); IBullet bullet = BulletHandler.getBullet(key); - if(bullet != null) + if(bullet!=null) bullet.addTooltip(stack, world, list, flag); } } + @Override public String getItemStackDisplayName(ItemStack stack) { - if(stack.getItemDamage() == 2) + if(stack.getItemDamage()==2) { String s = "item.immersiveengineering.bullet."; String key = ItemNBTHelper.getString(stack, "bullet"); @@ -203,9 +205,9 @@ public String getItemStackDisplayName(ItemStack stack) key = BulletHandler.handleLeagcyNames(key); s += key; IBullet bullet = BulletHandler.getBullet(key); - if(bullet != null) + if(bullet!=null) s = bullet.getUnlocalizedName(stack, s); - return I18n.translateToLocal(s + ".name").trim(); + return I18n.translateToLocal(s+".name").trim(); } return super.getItemStackDisplayName(stack); } @@ -215,31 +217,34 @@ public boolean hasCustomItemColours() { return true; } + @Override public int getColourForIEItem(ItemStack stack, int pass) { - if(stack.getMetadata() == 2 && ItemNBTHelper.hasKey(stack, "bullet")) + if(stack.getMetadata()==2&&ItemNBTHelper.hasKey(stack, "bullet")) { IBullet bullet = BulletHandler.getBullet(ItemNBTHelper.getString(stack, "bullet")); - if(bullet != null) + if(bullet!=null) return bullet.getColour(stack, pass); } return super.getColourForIEItem(stack, pass); } + @Override @SideOnly(Side.CLIENT) public String getModelCacheKey(ItemStack stack) { - if(stack.getMetadata() == 2 && ItemNBTHelper.hasKey(stack, "bullet")) + if(stack.getMetadata()==2&&ItemNBTHelper.hasKey(stack, "bullet")) return ItemNBTHelper.getString(stack, "bullet"); return null; } + @Override @SideOnly(Side.CLIENT) public List getTextures(ItemStack stack, String key) { IBullet bullet = BulletHandler.getBullet(key); - if(bullet != null) + if(bullet!=null) return Arrays.asList(bullet.getTextures()); return Arrays.asList(new ResourceLocation("immersiveengieering:items/bullet_casull")); } @@ -322,7 +327,7 @@ public static class PotionBullet extends BulletHandler.DamagingBullet { public PotionBullet() { - super(entities -> IEDamageSources.causePotionDamage((EntityRevolvershot) entities[0], entities[1]), + super(entities -> IEDamageSources.causePotionDamage((EntityRevolvershot)entities[0], entities[1]), IEConfig.Tools.bulletDamage_Potion, BulletHandler.emptyCasing, new ResourceLocation("immersiveengineering:items/bullet_potion"), new ResourceLocation("immersiveengineering:items/bullet_potion_layer")); @@ -343,7 +348,7 @@ else if(pot.getItem() instanceof ItemSplashPotion) @Override public Entity getProjectile(EntityPlayer shooter, ItemStack cartridge, Entity projectile, boolean electro) { - ((EntityRevolvershot) projectile).bulletPotion = ItemNBTHelper.getItemStack(cartridge, "potion"); + ((EntityRevolvershot)projectile).bulletPotion = ItemNBTHelper.getItemStack(cartridge, "potion"); return projectile; } @@ -352,11 +357,11 @@ public void onHitTarget(World world, RayTraceResult target, EntityLivingBase sho { super.onHitTarget(world, target, shooter, projectile, headshot); EntityRevolvershot bullet = (EntityRevolvershot)projectile; - if(!bullet.bulletPotion.isEmpty() && bullet.bulletPotion.hasTagCompound()) + if(!bullet.bulletPotion.isEmpty()&&bullet.bulletPotion.hasTagCompound()) { PotionType potionType = PotionUtils.getPotionFromItem(bullet.bulletPotion); List effects = PotionUtils.getEffectsFromStack(bullet.bulletPotion); - if(effects != null) + if(effects!=null) if(bullet.bulletPotion.getItem() instanceof ItemLingeringPotion) { EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(bullet.world, bullet.posX, bullet.posY, bullet.posZ); @@ -364,7 +369,7 @@ public void onHitTarget(World world, RayTraceResult target, EntityLivingBase sho entityareaeffectcloud.setRadius(3.0F); entityareaeffectcloud.setRadiusOnUse(-0.5F); entityareaeffectcloud.setWaitTime(10); - entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius() / (float)entityareaeffectcloud.getDuration()); + entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius()/(float)entityareaeffectcloud.getDuration()); entityareaeffectcloud.setPotion(potionType); for(PotionEffect potioneffect : effects) entityareaeffectcloud.addEffect(new PotionEffect(potioneffect.getPotion(), potioneffect.getDuration(), potioneffect.getAmplifier())); @@ -373,22 +378,22 @@ public void onHitTarget(World world, RayTraceResult target, EntityLivingBase sho else if(bullet.bulletPotion.getItem() instanceof ItemSplashPotion) { List livingEntities = bullet.world.getEntitiesWithinAABB(EntityLivingBase.class, bullet.getEntityBoundingBox().grow(4.0D, 2.0D, 4.0D)); - if(livingEntities != null && !livingEntities.isEmpty()) + if(livingEntities!=null&&!livingEntities.isEmpty()) for(EntityLivingBase living : livingEntities) if(living.canBeHitWithPotion()) { double dist = bullet.getDistanceSq(living); if(dist < 16D) { - double dist2 = 1 - Math.sqrt(dist) / 4D; - if(living == target.entityHit) + double dist2 = 1-Math.sqrt(dist)/4D; + if(living==target.entityHit) dist2 = 1D; for(PotionEffect p : effects) if(p.getPotion().isInstant()) p.getPotion().affectEntity(bullet, shooter, living, p.getAmplifier(), dist2); else { - int j = (int)(dist2 * p.getDuration() + .5D); + int j = (int)(dist2*p.getDuration()+.5D); if(j > 20) living.addPotionEffect(new PotionEffect(p.getPotion(), j, p.getAmplifier())); } @@ -412,17 +417,17 @@ else if(target.entityHit instanceof EntityLivingBase) public void addTooltip(ItemStack stack, World world, List list, ITooltipFlag flag) { ItemStack pot = ItemNBTHelper.getItemStack(stack, "potion"); - if(!pot.isEmpty() && pot.getItem() instanceof ItemPotion) + if(!pot.isEmpty()&&pot.getItem() instanceof ItemPotion) PotionUtils.addPotionTooltip(pot, list, 1f); } @Override public int getColour(ItemStack stack, int layer) { - if(layer == 1) + if(layer==1) { ItemStack pot = ItemNBTHelper.getItemStack(stack, "potion"); - return pot.isEmpty() ? 0xff385dc6 : PotionUtils.getPotionColorFromEffectList(PotionUtils.getEffectsFromStack(pot)); + return pot.isEmpty()?0xff385dc6: PotionUtils.getPotionColorFromEffectList(PotionUtils.getEffectsFromStack(pot)); } return 0xffffffff; } @@ -439,7 +444,7 @@ public FlareBullet() @Override public Entity getProjectile(EntityPlayer shooter, ItemStack cartridge, Entity projectile, boolean electro) { - EntityRevolvershotFlare flare = shooter!=null?new EntityRevolvershotFlare(projectile.world, shooter, projectile.motionX*1.5,projectile.motionY*1.5,projectile.motionZ*1.5, this, cartridge): new EntityRevolvershotFlare(projectile.world, projectile.posX,projectile.posY,projectile.posZ, 0,0,0, this); + EntityRevolvershotFlare flare = shooter!=null?new EntityRevolvershotFlare(projectile.world, shooter, projectile.motionX*1.5, projectile.motionY*1.5, projectile.motionZ*1.5, this, cartridge): new EntityRevolvershotFlare(projectile.world, projectile.posX, projectile.posY, projectile.posZ, 0, 0, 0, this); flare.motionX = projectile.motionX; flare.motionY = projectile.motionY; flare.motionZ = projectile.motionZ; @@ -472,16 +477,16 @@ public void addTooltip(ItemStack stack, World world, List list, ITooltip if(stack.getItem() instanceof IColouredItem) { String hexCol = Integer.toHexString(((IColouredItem)stack.getItem()).getColourForIEItem(stack, 1)); - list.add(I18n.translateToLocalFormatted(Lib.DESC_INFO + "bullet.flareColour", "")); + list.add(I18n.translateToLocalFormatted(Lib.DESC_INFO+"bullet.flareColour", "")); } } @Override public int getColour(ItemStack stack, int layer) { - if(layer != 1) + if(layer!=1) return 0xffffffff; - return ItemNBTHelper.hasKey(stack, "flareColour") ? ItemNBTHelper.getInt(stack, "flareColour") : 0xcc2e06; + return ItemNBTHelper.hasKey(stack, "flareColour")?ItemNBTHelper.getInt(stack, "flareColour"): 0xcc2e06; } @Override @@ -511,7 +516,7 @@ public DamageSource apply(Entity[] entities) @Override public Entity getProjectile(EntityPlayer shooter, ItemStack cartridge, Entity projectile, boolean electro) { - EntityRevolvershotHoming shot = shooter!=null?new EntityRevolvershotHoming(projectile.world, shooter, projectile.motionX*1.5,projectile.motionY*1.5,projectile.motionZ*1.5, this, cartridge): new EntityRevolvershotHoming(projectile.world, projectile.posX,projectile.posY,projectile.posZ, 0,0,0, this); + EntityRevolvershotHoming shot = shooter!=null?new EntityRevolvershotHoming(projectile.world, shooter, projectile.motionX*1.5, projectile.motionY*1.5, projectile.motionZ*1.5, this, cartridge): new EntityRevolvershotHoming(projectile.world, projectile.posX, projectile.posY, projectile.posZ, 0, 0, 0, this); shot.motionX = projectile.motionX; shot.motionY = projectile.motionY; shot.motionZ = projectile.motionZ; @@ -544,19 +549,19 @@ public void onHitTarget(World world, RayTraceResult target, EntityLivingBase sho int split = 6; for(int i = 0; i < split; i++) { - float angle = i * (360f / split); + float angle = i*(360f/split); Matrix4 matrix = new Matrix4(); matrix.rotate(angle, v.x, v.y, v.z); Vec3d vecDir = new Vec3d(0, 1, 0); vecDir = matrix.apply(vecDir); - EntityWolfpackShot bullet = shooter!=null?new EntityWolfpackShot(world, shooter, vecDir.x * 1.5, vecDir.y * 1.5, vecDir.z * 1.5, this, null) : new EntityWolfpackShot(world, 0,0,0, 0,0,0, this); + EntityWolfpackShot bullet = shooter!=null?new EntityWolfpackShot(world, shooter, vecDir.x*1.5, vecDir.y*1.5, vecDir.z*1.5, this, null): new EntityWolfpackShot(world, 0, 0, 0, 0, 0, 0, this); if(target.entityHit instanceof EntityLivingBase) bullet.targetOverride = (EntityLivingBase)target.entityHit; - bullet.setPosition(target.hitVec.x + vecDir.x, target.hitVec.y + vecDir.y, target.hitVec.z + vecDir.z); - bullet.motionX = vecDir.x * .375; - bullet.motionY = vecDir.y * .375; - bullet.motionZ = vecDir.z * .375; + bullet.setPosition(target.hitVec.x+vecDir.x, target.hitVec.y+vecDir.y, target.hitVec.z+vecDir.z); + bullet.motionX = vecDir.x*.375; + bullet.motionY = vecDir.y*.375; + bullet.motionZ = vecDir.z*.375; world.spawnEntity(bullet); } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemChemthrower.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemChemthrower.java index d9c04c13c8..c8f38a56aa 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemChemthrower.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemChemthrower.java @@ -75,7 +75,8 @@ private String formatFluidStack(FluidStack fs, int capacity) { TextFormatting rarity = fs.getFluid().getRarity()==EnumRarity.COMMON?TextFormatting.GRAY: fs.getFluid().getRarity().rarityColor; return rarity+fs.getLocalizedName()+TextFormatting.GRAY+": "+fs.amount+"/"+capacity+"mB"; - } else + } + else return I18n.format(Lib.DESC_FLAVOUR+"drill.empty"); } @@ -108,7 +109,8 @@ public ActionResult onItemRightClick(World world, EntityPlayer player { if(!world.isRemote) ItemNBTHelper.setBoolean(stack, "ignite", !ItemNBTHelper.getBoolean(stack, "ignite")); - } else + } + else player.setActiveHand(hand); return new ActionResult(EnumActionResult.SUCCESS, stack); } @@ -142,15 +144,16 @@ public void onUsingTick(ItemStack stack, EntityLivingBase player, int count) EntityChemthrowerShot chem = new EntityChemthrowerShot(player.world, player, vecDir.x*0.25, vecDir.y*0.25, vecDir.z*0.25, fs); // Apply momentum from the player. - chem.motionX = player.motionX + vecDir.x*range; - chem.motionY = player.motionY + vecDir.y*range; - chem.motionZ = player.motionZ + vecDir.z*range; + chem.motionX = player.motionX+vecDir.x*range; + chem.motionY = player.motionY+vecDir.y*range; + chem.motionZ = player.motionZ+vecDir.z*range; // Apply a small amount of backforce. - if (!player.onGround) { - player.motionX -= vecDir.x * 0.0025 * range; - player.motionY -= vecDir.y * 0.0025 * range; - player.motionZ -= vecDir.z * 0.0025 * range; + if(!player.onGround) + { + player.motionX -= vecDir.x*0.0025*range; + player.motionY -= vecDir.y*0.0025*range; + player.motionZ -= vecDir.z*0.0025*range; } if(ignite) chem.setFire(10); @@ -164,9 +167,11 @@ public void onUsingTick(ItemStack stack, EntityLivingBase player, int count) else player.world.playSound(null, player.posX, player.posY, player.posZ, IESounds.spray, SoundCategory.PLAYERS, .5f, .75f); } - } else + } + else player.stopActiveHand(); - } else + } + else player.stopActiveHand(); } @@ -204,7 +209,8 @@ public void switchTank(ItemStack stack, boolean forward) ItemNBTHelper.setTagCompound(stack, FluidHandlerItemStack.FLUID_NBT_KEY, fluidTag2); ItemNBTHelper.setTagCompound(stack, FluidHandlerItemStack.FLUID_NBT_KEY+"1", fluidTag); ItemNBTHelper.setTagCompound(stack, FluidHandlerItemStack.FLUID_NBT_KEY+"2", fluidTag1); - } else + } + else { ItemNBTHelper.setTagCompound(stack, FluidHandlerItemStack.FLUID_NBT_KEY, fluidTag1); ItemNBTHelper.setTagCompound(stack, FluidHandlerItemStack.FLUID_NBT_KEY+"1", fluidTag2); @@ -231,9 +237,9 @@ public boolean shouldRenderGroup(ItemStack stack, String group) if("base".equals(group)||"grip".equals(group)||"cage".equals(group)||"tanks".equals(group)) return true; NBTTagCompound upgrades = this.getUpgrades(stack); - if("large_tank".equals(group) && upgrades.getInteger("capacity")>0) + if("large_tank".equals(group)&&upgrades.getInteger("capacity") > 0) return true; - else if("multi_tank".equals(group) && upgrades.getBoolean("multitank")) + else if("multi_tank".equals(group)&&upgrades.getBoolean("multitank")) return true; else return "tank".equals(group); @@ -257,7 +263,7 @@ public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStac @Override public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { - if (!stack.isEmpty()) + if(!stack.isEmpty()) return new IEItemStackHandler(stack) { IEItemFluidHandler fluids = new IEItemFluidHandler(stack, 2000); @@ -266,18 +272,18 @@ public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) @Override public boolean hasCapability(@Nonnull Capability capability, EnumFacing facing) { - return capability == CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY || - capability == CapabilityShader.SHADER_CAPABILITY || + return capability==CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY|| + capability==CapabilityShader.SHADER_CAPABILITY|| super.hasCapability(capability, facing); } @Override public T getCapability(@Nonnull Capability capability, EnumFacing facing) { - if (capability == CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY) - return (T) fluids; - if (capability == CapabilityShader.SHADER_CAPABILITY) - return (T) shaders; + if(capability==CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY) + return (T)fluids; + if(capability==CapabilityShader.SHADER_CAPABILITY) + return (T)shaders; return super.getCapability(capability, facing); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemCoresample.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemCoresample.java index f5b18f8de9..18398e1334 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemCoresample.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemCoresample.java @@ -41,6 +41,7 @@ public ItemCoresample() { super("coresample", 1); } + @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, @Nullable World world, List list, ITooltipFlag flag) @@ -52,22 +53,22 @@ public void addInformation(ItemStack stack, @Nullable World world, List String mineral = ItemNBTHelper.getString(stack, "mineral"); String unloc = Lib.DESC_INFO+"mineral."+mineral; String loc = I18n.format(unloc); - list.add(I18n.format(Lib.CHAT_INFO+"coresample.mineral", (unloc.equals(loc)?mineral:loc))); + list.add(I18n.format(Lib.CHAT_INFO+"coresample.mineral", (unloc.equals(loc)?mineral: loc))); } else list.add(I18n.format(Lib.CHAT_INFO+"coresample.noMineral")); int[] coords = ItemNBTHelper.getIntArray(stack, "coords"); boolean singleplayer = Minecraft.getMinecraft().isSingleplayer(); - if (world==null || world.provider.getDimension()!=0) + if(world==null||world.provider.getDimension()!=0) { World clientWorld = Minecraft.getMinecraft().world; - if (clientWorld!=null&&clientWorld.provider.getDimension()==coords[0]) + if(clientWorld!=null&&clientWorld.provider.getDimension()==coords[0]) world = clientWorld; } String s0 = (coords[1]*16)+", "+(coords[2]*16); String s1 = (coords[1]*16+16)+", "+(coords[2]*16+16); String s2; - if(world!=null && world.provider!=null) + if(world!=null&&world.provider!=null) { String name = world.provider.getDimensionType().getName(); if(name.toLowerCase(Locale.ENGLISH).startsWith("the ")) @@ -77,7 +78,7 @@ public void addInformation(ItemStack stack, @Nullable World world, List else s2 = "Dimension "+coords[0]; list.add(s2); - list.add(I18n.format(Lib.CHAT_INFO+"coresample.pos", s0,s1,"")); + list.add(I18n.format(Lib.CHAT_INFO+"coresample.pos", s0, s1, "")); if(ItemNBTHelper.hasKey(stack, "infinite")) list.add(I18n.format(Lib.CHAT_INFO+"coresample.infinite")); @@ -85,16 +86,16 @@ else if(ItemNBTHelper.hasKey(stack, "depletion")) list.add(I18n.format(Lib.CHAT_INFO+"coresample.yield", ExcavatorHandler.mineralVeinCapacity-ItemNBTHelper.getInt(stack, "depletion"))); boolean hasStamp = ItemNBTHelper.hasKey(stack, "timestamp"); - if(hasStamp && world!=null) + if(hasStamp&&world!=null) { long timestamp = ItemNBTHelper.getLong(stack, "timestamp"); long dist = world.getTotalWorldTime()-timestamp; - if(dist<0) + if(dist < 0) list.add("Somehow this sample is dated in the future...are you a time traveller?!"); else list.add(I18n.format(Lib.CHAT_INFO+"coresample.timestamp", ClientUtils.fomatTimestamp(dist, ClientUtils.TimestampFormat.DHM))); } - else if (hasStamp) + else if(hasStamp) list.add(I18n.format(Lib.CHAT_INFO+"coresample.timezone")); else list.add(I18n.format(Lib.CHAT_INFO+"coresample.noTimestamp")); @@ -113,14 +114,14 @@ public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos if(!block.isReplaceable(world, pos)) pos = pos.offset(side); - if(!stack.isEmpty() && player.canPlayerEdit(pos, side, stack) && world.mayPlace(IEContent.blockStoneDevice, pos, false, side, null)) + if(!stack.isEmpty()&&player.canPlayerEdit(pos, side, stack)&&world.mayPlace(IEContent.blockStoneDevice, pos, false, side, null)) { IBlockState toolbox = IEContent.blockStoneDevice.getStateFromMeta(BlockTypes_StoneDevices.CORESAMPLE.getMeta()); if(world.setBlockState(pos, toolbox, 3)) { - IEContent.blockStoneDevice.onIEBlockPlacedBy(world, pos, toolbox, side, hitX,hitY,hitZ, player, stack); + IEContent.blockStoneDevice.onIEBlockPlacedBy(world, pos, toolbox, side, hitX, hitY, hitZ, player, stack); SoundType soundtype = world.getBlockState(pos).getBlock().getSoundType(world.getBlockState(pos), world, pos, player); - world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); + world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume()+1.0F)/2.0F, soundtype.getPitch()*0.8F); stack.shrink(1); } return EnumActionResult.SUCCESS; diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemDrill.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemDrill.java index 179aad001f..956b60cb54 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemDrill.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemDrill.java @@ -76,61 +76,67 @@ public class ItemDrill extends ItemUpgradeableTool implements IAdvancedFluidItem, IOBJModelCallback, ITool { - public static Material[] validMaterials = {Material.ANVIL,Material.CLAY,Material.GLASS,Material.GRASS,Material.GROUND,Material.ICE,Material.IRON,Material.PACKED_ICE,Material.PISTON,Material.ROCK,Material.SAND, Material.SNOW}; + public static Material[] validMaterials = {Material.ANVIL, Material.CLAY, Material.GLASS, Material.GRASS, Material.GROUND, Material.ICE, Material.IRON, Material.PACKED_ICE, Material.PISTON, Material.ROCK, Material.SAND, Material.SNOW}; public ItemDrill() { super("drill", 1, "DRILL", "diesel"); } + @Override public int getSlotCount(ItemStack stack) { return 5; } + @Override public Slot[] getWorkbenchSlots(Container container, ItemStack stack) { IItemHandler inv = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); return new Slot[] { - new IESlot.DrillHead(inv,0, 98,22), - new IESlot.Upgrades(container, inv,1, 78,52, "DRILL", stack, true), - new IESlot.Upgrades(container, inv,2, 98,52, "DRILL", stack, true), - new IESlot.Upgrades(container, inv,3, 118,52, "DRILL", stack, true) + new IESlot.DrillHead(inv, 0, 98, 22), + new IESlot.Upgrades(container, inv, 1, 78, 52, "DRILL", stack, true), + new IESlot.Upgrades(container, inv, 2, 98, 52, "DRILL", stack, true), + new IESlot.Upgrades(container, inv, 3, 118, 52, "DRILL", stack, true) }; } + @Override public boolean canModify(ItemStack stack) { return true; } + @Override public void recalculateUpgrades(ItemStack stack) { super.recalculateUpgrades(stack); FluidStack fs = getFluid(stack); - if(fs!=null && fs.amount>this.getCapacity(stack,2000)) + if(fs!=null&&fs.amount > this.getCapacity(stack, 2000)) { - fs.amount = this.getCapacity(stack,2000); - ItemNBTHelper.setFluidStack(stack, "Fluid",fs); + fs.amount = this.getCapacity(stack, 2000); + ItemNBTHelper.setFluidStack(stack, "Fluid", fs); } } + @Override public void finishUpgradeRecalculation(ItemStack stack) { FluidStack fs = getFluid(stack); - if(fs!=null && fs.amount > getCapacity(stack,2000)) + if(fs!=null&&fs.amount > getCapacity(stack, 2000)) { - fs.amount = getCapacity(stack,2000); + fs.amount = getCapacity(stack, 2000); ItemNBTHelper.setFluidStack(stack, "Fluid", fs); } } + @Override public void addInformation(ItemStack stack, @Nullable World world, List list, ITooltipFlag flag) { FluidStack fs = getFluid(stack); if(fs!=null) - list.add(I18n.format(Lib.DESC_FLAVOUR+"drill.fuel")+" "+fs.amount+"/"+getCapacity(stack,2000)+"mB"); + list.add(I18n.format(Lib.DESC_FLAVOUR+"drill.fuel")+" "+fs.amount+"/"+getCapacity(stack, 2000)+"mB"); else list.add(I18n.format(Lib.DESC_FLAVOUR+"drill.empty")); if(getHead(stack).isEmpty()) @@ -140,8 +146,8 @@ public void addInformation(ItemStack stack, @Nullable World world, List int maxDmg = getMaxHeadDamage(stack); int dmg = maxDmg-getHeadDamage(stack); float quote = dmg/(float)maxDmg; - String status = ""+(quote<.1? TextFormatting.RED: quote<.3? TextFormatting.GOLD: quote<.6? TextFormatting.YELLOW: TextFormatting.GREEN); - list.add(I18n.format(Lib.DESC_FLAVOUR + "drill.headDamage") + " " + status + dmg + "/" + maxDmg); + String status = ""+(quote < .1?TextFormatting.RED: quote < .3?TextFormatting.GOLD: quote < .6?TextFormatting.YELLOW: TextFormatting.GREEN); + list.add(I18n.format(Lib.DESC_FLAVOUR+"drill.headDamage")+" "+status+dmg+"/"+maxDmg); } } @@ -151,7 +157,9 @@ public boolean isFull3D() { return true; } + public static HashMap animationTimer = new HashMap(); + @Override public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack) { @@ -159,7 +167,7 @@ public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack) { if(!animationTimer.containsKey(entityLiving.getName())) animationTimer.put(entityLiving.getName(), 40); - else if(animationTimer.get(entityLiving.getName())<20) + else if(animationTimer.get(entityLiving.getName()) < 20) animationTimer.put(entityLiving.getName(), 20); } return true; @@ -169,13 +177,14 @@ else if(animationTimer.get(entityLiving.getName())<20) @Override public TextureAtlasSprite getTextureReplacement(ItemStack stack, String material) { - if(material.equals("head") && !this.getHead(stack).isEmpty() && this.getHead(stack).getItem() instanceof IDrillHead) + if(material.equals("head")&&!this.getHead(stack).isEmpty()&&this.getHead(stack).getItem() instanceof IDrillHead) { TextureAtlasSprite spr = ((IDrillHead)this.getHead(stack).getItem()).getDrillTexture(stack, this.getHead(stack)); return spr; } return null; } + @SideOnly(Side.CLIENT) @Override public boolean shouldRenderGroup(ItemStack stack, String group) @@ -194,13 +203,14 @@ public boolean shouldRenderGroup(ItemStack stack, String group) if(group.equals("upgrade_damage0")) return upgrades.getInteger("damage") > 0; - if(group.equals("upgrade_damage1") || group.equals("upgrade_damage2")) + if(group.equals("upgrade_damage1")||group.equals("upgrade_damage2")) return upgrades.getInteger("damage") > 1; - if(group.equals("upgrade_damage3") || group.equals("upgrade_damage4")) + if(group.equals("upgrade_damage3")||group.equals("upgrade_damage4")) return upgrades.getInteger("damage") > 2; } return false; } + @SideOnly(Side.CLIENT) @Override public Optional applyTransformations(ItemStack stack, String group, Optional transform) @@ -208,10 +218,10 @@ public Optional applyTransformations(ItemStack stack, String if(transform.isPresent()) { NBTTagCompound upgrades = this.getUpgrades(stack); - if(group.equals("drill_head") && upgrades.getInteger("damage")<=0) + if(group.equals("drill_head")&&upgrades.getInteger("damage") <= 0) { Matrix4 mat = new Matrix4(transform.get().getMatrix()); - mat.translate(-.25f,0,0); + mat.translate(-.25f, 0, 0); return Optional.of(new TRSRTransformation(mat.toMatrix4f())); } } @@ -229,8 +239,8 @@ public Optional applyTransformations(ItemStack stack, String private boolean shouldRotate(EntityLivingBase entity, ItemStack stack, TransformType transform) { - return entity!=null && canDrillBeUsed(stack, entity) && - (entity.getHeldItem(EnumHand.MAIN_HAND)==stack||entity.getHeldItem(EnumHand.OFF_HAND)==stack) && + return entity!=null&&canDrillBeUsed(stack, entity)&& + (entity.getHeldItem(EnumHand.MAIN_HAND)==stack||entity.getHeldItem(EnumHand.OFF_HAND)==stack)&& (transform==TransformType.FIRST_PERSON_RIGHT_HAND||transform==TransformType.FIRST_PERSON_LEFT_HAND|| transform==TransformType.THIRD_PERSON_RIGHT_HAND||transform==TransformType.THIRD_PERSON_LEFT_HAND); } @@ -239,41 +249,44 @@ private boolean shouldRotate(EntityLivingBase entity, ItemStack stack, Transform @SideOnly(Side.CLIENT) public String[][] getSpecialGroups(ItemStack stack, TransformType transform, EntityLivingBase entity) { - if (shouldRotate(entity, stack, transform)) + if(shouldRotate(entity, stack, transform)) return ROTATING; else return FIXED; } - private static final Matrix4 matAugers = new Matrix4().translate(.441f,0,0); + private static final Matrix4 matAugers = new Matrix4().translate(.441f, 0, 0); + @Nonnull @Override public Matrix4 getTransformForGroups(ItemStack stack, String[] groups, TransformType transform, EntityLivingBase entity, Matrix4 mat, float partialTicks) { mat.setIdentity(); - if (groups==FIXED[0]) + if(groups==FIXED[0]) return matAugers; //.069813f - float angle = (entity.ticksExisted%60+partialTicks)/60f * (float)(2*Math.PI); + float angle = (entity.ticksExisted%60+partialTicks)/60f*(float)(2*Math.PI); if("drill_head".equals(groups[0])) - mat.rotate(angle, 1,0,0); + mat.rotate(angle, 1, 0, 0); else if("upgrade_damage1".equals(groups[0])) - mat.translate(.441f,0,0).rotate(angle, 0,1,0); - else if( "upgrade_damage3".equals(groups[0])) - mat.translate(.441f,0,0).rotate(angle, 0,0,1); + mat.translate(.441f, 0, 0).rotate(angle, 0, 1, 0); + else if("upgrade_damage3".equals(groups[0])) + mat.translate(.441f, 0, 0).rotate(angle, 0, 0, 1); return mat; } @Override public double getDurabilityForDisplay(ItemStack stack) { - return (double)getHeadDamage(stack) / (double)getMaxHeadDamage(stack); + return (double)getHeadDamage(stack)/(double)getMaxHeadDamage(stack); } + @Override public boolean showDurabilityBar(ItemStack stack) { - return getHeadDamage(stack)>0; + return getHeadDamage(stack) > 0; } + @Override public EnumAction getItemUseAction(ItemStack p_77661_1_) { @@ -284,7 +297,7 @@ public EnumAction getItemUseAction(ItemStack p_77661_1_) public void removeFromWorkbench(EntityPlayer player, ItemStack stack) { IItemHandler inv = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); - if(inv!=null&&!inv.getStackInSlot(0).isEmpty() && !inv.getStackInSlot(1).isEmpty() && !inv.getStackInSlot(2).isEmpty() && !inv.getStackInSlot(3).isEmpty()) + if(inv!=null&&!inv.getStackInSlot(0).isEmpty()&&!inv.getStackInSlot(1).isEmpty()&&!inv.getStackInSlot(2).isEmpty()&&!inv.getStackInSlot(3).isEmpty()) Utils.unlockIEAdvancement(player, "main/upgrade_drill"); } @@ -294,16 +307,17 @@ public ItemStack getHead(ItemStack drill) ItemStack head; boolean remote = FMLCommonHandler.instance().getEffectiveSide()==Side.CLIENT; IItemHandler cap = drill.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); - if (!remote&&cap.getStackInSlot(0).isEmpty()) + if(!remote&&cap.getStackInSlot(0).isEmpty()) remote = true; - else if (remote&&!ItemNBTHelper.hasKey(drill, "head")) + else if(remote&&!ItemNBTHelper.hasKey(drill, "head")) remote = false; - if (remote) + if(remote) head = new ItemStack(ItemNBTHelper.getTagCompound(drill, "head")); else head = cap.getStackInSlot(0); - return !head.isEmpty() &&head.getItem() instanceof IDrillHead?head: ItemStack.EMPTY; + return !head.isEmpty()&&head.getItem() instanceof IDrillHead?head: ItemStack.EMPTY; } + public void setHead(ItemStack drill, ItemStack head) { IItemHandler inv = drill.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); @@ -319,24 +333,26 @@ public boolean isTool(ItemStack item) public boolean canDrillBeUsed(ItemStack drill, EntityLivingBase player) { - if(drill.getItemDamage()==0 && player.isInsideOfMaterial(Material.WATER) && !getUpgrades(drill).getBoolean("waterproof")) + if(drill.getItemDamage()==0&&player.isInsideOfMaterial(Material.WATER)&&!getUpgrades(drill).getBoolean("waterproof")) return false; - return !(drill.getItemDamage() == 0 && getFluid(drill) == null); + return !(drill.getItemDamage()==0&&getFluid(drill)==null); } public int getMaxHeadDamage(ItemStack stack) { ItemStack head = getHead(stack); - return !head.isEmpty() ?((IDrillHead)head.getItem()).getMaximumHeadDamage(head): 0; + return !head.isEmpty()?((IDrillHead)head.getItem()).getMaximumHeadDamage(head): 0; } + public int getHeadDamage(ItemStack stack) { ItemStack head = getHead(stack); - return !head.isEmpty() ?((IDrillHead)head.getItem()).getHeadDamage(head): 0; + return !head.isEmpty()?((IDrillHead)head.getItem()).getHeadDamage(head): 0; } + public boolean isDrillBroken(ItemStack stack) { - return getHeadDamage(stack)>=getMaxHeadDamage(stack) || getFluid(stack)==null || getFluid(stack).amount<1; + return getHeadDamage(stack) >= getMaxHeadDamage(stack)||getFluid(stack)==null||getFluid(stack).amount < 1; } // @Override @@ -352,12 +368,13 @@ public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingB { return true; } + @Override public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState state, BlockPos pos, EntityLivingBase living) { - if((double)state.getBlockHardness(world, pos) != 0.0D) + if((double)state.getBlockHardness(world, pos)!=0.0D) { - int dmg = ForgeHooks.isToolEffective(world, pos, stack)?1:3; + int dmg = ForgeHooks.isToolEffective(world, pos, stack)?1: 3; ItemStack head = getHead(stack); if(!head.isEmpty()) { @@ -367,7 +384,7 @@ public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState state, return true; ((IDrillHead)head.getItem()).afterBlockbreak(stack, head, (EntityPlayer)living); } - if(!getUpgrades(stack).getBoolean("oiled") || Utils.RAND.nextInt(4)==0) + if(!getUpgrades(stack).getBoolean("oiled")||Utils.RAND.nextInt(4)==0) ((IDrillHead)head.getItem()).damageHead(head, dmg); this.setHead(stack, head); IFluidHandler handler = FluidUtil.getFluidHandler(stack); @@ -377,21 +394,23 @@ public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState state, return true; } + @Override public int getItemEnchantability() { return 0; } + @Override public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) { Multimap multimap = super.getAttributeModifiers(slot, stack); - if(slot == EntityEquipmentSlot.MAINHAND) + if(slot==EntityEquipmentSlot.MAINHAND) { ItemStack head = getHead(stack); if(!head.isEmpty()) { - multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Tool modifier", ((IDrillHead) head.getItem()).getAttackDamage(head) + getUpgrades(stack).getInteger("damage"), 0)); + multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Tool modifier", ((IDrillHead)head.getItem()).getAttackDamage(head)+getUpgrades(stack).getInteger("damage"), 0)); multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", -2.5D, 0)); } } @@ -406,10 +425,11 @@ public int getHarvestLevel(ItemStack stack, String toolClass, @Nullable EntityPl return ((IDrillHead)head.getItem()).getMiningLevel(head)+ItemNBTHelper.getInt(stack, "harvestLevel"); return 0; } + @Override public Set getToolClasses(ItemStack stack) { - if(!getHead(stack).isEmpty() && !isDrillBroken(stack)) + if(!getHead(stack).isEmpty()&&!isDrillBroken(stack)) return ImmutableSet.of("pickaxe", "shovel"); return super.getToolClasses(stack); } @@ -417,26 +437,29 @@ public Set getToolClasses(ItemStack stack) public boolean isEffective(Material mat) { for(Material m : validMaterials) - if(m == mat) + if(m==mat) return true; return false; } + @Override public boolean canHarvestBlock(IBlockState state, ItemStack stack) { - return isEffective(state.getMaterial()) && !isDrillBroken(stack); + return isEffective(state.getMaterial())&&!isDrillBroken(stack); } + @Override public float getDestroySpeed(ItemStack stack, IBlockState state) { ItemStack head = getHead(stack); - if(!head.isEmpty() && !isDrillBroken(stack)) + if(!head.isEmpty()&&!isDrillBroken(stack)) return ((IDrillHead)head.getItem()).getMiningSpeed(head)+getUpgrades(stack).getFloat("speed"); return super.getDestroySpeed(stack, state); } + public boolean canBreakExtraBlock(World world, Block block, BlockPos pos, IBlockState state, EntityPlayer player, ItemStack drill, ItemStack head, boolean inWorld) { - if(block.canHarvestBlock(world, pos, player) && isEffective(state.getMaterial()) && !isDrillBroken(drill)) + if(block.canHarvestBlock(world, pos, player)&&isEffective(state.getMaterial())&&!isDrillBroken(drill)) { if(inWorld) return !((IDrillHead)head.getItem()).beforeBlockbreak(drill, head, player); @@ -445,15 +468,16 @@ public boolean canBreakExtraBlock(World world, Block block, BlockPos pos, IBlock } return false; } + @Override public boolean onBlockStartBreak(ItemStack stack, BlockPos iPos, EntityPlayer player) { World world = player.world; - if(player.isSneaking() || world.isRemote || !(player instanceof EntityPlayerMP)) + if(player.isSneaking()||world.isRemote||!(player instanceof EntityPlayerMP)) return false; RayTraceResult mop = this.rayTrace(world, player, true); ItemStack head = getHead(stack); - if(mop==null || head.isEmpty() || this.isDrillBroken(stack)) + if(mop==null||head.isEmpty()||this.isDrillBroken(stack)) return false; // EnumFacing side = mop.sideHit; // int diameter = ((IDrillHead)head.getItem()).getMiningSize(head)+getUpgrades(stack).getInteger("size"); @@ -492,18 +516,18 @@ public boolean onBlockStartBreak(ItemStack stack, BlockPos iPos, EntityPlayer pl IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); - if(block!=null && !block.isAir(state, world, pos) && state.getPlayerRelativeBlockHardness(player, world, pos) != 0) + if(block!=null&&!block.isAir(state, world, pos)&&state.getPlayerRelativeBlockHardness(player, world, pos)!=0) { if(!this.canBreakExtraBlock(world, block, pos, state, player, stack, head, true)) continue; - int xpDropEvent = ForgeHooks.onBlockBreakEvent(world, ((EntityPlayerMP)player).interactionManager.getGameType(), (EntityPlayerMP) player, pos); - if(xpDropEvent<0) + int xpDropEvent = ForgeHooks.onBlockBreakEvent(world, ((EntityPlayerMP)player).interactionManager.getGameType(), (EntityPlayerMP)player, pos); + if(xpDropEvent < 0) continue; if(player.capabilities.isCreativeMode) { block.onBlockHarvested(world, pos, state, player); - if (block.removedByPlayer(state, world, pos, player, false)) + if(block.removedByPlayer(state, world, pos, player, false)) block.onBlockDestroyedByPlayer(world, pos, state); } else @@ -514,7 +538,7 @@ public boolean onBlockStartBreak(ItemStack stack, BlockPos iPos, EntityPlayer pl stack.onBlockDestroyed(world, state, pos, player); if(block.removedByPlayer(state, world, pos, player, true)) { - block.onBlockDestroyedByPlayer( world, pos, state); + block.onBlockDestroyedByPlayer(world, pos, state); block.harvestBlock(world, player, pos, state, te, stack); block.dropXpOnBlockBreak(world, pos, xpDropEvent); } @@ -531,20 +555,20 @@ public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStac { if(slotChanged) return true; - if(oldStack.hasCapability(CapabilityShader.SHADER_CAPABILITY,null) && newStack.hasCapability(CapabilityShader.SHADER_CAPABILITY,null)) + if(oldStack.hasCapability(CapabilityShader.SHADER_CAPABILITY, null)&&newStack.hasCapability(CapabilityShader.SHADER_CAPABILITY, null)) { - ShaderWrapper wrapperOld = oldStack.getCapability(CapabilityShader.SHADER_CAPABILITY,null); - ShaderWrapper wrapperNew = newStack.getCapability(CapabilityShader.SHADER_CAPABILITY,null); + ShaderWrapper wrapperOld = oldStack.getCapability(CapabilityShader.SHADER_CAPABILITY, null); + ShaderWrapper wrapperNew = newStack.getCapability(CapabilityShader.SHADER_CAPABILITY, null); if(!ItemStack.areItemStacksEqual(wrapperOld.getShaderItem(), wrapperNew.getShaderItem())) return true; } - return super.shouldCauseReequipAnimation(oldStack,newStack,slotChanged); + return super.shouldCauseReequipAnimation(oldStack, newStack, slotChanged); } @Override public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { - if (!stack.isEmpty()) + if(!stack.isEmpty()) return new IEItemStackHandler(stack) { IEItemFluidHandler fluids = new IEItemFluidHandler(stack, 2000); @@ -553,32 +577,34 @@ public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) @Override public boolean hasCapability(Capability capability, EnumFacing facing) { - return capability == CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY || - capability == CapabilityShader.SHADER_CAPABILITY || + return capability==CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY|| + capability==CapabilityShader.SHADER_CAPABILITY|| super.hasCapability(capability, facing); } @Override public T getCapability(Capability capability, EnumFacing facing) { - if (capability == CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY) - return (T) fluids; - if (capability == CapabilityShader.SHADER_CAPABILITY) - return (T) shaders; + if(capability==CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY) + return (T)fluids; + if(capability==CapabilityShader.SHADER_CAPABILITY) + return (T)shaders; return super.getCapability(capability, facing); } }; return null; } + @Override public int getCapacity(ItemStack container, int baseCapacity) { return baseCapacity+getUpgrades(container).getInteger("capacity"); } + @Override public boolean allowFluid(ItemStack container, FluidStack fluid) { - return fluid!=null && DieselHandler.isValidDrillFuel(fluid.getFluid()); + return fluid!=null&&DieselHandler.isValidDrillFuel(fluid.getFluid()); } @Nullable @@ -586,7 +612,7 @@ public boolean allowFluid(ItemStack container, FluidStack fluid) public NBTTagCompound getNBTShareTag(ItemStack stack) { NBTTagCompound ret = super.getNBTShareTag(stack); - if (ret==null) + if(ret==null) ret = new NBTTagCompound(); else ret = ret.copy(); diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemDrillhead.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemDrillhead.java index a01aa0e023..f69019241c 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemDrillhead.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemDrillhead.java @@ -41,51 +41,54 @@ public class ItemDrillhead extends ItemIEBase implements IDrillHead { public ItemDrillhead() { - super("drillhead", 1, "steel","iron"); + super("drillhead", 1, "steel", "iron"); perms = new DrillHeadPerm[this.subNames.length]; //Maximal damage is slightly proportionate to pickaxes - addPerm(0, new DrillHeadPerm("ingotSteel",3,1,3,10,7,10000,"immersiveengineering:items/drill_diesel")); - addPerm(1, new DrillHeadPerm("ingotIron",2,1,2,9,6,6000,"immersiveengineering:items/drill_iron")); + addPerm(0, new DrillHeadPerm("ingotSteel", 3, 1, 3, 10, 7, 10000, "immersiveengineering:items/drill_diesel")); + addPerm(1, new DrillHeadPerm("ingotIron", 2, 1, 2, 9, 6, 6000, "immersiveengineering:items/drill_iron")); } public DrillHeadPerm[] perms; + private void addPerm(int i, DrillHeadPerm perm) { - if(i=0 && stack.getItemDamage()= 0&&stack.getItemDamage() < perms.length) return perms[stack.getItemDamage()]; - return new DrillHeadPerm("",0,0,0,0,0,0,"immersiveengineering:items/drill_diesel"); + return new DrillHeadPerm("", 0, 0, 0, 0, 0, 0, "immersiveengineering:items/drill_diesel"); } @Override public void addInformation(ItemStack stack, @Nullable World world, List list, ITooltipFlag flag) { - if(stack.getItemDamage() list) { if(this.isInCreativeTab(tab)) - for(int i=0;i0; + return ItemNBTHelper.getInt(stack, "headDamage") > 0; } public static class DrillHeadPerm @@ -177,14 +182,14 @@ public static class DrillHeadPerm public DrillHeadPerm(String repairMaterial, int drillSize, int drillDepth, int drillLevel, float drillSpeed, int drillAttack, int maxDamage, String texture) { - this.repairMaterial=repairMaterial; - this.drillSize=drillSize; - this.drillDepth=drillDepth; - this.drillLevel=drillLevel; - this.drillSpeed=drillSpeed; - this.drillAttack=drillAttack; - this.maxDamage=maxDamage; - this.texture=texture; + this.repairMaterial = repairMaterial; + this.drillSize = drillSize; + this.drillDepth = drillDepth; + this.drillLevel = drillLevel; + this.drillSpeed = drillSpeed; + this.drillAttack = drillAttack; + this.maxDamage = maxDamage; + this.texture = texture; } } @@ -195,13 +200,13 @@ public ImmutableList getExtraBlocksDug(ItemStack head, World world, En int diameter = getHeadPerm(head).drillSize; int depth = getHeadPerm(head).drillDepth; - BlockPos startPos=mop.getBlockPos(); + BlockPos startPos = mop.getBlockPos(); IBlockState state = world.getBlockState(startPos); Block block = state.getBlock(); float maxHardness = 1; - if(block!=null&&!block.isAir(state,world,startPos)) + if(block!=null&&!block.isAir(state, world, startPos)) maxHardness = state.getPlayerRelativeBlockHardness(player, world, startPos)*0.6F; - if(maxHardness<0) + if(maxHardness < 0) maxHardness = 0; if(diameter%2==0)//even numbers @@ -209,21 +214,21 @@ public ImmutableList getExtraBlocksDug(ItemStack head, World world, En float hx = (float)mop.hitVec.x-mop.getBlockPos().getX(); float hy = (float)mop.hitVec.y-mop.getBlockPos().getY(); float hz = (float)mop.hitVec.z-mop.getBlockPos().getZ(); - if((side.getAxis()==Axis.Y&&hx<.5)||(side.getAxis()==Axis.Z&&hx<.5)) - startPos = startPos.add(-diameter/2,0,0); - if(side.getAxis()!=Axis.Y&&hy<.5) - startPos = startPos.add(0,-diameter/2,0); - if((side.getAxis()==Axis.Y&&hz<.5)||(side.getAxis()==Axis.X&&hz<.5)) - startPos = startPos.add(0,0,-diameter/2); + if((side.getAxis()==Axis.Y&&hx < .5)||(side.getAxis()==Axis.Z&&hx < .5)) + startPos = startPos.add(-diameter/2, 0, 0); + if(side.getAxis()!=Axis.Y&&hy < .5) + startPos = startPos.add(0, -diameter/2, 0); + if((side.getAxis()==Axis.Y&&hz < .5)||(side.getAxis()==Axis.X&&hz < .5)) + startPos = startPos.add(0, 0, -diameter/2); } else//odd numbers { startPos = startPos.add(-(side.getAxis()==Axis.X?0: diameter/2), -(side.getAxis()==Axis.Y?0: diameter/2), -(side.getAxis()==Axis.Z?0: diameter/2)); } Builder b = ImmutableList.builder(); - for(int dd=0; dd getExtraBlocksDug(ItemStack head, World world, En float h = state.getPlayerRelativeBlockHardness(player, world, pos); boolean canHarvest = block.canHarvestBlock(world, pos, player); boolean drillMat = ((ItemDrill)IEContent.itemDrill).isEffective(state.getMaterial()); - boolean hardness = h>maxHardness; - if(canHarvest && drillMat && hardness) + boolean hardness = h > maxHardness; + if(canHarvest&&drillMat&&hardness) b.add(pos); } return b.build(); diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemEarmuffs.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemEarmuffs.java index 7be4df0e1a..a5919e9f41 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemEarmuffs.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemEarmuffs.java @@ -65,6 +65,7 @@ public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlo @SideOnly(Side.CLIENT) ModelBiped armorModel; + @Override @SideOnly(Side.CLIENT) public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, ModelBiped _default) @@ -78,6 +79,7 @@ public boolean hasCustomItemColours() { return true; } + @Override public int getColourForIEItem(ItemStack stack, int renderPass) { @@ -87,11 +89,13 @@ public int getColourForIEItem(ItemStack stack, int renderPass) return 0x486c94; return ItemNBTHelper.getInt(stack, Lib.NBT_EarmuffColour); } + @Override public boolean hasColor(ItemStack stack) { return true; } + @Override public int getColor(ItemStack stack) { @@ -99,17 +103,19 @@ public int getColor(ItemStack stack) return 0x486c94; return ItemNBTHelper.getInt(stack, Lib.NBT_EarmuffColour); } + @Override - public void removeColor(ItemStack stack) - { + public void removeColor(ItemStack stack) + { if(ItemNBTHelper.hasKey(stack, Lib.NBT_EarmuffColour)) ItemNBTHelper.remove(stack, Lib.NBT_EarmuffColour); - } + } + @Override - public void setColor(ItemStack stack, int color) - { + public void setColor(ItemStack stack, int color) + { ItemNBTHelper.setInt(stack, Lib.NBT_EarmuffColour, color); - } + } @Override public void addInformation(ItemStack stack, @Nullable World world, List list, ITooltipFlag flag) @@ -117,6 +123,7 @@ public void addInformation(ItemStack stack, @Nullable World world, List String hexCol = Integer.toHexString(this.getColourForIEItem(stack, 0)); list.add(I18n.format(Lib.DESC_INFO+"colour", "")); } + @Override @SideOnly(Side.CLIENT) public FontRenderer getFontRenderer(ItemStack stack) @@ -146,20 +153,24 @@ public Multimap getItemAttributeModifiers(EntityEquip @Override public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { - return new ArmorProperties(0,0,0); + return new ArmorProperties(0, 0, 0); } + @Override public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { return 0; } + @Override public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { } public static LinkedHashSet affectedSoundCategories = Sets.newLinkedHashSet(); - static{ + + static + { affectedSoundCategories.add("ambient"); affectedSoundCategories.add("weather"); affectedSoundCategories.add("record"); @@ -168,6 +179,7 @@ public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource s affectedSoundCategories.add("hostile"); affectedSoundCategories.add("player"); } + public static float getVolumeMod(ItemStack stack) { if(!ItemNBTHelper.hasKey(stack, "IE:Earmuffs:Volume")) @@ -180,20 +192,23 @@ public boolean canConfigure(ItemStack stack) { return true; } + @Override public ToolConfigBoolean[] getBooleanOptions(ItemStack stack) { ToolConfigBoolean[] array = new ToolConfigBoolean[affectedSoundCategories.size()]; - int i=-1; + int i = -1; for(String cat : affectedSoundCategories) - array[++i] = new ToolConfigBoolean(cat,60+i/4*55,32+10*(i%4),!ItemNBTHelper.getBoolean(stack,"IE:Earmuffs:Cat_"+cat)); + array[++i] = new ToolConfigBoolean(cat, 60+i/4*55, 32+10*(i%4), !ItemNBTHelper.getBoolean(stack, "IE:Earmuffs:Cat_"+cat)); return array; } + @Override public ToolConfigFloat[] getFloatOptions(ItemStack stack) { - return new ToolConfigFloat[]{new ToolConfigFloat("reductionValue", 60,20, 1-getVolumeMod(stack))}; + return new ToolConfigFloat[]{new ToolConfigFloat("reductionValue", 60, 20, 1-getVolumeMod(stack))}; } + @Override public String fomatConfigName(ItemStack stack, ToolConfig config) { @@ -201,18 +216,20 @@ public String fomatConfigName(ItemStack stack, ToolConfig config) return I18n.format(Lib.GUI_CONFIG+"earmuffs.noisegate"); return I18n.format(Lib.GUI_CONFIG+"earmuffs.soundcategory."+config.name); } + @Override public String fomatConfigDescription(ItemStack stack, ToolConfig config) { return null; } + @Override public void applyConfigOption(ItemStack stack, String key, Object value) { if(value instanceof Boolean) - ItemNBTHelper.setBoolean(stack,"IE:Earmuffs:Cat_"+key, !(Boolean)value); + ItemNBTHelper.setBoolean(stack, "IE:Earmuffs:Cat_"+key, !(Boolean)value); else if(value instanceof Float) - ItemNBTHelper.setFloat(stack,"IE:Earmuffs:Volume", 1-(Float)value); + ItemNBTHelper.setFloat(stack, "IE:Earmuffs:Volume", 1-(Float)value); } @Override diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemEngineersBlueprint.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemEngineersBlueprint.java index 29897439db..d26edf70fc 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemEngineersBlueprint.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemEngineersBlueprint.java @@ -49,21 +49,22 @@ public String getUnlocalizedName(ItemStack stack) @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, @Nullable World world, List list, ITooltipFlag flag) { - String key = ItemNBTHelper.getString(stack,"blueprint"); - if(key != null && !key.isEmpty() && BlueprintCraftingRecipe.blueprintCategories.contains(key)) + String key = ItemNBTHelper.getString(stack, "blueprint"); + if(key!=null&&!key.isEmpty()&&BlueprintCraftingRecipe.blueprintCategories.contains(key)) { - String formatKey = Lib.DESC_INFO + "blueprint." + key; + String formatKey = Lib.DESC_INFO+"blueprint."+key; String formatted = I18n.format(formatKey); - list.add(formatKey.equals(formatted)?key:formatted); - if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) + list.add(formatKey.equals(formatted)?key: formatted); + if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)||Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { - list.add(I18n.format(Lib.DESC_INFO + "blueprint.creates1")); + list.add(I18n.format(Lib.DESC_INFO+"blueprint.creates1")); BlueprintCraftingRecipe[] recipes = BlueprintCraftingRecipe.findRecipes(key); if(recipes.length > 0) for(int i = 0; i < recipes.length; i++) - list.add(" " + recipes[i].output.getDisplayName()); - } else - list.add(I18n.format(Lib.DESC_INFO + "blueprint.creates0")); + list.add(" "+recipes[i].output.getDisplayName()); + } + else + list.add(I18n.format(Lib.DESC_INFO+"blueprint.creates0")); } } @@ -86,6 +87,7 @@ public boolean canModify(ItemStack stack) { return true; } + @Override public Slot[] getWorkbenchSlots(Container container, ItemStack stack) { @@ -99,29 +101,29 @@ public Slot[] getWorkbenchSlots(Container container, ItemStack stack) slots.add(new IESlot.BlueprintInput(container, inv, 4, 74, 57, stack)); slots.add(new IESlot.BlueprintInput(container, inv, 5, 92, 57, stack)); - BlueprintCraftingRecipe[] recipes = BlueprintCraftingRecipe.findRecipes(ItemNBTHelper.getString(stack,"blueprint")); - for(int i=0; i query = NonNullList.withSize(6, ItemStack.EMPTY); - for(int i=0; i0) - handler.setStackInSlot(i, Utils.copyStackWithAmount(recipes[i-6].output, Math.min(recipes[i-6].output.getCount() * craftable, 64 - (64 % recipes[i-6].output.getCount())))); + if(craftable > 0) + handler.setStackInSlot(i, Utils.copyStackWithAmount(recipes[i-6].output, Math.min(recipes[i-6].output.getCount()*craftable, 64-(64%recipes[i-6].output.getCount())))); } } @@ -129,24 +131,24 @@ public void reduceInputs(BlueprintCraftingRecipe recipe, ItemStack stack, ItemSt { IItemHandlerModifiable handler = (IItemHandlerModifiable)stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); NonNullList query = NonNullList.withSize(6, ItemStack.EMPTY); - for(int i=0; i<6; i++) + for(int i = 0; i < 6; i++) query.set(i, handler.getStackInSlot(i)); recipe.consumeInputs(query, crafted.getCount()/recipe.output.getCount()); - for(int i=0; i<6; i++) + for(int i = 0; i < 6; i++) handler.setStackInSlot(i, query.get(i)); } @Override public int getSlotCount(ItemStack stack) { - return 6 + BlueprintCraftingRecipe.findRecipes(ItemNBTHelper.getString(stack, "blueprint")).length; + return 6+BlueprintCraftingRecipe.findRecipes(ItemNBTHelper.getString(stack, "blueprint")).length; } @Override public boolean canTakeFromWorkbench(ItemStack stack) { IItemHandler handler = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); - for(int i=0; i<6; i++) + for(int i = 0; i < 6; i++) if(!handler.getStackInSlot(i).isEmpty()) return false; return true; diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemFaradaySuit.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemFaradaySuit.java index b2898d9489..8176a40992 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemFaradaySuit.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemFaradaySuit.java @@ -28,6 +28,7 @@ public class ItemFaradaySuit extends ItemArmor implements IElectricEquipment { public static ArmorMaterial mat; + public ItemFaradaySuit(EntityEquipmentSlot type) { super(mat, 0, type); @@ -38,7 +39,7 @@ public ItemFaradaySuit(EntityEquipmentSlot type) // ImmersiveEngineering.registerItem(this, name); IEContent.registeredIEItems.add(this); } - + @Override public void onStrike(ItemStack s, EntityEquipmentSlot eqSlot, EntityLivingBase p, Map cache, @Nullable DamageSource dSource, ElectricSource eSource) @@ -46,9 +47,9 @@ public void onStrike(ItemStack s, EntityEquipmentSlot eqSlot, EntityLivingBase p if(!(dSource instanceof ElectricDamageSource)) return; ElectricDamageSource dmg = (ElectricDamageSource)dSource; - if(dmg.source.level<1.75) + if(dmg.source.level < 1.75) { - if (cache.containsKey("faraday")) + if(cache.containsKey("faraday")) cache.put("faraday", (1<0) + if(stack.getCount() > 0) player.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, stack); else player.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.EMPTY); @@ -76,15 +77,17 @@ public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos } return super.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ); } + public static float[] getRGB(ItemStack s) { - if (ItemNBTHelper.hasKey(s, "rgb")) + if(ItemNBTHelper.hasKey(s, "rgb")) { NBTTagCompound nbt = ItemNBTHelper.getTagCompound(s, "rgb"); return new float[]{nbt.getFloat("r"), nbt.getFloat("g"), nbt.getFloat("b")}; } return new float[]{1, 1, 1}; } + public static void setRGB(ItemStack s, float[] rgb) { NBTTagCompound nbt = new NBTTagCompound(); @@ -93,16 +96,19 @@ public static void setRGB(ItemStack s, float[] rgb) nbt.setFloat("b", rgb[2]); ItemNBTHelper.setTagCompound(s, "rgb", nbt); } + @Override public boolean canConfigure(ItemStack stack) { return true; } + @Override public ToolConfigBoolean[] getBooleanOptions(ItemStack stack) { return new ToolConfigBoolean[0]; } + @Override public ToolConfigFloat[] getFloatOptions(ItemStack stack) { @@ -113,24 +119,28 @@ public ToolConfigFloat[] getFloatOptions(ItemStack stack) ret[2] = new ToolConfigFloat("blue", 60, 60, rgb[2]); return ret; } + @Override public void applyConfigOption(ItemStack stack, String key, Object value) { - int id = key.equals("red")?0:(key.equals("green")?1:2); + int id = key.equals("red")?0: (key.equals("green")?1: 2); float[] rgb = getRGB(stack); - rgb[id] = (float) value; + rgb[id] = (float)value; setRGB(stack, rgb); } + @Override public String fomatConfigName(ItemStack stack, ToolConfig config) { return config.name; } + @Override public String fomatConfigDescription(ItemStack stack, ToolConfig config) { return config.name; } + @SideOnly(Side.CLIENT) @Override public void addInformation(ItemStack stack, @Nullable World world, List list, ITooltipFlag flag) @@ -144,11 +154,13 @@ public FontRenderer getFontRenderer(ItemStack stack) { return ClientProxy.itemFont; } + @Override public boolean hasCustomItemColours() { return true; } + @Override public int getColourForIEItem(ItemStack stack, int pass) { @@ -156,15 +168,17 @@ public int getColourForIEItem(ItemStack stack, int pass) return getRGBInt(stack, 1); return super.getColourForIEItem(stack, pass); } + public static int getRGBInt(ItemStack stack, float factor) { float[] fRGB = getRGB(stack); return (((int)(fRGB[0]*255*factor)<<16)+((int)(fRGB[1]*255*factor)<<8)+(int)(fRGB[2]*255*factor)); } + public static String hexColorString(ItemStack stack) { String hexCol = Integer.toHexString(getRGBInt(stack, 1)); - while (hexCol.length()<6) + while(hexCol.length() < 6) hexCol = "0"+hexCol; return hexCol; } @@ -194,11 +208,11 @@ public void onStrike(ItemStack s, EntityEquipmentSlot eqSlot, EntityLivingBase p public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected); - if (!worldIn.isRemote&&isLit(stack)) + if(!worldIn.isRemote&&isLit(stack)) { int litTicksRemaining = ItemNBTHelper.getInt(stack, LIT_TIME); litTicksRemaining--; - if (litTicksRemaining <= 0) + if(litTicksRemaining <= 0) { ItemNBTHelper.remove(stack, LIT_TIME); ItemNBTHelper.remove(stack, LIT_STRENGTH); @@ -215,10 +229,11 @@ public boolean shouldCauseReequipAnimation(ItemStack oldStack, @Nonnull ItemStac } private static final String[][] special = {{"tube"}}; + @Override public String[][] getSpecialGroups(ItemStack stack, ItemCameraTransforms.TransformType transform, EntityLivingBase entity) { - if (isLit(stack)) + if(isLit(stack)) return special; return IOBJModelCallback.EMPTY_STRING_A; } @@ -232,12 +247,12 @@ public boolean areGroupsFullbright(ItemStack stack, String[] groups) @Override public int getRenderColour(ItemStack object, String group) { - if ("tube".equals(group)) + if("tube".equals(group)) { boolean lit = isLit(object); - float min = .3F+(lit?ItemNBTHelper.getFloat(object, LIT_STRENGTH)*.68F:0); - float mult = min+(lit? Utils.RAND.nextFloat()*MathHelper.clamp(1-min, 0, .1F):0); - return getRGBInt(object, mult) | 0xff000000; + float min = .3F+(lit?ItemNBTHelper.getFloat(object, LIT_STRENGTH)*.68F: 0); + float mult = min+(lit?Utils.RAND.nextFloat()*MathHelper.clamp(1-min, 0, .1F): 0); + return getRGBInt(object, mult)|0xff000000; } else return 0xff111111; diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemGraphiteElectrode.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemGraphiteElectrode.java index 457dc98689..4178896c30 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemGraphiteElectrode.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemGraphiteElectrode.java @@ -24,19 +24,22 @@ public class ItemGraphiteElectrode extends ItemIEBase { public static int electrodeMaxDamage; + public ItemGraphiteElectrode() { super("graphite_electrode", 16); electrodeMaxDamage = IEConfig.Machines.arcfurnace_electrodeDamage; } + @Override public void addInformation(ItemStack stack, @Nullable World world, List list, ITooltipFlag flag) { float integrity = 100-(float)getDurabilityForDisplay(stack)*100f; - list.add( String.format("%s %.2f %%", I18n.format(Lib.DESC_INFO+"electrodeIntegrity"),integrity) ); + list.add(String.format("%s %.2f %%", I18n.format(Lib.DESC_INFO+"electrodeIntegrity"), integrity)); if(super.getDamage(stack)!=0) list.add("This item is deprecated. Hold it in your inventory to update it."); } + @Override public void onUpdate(ItemStack stack, World world, Entity ent, int slot, boolean hand) { @@ -48,31 +51,37 @@ public void onUpdate(ItemStack stack, World world, Entity ent, int slot, boolean ((EntityPlayer)ent).inventory.setInventorySlotContents(slot, fixed); } } + @Override public boolean isEnchantable(ItemStack stack) { return false; } + @Override public double getDurabilityForDisplay(ItemStack stack) { - return ItemNBTHelper.getInt(stack, "graphDmg") / (double)electrodeMaxDamage; + return ItemNBTHelper.getInt(stack, "graphDmg")/(double)electrodeMaxDamage; } + @Override public int getMaxDamage(ItemStack stack) { return electrodeMaxDamage; } + @Override public boolean isDamaged(ItemStack stack) { return ItemNBTHelper.getInt(stack, "graphDmg") > 0; } + @Override public int getDamage(ItemStack stack) { return ItemNBTHelper.getInt(stack, "graphDmg"); } + @Override public void setDamage(ItemStack stack, int damage) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemIEBase.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemIEBase.java index cb61bdb0a7..ebaf3a7fc2 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemIEBase.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemIEBase.java @@ -23,19 +23,19 @@ public class ItemIEBase extends Item implements IColouredItem public String itemName; protected String[] subNames; boolean[] isMetaHidden; - public boolean registerSubModels=true; + public boolean registerSubModels = true; private int[] burnTime; public ItemIEBase(String name, int stackSize, String... subNames) { this.setUnlocalizedName(ImmersiveEngineering.MODID+"."+name); - this.setHasSubtypes(subNames!=null&&subNames.length>0); + this.setHasSubtypes(subNames!=null&&subNames.length > 0); this.setCreativeTab(ImmersiveEngineering.creativeTab); this.setMaxStackSize(stackSize); this.itemName = name; - this.subNames = subNames!=null&&subNames.length>0?subNames:null; - this.isMetaHidden = new boolean[this.subNames!=null?this.subNames.length:1]; - this.burnTime = new int[this.subNames!=null?this.subNames.length:1]; + this.subNames = subNames!=null&&subNames.length > 0?subNames: null; + this.isMetaHidden = new boolean[this.subNames!=null?this.subNames.length: 1]; + this.burnTime = new int[this.subNames!=null?this.subNames.length: 1]; // ImmersiveEngineering.registerItem(this, name); IEContent.registeredIEItems.add(this); } @@ -44,6 +44,7 @@ public String[] getSubNames() { return subNames; } + @Override @SideOnly(Side.CLIENT) public void getSubItems(CreativeTabs tab, NonNullList list) @@ -51,20 +52,21 @@ public void getSubItems(CreativeTabs tab, NonNullList list) if(this.isInCreativeTab(tab)) if(getSubNames()!=null) { - for(int i=0;i=0 && i= 0&&i < this.isMetaHidden.length) this.isMetaHidden[i] = true; return this; } + public ItemIEBase setMetaUnhidden(int... meta) { for(int i : meta) - if(i>=0 && i= 0&&i < this.isMetaHidden.length) this.isMetaHidden[i] = false; return this; } + public boolean isMetaHidden(int meta) { return this.isMetaHidden[Math.max(0, Math.min(meta, this.isMetaHidden.length-1))]; @@ -97,10 +101,11 @@ public ItemIEBase setRegisterSubModels(boolean register) public ItemIEBase setBurnTime(int meta, int burnTime) { - if(meta>=0 && meta= 0&&meta < this.burnTime.length) this.burnTime[meta] = burnTime; return this; } + @Override public int getItemBurnTime(ItemStack itemStack) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemIESeed.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemIESeed.java index 0f6b8ea7fc..82ee442f41 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemIESeed.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemIESeed.java @@ -23,7 +23,8 @@ public class ItemIESeed extends ItemIEBase implements IPlantable { - private Block cropBlock; + private Block cropBlock; + public ItemIESeed(Block cropBlock, String... subNames) { super("seed", 64, subNames); @@ -34,14 +35,14 @@ public ItemIESeed(Block cropBlock, String... subNames) 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(side != EnumFacing.UP) + if(side!=EnumFacing.UP) return EnumActionResult.PASS; - else if (player.canPlayerEdit(pos, side, stack) && player.canPlayerEdit(pos.add(0,1,0), side, stack)) + else if(player.canPlayerEdit(pos, side, stack)&&player.canPlayerEdit(pos.add(0, 1, 0), side, stack)) { IBlockState state = world.getBlockState(pos); - if(state.getBlock().canSustainPlant(state, world, pos, EnumFacing.UP, this) && world.isAirBlock(pos.add(0,1,0))) + if(state.getBlock().canSustainPlant(state, world, pos, EnumFacing.UP, this)&&world.isAirBlock(pos.add(0, 1, 0))) { - world.setBlockState(pos.add(0,1,0), this.cropBlock.getDefaultState()); + world.setBlockState(pos.add(0, 1, 0), this.cropBlock.getDefaultState()); stack.shrink(1); return EnumActionResult.SUCCESS; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemIEShield.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemIEShield.java index a7b5d5a96d..7012bea5e6 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemIEShield.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemIEShield.java @@ -62,7 +62,7 @@ public ItemIEShield() @Override public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { - if (!stack.isEmpty()) + if(!stack.isEmpty()) return new IEItemStackHandler(stack) { final EnergyHelper.ItemEnergyStorage energyStorage = new EnergyHelper.ItemEnergyStorage(stack); @@ -71,18 +71,18 @@ public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) @Override public boolean hasCapability(@Nonnull Capability capability, EnumFacing facing) { - return capability == CapabilityEnergy.ENERGY || - capability == CapabilityShader.SHADER_CAPABILITY || + return capability==CapabilityEnergy.ENERGY|| + capability==CapabilityShader.SHADER_CAPABILITY|| super.hasCapability(capability, facing); } @Override public T getCapability(@Nonnull Capability capability, EnumFacing facing) { - if (capability == CapabilityEnergy.ENERGY) - return (T) energyStorage; - if (capability == CapabilityShader.SHADER_CAPABILITY) - return (T) shaders; + if(capability==CapabilityEnergy.ENERGY) + return (T)energyStorage; + if(capability==CapabilityShader.SHADER_CAPABILITY) + return (T)shaders; return super.getCapability(capability, facing); } }; @@ -94,21 +94,21 @@ public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStac { if(slotChanged) return true; - if(oldStack.hasCapability(CapabilityShader.SHADER_CAPABILITY,null) && newStack.hasCapability(CapabilityShader.SHADER_CAPABILITY,null)) + if(oldStack.hasCapability(CapabilityShader.SHADER_CAPABILITY, null)&&newStack.hasCapability(CapabilityShader.SHADER_CAPABILITY, null)) { - ShaderWrapper wrapperOld = oldStack.getCapability(CapabilityShader.SHADER_CAPABILITY,null); - ShaderWrapper wrapperNew = newStack.getCapability(CapabilityShader.SHADER_CAPABILITY,null); + ShaderWrapper wrapperOld = oldStack.getCapability(CapabilityShader.SHADER_CAPABILITY, null); + ShaderWrapper wrapperNew = newStack.getCapability(CapabilityShader.SHADER_CAPABILITY, null); if(!ItemStack.areItemStacksEqual(wrapperOld.getShaderItem(), wrapperNew.getShaderItem())) return true; } - return super.shouldCauseReequipAnimation(oldStack,newStack,slotChanged); + return super.shouldCauseReequipAnimation(oldStack, newStack, slotChanged); } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, @Nullable World world, List list, ITooltipFlag flag) { - if(this.getMaxEnergyStored(stack)>0) + if(this.getMaxEnergyStored(stack) > 0) { String stored = this.getEnergyStored(stack)+"/"+this.getMaxEnergyStored(stack); list.add(I18n.format(Lib.DESC+"info.energyStored", stored)); @@ -125,23 +125,23 @@ public void onUpdate(ItemStack stack, World world, Entity ent, int slot, boolean if(ent instanceof EntityLivingBase) inHand |= ((EntityLivingBase)ent).getHeldItem(EnumHand.OFF_HAND)==stack; - boolean blocking = ent instanceof EntityLivingBase && ((EntityLivingBase)ent).isActiveItemStackBlocking(); - if(!inHand || !blocking)//Don't recharge if in use, to avoid flickering + boolean blocking = ent instanceof EntityLivingBase&&((EntityLivingBase)ent).isActiveItemStackBlocking(); + if(!inHand||!blocking)//Don't recharge if in use, to avoid flickering { - if(getUpgrades(stack).hasKey("flash_cooldown") && this.extractEnergy(stack, 20, true)==20) + if(getUpgrades(stack).hasKey("flash_cooldown")&&this.extractEnergy(stack, 20, true)==20) { this.extractEnergy(stack, 20, false); int cooldown = getUpgrades(stack).getInteger("flash_cooldown"); - if(--cooldown<=0) + if(--cooldown <= 0) getUpgrades(stack).removeTag("flash_cooldown"); else getUpgrades(stack).setInteger("flash_cooldown", cooldown); } - if(getUpgrades(stack).hasKey("shock_cooldown") && this.extractEnergy(stack, 20, true)==20) + if(getUpgrades(stack).hasKey("shock_cooldown")&&this.extractEnergy(stack, 20, true)==20) { this.extractEnergy(stack, 20, false); int cooldown = getUpgrades(stack).getInteger("shock_cooldown"); - if(--cooldown<=0) + if(--cooldown <= 0) getUpgrades(stack).removeTag("shock_cooldown"); else getUpgrades(stack).setInteger("shock_cooldown", cooldown); @@ -157,7 +157,7 @@ public boolean isShield(ItemStack stack, @Nullable EntityLivingBase entity) public void hitShield(ItemStack stack, EntityPlayer player, DamageSource source, float amount, LivingAttackEvent event) { - if(getUpgrades(stack).getBoolean("flash") && getUpgrades(stack).getInteger("flash_cooldown")<=0) + if(getUpgrades(stack).getBoolean("flash")&&getUpgrades(stack).getInteger("flash_cooldown") <= 0) { Vec3d look = player.getLookVec(); //Offsets Player position by look backwards, then truncates cone at 1 @@ -165,23 +165,23 @@ public void hitShield(ItemStack stack, EntityPlayer player, DamageSource source, for(EntityLivingBase t : targets) if(!player.equals(t)) { - t.addPotionEffect(new PotionEffect(IEPotions.flashed,100,1)); + t.addPotionEffect(new PotionEffect(IEPotions.flashed, 100, 1)); if(t instanceof EntityLiving) ((EntityLiving)t).setAttackTarget(null); } - getUpgrades(stack).setInteger("flash_cooldown",40); + getUpgrades(stack).setInteger("flash_cooldown", 40); } - if(getUpgrades(stack).getBoolean("shock") && getUpgrades(stack).getInteger("shock_cooldown")<=0) + if(getUpgrades(stack).getBoolean("shock")&&getUpgrades(stack).getInteger("shock_cooldown") <= 0) { boolean b = false; - if(event.getSource().isProjectile() && event.getSource().getImmediateSource()!=null) + if(event.getSource().isProjectile()&&event.getSource().getImmediateSource()!=null) { Entity projectile = event.getSource().getImmediateSource(); projectile.setDead(); event.setCanceled(true); b = true; } - if(event.getSource().getTrueSource()!=null && event.getSource().getTrueSource() instanceof EntityLivingBase && event.getSource().getTrueSource().getDistanceSq(player)<4) + if(event.getSource().getTrueSource()!=null&&event.getSource().getTrueSource() instanceof EntityLivingBase&&event.getSource().getTrueSource().getDistanceSq(player) < 4) { ElectricDamageSource dmgsrc = IEDamageSources.causeTeslaDamage(1, true); dmgsrc.apply(event.getSource().getTrueSource()); @@ -189,7 +189,7 @@ public void hitShield(ItemStack stack, EntityPlayer player, DamageSource source, } if(b) { - getUpgrades(stack).setInteger("shock_cooldown",40); + getUpgrades(stack).setInteger("shock_cooldown", 40); player.world.playSound(null, player.posX, player.posY, player.posZ, IESounds.spark, SoundCategory.BLOCKS, 2.5F, 0.5F+Utils.RAND.nextFloat()); } } @@ -204,7 +204,7 @@ public boolean getIsRepairable(ItemStack stack, ItemStack material) @Override public int getMaxEnergyStored(ItemStack container) { - return (getUpgrades(container).getBoolean("flash")||getUpgrades(container).getBoolean("shock"))?1600:0; + return (getUpgrades(container).getBoolean("flash")||getUpgrades(container).getBoolean("shock"))?1600: 0; } @Override @@ -212,6 +212,7 @@ public int getMaxItemUseDuration(ItemStack stack) { return 72000; } + @Override public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { @@ -219,6 +220,7 @@ public ActionResult onItemRightClick(World worldIn, EntityPlayer play playerIn.setActiveHand(handIn); return new ActionResult(EnumActionResult.SUCCESS, itemstack); } + @Override public EnumAction getItemUseAction(ItemStack stack) { @@ -234,11 +236,12 @@ else if("shock".equals(group)) return getUpgrades(object).getBoolean("shock"); return true; } + @Override public Matrix4 handlePerspective(ItemStack Object, TransformType cameraTransformType, Matrix4 perspective, EntityLivingBase entity) { - if(entity!=null && entity.isHandActive()) - if((entity.getActiveHand()==EnumHand.MAIN_HAND) == (entity.getPrimaryHand()==EnumHandSide.RIGHT)) + if(entity!=null&&entity.isHandActive()) + if((entity.getActiveHand()==EnumHand.MAIN_HAND)==(entity.getPrimaryHand()==EnumHandSide.RIGHT)) { if(cameraTransformType==TransformType.FIRST_PERSON_RIGHT_HAND) perspective.rotate(-.15, 1, 0, 0).translate(-.25, .5, -.4375); @@ -260,18 +263,20 @@ public boolean canModify(ItemStack stack) { return true; } + @Override public Slot[] getWorkbenchSlots(Container container, ItemStack stack) { IItemHandler inv = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); return new Slot[] { - new IESlot.Upgrades(container, inv,0, 80,32, "SHIELD", stack, true), - new IESlot.Upgrades(container, inv,1,100,32, "SHIELD", stack, true) + new IESlot.Upgrades(container, inv, 0, 80, 32, "SHIELD", stack, true), + new IESlot.Upgrades(container, inv, 1, 100, 32, "SHIELD", stack, true) // new IESlot.Upgrades(container, invItem,2,100,32, "SHIELD", stack, true) }; } + @Override public int getSlotCount(ItemStack stack) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemInternalStorage.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemInternalStorage.java index 702061cd4f..3d1bb256ba 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemInternalStorage.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemInternalStorage.java @@ -41,7 +41,7 @@ public ItemInternalStorage(String name, int stackSize, String... subNames) @Override public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) { - if (!stack.isEmpty()) + if(!stack.isEmpty()) return new IEItemStackHandler(stack); return null; } @@ -49,12 +49,12 @@ public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCom public void setContainedItems(ItemStack stack, NonNullList inventory) { IItemHandler handler = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); - if (handler instanceof IItemHandlerModifiable) + if(handler instanceof IItemHandlerModifiable) { - if (inventory.size()!=handler.getSlots()) + if(inventory.size()!=handler.getSlots()) throw new IllegalArgumentException("Parameter inventory has "+inventory.size()+" slots, capability inventory has "+handler.getSlots()); - for (int i = 0; i < handler.getSlots(); i++) - ((IItemHandlerModifiable) handler).setStackInSlot(i, inventory.get(i)); + for(int i = 0; i < handler.getSlots(); i++) + ((IItemHandlerModifiable)handler).setStackInSlot(i, inventory.get(i)); } else IELogger.warn("No valid inventory handler found for "+stack); @@ -63,13 +63,13 @@ public void setContainedItems(ItemStack stack, NonNullList inventory) public NonNullList getContainedItems(ItemStack stack) { IItemHandler handler = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); - if (handler instanceof IEItemStackHandler) + if(handler instanceof IEItemStackHandler) return ((IEItemStackHandler)handler).getContainedItems(); - else if (handler != null) + else if(handler!=null) { IELogger.warn("Inefficiently getting contained items. Why does "+stack+" have a non-IE IItemHandler?"); NonNullList inv = NonNullList.withSize(handler.getSlots(), ItemStack.EMPTY); - for (int i = 0; i < handler.getSlots(); i++) + for(int i = 0; i < handler.getSlots(); i++) inv.set(i, handler.getStackInSlot(i)); return inv; } @@ -83,14 +83,14 @@ public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSl { super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected); //Update old inventories to caps - if (ItemNBTHelper.hasKey(stack, "Inv")) + if(ItemNBTHelper.hasKey(stack, "Inv")) { NBTTagList list = ItemNBTHelper.getTag(stack).getTagList("Inv", 10); setContainedItems(stack, Utils.readInventory(list, getSlotCount(stack))); ItemNBTHelper.remove(stack, "Inv"); //Sync the changes - if (entityIn instanceof EntityPlayerMP && !worldIn.isRemote) - ((EntityPlayerMP) entityIn).connection.sendPacket(new SPacketSetSlot(-2, itemSlot, stack)); + if(entityIn instanceof EntityPlayerMP&&!worldIn.isRemote) + ((EntityPlayerMP)entityIn).connection.sendPacket(new SPacketSetSlot(-2, itemSlot, stack)); } } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemJerrycan.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemJerrycan.java index f0d4eea33b..373cb27c07 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemJerrycan.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemJerrycan.java @@ -50,8 +50,8 @@ public void addInformation(ItemStack stack, @Nullable World world, List FluidStack fs = FluidUtil.getFluidContained(stack); if(fs!=null) { - TextFormatting rarity = fs.getFluid().getRarity()==EnumRarity.COMMON? TextFormatting.GRAY:fs.getFluid().getRarity().rarityColor; - list.add(rarity+fs.getLocalizedName()+ TextFormatting.GRAY+": "+fs.amount+"/"+10000+"mB"); + TextFormatting rarity = fs.getFluid().getRarity()==EnumRarity.COMMON?TextFormatting.GRAY: fs.getFluid().getRarity().rarityColor; + list.add(rarity+fs.getLocalizedName()+TextFormatting.GRAY+": "+fs.amount+"/"+10000+"mB"); } else list.add(I18n.format(Lib.DESC_FLAVOUR+"drill.empty")); @@ -62,12 +62,12 @@ public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos { ItemStack stack = player.getHeldItem(hand); TileEntity tileEntity = world.getTileEntity(pos); - if(tileEntity == null || !tileEntity.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null)) + if(tileEntity==null||!tileEntity.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null)) { FluidStack fs = FluidUtil.getFluidContained(stack); if(Utils.placeFluidBlock(world, pos.offset(side), fs)) { - if(fs.amount<=0) + if(fs.amount <= 0) fs = null; ItemNBTHelper.setFluidStack(stack, "Fluid", fs); return EnumActionResult.SUCCESS; @@ -79,8 +79,9 @@ public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos @Override public boolean hasContainerItem(ItemStack stack) { - return ItemNBTHelper.hasKey(stack, "jerrycanDrain") || FluidUtil.getFluidContained(stack)!=null; + return ItemNBTHelper.hasKey(stack, "jerrycanDrain")||FluidUtil.getFluidContained(stack)!=null; } + @Override public ItemStack getContainerItem(ItemStack stack) { @@ -105,7 +106,7 @@ else if(FluidUtil.getFluidContained(stack)!=null) @Override public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { - if (!stack.isEmpty()) + if(!stack.isEmpty()) return new FluidHandlerItemStack(stack, 10000); return null; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemMaterial.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemMaterial.java index 6d3257e922..1f6939759d 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemMaterial.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemMaterial.java @@ -29,7 +29,7 @@ public ItemMaterial() "wooden_grip", "gunpart_barrel", "gunpart_drum", "gunpart_hammer", "dust_coke", "dust_hop_graphite", "ingot_hop_graphite", "wire_copper", "wire_electrum", "wire_aluminum", "wire_steel", - "dust_saltpeter","dust_sulfur", "electron_tube", "circuit_board"); + "dust_saltpeter", "dust_sulfur", "electron_tube", "circuit_board"); } @Override diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemPowerpack.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemPowerpack.java index 02331c86be..c29065252e 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemPowerpack.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemPowerpack.java @@ -79,6 +79,7 @@ public void addInformation(ItemStack stack, @Nullable World world, List String stored = this.getEnergyStored(stack)+"/"+this.getMaxEnergyStored(stack); list.add(I18n.format(Lib.DESC+"info.energyStored", stored)); } + @Override @SideOnly(Side.CLIENT) public FontRenderer getFontRenderer(ItemStack stack) @@ -90,11 +91,11 @@ public FontRenderer getFontRenderer(ItemStack stack) public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { int energy = getEnergyStored(itemStack); - if(energy>0) + if(energy > 0) { int pre = energy; for(EntityEquipmentSlot slot : EntityEquipmentSlot.values()) - if(EnergyHelper.isFluxItem(player.getItemStackFromSlot(slot)) && !(player.getItemStackFromSlot(slot).getItem() instanceof ItemPowerpack)) + if(EnergyHelper.isFluxItem(player.getItemStackFromSlot(slot))&&!(player.getItemStackFromSlot(slot).getItem() instanceof ItemPowerpack)) energy -= EnergyHelper.insertFlux(player.getItemStackFromSlot(slot), Math.min(energy, 256), false); if(pre!=energy) EnergyHelper.extractFlux(itemStack, pre-energy, false); @@ -110,13 +111,15 @@ public Multimap getItemAttributeModifiers(EntityEquip @Override public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { - return new ArmorProperties(0,0,0); + return new ArmorProperties(0, 0, 0); } + @Override public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { return 0; } + @Override public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { @@ -127,10 +130,11 @@ public int getMaxEnergyStored(ItemStack container) { return 100000; } + @Override - public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) + public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { - if (!stack.isEmpty()) + if(!stack.isEmpty()) return new ICapabilityProvider() { final EnergyHelper.ItemEnergyStorage energyStorage = new EnergyHelper.ItemEnergyStorage(stack); @@ -138,14 +142,14 @@ public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt @Override public boolean hasCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { - return capability == CapabilityEnergy.ENERGY; + return capability==CapabilityEnergy.ENERGY; } @Nullable @Override public T getCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { - return capability == CapabilityEnergy.ENERGY ? (T) energyStorage : null; + return capability==CapabilityEnergy.ENERGY?(T)energyStorage: null; } }; else diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemRailgun.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemRailgun.java index 7ef1856abf..73c43dd58c 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemRailgun.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemRailgun.java @@ -67,33 +67,37 @@ public int getSlotCount(ItemStack stack) { return 2+1; } + @Override public Slot[] getWorkbenchSlots(Container container, ItemStack stack) { IItemHandler inv = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); return new Slot[] { - new IESlot.Upgrades(container, inv,0, 80,32, "RAILGUN", stack, true), - new IESlot.Upgrades(container, inv,1,100,32, "RAILGUN", stack, true) + new IESlot.Upgrades(container, inv, 0, 80, 32, "RAILGUN", stack, true), + new IESlot.Upgrades(container, inv, 1, 100, 32, "RAILGUN", stack, true) }; } + @Override public boolean canModify(ItemStack stack) { return true; } + @Override public void recalculateUpgrades(ItemStack stack) { super.recalculateUpgrades(stack); - if(this.getEnergyStored(stack)>this.getMaxEnergyStored(stack)) + if(this.getEnergyStored(stack) > this.getMaxEnergyStored(stack)) ItemNBTHelper.setInt(stack, "energy", this.getMaxEnergyStored(stack)); } + @Override public void clearUpgrades(ItemStack stack) { super.clearUpgrades(stack); - if(this.getEnergyStored(stack)>this.getMaxEnergyStored(stack)) + if(this.getEnergyStored(stack) > this.getMaxEnergyStored(stack)) ItemNBTHelper.setInt(stack, "energy", this.getMaxEnergyStored(stack)); } @@ -102,20 +106,20 @@ public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStac { if(slotChanged) return true; - if(oldStack.hasCapability(CapabilityShader.SHADER_CAPABILITY,null) && newStack.hasCapability(CapabilityShader.SHADER_CAPABILITY,null)) + if(oldStack.hasCapability(CapabilityShader.SHADER_CAPABILITY, null)&&newStack.hasCapability(CapabilityShader.SHADER_CAPABILITY, null)) { - ShaderWrapper wrapperOld = oldStack.getCapability(CapabilityShader.SHADER_CAPABILITY,null); - ShaderWrapper wrapperNew = newStack.getCapability(CapabilityShader.SHADER_CAPABILITY,null); + ShaderWrapper wrapperOld = oldStack.getCapability(CapabilityShader.SHADER_CAPABILITY, null); + ShaderWrapper wrapperNew = newStack.getCapability(CapabilityShader.SHADER_CAPABILITY, null); if(!ItemStack.areItemStacksEqual(wrapperOld.getShaderItem(), wrapperNew.getShaderItem())) return true; } - return super.shouldCauseReequipAnimation(oldStack,newStack,slotChanged); + return super.shouldCauseReequipAnimation(oldStack, newStack, slotChanged); } @Override public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { - if (!stack.isEmpty()) + if(!stack.isEmpty()) return new IEItemStackHandler(stack) { final EnergyHelper.ItemEnergyStorage energyStorage = new EnergyHelper.ItemEnergyStorage(stack); @@ -124,18 +128,18 @@ public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) @Override public boolean hasCapability(@Nonnull Capability capability, EnumFacing facing) { - return capability == CapabilityEnergy.ENERGY || - capability == CapabilityShader.SHADER_CAPABILITY || + return capability==CapabilityEnergy.ENERGY|| + capability==CapabilityShader.SHADER_CAPABILITY|| super.hasCapability(capability, facing); } @Override public T getCapability(@Nonnull Capability capability, EnumFacing facing) { - if (capability == CapabilityEnergy.ENERGY) - return (T) energyStorage; - if (capability == CapabilityShader.SHADER_CAPABILITY) - return (T) shaders; + if(capability==CapabilityEnergy.ENERGY) + return (T)energyStorage; + if(capability==CapabilityShader.SHADER_CAPABILITY) + return (T)shaders; return super.getCapability(capability, facing); } }; @@ -148,6 +152,7 @@ public void addInformation(ItemStack stack, @Nullable World world, List String stored = this.getEnergyStored(stack)+"/"+this.getMaxEnergyStored(stack); list.add(I18n.format(Lib.DESC+"info.energyStored", stored)); } + @Override public String getUnlocalizedName(ItemStack stack) { @@ -159,6 +164,7 @@ public String getUnlocalizedName(ItemStack stack) // } return super.getUnlocalizedName(stack); } + @Override public boolean isFull3D() { @@ -210,49 +216,51 @@ public ActionResult onItemRightClick(World world, EntityPlayer player { ItemStack stack = player.getHeldItem(hand); int energy = IEConfig.Tools.railgun_consumption; - float energyMod = 1 + this.getUpgrades(stack).getFloat("consumption"); + float energyMod = 1+this.getUpgrades(stack).getFloat("consumption"); energy = (int)(energy*energyMod); - if(this.extractEnergy(stack, energy, true)==energy && !findAmmo(player).isEmpty()) + if(this.extractEnergy(stack, energy, true)==energy&&!findAmmo(player).isEmpty()) { player.setActiveHand(hand); - player.world.playSound(null, player.posX, player.posY, player.posZ, getChargeTime(stack) <= 20 ? IESounds.chargeFast : IESounds.chargeSlow, SoundCategory.PLAYERS, 1.5f, 1f); + player.world.playSound(null, player.posX, player.posY, player.posZ, getChargeTime(stack) <= 20?IESounds.chargeFast: IESounds.chargeSlow, SoundCategory.PLAYERS, 1.5f, 1f); return new ActionResult(EnumActionResult.SUCCESS, stack); } return new ActionResult<>(EnumActionResult.PASS, stack); } + @Override public void onUsingTick(ItemStack stack, EntityLivingBase user, int count) { int inUse = this.getMaxItemUseDuration(stack)-count; - if(inUse>getChargeTime(stack) && inUse%20 == user.getRNG().nextInt(20)) + if(inUse > getChargeTime(stack)&&inUse%20==user.getRNG().nextInt(20)) user.world.playSound(null, user.posX, user.posY, user.posZ, IESounds.spark, SoundCategory.PLAYERS, .8f+(.2f*user.getRNG().nextFloat()), .5f+(.5f*user.getRNG().nextFloat())); } + @Override public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase user, int timeLeft) { if(user instanceof EntityPlayer) { - int inUse = this.getMaxItemUseDuration(stack) - timeLeft; + int inUse = this.getMaxItemUseDuration(stack)-timeLeft; ItemNBTHelper.remove(stack, "inUse"); - if (inUse < getChargeTime(stack)) + if(inUse < getChargeTime(stack)) return; int energy = IEConfig.Tools.railgun_consumption; - float energyMod = 1 + this.getUpgrades(stack).getFloat("consumption"); - energy = (int) (energy * energyMod); - if (this.extractEnergy(stack, energy, true) == energy) + float energyMod = 1+this.getUpgrades(stack).getFloat("consumption"); + energy = (int)(energy*energyMod); + if(this.extractEnergy(stack, energy, true)==energy) { ItemStack ammo = findAmmo((EntityPlayer)user); if(!ammo.isEmpty()) { Vec3d vec = user.getLookVec(); float speed = 20; - EntityRailgunShot shot = new EntityRailgunShot(user.world, user, vec.x * speed, vec.y * speed, vec.z * speed, Utils.copyStackWithAmount(ammo, 1)); + EntityRailgunShot shot = new EntityRailgunShot(user.world, user, vec.x*speed, vec.y*speed, vec.z*speed, Utils.copyStackWithAmount(ammo, 1)); ammo.shrink(1); - if(ammo.getCount()<=0) + if(ammo.getCount() <= 0) ((EntityPlayer)user).inventory.deleteStack(ammo); - user.world.playSound(null, user.posX, user.posY, user.posZ, IESounds.railgunFire, SoundCategory.PLAYERS,1, .5f + (.5f * user.getRNG().nextFloat())); + user.world.playSound(null, user.posX, user.posY, user.posZ, IESounds.railgunFire, SoundCategory.PLAYERS, 1, .5f+(.5f*user.getRNG().nextFloat())); this.extractEnergy(stack, energy, false); - if (!world.isRemote) + if(!world.isRemote) user.world.spawnEntity(shot); } } @@ -266,7 +274,7 @@ public static ItemStack findAmmo(EntityPlayer player) else if(isAmmo(player.getHeldItem(EnumHand.MAIN_HAND))) return player.getHeldItem(EnumHand.MAIN_HAND); else - for(int i=0; i0) + if(upgrades.getDouble("speed") > 0) render.add("upgrade_speed"); if(upgrades.getBoolean("scope")) render.add("upgrade_scope"); @@ -330,7 +339,9 @@ public boolean canZoom(ItemStack stack, EntityPlayer player) { return this.getUpgrades(stack).getBoolean("scope"); } - float[] zoomSteps = new float[]{.1f,.15625f,.2f,.25f, .3125f, .4f, .5f,.625f}; + + float[] zoomSteps = new float[]{.1f, .15625f, .2f, .25f, .3125f, .4f, .5f, .625f}; + @Override public float[] getZoomSteps(ItemStack stack, EntityPlayer player) { @@ -347,12 +358,13 @@ public boolean isTool(ItemStack item) @Override public boolean shouldRenderGroup(ItemStack stack, String group) { - if (group.equals("upgrade_scope")) + if(group.equals("upgrade_scope")) return getUpgrades(stack).getBoolean("scope"); - if (group.equals("upgrade_speed")) - return getUpgrades(stack).getDouble("speed")>0; + if(group.equals("upgrade_speed")) + return getUpgrades(stack).getDouble("speed") > 0; return true; } + @SideOnly(Side.CLIENT) @Override public Optional applyTransformations(ItemStack stack, String group, Optional transform) @@ -366,6 +378,7 @@ public Optional applyTransformations(ItemStack stack, String // } return transform; } + @SideOnly(Side.CLIENT) @Override public Matrix4 handlePerspective(ItemStack stack, TransformType cameraTransformType, Matrix4 perspective, EntityLivingBase entity) diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemRevolver.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemRevolver.java index 2c6f9325a9..57337812f7 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemRevolver.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemRevolver.java @@ -79,19 +79,21 @@ public ItemRevolver() { super("revolver", 1, "REVOLVER"); } + public static UUID speedModUUID = Utils.generateNewUUID(); public HashMap revolverIcons = new HashMap<>(); public TextureAtlasSprite revolverDefaultTexture; + public void stichRevolverTextures(TextureMap map) { revolverDefaultTexture = ApiUtils.getRegisterSprite(map, "immersiveengineering:revolvers/revolver"); for(String key : specialRevolversByTag.keySet()) - if(!key.isEmpty() && !specialRevolversByTag.get(key).tag.isEmpty()) + if(!key.isEmpty()&&!specialRevolversByTag.get(key).tag.isEmpty()) { int split = key.lastIndexOf("_"); - if(split<0) + if(split < 0) split = key.length(); - revolverIcons.put(key, ApiUtils.getRegisterSprite(map, "immersiveengineering:revolvers/revolver_"+key.substring(0,split).toLowerCase())); + revolverIcons.put(key, ApiUtils.getRegisterSprite(map, "immersiveengineering:revolvers/revolver_"+key.substring(0, split).toLowerCase())); } } @@ -100,16 +102,18 @@ public int getSlotCount(ItemStack stack) { return 18+2+1; } + @Override public Slot[] getWorkbenchSlots(Container container, ItemStack stack) { IItemHandler inv = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); return new Slot[] { - new IESlot.Upgrades(container, inv,18+0, 80,32, "REVOLVER", stack, true), - new IESlot.Upgrades(container, inv,18+1,100,32, "REVOLVER", stack, true) + new IESlot.Upgrades(container, inv, 18+0, 80, 32, "REVOLVER", stack, true), + new IESlot.Upgrades(container, inv, 18+1, 100, 32, "REVOLVER", stack, true) }; } + @Override public boolean canModify(ItemStack stack) { @@ -121,17 +125,17 @@ public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStac { if(slotChanged) return true; - if(super.shouldCauseReequipAnimation(oldStack,newStack,slotChanged)) + if(super.shouldCauseReequipAnimation(oldStack, newStack, slotChanged)) return true; - if(oldStack.hasCapability(CapabilityShader.SHADER_CAPABILITY,null) && newStack.hasCapability(CapabilityShader.SHADER_CAPABILITY,null)) + if(oldStack.hasCapability(CapabilityShader.SHADER_CAPABILITY, null)&&newStack.hasCapability(CapabilityShader.SHADER_CAPABILITY, null)) { - ShaderWrapper wrapperOld = oldStack.getCapability(CapabilityShader.SHADER_CAPABILITY,null); - ShaderWrapper wrapperNew = newStack.getCapability(CapabilityShader.SHADER_CAPABILITY,null); + ShaderWrapper wrapperOld = oldStack.getCapability(CapabilityShader.SHADER_CAPABILITY, null); + ShaderWrapper wrapperNew = newStack.getCapability(CapabilityShader.SHADER_CAPABILITY, null); if(!ItemStack.areItemStacksEqual(wrapperOld.getShaderItem(), wrapperNew.getShaderItem())) return true; } - if(ItemNBTHelper.hasKey(oldStack, "elite") || ItemNBTHelper.hasKey(newStack, "elite")) + if(ItemNBTHelper.hasKey(oldStack, "elite")||ItemNBTHelper.hasKey(newStack, "elite")) return !ItemNBTHelper.getString(oldStack, "elite").equals(ItemNBTHelper.getString(newStack, "elite")); return false; @@ -140,7 +144,7 @@ public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStac @Override public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { - if (!stack.isEmpty()) + if(!stack.isEmpty()) return new IEItemStackHandler(stack) { final ShaderWrapper_Item shaders = new ShaderWrapper_Item("immersiveengineering:revolver", stack); @@ -148,15 +152,15 @@ public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) @Override public boolean hasCapability(@Nonnull Capability capability, EnumFacing facing) { - return capability == CapabilityShader.SHADER_CAPABILITY || + return capability==CapabilityShader.SHADER_CAPABILITY|| super.hasCapability(capability, facing); } @Override public T getCapability(@Nonnull Capability capability, EnumFacing facing) { - if (capability == CapabilityShader.SHADER_CAPABILITY) - return (T) shaders; + if(capability==CapabilityShader.SHADER_CAPABILITY) + return (T)shaders; return super.getCapability(capability, facing); } }; @@ -177,6 +181,7 @@ public void getSubItems(CreativeTabs tab, NonNullList list) // list.add(stack); // } } + @Override public void addInformation(ItemStack stack, @Nullable World world, List list, ITooltipFlag flag) { @@ -198,6 +203,7 @@ else if(stack.getMetadata()==0) // } } } + @Override public String getUnlocalizedName(ItemStack stack) { @@ -209,6 +215,7 @@ public String getUnlocalizedName(ItemStack stack) } return super.getUnlocalizedName(stack); } + @Override public boolean isFull3D() { @@ -224,13 +231,13 @@ public Multimap getAttributeModifiers(@Nonnull EntityEquipmentSlot slot, ItemSta if(getUpgrades(stack).getBoolean("fancyAnimation")) multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2, 0)); double melee = getUpgrades(stack).getDouble("melee"); - if(melee != 0) + if(melee!=0) { multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", melee, 0)); multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.4000000953674316D, 0)); } double speed = getUpgrades(stack).getDouble("speed"); - if(speed != 0) + if(speed!=0) multimap.put(SharedMonsterAttributes.MOVEMENT_SPEED.getName(), new AttributeModifier(speedModUUID, "Weapon modifier", speed, 1)); } return multimap; @@ -265,6 +272,7 @@ public void onUpdate(ItemStack stack, World world, Entity ent, int slot, boolean } } } + @Override public ActionResult onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { @@ -273,16 +281,16 @@ public ActionResult onItemRightClick(World world, EntityPlayer player { if(player.isSneaking()) { - CommonProxy.openGuiForItem(player, hand==EnumHand.MAIN_HAND? EntityEquipmentSlot.MAINHAND:EntityEquipmentSlot.OFFHAND); + CommonProxy.openGuiForItem(player, hand==EnumHand.MAIN_HAND?EntityEquipmentSlot.MAINHAND: EntityEquipmentSlot.OFFHAND); return new ActionResult(EnumActionResult.SUCCESS, revolver); } - else if(player.getCooledAttackStrength(1)>=1) + else if(player.getCooledAttackStrength(1) >= 1) { if(this.getUpgrades(revolver).getBoolean("nerf")) world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 1f, 0.6f); else { - if(getShootCooldown(revolver) > 0 || ItemNBTHelper.hasKey(revolver, "reload")) + if(getShootCooldown(revolver) > 0||ItemNBTHelper.hasKey(revolver, "reload")) return new ActionResult(EnumActionResult.PASS, revolver); NonNullList bullets = getBullets(revolver); @@ -291,7 +299,7 @@ else if(player.getCooledAttackStrength(1)>=1) for(int i = 0; i < player.inventory.getSizeInventory(); i++) { ItemStack stack = player.inventory.getStackInSlot(i); - if(stack.getItem() instanceof ItemSpeedloader && !((ItemSpeedloader)stack.getItem()).isEmpty(stack)) + if(stack.getItem() instanceof ItemSpeedloader&&!((ItemSpeedloader)stack.getItem()).isEmpty(stack)) { for(ItemStack b : bullets) if(!b.isEmpty()) @@ -322,7 +330,8 @@ else if(player.getCooledAttackStrength(1)>=1) { Entity entBullet = getBullet(player, vec, vec, key, bullets.get(0), electro); player.world.spawnEntity(bullet.getProjectile(player, bullets.get(0), entBullet, electro)); - } else + } + else for(int i = 0; i < count; i++) { Vec3d vecDir = vec.addVector(player.getRNG().nextGaussian()*.1, player.getRNG().nextGaussian()*.1, player.getRNG().nextGaussian()*.1); @@ -334,9 +343,11 @@ else if(player.getCooledAttackStrength(1)>=1) if(sound==null) sound = IESounds.revolverFire; world.playSound(null, player.posX, player.posY, player.posZ, sound, SoundCategory.PLAYERS, 1f, 1f); - } else + } + else world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_NOTE_HAT, SoundCategory.PLAYERS, 1f, 1f); - } else + } + else world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_NOTE_HAT, SoundCategory.PLAYERS, 1f, 1f); NonNullList cycled = NonNullList.withSize(getBulletCount(revolver), ItemStack.EMPTY); @@ -369,7 +380,7 @@ else if(!player.isSneaking()&&revolver.getItemDamage()==0) EntityRevolvershot getBullet(EntityPlayer player, Vec3d vecSpawn, Vec3d vecDir, String type, ItemStack stack, boolean electro) { - EntityRevolvershot bullet = new EntityRevolvershot(player.world, player, vecDir.x * 1.5, vecDir.y * 1.5, vecDir.z * 1.5, type, stack); + EntityRevolvershot bullet = new EntityRevolvershot(player.world, player, vecDir.x*1.5, vecDir.y*1.5, vecDir.z*1.5, type, stack); bullet.motionX = vecDir.x*2; bullet.motionY = vecDir.y*2; bullet.motionZ = vecDir.z*2; @@ -381,6 +392,7 @@ public int getShootCooldown(ItemStack stack) { return ItemNBTHelper.getInt(stack, "cooldown"); } + public int getMaxShootCooldown(ItemStack stack) { return 15; @@ -389,41 +401,45 @@ public int getMaxShootCooldown(ItemStack stack) public boolean isEmpty(ItemStack stack, boolean allowCasing) { IItemHandler inv = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); - if (inv!=null) - for (int i = 0; i < inv.getSlots(); i++) + if(inv!=null) + for(int i = 0; i < inv.getSlots(); i++) { ItemStack b = inv.getStackInSlot(i); - if(!b.isEmpty() && b.getItem() instanceof ItemBullet && (allowCasing||ItemNBTHelper.hasKey(b, "bullet"))) + if(!b.isEmpty()&&b.getItem() instanceof ItemBullet&&(allowCasing||ItemNBTHelper.hasKey(b, "bullet"))) return false; } return true; } + @Override public NonNullList getBullets(ItemStack revolver, boolean remote) { - if (!remote&&isEmpty(revolver, true)) + if(!remote&&isEmpty(revolver, true)) remote = true; - else if (remote&&!ItemNBTHelper.hasKey(revolver, "bullets")) + else if(remote&&!ItemNBTHelper.hasKey(revolver, "bullets")) remote = false; - if (!remote) + if(!remote) return ListUtils.fromItems(this.getContainedItems(revolver).subList(0, getBulletCount(revolver))); else return Utils.readInventory(ItemNBTHelper.getTag(revolver).getTagList("bullets", 10), getBulletCount(revolver)); } + public void setBullets(ItemStack revolver, NonNullList bullets) { - IItemHandlerModifiable inv = (IItemHandlerModifiable) revolver.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); + IItemHandlerModifiable inv = (IItemHandlerModifiable)revolver.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); assert inv!=null; - for (int i = 0;i<18;i++) + for(int i = 0; i < 18; i++) inv.setStackInSlot(i, ItemStack.EMPTY); - for(int i = 0; i< bullets.size(); i++) + for(int i = 0; i < bullets.size(); i++) inv.setStackInSlot(i, bullets.get(i)); } + @Override public int getBulletCount(ItemStack revolver) { return 8+this.getUpgrades(revolver).getInteger("bullets"); } + @Override public NBTTagCompound getUpgradeBase(ItemStack stack) { @@ -436,9 +452,9 @@ public String getRevolverDisplayTag(ItemStack revolver) if(!tag.isEmpty()) { int split = tag.lastIndexOf("_"); - if(split<0) + if(split < 0) split = tag.length(); - return tag.substring(0,split); + return tag.substring(0, split); } return ""; } @@ -453,6 +469,7 @@ public TextureAtlasSprite getTextureReplacement(ItemStack stack, String material else return this.revolverDefaultTexture; } + @SideOnly(Side.CLIENT) @Override public boolean shouldRenderGroup(ItemStack stack, String group) @@ -463,24 +480,24 @@ public boolean shouldRenderGroup(ItemStack stack, String group) HashSet render = new HashSet(); String tag = ItemNBTHelper.getString(stack, "elite"); String flavour = ItemNBTHelper.getString(stack, "flavour"); - if(tag!=null && !tag.isEmpty() && specialRevolversByTag.containsKey(tag)) + if(tag!=null&&!tag.isEmpty()&&specialRevolversByTag.containsKey(tag)) { SpecialRevolver r = specialRevolversByTag.get(tag); - if(r!=null && r.renderAdditions!=null) + if(r!=null&&r.renderAdditions!=null) for(String ss : r.renderAdditions) render.add(ss); } - else if(flavour!=null && !flavour.isEmpty() && specialRevolversByTag.containsKey(flavour)) + else if(flavour!=null&&!flavour.isEmpty()&&specialRevolversByTag.containsKey(flavour)) { SpecialRevolver r = specialRevolversByTag.get(flavour); - if(r!=null && r.renderAdditions!=null) + if(r!=null&&r.renderAdditions!=null) for(String ss : r.renderAdditions) render.add(ss); } NBTTagCompound upgrades = this.getUpgrades(stack); - if(upgrades.getInteger("bullets")>0 && !render.contains("dev_mag")) + if(upgrades.getInteger("bullets") > 0&&!render.contains("dev_mag")) render.add("player_mag"); - if(upgrades.getDouble("melee")>0 && !render.contains("dev_bayonet")) + if(upgrades.getDouble("melee") > 0&&!render.contains("dev_bayonet")) { render.add("bayonet_attachment"); render.add("player_bayonet"); @@ -492,15 +509,16 @@ else if(flavour!=null && !flavour.isEmpty() && specialRevolversByTag.containsKey } return render.contains(group); } + @SideOnly(Side.CLIENT) @Override public Matrix4 handlePerspective(ItemStack stack, TransformType cameraTransformType, Matrix4 perspective, @Nullable EntityLivingBase entity) { - if(entity instanceof EntityPlayer && (cameraTransformType==TransformType.FIRST_PERSON_RIGHT_HAND||cameraTransformType==TransformType.FIRST_PERSON_LEFT_HAND||cameraTransformType==TransformType.THIRD_PERSON_RIGHT_HAND||cameraTransformType==TransformType.THIRD_PERSON_LEFT_HAND)) + if(entity instanceof EntityPlayer&&(cameraTransformType==TransformType.FIRST_PERSON_RIGHT_HAND||cameraTransformType==TransformType.FIRST_PERSON_LEFT_HAND||cameraTransformType==TransformType.THIRD_PERSON_RIGHT_HAND||cameraTransformType==TransformType.THIRD_PERSON_LEFT_HAND)) { boolean main = (cameraTransformType==TransformType.FIRST_PERSON_RIGHT_HAND||cameraTransformType==TransformType.THIRD_PERSON_RIGHT_HAND)==(entity.getPrimaryHand()==EnumHandSide.RIGHT); boolean left = cameraTransformType==TransformType.FIRST_PERSON_LEFT_HAND||cameraTransformType==TransformType.THIRD_PERSON_LEFT_HAND; - if(getUpgrades(stack).getBoolean("fancyAnimation") && main) + if(getUpgrades(stack).getBoolean("fancyAnimation")&&main) { float f = ((EntityPlayer)entity).getCooledAttackStrength(ClientUtils.mc().timer.renderPartialTicks); if(f < 1) @@ -514,29 +532,30 @@ public Matrix4 handlePerspective(ItemStack stack, TransformType cameraTransformT } //Re-grab stack because the other one doesn't do reloads properly - stack = main?entity.getHeldItemMainhand():entity.getHeldItemOffhand(); + stack = main?entity.getHeldItemMainhand(): entity.getHeldItemOffhand(); if(ItemNBTHelper.hasKey(stack, "reload")) { float f = 3-ItemNBTHelper.getInt(stack, "reload")/20f; //Reload time in seconds, for coordinating with audio - if(f>.35&&f<1.95) + if(f > .35&&f < 1.95) if(f < .5) - perspective.translate((.35-f)*2, 0, 0).rotate(2.64*(f-.35), 0, 0, left?-1:1); + perspective.translate((.35-f)*2, 0, 0).rotate(2.64*(f-.35), 0, 0, left?-1: 1); else if(f < .6) - perspective.translate((f-.5)*6, (.5-f)*1, 0).rotate(.87266, 0, 0, left?-1:1); + perspective.translate((f-.5)*6, (.5-f)*1, 0).rotate(.87266, 0, 0, left?-1: 1); else if(f < 1.7) - perspective.translate(0, -.6, 0).rotate(.87266, 0, 0, left?-1:1); + perspective.translate(0, -.6, 0).rotate(.87266, 0, 0, left?-1: 1); else if(f < 1.8) - perspective.translate((1.8-f)*6, (f-1.8)*1, 0).rotate(.87266, 0, 0, left?-1:1); + perspective.translate((1.8-f)*6, (f-1.8)*1, 0).rotate(.87266, 0, 0, left?-1: 1); else - perspective.translate((f-1.95f)*2, 0, 0).rotate(2.64*(1.95-f), 0, 0, left?-1:1); + perspective.translate((f-1.95f)*2, 0, 0).rotate(2.64*(1.95-f), 0, 0, left?-1: 1); } else if(((EntityPlayer)entity).openContainer instanceof ContainerRevolver) - perspective.translate(left?.4:-.4, .4, 0).rotate(.87266, 0, 0, left?-1:1); + perspective.translate(left?.4: -.4, .4, 0).rotate(.87266, 0, 0, left?-1: 1); } return perspective; } private static final String[][] groups = {{"frame"}, {"cylinder"}}; + @SideOnly(Side.CLIENT) @Override public String[][] getSpecialGroups(ItemStack stack, TransformType transform, EntityLivingBase entity) @@ -553,12 +572,12 @@ public String[][] getSpecialGroups(ItemStack stack, TransformType transform, Ent public Matrix4 getTransformForGroups(ItemStack stack, String[] groups, TransformType transform, EntityLivingBase entity, Matrix4 mat, float partialTicks) { - if(entity instanceof EntityPlayer && (transform==TransformType.FIRST_PERSON_RIGHT_HAND||transform==TransformType.FIRST_PERSON_LEFT_HAND||transform==TransformType.THIRD_PERSON_RIGHT_HAND||transform==TransformType.THIRD_PERSON_LEFT_HAND)) + if(entity instanceof EntityPlayer&&(transform==TransformType.FIRST_PERSON_RIGHT_HAND||transform==TransformType.FIRST_PERSON_LEFT_HAND||transform==TransformType.THIRD_PERSON_RIGHT_HAND||transform==TransformType.THIRD_PERSON_LEFT_HAND)) { boolean main = (transform==TransformType.FIRST_PERSON_RIGHT_HAND||transform==TransformType.THIRD_PERSON_RIGHT_HAND)==(entity.getPrimaryHand()==EnumHandSide.RIGHT); boolean left = transform==TransformType.FIRST_PERSON_LEFT_HAND||transform==TransformType.THIRD_PERSON_LEFT_HAND; //Re-grab stack because the other one doesn't do reloads properly - stack = main?entity.getHeldItemMainhand():entity.getHeldItemOffhand(); + stack = main?entity.getHeldItemMainhand(): entity.getHeldItemOffhand(); if(ItemNBTHelper.hasKey(stack, "reload")) { float f = 3-ItemNBTHelper.getInt(stack, "reload")/20f; //Reload time in seconds, for coordinating with audio @@ -573,19 +592,19 @@ else if(f < 1.8) else return mat.setIdentity().translate(-.625, .25, 0).rotate(-2.64*(1.95-f), 0, 0, 1); } - else if(f>2.5 && f<2.9) - return mat.setIdentity().translate(0, .6875, 0).rotate(-15.70795*(f-2.5), left?-1:1, 0, 0); + else if(f > 2.5&&f < 2.9) + return mat.setIdentity().translate(0, .6875, 0).rotate(-15.70795*(f-2.5), left?-1: 1, 0, 0); } - else if("frame".equals(groups[0]) && ((EntityPlayer)entity).openContainer instanceof ContainerRevolver) + else if("frame".equals(groups[0])&&((EntityPlayer)entity).openContainer instanceof ContainerRevolver) return matOpen; } - return "frame".equals(groups[0])?matClose:matCylinder; + return "frame".equals(groups[0])?matClose: matCylinder; } @Override public void onCreated(ItemStack stack, World world, EntityPlayer player) { - if(stack.isEmpty() || player==null) + if(stack.isEmpty()||player==null) return; if(stack.getItemDamage()==1) @@ -602,9 +621,9 @@ public void onCreated(ItemStack stack, World world, EntityPlayer player) applySpecialCrafting(stack, list.get(0)); else { - int i=0; - for(; i e : r.baseUpgrades.entrySet()) @@ -642,6 +662,7 @@ else if(e.getValue() instanceof String) } ItemNBTHelper.setTagCompound(stack, "baseUpgrades", baseUpgrades); } + @Override public void removeFromWorkbench(EntityPlayer player, ItemStack stack) { @@ -655,15 +676,15 @@ public void removeFromWorkbench(EntityPlayer player, ItemStack stack) public NBTTagCompound getNBTShareTag(ItemStack stack) { NBTTagCompound ret = super.getNBTShareTag(stack); - if (ret==null) + if(ret==null) ret = new NBTTagCompound(); else ret = ret.copy(); IItemHandler handler = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); - if (handler!=null) + if(handler!=null) { NonNullList bullets = NonNullList.withSize(getBulletCount(stack), ItemStack.EMPTY); - for (int i = 0; i < getBulletCount(stack); i++) + for(int i = 0; i < getBulletCount(stack); i++) bullets.set(i, handler.getStackInSlot(i)); ret.setTag("bullets", Utils.writeInventory(bullets)); } @@ -687,13 +708,14 @@ public static class SpecialRevolver public final String flavour; public final HashMap baseUpgrades; public final String[] renderAdditions; + public SpecialRevolver(String[] uuid, String tag, String flavour, HashMap baseUpgrades, String[] renderAdditions) { - this.uuid=uuid; - this.tag=tag; - this.flavour=flavour; - this.baseUpgrades=baseUpgrades; - this.renderAdditions=renderAdditions; + this.uuid = uuid; + this.tag = tag; + this.flavour = flavour; + this.baseUpgrades = baseUpgrades; + this.renderAdditions = renderAdditions; } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemShaderBag.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemShaderBag.java index 0c51ecdcf0..47a77c53ff 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemShaderBag.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemShaderBag.java @@ -44,6 +44,7 @@ public boolean hasCustomItemColours() { return true; } + @Override public int getColourForIEItem(ItemStack stack, int pass) { @@ -55,7 +56,7 @@ public int getColourForIEItem(ItemStack stack, int pass) public void getSubItems(CreativeTabs tab, NonNullList list) { if(this.isInCreativeTab(tab)) - for(int i=ShaderRegistry.sortedRarityMap.size()-1; i>=0; i--) + for(int i = ShaderRegistry.sortedRarityMap.size()-1; i >= 0; i--) { EnumRarity rarity = ShaderRegistry.sortedRarityMap.get(i); ItemStack s = new ItemStack(this); @@ -67,7 +68,7 @@ public void getSubItems(CreativeTabs tab, NonNullList list) @Override public String getItemStackDisplayName(ItemStack stack) { - return getRarity(stack).rarityName +" "+ super.getItemStackDisplayName(stack); + return getRarity(stack).rarityName+" "+super.getItemStackDisplayName(stack); } @Override @@ -88,14 +89,14 @@ public ActionResult onItemRightClick(World world, EntityPlayer player if(ShaderRegistry.totalWeight.containsKey(stack.getRarity())) { String shader = ShaderRegistry.getRandomShader(player.getName(), player.getRNG(), stack.getRarity(), true); - if(shader==null || shader.isEmpty()) + if(shader==null||shader.isEmpty()) return new ActionResult(EnumActionResult.FAIL, stack); ItemStack shaderItem = new ItemStack(IEContent.itemShader); ItemNBTHelper.setString(shaderItem, "shader_name", shader); - if(ShaderRegistry.sortedRarityMap.indexOf(ShaderRegistry.shaderRegistry.get(shader).getRarity())<=ShaderRegistry.sortedRarityMap.indexOf(EnumRarity.EPIC) && ShaderRegistry.sortedRarityMap.indexOf(stack.getRarity())>=ShaderRegistry.sortedRarityMap.indexOf(EnumRarity.COMMON)) + if(ShaderRegistry.sortedRarityMap.indexOf(ShaderRegistry.shaderRegistry.get(shader).getRarity()) <= ShaderRegistry.sortedRarityMap.indexOf(EnumRarity.EPIC)&&ShaderRegistry.sortedRarityMap.indexOf(stack.getRarity()) >= ShaderRegistry.sortedRarityMap.indexOf(EnumRarity.COMMON)) Utils.unlockIEAdvancement(player, "main/secret_luckofthedraw"); stack.shrink(1); - if(stack.getCount()<=0) + if(stack.getCount() <= 0) return new ActionResult(EnumActionResult.SUCCESS, shaderItem); if(!player.inventory.addItemStackToInventory(shaderItem)) player.dropItem(shaderItem, false, true); diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemSkyhook.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemSkyhook.java index 4057f99efa..1a004709ab 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemSkyhook.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemSkyhook.java @@ -28,7 +28,6 @@ import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; @@ -80,13 +79,13 @@ public ActionResult onItemRightClick(World world, EntityPlayer player TileEntity connector = null; Connection line = null; Connection con = ApiUtils.getTargetConnection(world, player, null, 0); - if (con != null) + if(con!=null) { connector = world.getTileEntity(con.start); line = con; } ItemStack stack = player.getHeldItem(hand); - if (line != null && connector != null) + if(line!=null&&connector!=null) { SkylineHelper.spawnHook(player, connector, line); player.setActiveHand(hand); diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemSpeedloader.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemSpeedloader.java index da04cc2c28..81566329fa 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemSpeedloader.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemSpeedloader.java @@ -48,18 +48,18 @@ public ActionResult onItemRightClick(World world, EntityPlayer player { ItemStack stack = player.getHeldItem(hand); if(!world.isRemote) - CommonProxy.openGuiForItem(player, hand==EnumHand.MAIN_HAND? EntityEquipmentSlot.MAINHAND:EntityEquipmentSlot.OFFHAND); + CommonProxy.openGuiForItem(player, hand==EnumHand.MAIN_HAND?EntityEquipmentSlot.MAINHAND: EntityEquipmentSlot.OFFHAND); return new ActionResult(EnumActionResult.SUCCESS, stack); } public boolean isEmpty(ItemStack stack) { IItemHandler inv = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); - if (inv!=null) - for (int i = 0; i < inv.getSlots(); i++) + if(inv!=null) + for(int i = 0; i < inv.getSlots(); i++) { ItemStack b = inv.getStackInSlot(i); - if(!b.isEmpty() && b.getItem() instanceof ItemBullet && ItemNBTHelper.hasKey(b, "bullet")) + if(!b.isEmpty()&&b.getItem() instanceof ItemBullet&&ItemNBTHelper.hasKey(b, "bullet")) return false; } return true; @@ -86,12 +86,12 @@ public int getBulletCount(ItemStack container) @Override public NonNullList getBullets(ItemStack revolver, boolean remote) { - if (!remote&&isEmpty(revolver)) + if(!remote&&isEmpty(revolver)) remote = true; - else if (remote&&!ItemNBTHelper.hasKey(revolver, "bullets")) + else if(remote&&!ItemNBTHelper.hasKey(revolver, "bullets")) remote = false; - if (!remote) - return ListUtils.fromItems(this.getContainedItems(revolver).subList(0,getSlotCount(revolver))); + if(!remote) + return ListUtils.fromItems(this.getContainedItems(revolver).subList(0, getSlotCount(revolver))); else return Utils.readInventory(ItemNBTHelper.getTag(revolver).getTagList("bullets", 10), getSlotCount(revolver)); } @@ -101,15 +101,15 @@ else if (remote&&!ItemNBTHelper.hasKey(revolver, "bullets")) public NBTTagCompound getNBTShareTag(ItemStack stack) { NBTTagCompound ret = super.getNBTShareTag(stack); - if (ret==null) + if(ret==null) ret = new NBTTagCompound(); else ret = ret.copy(); IItemHandler handler = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); - if (handler!=null) + if(handler!=null) { NonNullList bullets = NonNullList.withSize(getSlotCount(stack), ItemStack.EMPTY); - for (int i = 0; i < getSlotCount(stack); i++) + for(int i = 0; i < getSlotCount(stack); i++) bullets.set(i, handler.getStackInSlot(i)); ret.setTag("bullets", Utils.writeInventory(bullets)); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemToolUpgrade.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemToolUpgrade.java index 7edc7c8c7b..ba56467572 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemToolUpgrade.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemToolUpgrade.java @@ -27,40 +27,44 @@ import java.util.function.BiConsumer; import java.util.function.BiPredicate; -public class ItemToolUpgrade extends ItemIEBase implements IUpgrade { +public class ItemToolUpgrade extends ItemIEBase implements IUpgrade +{ public enum ToolUpgrades { - DRILL_WATERPROOF(ImmutableSet.of("DRILL"), (upgrade, modifications)-> modifications.setBoolean("waterproof", true)), - DRILL_LUBE(ImmutableSet.of("DRILL"), (upgrade, modifications)-> modifications.setBoolean("oiled", true)), - DRILL_DAMAGE(ImmutableSet.of("DRILL"), 3, (upgrade, modifications)-> { + DRILL_WATERPROOF(ImmutableSet.of("DRILL"), (upgrade, modifications) -> modifications.setBoolean("waterproof", true)), + DRILL_LUBE(ImmutableSet.of("DRILL"), (upgrade, modifications) -> modifications.setBoolean("oiled", true)), + DRILL_DAMAGE(ImmutableSet.of("DRILL"), 3, (upgrade, modifications) -> { ItemNBTHelper.modifyFloat(modifications, "speed", upgrade.getCount()*2f); ItemNBTHelper.modifyInt(modifications, "damage", upgrade.getCount()); }), - DRILL_CAPACITY(ImmutableSet.of("DRILL","CHEMTHROWER"), 1, (target, upgrade)->!((IUpgradeableTool)target.getItem()).getUpgrades(target).hasKey("multitank"), (upgrade, modifications)-> ItemNBTHelper.modifyInt(modifications, "capacity", 2000)), - REVOLVER_BAYONET(ImmutableSet.of("REVOLVER"), (upgrade, modifications)-> ItemNBTHelper.modifyFloat(modifications, "melee", 6f)), - REVOLVER_MAGAZINE(ImmutableSet.of("REVOLVER"), 1, (target, upgrade)->!((IUpgradeableTool)target.getItem()).getUpgrades(target).hasKey("bullets"), (upgrade, modifications)-> ItemNBTHelper.modifyInt(modifications, "bullets", 6)), - REVOLVER_ELECTRO(ImmutableSet.of("REVOLVER"), (upgrade, modifications)-> modifications.setBoolean("electro",true)), - CHEMTHROWER_FOCUS(ImmutableSet.of("CHEMTHROWER"), (upgrade, modifications)-> modifications.setBoolean("focus",true)), - RAILGUN_SCOPE(ImmutableSet.of("RAILGUN"), (upgrade, modifications)-> modifications.setBoolean("scope",true)), - RAILGUN_CAPACITORS(ImmutableSet.of("RAILGUN"), (upgrade, modifications)-> modifications.setFloat("speed",1f)), - SHIELD_FLASH(ImmutableSet.of("SHIELD"), (upgrade, modifications)-> modifications.setBoolean("flash",true)), - SHIELD_SHOCK(ImmutableSet.of("SHIELD"), (upgrade, modifications)-> modifications.setBoolean("shock",true)), - SHIELD_MAGNET(ImmutableSet.of("SHIELD"), (upgrade, modifications)-> modifications.setBoolean("magnet",true)), - CHEMTHROWER_MULTITANK(ImmutableSet.of("CHEMTHROWER"), 1, (target, upgrade)->!((IUpgradeableTool)target.getItem()).getUpgrades(target).hasKey("capacity"), (upgrade, modifications)-> modifications.setBoolean("multitank",true)); + DRILL_CAPACITY(ImmutableSet.of("DRILL", "CHEMTHROWER"), 1, (target, upgrade) -> !((IUpgradeableTool)target.getItem()).getUpgrades(target).hasKey("multitank"), (upgrade, modifications) -> ItemNBTHelper.modifyInt(modifications, "capacity", 2000)), + REVOLVER_BAYONET(ImmutableSet.of("REVOLVER"), (upgrade, modifications) -> ItemNBTHelper.modifyFloat(modifications, "melee", 6f)), + REVOLVER_MAGAZINE(ImmutableSet.of("REVOLVER"), 1, (target, upgrade) -> !((IUpgradeableTool)target.getItem()).getUpgrades(target).hasKey("bullets"), (upgrade, modifications) -> ItemNBTHelper.modifyInt(modifications, "bullets", 6)), + REVOLVER_ELECTRO(ImmutableSet.of("REVOLVER"), (upgrade, modifications) -> modifications.setBoolean("electro", true)), + CHEMTHROWER_FOCUS(ImmutableSet.of("CHEMTHROWER"), (upgrade, modifications) -> modifications.setBoolean("focus", true)), + RAILGUN_SCOPE(ImmutableSet.of("RAILGUN"), (upgrade, modifications) -> modifications.setBoolean("scope", true)), + RAILGUN_CAPACITORS(ImmutableSet.of("RAILGUN"), (upgrade, modifications) -> modifications.setFloat("speed", 1f)), + SHIELD_FLASH(ImmutableSet.of("SHIELD"), (upgrade, modifications) -> modifications.setBoolean("flash", true)), + SHIELD_SHOCK(ImmutableSet.of("SHIELD"), (upgrade, modifications) -> modifications.setBoolean("shock", true)), + SHIELD_MAGNET(ImmutableSet.of("SHIELD"), (upgrade, modifications) -> modifications.setBoolean("magnet", true)), + CHEMTHROWER_MULTITANK(ImmutableSet.of("CHEMTHROWER"), 1, (target, upgrade) -> !((IUpgradeableTool)target.getItem()).getUpgrades(target).hasKey("capacity"), (upgrade, modifications) -> modifications.setBoolean("multitank", true)); private ImmutableSet toolset; - private int stackSize=1; + private int stackSize = 1; private BiPredicate applyCheck; private BiConsumer function; + ToolUpgrades(ImmutableSet toolset, BiConsumer function) { this(toolset, 1, function); } + ToolUpgrades(ImmutableSet toolset, int stackSize, BiConsumer function) { this(toolset, stackSize, null, function); } + ToolUpgrades(ImmutableSet toolset, int stackSize, BiPredicate applyCheck, BiConsumer function) { this.toolset = toolset; @@ -72,13 +76,14 @@ public enum ToolUpgrades static String[] parse() { String[] ret = new String[values().length]; - for(int i=0; i=0&&meta= 0&&meta < values().length) return values()[meta]; return DRILL_WATERPROOF; } @@ -92,13 +97,14 @@ public ItemToolUpgrade() @Override public void addInformation(ItemStack stack, @Nullable World world, List list, ITooltipFlag flag) { - if(stack.getItemDamage() getUpgradeTypes(ItemStack upgrade) public boolean canApplyUpgrades(ItemStack target, ItemStack upgrade) { BiPredicate check = ToolUpgrades.get(upgrade.getMetadata()).applyCheck; - if(check!=null && target.getItem() instanceof IUpgradeableTool) + if(check!=null&&target.getItem() instanceof IUpgradeableTool) return check.test(target, upgrade); return true; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemToolbox.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemToolbox.java index 02047032f3..565d992520 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemToolbox.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemToolbox.java @@ -33,12 +33,14 @@ public class ItemToolbox extends ItemInternalStorage implements IGuiItem { public static final int SLOT_COUNT = 23; + public ItemToolbox() { super("toolbox", 1); ToolboxHandler.addToolType(new Predicate() { final Set set = Sets.newHashSet(Config.IEConfig.Tools.toolbox_tools); + @Override public boolean test(ItemStack stack) { @@ -48,6 +50,7 @@ public boolean test(ItemStack stack) ToolboxHandler.addFoodType(new Predicate() { final Set set = Sets.newHashSet(Config.IEConfig.Tools.toolbox_foods); + @Override public boolean test(ItemStack stack) { @@ -57,6 +60,7 @@ public boolean test(ItemStack stack) ToolboxHandler.addWiringType(new BiPredicate() { final Set set = Sets.newHashSet(Config.IEConfig.Tools.toolbox_wiring); + @Override public boolean test(ItemStack stack, World world) { @@ -76,7 +80,7 @@ public ActionResult onItemRightClick(World world, EntityPlayer player { ItemStack stack = player.getHeldItem(hand); if(!world.isRemote) - CommonProxy.openGuiForItem(player, hand==EnumHand.MAIN_HAND? EntityEquipmentSlot.MAINHAND:EntityEquipmentSlot.OFFHAND); + CommonProxy.openGuiForItem(player, hand==EnumHand.MAIN_HAND?EntityEquipmentSlot.MAINHAND: EntityEquipmentSlot.OFFHAND); return new ActionResult<>(EnumActionResult.SUCCESS, stack); } @@ -91,15 +95,15 @@ public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos if(!block.isReplaceable(world, pos)) pos = pos.offset(side); - if(stack.getCount() != 0 && player.canPlayerEdit(pos, side, stack) && world.mayPlace(IEContent.blockMetalDecoration2, pos, false, side, null)) + if(stack.getCount()!=0&&player.canPlayerEdit(pos, side, stack)&&world.mayPlace(IEContent.blockMetalDecoration2, pos, false, side, null)) { IBlockState toolbox = IEContent.blockMetalDecoration2.getStateFromMeta(BlockTypes_MetalDecoration2.TOOLBOX.getMeta()); if(world.setBlockState(pos, toolbox, 3)) { - IEContent.blockMetalDecoration2.onIEBlockPlacedBy(world, pos, toolbox, side, hitX,hitY,hitZ, player, stack); + IEContent.blockMetalDecoration2.onIEBlockPlacedBy(world, pos, toolbox, side, hitX, hitY, hitZ, player, stack); SoundType soundtype = world.getBlockState(pos).getBlock().getSoundType(world.getBlockState(pos), world, pos, player); - world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); + world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume()+1.0F)/2.0F, soundtype.getPitch()*0.8F); stack.shrink(1); } return EnumActionResult.SUCCESS; diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemUpgradeableTool.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemUpgradeableTool.java index c92badc138..b65cf506e3 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemUpgradeableTool.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemUpgradeableTool.java @@ -27,7 +27,7 @@ public abstract class ItemUpgradeableTool extends ItemInternalStorage implements public ItemUpgradeableTool(String name, int stackSize, String upgradeType, String... subNames) { super(name, stackSize, subNames); - this.upgradeType=upgradeType; + this.upgradeType = upgradeType; } @Override @@ -41,11 +41,13 @@ public NBTTagCompound getUpgrades(ItemStack stack) { return ItemNBTHelper.getTagCompound(stack, "upgrades"); } + @Override public void clearUpgrades(ItemStack stack) { ItemNBTHelper.remove(stack, "upgrades"); } + @Override public void finishUpgradeRecalculation(ItemStack stack) { @@ -57,15 +59,15 @@ public void recalculateUpgrades(ItemStack stack) clearUpgrades(stack); IItemHandler inv = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); NBTTagCompound upgradeTag = getUpgradeBase(stack).copy(); - if (inv!=null) + if(inv!=null) { - for (int i = 0; i < inv.getSlots(); i++) + for(int i = 0; i < inv.getSlots(); i++) { ItemStack u = inv.getStackInSlot(i); - if (!u.isEmpty() && u.getItem() instanceof IUpgrade) + if(!u.isEmpty()&&u.getItem() instanceof IUpgrade) { - IUpgrade upg = (IUpgrade) u.getItem(); - if (upg.getUpgradeTypes(u).contains(upgradeType) && upg.canApplyUpgrades(stack, u)) + IUpgrade upg = (IUpgrade)u.getItem(); + if(upg.getUpgradeTypes(u).contains(upgradeType)&&upg.canApplyUpgrades(stack, u)) upg.applyUpgrades(stack, u, upgradeTag); } } @@ -73,15 +75,18 @@ public void recalculateUpgrades(ItemStack stack) finishUpgradeRecalculation(stack); } } + public NBTTagCompound getUpgradeBase(ItemStack stack) { return new NBTTagCompound(); } + @Override public boolean canTakeFromWorkbench(ItemStack stack) { return true; } + @Override public void removeFromWorkbench(EntityPlayer player, ItemStack stack) { @@ -89,6 +94,7 @@ public void removeFromWorkbench(EntityPlayer player, ItemStack stack) @Override public abstract boolean canModify(ItemStack stack); + @Override public abstract Slot[] getWorkbenchSlots(Container container, ItemStack stack); } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/items/ItemWireCoil.java b/src/main/java/blusunrize/immersiveengineering/common/items/ItemWireCoil.java index 6625c11414..751d4f4b46 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/items/ItemWireCoil.java +++ b/src/main/java/blusunrize/immersiveengineering/common/items/ItemWireCoil.java @@ -8,39 +8,23 @@ package blusunrize.immersiveengineering.common.items; -import blusunrize.immersiveengineering.ImmersiveEngineering; import blusunrize.immersiveengineering.api.ApiUtils; import blusunrize.immersiveengineering.api.Lib; -import blusunrize.immersiveengineering.api.TargetingInfo; -import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable; import blusunrize.immersiveengineering.api.energy.wires.IWireCoil; -import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler; -import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection; import blusunrize.immersiveengineering.api.energy.wires.WireType; -import blusunrize.immersiveengineering.common.IESaveData; -import blusunrize.immersiveengineering.common.util.ItemNBTHelper; -import blusunrize.immersiveengineering.common.util.Utils; -import net.minecraft.block.state.IBlockState; import net.minecraft.client.resources.I18n; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; -import net.minecraft.util.math.Vec3i; -import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.util.HashSet; import java.util.List; -import java.util.Set; public class ItemWireCoil extends ItemIEBase implements IWireCoil @@ -79,20 +63,21 @@ public WireType getWireType(ItemStack stack) @Override public void addInformation(ItemStack stack, @Nullable World world, List list, ITooltipFlag flag) { - if(stack.getItemDamage() == 5) + if(stack.getItemDamage()==5) { - list.add(I18n.format(Lib.DESC_FLAVOUR + "coil.redstone")); - list.add(I18n.format(Lib.DESC_FLAVOUR + "coil.construction1")); - } else if(stack.getItemDamage()%6 > 2) + list.add(I18n.format(Lib.DESC_FLAVOUR+"coil.redstone")); + list.add(I18n.format(Lib.DESC_FLAVOUR+"coil.construction1")); + } + else if(stack.getItemDamage()%6 > 2) { list.add(I18n.format(Lib.DESC_FLAVOUR+"coil.construction0")); list.add(I18n.format(Lib.DESC_FLAVOUR+"coil.construction1")); } - if(stack.getTagCompound()!=null && stack.getTagCompound().hasKey("linkingPos")) + if(stack.getTagCompound()!=null&&stack.getTagCompound().hasKey("linkingPos")) { int[] link = stack.getTagCompound().getIntArray("linkingPos"); - if(link!=null&&link.length>3) - list.add(I18n.format(Lib.DESC_INFO+"attachedToDim", link[1],link[2],link[3],link[0])); + if(link!=null&&link.length > 3) + list.add(I18n.format(Lib.DESC_INFO+"attachedToDim", link[1], link[2], link[3], link[0])); } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/ChatUtils.java b/src/main/java/blusunrize/immersiveengineering/common/util/ChatUtils.java index abee31a2d4..65fc4a60f2 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/ChatUtils.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/ChatUtils.java @@ -27,16 +27,16 @@ public class ChatUtils public static void sendClientNoSpamMessages(ITextComponent[] messages) { GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI(); - for(int i=DELETION_ID+messages.length-1; i<=lastAdded; i++) + for(int i = DELETION_ID+messages.length-1; i <= lastAdded; i++) chat.deleteChatLine(i); - for(int i=0; i0 && player instanceof EntityPlayerMP) + if(messages.length > 0&&player instanceof EntityPlayerMP) ImmersiveEngineering.packetHandler.sendTo(new MessageNoSpamChatComponents(messages), (EntityPlayerMP)player); } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/EnergyHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/EnergyHelper.java index 5a0870d3cb..131ece6557 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/EnergyHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/EnergyHelper.java @@ -34,6 +34,7 @@ public static boolean isFluxItem(ItemStack stack) return true; return stack.hasCapability(CapabilityEnergy.ENERGY, null); } + public static int getEnergyStored(ItemStack stack) { if(stack.isEmpty()) @@ -44,6 +45,7 @@ public static int getEnergyStored(ItemStack stack) return stack.getCapability(CapabilityEnergy.ENERGY, null).getEnergyStored(); return 0; } + public static int getMaxEnergyStored(ItemStack stack) { if(stack.isEmpty()) @@ -54,6 +56,7 @@ public static int getMaxEnergyStored(ItemStack stack) return stack.getCapability(CapabilityEnergy.ENERGY, null).getMaxEnergyStored(); return 0; } + public static int insertFlux(ItemStack stack, int energy, boolean simulate) { if(stack.isEmpty()) @@ -64,6 +67,7 @@ public static int insertFlux(ItemStack stack, int energy, boolean simulate) return stack.getCapability(CapabilityEnergy.ENERGY, null).receiveEnergy(energy, simulate); return 0; } + public static int extractFlux(ItemStack stack, int energy, boolean simulate) { if(stack.isEmpty()) @@ -74,7 +78,9 @@ public static int extractFlux(ItemStack stack, int energy, boolean simulate) return stack.getCapability(CapabilityEnergy.ENERGY, null).extractEnergy(energy, simulate); return 0; } - static HashMap reverseInsertion = new HashMap(); + + static HashMap reverseInsertion = new HashMap(); + public static int forceExtractFlux(ItemStack stack, int energy, boolean simulate) { if(stack.isEmpty()) @@ -95,7 +101,7 @@ public static int forceExtractFlux(ItemStack stack, int energy, boolean simulate insertFlux(stack, -energy, simulate); drawn = stored-getEnergyStored(stack); //if reverse insertion was succesful, it'll be the default approach in future - reverseInsertion.put(stack.getItem(),drawn>0?Boolean.TRUE:Boolean.FALSE); + reverseInsertion.put(stack.getItem(), drawn > 0?Boolean.TRUE: Boolean.FALSE); } return drawn; } @@ -103,9 +109,9 @@ public static int forceExtractFlux(ItemStack stack, int energy, boolean simulate public static boolean isFluxReceiver(TileEntity tile, EnumFacing facing) { - if(tile == null) + if(tile==null) return false; - if(tile instanceof IFluxReceiver && ((IFluxReceiver)tile).canConnectEnergy(facing)) + if(tile instanceof IFluxReceiver&&((IFluxReceiver)tile).canConnectEnergy(facing)) return true; if(tile.hasCapability(CapabilityEnergy.ENERGY, facing)) return tile.getCapability(CapabilityEnergy.ENERGY, facing).canReceive(); @@ -114,9 +120,9 @@ public static boolean isFluxReceiver(TileEntity tile, EnumFacing facing) public static int insertFlux(TileEntity tile, EnumFacing facing, int energy, boolean simulate) { - if(tile == null) + if(tile==null) return 0; - if(tile instanceof IFluxReceiver && ((IFluxReceiver)tile).canConnectEnergy(facing)) + if(tile instanceof IFluxReceiver&&((IFluxReceiver)tile).canConnectEnergy(facing)) return ((IFluxReceiver)tile).receiveEnergy(facing, energy, simulate); if(tile.hasCapability(CapabilityEnergy.ENERGY, facing)) return tile.getCapability(CapabilityEnergy.ENERGY, facing).receiveEnergy(energy, simulate); @@ -125,7 +131,8 @@ public static int insertFlux(TileEntity tile, EnumFacing facing, int energy, boo public interface IIEInternalFluxHandler extends IIEInternalFluxConnector, IFluxReceiver, IFluxProvider { - @Nonnull FluxStorage getFluxStorage(); + @Nonnull + FluxStorage getFluxStorage(); default void postEnergyTransferUpdate(int energy, boolean simulate) { @@ -135,7 +142,7 @@ default void postEnergyTransferUpdate(int energy, boolean simulate) @Override default int extractEnergy(@Nullable EnumFacing fd, int amount, boolean simulate) { - if(((TileEntity)this).getWorld().isRemote || getEnergySideConfig(fd) != SideConfig.OUTPUT) + if(((TileEntity)this).getWorld().isRemote||getEnergySideConfig(fd)!=SideConfig.OUTPUT) return 0; int r = getFluxStorage().extractEnergy(amount, simulate); postEnergyTransferUpdate(-r, simulate); @@ -157,7 +164,7 @@ default int getMaxEnergyStored(@Nullable EnumFacing fd) @Override default int receiveEnergy(@Nullable EnumFacing fd, int amount, boolean simulate) { - if(((TileEntity)this).getWorld().isRemote || getEnergySideConfig(fd) != SideConfig.INPUT) + if(((TileEntity)this).getWorld().isRemote||getEnergySideConfig(fd)!=SideConfig.INPUT) return 0; int r = getFluxStorage().receiveEnergy(amount, simulate); postEnergyTransferUpdate(r, simulate); @@ -167,12 +174,13 @@ default int receiveEnergy(@Nullable EnumFacing fd, int amount, boolean simulate) public interface IIEInternalFluxConnector extends IFluxConnection { - @Nonnull SideConfig getEnergySideConfig(@Nullable EnumFacing facing); + @Nonnull + SideConfig getEnergySideConfig(@Nullable EnumFacing facing); @Override default boolean canConnectEnergy(@Nullable EnumFacing fd) { - return getEnergySideConfig(fd) != SideConfig.NONE; + return getEnergySideConfig(fd)!=SideConfig.NONE; } IEForgeEnergyWrapper getCapabilityWrapper(EnumFacing facing); @@ -257,11 +265,13 @@ default int receiveEnergy(ItemStack container, int energy, boolean simulate) { return ItemNBTHelper.insertFluxItem(container, energy, getMaxEnergyStored(container), simulate); } + @Override default int extractEnergy(ItemStack container, int energy, boolean simulate) { return ItemNBTHelper.extractFluxFromItem(container, energy, simulate); } + @Override default int getEnergyStored(ItemStack container) { @@ -276,7 +286,7 @@ public static class ItemEnergyStorage implements IEnergyStorage public ItemEnergyStorage(ItemStack item) { - assert(item.getItem() instanceof IIEEnergyItem); + assert (item.getItem() instanceof IIEEnergyItem); this.stack = item; this.ieEnergyItem = (IIEEnergyItem)item.getItem(); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/FakePlayerUtil.java b/src/main/java/blusunrize/immersiveengineering/common/util/FakePlayerUtil.java index 1424fc2e3f..9b6e516069 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/FakePlayerUtil.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/FakePlayerUtil.java @@ -19,12 +19,12 @@ public class FakePlayerUtil { private static GameProfile IE_PROFILE = new GameProfile(UUID.fromString("99562b85-bd1a-4ded-bb1a-c307bf0c0133"), "[ImmersiveEngineering]"); private static FakePlayer fakePlayerInstance; - + public static FakePlayer getFakePlayer(WorldServer world) - { + { if(fakePlayerInstance==null) fakePlayerInstance = FakePlayerFactory.get(world, IE_PROFILE); return fakePlayerInstance; - } - + } + } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/IEDamageSources.java b/src/main/java/blusunrize/immersiveengineering/common/util/IEDamageSources.java index 21615f497b..ac732f7322 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/IEDamageSources.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/IEDamageSources.java @@ -15,17 +15,12 @@ import blusunrize.immersiveengineering.common.entities.EntityRevolvershot; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.inventory.EntityEquipmentSlot; -import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.util.EntityDamageSource; import net.minecraft.util.EntityDamageSourceIndirect; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentTranslation; -import java.util.HashMap; -import java.util.Map; - public class IEDamageSources { public static class IEDamageSource_Indirect extends EntityDamageSourceIndirect @@ -35,6 +30,7 @@ public IEDamageSource_Indirect(String tag, Entity shot, Entity shooter) super(tag, shot, shooter); } } + public static class IEDamageSource_Direct extends EntityDamageSource { public IEDamageSource_Direct(String tag, Entity attacker) @@ -42,6 +38,7 @@ public IEDamageSource_Direct(String tag, Entity attacker) super(tag, attacker); } } + public static class IEDamageSource extends DamageSource { public IEDamageSource(String tag) @@ -49,10 +46,12 @@ public IEDamageSource(String tag) super(tag); } } + public static class ElectricDamageSource extends DamageSource { public IElectricEquipment.ElectricSource source; public float dmg; + public ElectricDamageSource(String tag, IElectricEquipment.ElectricSource source, float amount) { super(tag); @@ -60,21 +59,24 @@ public ElectricDamageSource(String tag, IElectricEquipment.ElectricSource source dmg = amount; setDamageBypassesArmor(); } + public boolean apply(Entity e) { - if (e instanceof EntityLivingBase) + if(e instanceof EntityLivingBase) IElectricEquipment.applyToEntity((EntityLivingBase)e, this, source); - if (dmg>0) + if(dmg > 0) e.attackEntityFrom(this, dmg); - return dmg>0; + return dmg > 0; } } + public static class TurretDamageSource extends IEDamageSource { public TurretDamageSource(String damageTypeIn) { super(damageTypeIn); } + @Override public ITextComponent getDeathMessage(EntityLivingBase entityLivingBaseIn) { @@ -89,36 +91,42 @@ public static DamageSource causeCasullDamage(EntityRevolvershot shot, Entity sho return new TurretDamageSource(Lib.DMG_RevolverCasull); return new IEDamageSource_Indirect(Lib.DMG_RevolverCasull, shot, shooter); } + public static DamageSource causePiercingDamage(EntityRevolvershot shot, Entity shooter) { if(shooter==null) return new TurretDamageSource(Lib.DMG_RevolverAP).setDamageBypassesArmor(); return new IEDamageSource_Indirect(Lib.DMG_RevolverAP, shot, shooter).setDamageBypassesArmor(); } + public static DamageSource causeBuckshotDamage(EntityRevolvershot shot, Entity shooter) { if(shooter==null) return new TurretDamageSource(Lib.DMG_RevolverBuck); return new IEDamageSource_Indirect(Lib.DMG_RevolverBuck, shot, shooter); } + public static DamageSource causeDragonsbreathDamage(EntityRevolvershot shot, Entity shooter) { if(shooter==null) return new TurretDamageSource(Lib.DMG_RevolverDragon).setFireDamage(); return new IEDamageSource_Indirect(Lib.DMG_RevolverDragon, shot, shooter).setFireDamage(); } + public static DamageSource causeHomingDamage(EntityRevolvershot shot, Entity shooter) { if(shooter==null) return new TurretDamageSource(Lib.DMG_RevolverHoming); return new IEDamageSource_Indirect(Lib.DMG_RevolverHoming, shot, shooter); } + public static DamageSource causeWolfpackDamage(EntityRevolvershot shot, Entity shooter) { if(shooter==null) return new TurretDamageSource(Lib.DMG_RevolverWolfpack); return new IEDamageSource_Indirect(Lib.DMG_RevolverWolfpack, shot, shooter); } + public static DamageSource causeSilverDamage(EntityRevolvershot shot, Entity shooter) { if(shooter==null) @@ -146,9 +154,10 @@ public static DamageSource causePotionDamage(EntityRevolvershot shot, Entity sho private static final IElectricEquipment.ElectricSource TC_LOW = new IElectricEquipment.ElectricSource(.25F); private static final IElectricEquipment.ElectricSource TC_HIGH = new IElectricEquipment.ElectricSource(2); + public static ElectricDamageSource causeTeslaDamage(float amount, boolean lowPower) { - return new ElectricDamageSource(Lib.DMG_Tesla, lowPower?TC_LOW:TC_HIGH, amount); + return new ElectricDamageSource(Lib.DMG_Tesla, lowPower?TC_LOW: TC_HIGH, amount); } public static ElectricDamageSource causeWireDamage(float amount, IElectricEquipment.ElectricSource source) @@ -160,7 +169,9 @@ public static DamageSource causeRailgunDamage(EntityRailgunShot shot, Entity sho { return new IEDamageSource_Indirect(Lib.DMG_Railgun, shot, shooter).setDamageBypassesArmor(); } - public static DamageSource causeTeslaPrimaryDamage() { + + public static DamageSource causeTeslaPrimaryDamage() + { return new IEDamageSource(Lib.DMG_Tesla_prim).setDamageBypassesArmor(); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/IEExplosion.java b/src/main/java/blusunrize/immersiveengineering/common/util/IEExplosion.java index c46606fbc9..b7ce0761be 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/IEExplosion.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/IEExplosion.java @@ -35,26 +35,27 @@ public class IEExplosion extends Explosion { - public float dropChance=1; + public float dropChance = 1; private int blockDestroyInt = 0; public int blocksPerTick = 8; public boolean isExplosionFinished = false; - + public IEExplosion(World world, Entity igniter, double x, double y, double z, float size, boolean isFlaming, boolean isSmoking) { super(world, igniter, x, y, z, size, isFlaming, isSmoking); this.dropChance = 1/this.size; } + public IEExplosion setDropChance(float chance) { this.dropChance = chance; return this; } - + public void doExplosionTick() { int max = Math.min(blockDestroyInt+blocksPerTick, this.affectedBlockPositions.size()); - for(;blockDestroyInt=this.affectedBlockPositions.size()) + if(blockDestroyInt >= this.affectedBlockPositions.size()) this.isExplosionFinished = true; } @Override - public void doExplosionA() - { - Set set = Sets.newHashSet(); - int i = 16; - - for (int j = 0; j < 16; ++j) - for (int k = 0; k < 16; ++k) - for (int l = 0; l < 16; ++l) - if(j == 0 || j == 15 || k == 0 || k == 15 || l == 0 || l == 15) - { - double d0 = (double)((float)j / 15.0F * 2.0F - 1.0F); - double d1 = (double)((float)k / 15.0F * 2.0F - 1.0F); - double d2 = (double)((float)l / 15.0F * 2.0F - 1.0F); - double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2); - d0 = d0 / d3; - d1 = d1 / d3; - d2 = d2 / d3; - float f = this.size * (0.7F + Utils.RAND.nextFloat() * 0.6F); - double d4 = this.x; - double d6 = this.y; - double d8 = this.z; - - for(float f1 = 0.3F; f > 0.0F; f -= 0.22500001F) - { - BlockPos blockpos = new BlockPos(d4, d6, d8); - IBlockState iblockstate = this.world.getBlockState(blockpos); - - if (iblockstate.getMaterial() != Material.AIR) - { - float f2 = this.exploder != null ? this.exploder.getExplosionResistance(this, this.world, blockpos, iblockstate) : iblockstate.getBlock().getExplosionResistance(world, blockpos, null, this); - f -= (f2 + 0.3F) * 0.3F; - } - - if (f > 0.0F && (this.exploder == null || this.exploder.canExplosionDestroyBlock(this, this.world, blockpos, iblockstate, f))) - set.add(blockpos); - - d4 += d0 * 0.30000001192092896D; - d6 += d1 * 0.30000001192092896D; - d8 += d2 * 0.30000001192092896D; - } - } - - this.affectedBlockPositions.addAll(set); - Collections.sort(this.affectedBlockPositions, new Comparator(){ + public void doExplosionA() + { + Set set = Sets.newHashSet(); + int i = 16; + + for(int j = 0; j < 16; ++j) + for(int k = 0; k < 16; ++k) + for(int l = 0; l < 16; ++l) + if(j==0||j==15||k==0||k==15||l==0||l==15) + { + double d0 = (double)((float)j/15.0F*2.0F-1.0F); + double d1 = (double)((float)k/15.0F*2.0F-1.0F); + double d2 = (double)((float)l/15.0F*2.0F-1.0F); + double d3 = Math.sqrt(d0*d0+d1*d1+d2*d2); + d0 = d0/d3; + d1 = d1/d3; + d2 = d2/d3; + float f = this.size*(0.7F+Utils.RAND.nextFloat()*0.6F); + double d4 = this.x; + double d6 = this.y; + double d8 = this.z; + + for(float f1 = 0.3F; f > 0.0F; f -= 0.22500001F) + { + BlockPos blockpos = new BlockPos(d4, d6, d8); + IBlockState iblockstate = this.world.getBlockState(blockpos); + + if(iblockstate.getMaterial()!=Material.AIR) + { + float f2 = this.exploder!=null?this.exploder.getExplosionResistance(this, this.world, blockpos, iblockstate): iblockstate.getBlock().getExplosionResistance(world, blockpos, null, this); + f -= (f2+0.3F)*0.3F; + } + + if(f > 0.0F&&(this.exploder==null||this.exploder.canExplosionDestroyBlock(this, this.world, blockpos, iblockstate, f))) + set.add(blockpos); + + d4 += d0*0.30000001192092896D; + d6 += d1*0.30000001192092896D; + d8 += d2*0.30000001192092896D; + } + } + + this.affectedBlockPositions.addAll(set); + Collections.sort(this.affectedBlockPositions, new Comparator() + { @Override public int compare(BlockPos arg0, BlockPos arg1) { - return Double.compare(arg0.distanceSq(x,y,z), arg1.distanceSq(x,y,z)); + return Double.compare(arg0.distanceSq(x, y, z), arg1.distanceSq(x, y, z)); } - }); - - float f3 = this.size * 2.0F; - int k1 = MathHelper.floor(this.x - (double)f3 - 1.0D); - int l1 = MathHelper.floor(this.x + (double)f3 + 1.0D); - int i2 = MathHelper.floor(this.y - (double)f3 - 1.0D); - int i1 = MathHelper.floor(this.y + (double)f3 + 1.0D); - int j2 = MathHelper.floor(this.z - (double)f3 - 1.0D); - int j1 = MathHelper.floor(this.z + (double)f3 + 1.0D); - List list = this.world.getEntitiesWithinAABBExcludingEntity(this.exploder, new AxisAlignedBB((double)k1, (double)i2, (double)j2, (double)l1, (double)i1, (double)j1)); - net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate(this.world, this, list, f3); - Vec3d vec3 = new Vec3d(this.x, this.y, this.z); - - for(int k2 = 0; k2 < list.size(); ++k2) - { - Entity entity = list.get(k2); - if(!entity.isImmuneToExplosions()) - { - double d12 = entity.getDistance(this.x, this.y, this.z) / (double)f3; - if(d12 <= 1.0D) - { - double d5 = entity.posX - this.x; - double d7 = entity.posY + (double)entity.getEyeHeight() - this.y; - double d9 = entity.posZ - this.z; - double d13 = (double) MathHelper.sqrt(d5 * d5 + d7 * d7 + d9 * d9); - if(d13 != 0.0D) - { - d5 = d5 / d13; - d7 = d7 / d13; - d9 = d9 / d13; - double d14 = (double)this.world.getBlockDensity(vec3, entity.getEntityBoundingBox()); - double d10 = (1.0D - d12) * d14; - entity.attackEntityFrom(DamageSource.causeExplosionDamage(this), (float)((int)((d10 * d10 + d10) / 2.0D * 8.0D * (double)f3 + 1.0D))); - double d11 = entity instanceof EntityLivingBase?EnchantmentProtection.getBlastDamageReduction((EntityLivingBase)entity, d10):d10; - entity.motionX += d5 * d11; - entity.motionY += d7 * d11; - entity.motionZ += d9 * d11; - if (entity instanceof EntityPlayer && !((EntityPlayer)entity).capabilities.disableDamage) - this.playerKnockbackMap.put((EntityPlayer)entity, new Vec3d(d5 * d10, d7 * d10, d9 * d10)); - } - } - } - } - } + }); + + float f3 = this.size*2.0F; + int k1 = MathHelper.floor(this.x-(double)f3-1.0D); + int l1 = MathHelper.floor(this.x+(double)f3+1.0D); + int i2 = MathHelper.floor(this.y-(double)f3-1.0D); + int i1 = MathHelper.floor(this.y+(double)f3+1.0D); + int j2 = MathHelper.floor(this.z-(double)f3-1.0D); + int j1 = MathHelper.floor(this.z+(double)f3+1.0D); + List list = this.world.getEntitiesWithinAABBExcludingEntity(this.exploder, new AxisAlignedBB((double)k1, (double)i2, (double)j2, (double)l1, (double)i1, (double)j1)); + net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate(this.world, this, list, f3); + Vec3d vec3 = new Vec3d(this.x, this.y, this.z); + + for(int k2 = 0; k2 < list.size(); ++k2) + { + Entity entity = list.get(k2); + if(!entity.isImmuneToExplosions()) + { + double d12 = entity.getDistance(this.x, this.y, this.z)/(double)f3; + if(d12 <= 1.0D) + { + double d5 = entity.posX-this.x; + double d7 = entity.posY+(double)entity.getEyeHeight()-this.y; + double d9 = entity.posZ-this.z; + double d13 = (double)MathHelper.sqrt(d5*d5+d7*d7+d9*d9); + if(d13!=0.0D) + { + d5 = d5/d13; + d7 = d7/d13; + d9 = d9/d13; + double d14 = (double)this.world.getBlockDensity(vec3, entity.getEntityBoundingBox()); + double d10 = (1.0D-d12)*d14; + entity.attackEntityFrom(DamageSource.causeExplosionDamage(this), (float)((int)((d10*d10+d10)/2.0D*8.0D*(double)f3+1.0D))); + double d11 = entity instanceof EntityLivingBase?EnchantmentProtection.getBlastDamageReduction((EntityLivingBase)entity, d10): d10; + entity.motionX += d5*d11; + entity.motionY += d7*d11; + entity.motionZ += d9*d11; + if(entity instanceof EntityPlayer&&!((EntityPlayer)entity).capabilities.disableDamage) + this.playerKnockbackMap.put((EntityPlayer)entity, new Vec3d(d5*d10, d7*d10, d9*d10)); + } + } + } + } + } + @Override public void doExplosionB(boolean spawnParticles) { - this.world.playSound(this.x, this.y, this.z, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.NEUTRAL, 4.0F, (1.0F + (Utils.RAND.nextFloat() - Utils.RAND.nextFloat()) * 0.2F) * 0.7F, true); + this.world.playSound(this.x, this.y, this.z, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.NEUTRAL, 4.0F, (1.0F+(Utils.RAND.nextFloat()-Utils.RAND.nextFloat())*0.2F)*0.7F, true); - if(this.size >= 2.0F && this.damagesTerrain) + if(this.size >= 2.0F&&this.damagesTerrain) this.world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, this.x, this.y, this.z, 1.0D, 0.0D, 0.0D); else this.world.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.x, this.y, this.z, 1.0D, 0.0D, 0.0D); diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/IEFluid.java b/src/main/java/blusunrize/immersiveengineering/common/util/IEFluid.java index 07777e8e99..c7d21cecb6 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/IEFluid.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/IEFluid.java @@ -55,7 +55,7 @@ public FluidPotion(String fluidName, ResourceLocation still, ResourceLocation fl @SideOnly(Side.CLIENT) public void addTooltipInfo(FluidStack fluidStack, @Nullable EntityPlayer player, List tooltip) { - if(fluidStack!=null && fluidStack.tag!=null) + if(fluidStack!=null&&fluidStack.tag!=null) { List effects = PotionUtils.getEffectsFromTag(fluidStack.tag); if(effects.isEmpty()) @@ -67,10 +67,10 @@ public void addTooltipInfo(FluidStack fluidStack, @Nullable EntityPlayer player, String s1 = I18n.translateToLocal(potioneffect.getEffectName()).trim(); Potion potion = potioneffect.getPotion(); - if(potioneffect.getAmplifier()>0) + if(potioneffect.getAmplifier() > 0) s1 = s1+" "+I18n.translateToLocal("potion.potency."+potioneffect.getAmplifier()).trim(); - if(potioneffect.getDuration()>20) + if(potioneffect.getDuration() > 20) s1 = s1+" ("+Potion.getPotionDurationString(potioneffect, 1)+")"; if(potion.isBadEffect()) @@ -85,7 +85,7 @@ public void addTooltipInfo(FluidStack fluidStack, @Nullable EntityPlayer player, @Override public String getLocalizedName(FluidStack stack) { - if(stack==null || stack.tag==null) + if(stack==null||stack.tag==null) return super.getLocalizedName(stack); return I18n.translateToLocal(PotionUtils.getPotionTypeFromNBT(stack.tag).getNamePrefixed("potion.effect.")); } @@ -93,8 +93,8 @@ public String getLocalizedName(FluidStack stack) @Override public int getColor(FluidStack stack) { - if(stack==null || stack.tag!=null) - return 0xff000000 | PotionUtils.getPotionColorFromEffectList(PotionUtils.getEffectsFromTag(stack.tag)); + if(stack==null||stack.tag!=null) + return 0xff000000|PotionUtils.getPotionColorFromEffectList(PotionUtils.getEffectsFromTag(stack.tag)); return 0xff0000ff; } } @@ -109,12 +109,14 @@ public void write(PacketBuffer buf, Optional value) if(fs!=null) buf.writeCompoundTag(fs.writeToNBT(new NBTTagCompound())); } + @Override public Optional read(PacketBuffer buf) throws IOException { - FluidStack fs = !buf.readBoolean()?null : FluidStack.loadFluidStackFromNBT(buf.readCompoundTag()); + FluidStack fs = !buf.readBoolean()?null: FluidStack.loadFluidStackFromNBT(buf.readCompoundTag()); return Optional.fromNullable(fs); } + @Override public DataParameter> createKey(int id) { @@ -124,7 +126,7 @@ public DataParameter> createKey(int id) @Override public Optional copyValue(Optional value) { - return value.isPresent()?Optional.of(value.get().copy()):Optional.absent(); + return value.isPresent()?Optional.of(value.get().copy()): Optional.absent(); } }; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/IEItemFluidHandler.java b/src/main/java/blusunrize/immersiveengineering/common/util/IEItemFluidHandler.java index 6a04d93a80..6fa3f7bf6c 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/IEItemFluidHandler.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/IEItemFluidHandler.java @@ -43,17 +43,17 @@ public boolean canFillFluidType(FluidStack fluid) @Override public IFluidTankProperties[] getTankProperties() { - return new FluidTankProperties[] { new FluidTankProperties(getFluid(), getCapacity()) }; + return new FluidTankProperties[]{new FluidTankProperties(getFluid(), getCapacity())}; } @Override public int fill(FluidStack resource, boolean doFill) { - if(container.getCount() != 1 || resource == null || resource.amount <= 0 || !canFillFluidType(resource)) + if(container.getCount()!=1||resource==null||resource.amount <= 0||!canFillFluidType(resource)) return 0; FluidStack contained = getFluid(); - if(contained == null) + if(contained==null) { int fillAmount = Math.min(getCapacity(), resource.amount); if(doFill) @@ -69,7 +69,7 @@ public int fill(FluidStack resource, boolean doFill) if(contained.isFluidEqual(resource)) { int fillAmount = Math.min(getCapacity()-contained.amount, resource.amount); - if (doFill && fillAmount > 0) + if(doFill&&fillAmount > 0) { contained.amount += fillAmount; setFluid(contained); diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/IELootEntry.java b/src/main/java/blusunrize/immersiveengineering/common/util/IELootEntry.java index 9c053c6175..b8e630e98b 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/IELootEntry.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/IELootEntry.java @@ -36,7 +36,9 @@ public class IELootEntry extends LootEntryItem { public static LootFunction blueprintRename; - static{ + + static + { NBTTagCompound tag = new NBTTagCompound(); tag.setTag("display", new NBTTagCompound()); tag.getCompoundTag("display").setString("name", "Super Special BluPrintz"); @@ -61,9 +63,9 @@ static LootFunction[] buildFunctions(ItemStack stack, LootFunction[] functions) for(LootFunction f : functions) totalFunctions.add(f); if(stack.getMetadata()!=0) - totalFunctions.add(new SetMetadata(new LootCondition[0], new RandomValueRange(stack.getMetadata(),stack.getMetadata()))); + totalFunctions.add(new SetMetadata(new LootCondition[0], new RandomValueRange(stack.getMetadata(), stack.getMetadata()))); if(stack.getCount() > 1) - totalFunctions.add(new SetCount(new LootCondition[0], new RandomValueRange(stack.getMetadata(),stack.getMetadata()))); + totalFunctions.add(new SetCount(new LootCondition[0], new RandomValueRange(stack.getMetadata(), stack.getMetadata()))); if(stack.getTagCompound()!=null) totalFunctions.add(new SetNBT(new LootCondition[0], stack.getTagCompound())); return totalFunctions.toArray(new LootFunction[totalFunctions.size()]); diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/IEPotions.java b/src/main/java/blusunrize/immersiveengineering/common/util/IEPotions.java index 902b3da469..e3ed028cc8 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/IEPotions.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/IEPotions.java @@ -35,28 +35,29 @@ public class IEPotions public static void init() { - flammable = new IEPotion(new ResourceLocation(ImmersiveEngineering.MODID, "flammable"), true,0x8f3f1f,0, false,0, true,true).setPotionName("immersiveengineering.potion.flammable"); - slippery = new IEPotion(new ResourceLocation(ImmersiveEngineering.MODID, "slippery"), true,0x171003,0, false,1, true,true).setPotionName("immersiveengineering.potion.slippery"); - conductive = new IEPotion(new ResourceLocation(ImmersiveEngineering.MODID, "conductive"), true,0x690000,0, false,2, true,true).setPotionName("immersiveengineering.potion.conductive"); - sticky = new IEPotion(new ResourceLocation(ImmersiveEngineering.MODID, "sticky"), true,0x9c6800,0, false,3, true,true).setPotionName("immersiveengineering.potion.sticky").registerPotionAttributeModifier(SharedMonsterAttributes.MOVEMENT_SPEED, Utils.generateNewUUID().toString(), -0.50000000298023224D, 2); - stunned = new IEPotion(new ResourceLocation(ImmersiveEngineering.MODID, "stunned"), true,0x624a98,0, false,4, true,true).setPotionName("immersiveengineering.potion.stunned"); - concreteFeet = new IEPotion(new ResourceLocation(ImmersiveEngineering.MODID, "concreteFeet"), true,0x624a98,0, false,5, true,true).setPotionName("immersiveengineering.potion.concreteFeet").registerPotionAttributeModifier(SharedMonsterAttributes.MOVEMENT_SPEED, Utils.generateNewUUID().toString(), -2D, 2); - flashed = new IEPotion(new ResourceLocation(ImmersiveEngineering.MODID, "flashed"), true,0x624a98,0, false,6, true,true).setPotionName("immersiveengineering.potion.flashed").registerPotionAttributeModifier(SharedMonsterAttributes.MOVEMENT_SPEED, Utils.generateNewUUID().toString(), -0.15000000596046448D, 2); + flammable = new IEPotion(new ResourceLocation(ImmersiveEngineering.MODID, "flammable"), true, 0x8f3f1f, 0, false, 0, true, true).setPotionName("immersiveengineering.potion.flammable"); + slippery = new IEPotion(new ResourceLocation(ImmersiveEngineering.MODID, "slippery"), true, 0x171003, 0, false, 1, true, true).setPotionName("immersiveengineering.potion.slippery"); + conductive = new IEPotion(new ResourceLocation(ImmersiveEngineering.MODID, "conductive"), true, 0x690000, 0, false, 2, true, true).setPotionName("immersiveengineering.potion.conductive"); + sticky = new IEPotion(new ResourceLocation(ImmersiveEngineering.MODID, "sticky"), true, 0x9c6800, 0, false, 3, true, true).setPotionName("immersiveengineering.potion.sticky").registerPotionAttributeModifier(SharedMonsterAttributes.MOVEMENT_SPEED, Utils.generateNewUUID().toString(), -0.50000000298023224D, 2); + stunned = new IEPotion(new ResourceLocation(ImmersiveEngineering.MODID, "stunned"), true, 0x624a98, 0, false, 4, true, true).setPotionName("immersiveengineering.potion.stunned"); + concreteFeet = new IEPotion(new ResourceLocation(ImmersiveEngineering.MODID, "concreteFeet"), true, 0x624a98, 0, false, 5, true, true).setPotionName("immersiveengineering.potion.concreteFeet").registerPotionAttributeModifier(SharedMonsterAttributes.MOVEMENT_SPEED, Utils.generateNewUUID().toString(), -2D, 2); + flashed = new IEPotion(new ResourceLocation(ImmersiveEngineering.MODID, "flashed"), true, 0x624a98, 0, false, 6, true, true).setPotionName("immersiveengineering.potion.flashed").registerPotionAttributeModifier(SharedMonsterAttributes.MOVEMENT_SPEED, Utils.generateNewUUID().toString(), -0.15000000596046448D, 2); - IEApi.potions = new Potion[]{flammable,slippery,conductive,sticky,stunned,concreteFeet,flashed}; + IEApi.potions = new Potion[]{flammable, slippery, conductive, sticky, stunned, concreteFeet, flashed}; } public static class IEPotion extends Potion { - static ResourceLocation tex = new ResourceLocation("immersiveengineering","textures/gui/potioneffects.png"); + static ResourceLocation tex = new ResourceLocation("immersiveengineering", "textures/gui/potioneffects.png"); final int tickrate; final boolean halfTickRateWIthAmplifier; boolean showInInventory = true; boolean showInHud = true; + public IEPotion(ResourceLocation resource, boolean isBad, int colour, int tick, boolean halveTick, int icon, boolean showInInventory, boolean showInHud) { super(isBad, colour); - this.setPotionName("potion." + resource.getResourcePath()); + this.setPotionName("potion."+resource.getResourcePath()); this.showInInventory = showInInventory; this.showInHud = showInHud; this.tickrate = tick; @@ -71,11 +72,13 @@ public boolean shouldRender(PotionEffect effect) { return showInInventory; } + @Override public boolean shouldRenderInvText(PotionEffect effect) { return showInInventory; } + @Override public boolean shouldRenderHUD(PotionEffect effect) { @@ -88,33 +91,35 @@ public int getStatusIconIndex() Minecraft.getMinecraft().getTextureManager().bindTexture(tex); return super.getStatusIconIndex(); } + @Override public boolean isReady(int duration, int amplifier) { - if(tickrate<0) + if(tickrate < 0) return false; int k = tickrate >> amplifier; - return k <= 0 || duration % k == 0; + return k <= 0||duration%k==0; } + @Override public void performEffect(EntityLivingBase living, int amplifier) { if(this==IEPotions.slippery) { if(living.onGround) - living.moveRelative(0,0,1, 0.005F); - EntityEquipmentSlot hand = living.getRNG().nextBoolean()?EntityEquipmentSlot.MAINHAND:EntityEquipmentSlot.OFFHAND; - if(!living.world.isRemote && living.getRNG().nextInt(300)==0 && !living.getItemStackFromSlot(hand).isEmpty()) + living.moveRelative(0, 0, 1, 0.005F); + EntityEquipmentSlot hand = living.getRNG().nextBoolean()?EntityEquipmentSlot.MAINHAND: EntityEquipmentSlot.OFFHAND; + if(!living.world.isRemote&&living.getRNG().nextInt(300)==0&&!living.getItemStackFromSlot(hand).isEmpty()) { EntityItem dropped = living.entityDropItem(living.getItemStackFromSlot(hand).copy(), 1); dropped.setPickupDelay(20); living.setItemStackToSlot(hand, ItemStack.EMPTY); } } - else if(this==IEPotions.concreteFeet && !living.world.isRemote) + else if(this==IEPotions.concreteFeet&&!living.world.isRemote) { IBlockState state = living.world.getBlockState(living.getPosition()); - if(state.getBlock()!=IEContent.blockStoneDecoration && state.getBlock()!=IEContent.blockStoneDecorationSlabs && state.getBlock()!=IEContent.blockStoneDevice) + if(state.getBlock()!=IEContent.blockStoneDecoration&&state.getBlock()!=IEContent.blockStoneDecorationSlabs&&state.getBlock()!=IEContent.blockStoneDevice) { PotionEffect effect = living.getActivePotionEffect(this); if(effect!=null) diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/IESounds.java b/src/main/java/blusunrize/immersiveengineering/common/util/IESounds.java index 8b86f76c4a..8f14034d71 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/IESounds.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/IESounds.java @@ -31,7 +31,7 @@ public class IESounds public static SoundEvent revolverFire = registerSound("revolverFire"); public static SoundEvent revolverFireThump = registerSound("revolverFireThump"); public static SoundEvent revolverReload = registerSound("revolverReload"); - public static SoundEvent spray= registerSound("spray"); + public static SoundEvent spray = registerSound("spray"); public static SoundEvent sprayFire = registerSound("spray_fire"); public static SoundEvent chargeFast = registerSound("chargeFast"); public static SoundEvent chargeSlow = registerSound("chargeSlow"); @@ -49,6 +49,7 @@ private static SoundEvent registerSound(String name) registeredEvents.add(event.setRegistryName(location)); return event; } + public static void init() { for(SoundEvent event : registeredEvents) @@ -58,6 +59,6 @@ public static void init() public static void PlaySoundForPlayer(Entity player, SoundEvent sound, float volume, float pitch) { if(player instanceof EntityPlayerMP) - ((EntityPlayerMP) player).connection.sendPacket(new SPacketSoundEffect(sound, player.getSoundCategory(), player.posX, player.posY, player.posZ, volume, pitch)); + ((EntityPlayerMP)player).connection.sendPacket(new SPacketSoundEffect(sound, player.getSoundCategory(), player.posX, player.posY, player.posZ, volume, pitch)); } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/ItemNBTHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/ItemNBTHelper.java index 4ced69e279..bdf5a95b93 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/ItemNBTHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/ItemNBTHelper.java @@ -24,13 +24,15 @@ public static NBTTagCompound getTag(ItemStack stack) stack.setTagCompound(new NBTTagCompound()); return stack.getTagCompound(); } + public static boolean hasTag(ItemStack stack) { return stack.hasTagCompound(); } + public static boolean hasKey(ItemStack stack, String key) { - return hasTag(stack) && getTag(stack).hasKey(key); + return hasTag(stack)&&getTag(stack).hasKey(key); } public static void remove(ItemStack stack, String key) @@ -48,86 +50,97 @@ public static void setInt(ItemStack stack, String key, int val) { getTag(stack).setInteger(key, val); } + public static void modifyInt(ItemStack stack, String key, int mod) { modifyInt(getTag(stack), key, mod); } + public static void modifyInt(NBTTagCompound tagCompound, String key, int mod) { tagCompound.setInteger(key, tagCompound.getInteger(key)+mod); } + public static int getInt(ItemStack stack, String key) { - return hasTag(stack) ? getTag(stack).getInteger(key) : 0; + return hasTag(stack)?getTag(stack).getInteger(key): 0; } public static void setString(ItemStack stack, String key, String val) { getTag(stack).setString(key, val); } + public static String getString(ItemStack stack, String key) { - return hasTag(stack) ? getTag(stack).getString(key) : ""; + return hasTag(stack)?getTag(stack).getString(key): ""; } public static void setLong(ItemStack stack, String key, long val) { getTag(stack).setLong(key, val); } + public static long getLong(ItemStack stack, String key) { - return hasTag(stack) ? getTag(stack).getLong(key) : 0; + return hasTag(stack)?getTag(stack).getLong(key): 0; } public static void setIntArray(ItemStack stack, String key, int[] val) { getTag(stack).setIntArray(key, val); } + public static int[] getIntArray(ItemStack stack, String key) { - return hasTag(stack) ? getTag(stack).getIntArray(key) : new int[0]; + return hasTag(stack)?getTag(stack).getIntArray(key): new int[0]; } public static void setFloat(ItemStack stack, String key, float val) { getTag(stack).setFloat(key, val); } + public static void modifyFloat(NBTTagCompound tagCompound, String key, float mod) { tagCompound.setFloat(key, tagCompound.getFloat(key)+mod); } + public static float getFloat(ItemStack stack, String key) { - return hasTag(stack) ? getTag(stack).getFloat(key) : 0; + return hasTag(stack)?getTag(stack).getFloat(key): 0; } public static void setBoolean(ItemStack stack, String key, boolean val) { getTag(stack).setBoolean(key, val); } + public static boolean getBoolean(ItemStack stack, String key) { - return hasTag(stack) && getTag(stack).getBoolean(key); + return hasTag(stack)&&getTag(stack).getBoolean(key); } public static void setTagCompound(ItemStack stack, String key, NBTTagCompound val) { getTag(stack).setTag(key, val); } + public static NBTTagCompound getTagCompound(ItemStack stack, String key) { - return hasTag(stack) ? getTag(stack).getCompoundTag(key) : new NBTTagCompound(); + return hasTag(stack)?getTag(stack).getCompoundTag(key): new NBTTagCompound(); } public static void setFluidStack(ItemStack stack, String key, FluidStack val) { - if(val!=null && val.getFluid()!=null) + if(val!=null&&val.getFluid()!=null) { setTagCompound(stack, key, val.writeToNBT(new NBTTagCompound())); } else remove(stack, key); } + public static FluidStack getFluidStack(ItemStack stack, String key) { if(hasTag(stack)) @@ -141,9 +154,10 @@ public static void setItemStack(ItemStack stack, String key, ItemStack val) { getTag(stack).setTag(key, val.writeToNBT(new NBTTagCompound())); } + public static ItemStack getItemStack(ItemStack stack, String key) { - if(hasTag(stack) && getTag(stack).hasKey(key)) + if(hasTag(stack)&&getTag(stack).hasKey(key)) return new ItemStack(getTagCompound(stack, key)); return ItemStack.EMPTY; } @@ -169,6 +183,7 @@ public static int insertFluxItem(ItemStack container, int energy, int maxEnergy, } return accepted; } + public static int extractFluxFromItem(ItemStack container, int energy, boolean simulate) { int stored = getFluxStoredInItem(container); @@ -180,6 +195,7 @@ public static int extractFluxFromItem(ItemStack container, int energy, boolean s } return extracted; } + public static int getFluxStoredInItem(ItemStack container) { return getInt(container, "energy"); @@ -187,8 +203,8 @@ public static int getFluxStoredInItem(ItemStack container) public static ItemStack stackWithData(ItemStack stack, Object... data) { - assert(data.length%2==0); - for(int i=0; i fromItem(ItemStack itemStack) { - NonNullList list = NonNullList.create(); - if (itemStack != null) - { - list.add(0, itemStack); - } - return list; - } + public static NonNullList fromItem(ItemStack itemStack) + { + NonNullList list = NonNullList.create(); + if(itemStack!=null) + { + list.add(0, itemStack); + } + return list; + } - public static NonNullList fromItems(ItemStack... itemStack) { - NonNullList list = NonNullList.create(); - for (int i = 0; i < itemStack.length; i++) - { - list.add(i, itemStack[i] != null ? (itemStack[i]) : ItemStack.EMPTY); - } - return list; - } + public static NonNullList fromItems(ItemStack... itemStack) + { + NonNullList list = NonNullList.create(); + for(int i = 0; i < itemStack.length; i++) + { + list.add(i, itemStack[i]!=null?(itemStack[i]): ItemStack.EMPTY); + } + return list; + } - private ListUtils() {} + private ListUtils() + { + } - public static NonNullList fromItems(List stackList) { - NonNullList list = NonNullList.create(); - for (ItemStack itemStack : stackList) { - list.add(itemStack); - } - return list; - } + public static NonNullList fromItems(List stackList) + { + NonNullList list = NonNullList.create(); + for(ItemStack itemStack : stackList) + { + list.add(itemStack); + } + return list; + } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/RotationUtil.java b/src/main/java/blusunrize/immersiveengineering/common/util/RotationUtil.java index 8892a33cd7..bedf0648b2 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/RotationUtil.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/RotationUtil.java @@ -27,7 +27,9 @@ public class RotationUtil { public static HashSet> permittedRotation = new HashSet<>(); public static HashSet> permittedTileRotation = new HashSet<>(); - static{ + + static + { permittedRotation.add(state -> { //preventing extended pistons from rotating return !((state.getBlock()==Blocks.PISTON||state.getBlock()==Blocks.STICKY_PISTON)&&state.getValue(BlockPistonBase.EXTENDED)); @@ -55,7 +57,7 @@ public class RotationUtil if(tile instanceof TileEntityChest) { TileEntityChest chest = (TileEntityChest)tile; - return chest.adjacentChestXNeg!=null || chest.adjacentChestXPos!=null || chest.adjacentChestZNeg!=null || chest.adjacentChestZPos!=null; + return chest.adjacentChestXNeg!=null||chest.adjacentChestXPos!=null||chest.adjacentChestZNeg!=null||chest.adjacentChestZPos!=null; } return true; }); @@ -77,7 +79,7 @@ public static boolean rotateBlock(World world, BlockPos pos, EnumFacing axis) } return state.getBlock().rotateBlock(world, pos, axis); } - + public static boolean rotateEntity(Entity entity, EntityPlayer player) { if(entity instanceof EntityArmorStand) diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/SkylineHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/SkylineHelper.java index f5970d8cfb..ac453db824 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/SkylineHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/SkylineHelper.java @@ -11,7 +11,6 @@ import blusunrize.immersiveengineering.api.ApiUtils; import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable; -import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler; import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection; import blusunrize.immersiveengineering.common.entities.EntitySkylineHook; import blusunrize.immersiveengineering.common.items.ItemSkyhook; @@ -22,10 +21,6 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; -import org.apache.commons.lang3.tuple.Triple; - -import java.util.Map; -import java.util.Set; import static blusunrize.immersiveengineering.api.ApiUtils.getConnectionCatenary; import static blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection.vertices; @@ -34,8 +29,8 @@ public class SkylineHelper { public static EntitySkylineHook spawnHook(EntityPlayer player, TileEntity start, Connection connection) { - BlockPos cc0 = connection.end==Utils.toCC(start)?connection.start:connection.end; - BlockPos cc1 = connection.end==Utils.toCC(start)?connection.end:connection.start; + BlockPos cc0 = connection.end==Utils.toCC(start)?connection.start: connection.end; + BlockPos cc1 = connection.end==Utils.toCC(start)?connection.end: connection.start; IImmersiveConnectable iicStart = ApiUtils.toIIC(cc1, player.world); IImmersiveConnectable iicEnd = ApiUtils.toIIC(cc0, player.world); Vec3d vStart = new Vec3d(cc1); @@ -54,7 +49,7 @@ public static EntitySkylineHook spawnHook(EntityPlayer player, TileEntity start, Vec3d[] steps = getConnectionCatenary(connection, vStart, vEnd); int tInt = MathHelper.clamp(0, (int)(t*vertices), vertices-1); - EntitySkylineHook hook = new EntitySkylineHook(player.world, pos.x,pos.y,pos.z, connection, cc0, steps, tInt+1); + EntitySkylineHook hook = new EntitySkylineHook(player.world, pos.x, pos.y, pos.z, connection, cc0, steps, tInt+1); float speed = 1; if(!player.getActiveItemStack().isEmpty()&&player.getActiveItemStack().getItem() instanceof ItemSkyhook) speed = ((ItemSkyhook)player.getActiveItemStack().getItem()).getSkylineSpeed(player.getActiveItemStack()); @@ -82,18 +77,19 @@ public static Vec3d getSubMovementVector(Vec3d start, Vec3d target, float speed) int lPixel = (int)Math.max(1, (movementVec.lengthVector()/(.125*speed))); return new Vec3d(movementVec.x/lPixel, movementVec.y/lPixel, movementVec.z/lPixel); } + public static boolean isInBlock(EntityPlayer player, World w) { BlockPos init = player.getPosition(); AxisAlignedBB hitbox = player.getEntityBoundingBox(); hitbox = new AxisAlignedBB(hitbox.minX-1, hitbox.minY-1, hitbox.minZ-1, hitbox.maxX, hitbox.maxY, hitbox.maxZ); - - for (int xOff = 0;xOff<2;xOff++) - for (int yOff = 0;yOff<3;yOff++) - for (int zOff = 0;zOff<2;zOff++) + + for(int xOff = 0; xOff < 2; xOff++) + for(int yOff = 0; yOff < 3; yOff++) + for(int zOff = 0; zOff < 2; zOff++) { Vec3d v = new Vec3d(init.getX()+xOff, init.getY()+yOff, init.getZ()+zOff); - if (hitbox.contains(v)&&!w.isAirBlock(new BlockPos(v))) + if(hitbox.contains(v)&&!w.isAirBlock(new BlockPos(v))) return true; } return false; diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/Utils.java b/src/main/java/blusunrize/immersiveengineering/common/util/Utils.java index 65e1ec8882..a471c525d8 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/Utils.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/Utils.java @@ -99,49 +99,54 @@ public static boolean compareToOreName(ItemStack stack, String oreName) return false; ItemStack comp = copyStackWithAmount(stack, 1); List s = OreDictionary.getOres(oreName); - for(ItemStack st:s) + for(ItemStack st : s) if(OreDictionary.itemMatches(st, comp, false)) return true; return false; } + public static boolean stackMatchesObject(ItemStack stack, Object o) { return stackMatchesObject(stack, o, false); } + public static boolean stackMatchesObject(ItemStack stack, Object o, boolean checkNBT) { if(o instanceof ItemStack) - return OreDictionary.itemMatches((ItemStack)o, stack, false) && (!checkNBT || ((ItemStack)o).getItemDamage()==OreDictionary.WILDCARD_VALUE || Utils.compareItemNBT((ItemStack)o, stack)); + return OreDictionary.itemMatches((ItemStack)o, stack, false)&&(!checkNBT||((ItemStack)o).getItemDamage()==OreDictionary.WILDCARD_VALUE||Utils.compareItemNBT((ItemStack)o, stack)); else if(o instanceof Collection) { for(Object io : (Collection)o) - if(io instanceof ItemStack && OreDictionary.itemMatches((ItemStack)io, stack, false) && (!checkNBT || ((ItemStack)io).getItemDamage()==OreDictionary.WILDCARD_VALUE || Utils.compareItemNBT((ItemStack)io, stack))) + if(io instanceof ItemStack&&OreDictionary.itemMatches((ItemStack)io, stack, false)&&(!checkNBT||((ItemStack)io).getItemDamage()==OreDictionary.WILDCARD_VALUE||Utils.compareItemNBT((ItemStack)io, stack))) return true; - } else if(o instanceof IngredientStack) + } + else if(o instanceof IngredientStack) return ((IngredientStack)o).matchesItemStack(stack); else if(o instanceof ItemStack[]) { for(ItemStack io : (ItemStack[])o) - if(OreDictionary.itemMatches(io, stack, false) && (!checkNBT || io.getItemDamage()==OreDictionary.WILDCARD_VALUE || Utils.compareItemNBT(io, stack))) + if(OreDictionary.itemMatches(io, stack, false)&&(!checkNBT||io.getItemDamage()==OreDictionary.WILDCARD_VALUE||Utils.compareItemNBT(io, stack))) return true; - } else if(o instanceof FluidStack) + } + else if(o instanceof FluidStack) { FluidStack fs = FluidUtil.getFluidContained(stack); - return fs != null && fs.containsFluid((FluidStack)o); + return fs!=null&&fs.containsFluid((FluidStack)o); } else if(o instanceof String) return compareToOreName(stack, (String)o); return false; } + public static boolean compareItemNBT(ItemStack stack1, ItemStack stack2) { - if((stack1.isEmpty()) != (stack2.isEmpty())) + if((stack1.isEmpty())!=(stack2.isEmpty())) return false; boolean empty1 = (stack1.getTagCompound()==null||stack1.getTagCompound().hasNoTags()); boolean empty2 = (stack2.getTagCompound()==null||stack2.getTagCompound().hasNoTags()); if(empty1!=empty2) return false; - if(!empty1 && !stack1.getTagCompound().equals(stack2.getTagCompound())) + if(!empty1&&!stack1.getTagCompound().equals(stack2.getTagCompound())) return false; return stack1.areCapsCompatible(stack2); } @@ -163,17 +168,18 @@ public static boolean canCombineArrays(ItemStack[] stacks, ItemStack[] target) int taken = Math.min(size, in.inputSize); size -= taken; in.inputSize -= taken; - if(in.inputSize<=0) + if(in.inputSize <= 0) it.remove(); - if(size<=0) + if(size <= 0) break; } } - if(size>0) + if(size > 0) return false; } return true; } + public static ItemStack copyStackWithAmount(ItemStack stack, int amount) { if(stack.isEmpty()) @@ -182,26 +188,29 @@ public static ItemStack copyStackWithAmount(ItemStack stack, int amount) s2.setCount(amount); return s2; } - public static String[] dyeNames = {"Black","Red","Green","Brown","Blue","Purple","Cyan","LightGray","Gray","Pink","Lime","Yellow","LightBlue","Magenta","Orange","White"}; + + public static String[] dyeNames = {"Black", "Red", "Green", "Brown", "Blue", "Purple", "Cyan", "LightGray", "Gray", "Pink", "Lime", "Yellow", "LightBlue", "Magenta", "Orange", "White"}; + public static int getDye(ItemStack stack) { if(stack.isEmpty()) return -1; if(stack.getItem().equals(Items.DYE)) return stack.getItemDamage(); - for(int dye=0;dye=1000000000?value/1000000000f : value>=1000000?value/1000000f: value>=useKilo?value/1000f: value; - String notation = value>=1000000000?"G" : value>=1000000?"M": value>=useKilo?"K": ""; + float formatted = value >= 1000000000?value/1000000000f: value >= 1000000?value/1000000f: value >= useKilo?value/1000f: value; + String notation = value >= 1000000000?"G": value >= 1000000?"M": value >= useKilo?"K": ""; return formatDouble(formatted, "0."+decimalPrecision)+notation; } + public static String toCamelCase(String s) { - return s.substring(0,1).toUpperCase(Locale.ENGLISH) + s.substring(1).toLowerCase(Locale.ENGLISH); + return s.substring(0, 1).toUpperCase(Locale.ENGLISH)+s.substring(1).toLowerCase(Locale.ENGLISH); } + static Method m_getHarvestLevel = null; + public static String getHarvestLevelName(int lvl) { if(Loader.isModLoaded("TConstruct")) { - try{ + try + { if(m_getHarvestLevel==null) { Class clazz = Class.forName("tconstruct.library.util"); @@ -315,7 +334,9 @@ public static String getHarvestLevelName(int lvl) } if(m_getHarvestLevel!=null) return (String)m_getHarvestLevel.invoke(null, lvl); - }catch(Exception e){} + } catch(Exception e) + { + } } return I18n.format(Lib.DESC_INFO+"mininglvl."+Math.max(-1, Math.min(lvl, 6))); } @@ -337,15 +358,15 @@ public static EnumFacing rotateFacingTowardsDir(EnumFacing f, EnumFacing dir) { if(dir==EnumFacing.NORTH) return f; - else if(dir==EnumFacing.SOUTH && f.getAxis()!=Axis.Y) + else if(dir==EnumFacing.SOUTH&&f.getAxis()!=Axis.Y) return f.rotateY().rotateY(); - else if(dir==EnumFacing.WEST && f.getAxis()!=Axis.Y) + else if(dir==EnumFacing.WEST&&f.getAxis()!=Axis.Y) return f.rotateYCCW(); - else if(dir==EnumFacing.EAST && f.getAxis()!=Axis.Y) + else if(dir==EnumFacing.EAST&&f.getAxis()!=Axis.Y) return f.rotateY(); - else if(dir==EnumFacing.DOWN && f.getAxis()!=Axis.Y) + else if(dir==EnumFacing.DOWN&&f.getAxis()!=Axis.Y) return f.rotateAround(Axis.X); - else if(dir==EnumFacing.UP && f.getAxis()!=Axis.X) + else if(dir==EnumFacing.UP&&f.getAxis()!=Axis.X) return f.rotateAround(Axis.X).getOpposite(); return f; } @@ -353,32 +374,34 @@ else if(dir==EnumFacing.UP && f.getAxis()!=Axis.X) public static RayTraceResult getMovingObjectPositionFromPlayer(World world, EntityLivingBase living, boolean bool) { float f = 1.0F; - float f1 = living.prevRotationPitch + (living.rotationPitch - living.prevRotationPitch) * f; - float f2 = living.prevRotationYaw + (living.rotationYaw - living.prevRotationYaw) * f; - double d0 = living.prevPosX + (living.posX - living.prevPosX) * (double)f; - double d1 = living.prevPosY + (living.posY - living.prevPosY) * (double)f + (double)(world.isRemote ? living.getEyeHeight() - (living instanceof EntityPlayer?((EntityPlayer)living).getDefaultEyeHeight():0) : living.getEyeHeight()); // isRemote check to revert changes to ray trace position due to adding the eye height clientside and player yOffset differences - double d2 = living.prevPosZ + (living.posZ - living.prevPosZ) * (double)f; + float f1 = living.prevRotationPitch+(living.rotationPitch-living.prevRotationPitch)*f; + float f2 = living.prevRotationYaw+(living.rotationYaw-living.prevRotationYaw)*f; + double d0 = living.prevPosX+(living.posX-living.prevPosX)*(double)f; + double d1 = living.prevPosY+(living.posY-living.prevPosY)*(double)f+(double)(world.isRemote?living.getEyeHeight()-(living instanceof EntityPlayer?((EntityPlayer)living).getDefaultEyeHeight(): 0): living.getEyeHeight()); // isRemote check to revert changes to ray trace position due to adding the eye height clientside and player yOffset differences + double d2 = living.prevPosZ+(living.posZ-living.prevPosZ)*(double)f; Vec3d vec3 = new Vec3d(d0, d1, d2); - float f3 = MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI); - float f4 = MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI); - float f5 = -MathHelper.cos(-f1 * 0.017453292F); - float f6 = MathHelper.sin(-f1 * 0.017453292F); - float f7 = f4 * f5; - float f8 = f3 * f5; + float f3 = MathHelper.cos(-f2*0.017453292F-(float)Math.PI); + float f4 = MathHelper.sin(-f2*0.017453292F-(float)Math.PI); + float f5 = -MathHelper.cos(-f1*0.017453292F); + float f6 = MathHelper.sin(-f1*0.017453292F); + float f7 = f4*f5; + float f8 = f3*f5; double d3 = 5.0D; - if (living instanceof EntityPlayerMP) + if(living instanceof EntityPlayerMP) d3 = ((EntityPlayerMP)living).interactionManager.getBlockReachDistance(); - Vec3d vec31 = vec3.addVector((double)f7 * d3, (double)f6 * d3, (double)f8 * d3); + Vec3d vec31 = vec3.addVector((double)f7*d3, (double)f6*d3, (double)f8*d3); return world.rayTraceBlocks(vec3, vec31, bool, !bool, false); } + public static boolean canBlocksSeeOther(World world, BlockPos cc0, BlockPos cc1, Vec3d pos0, Vec3d pos1) { HashSet inter = rayTrace(pos0, pos1, world); Iterator it = inter.iterator(); - while (it.hasNext()) { + while(it.hasNext()) + { BlockPos cc = it.next(); - if (!cc.equals(cc0)&&!cc.equals(cc1)) + if(!cc.equals(cc0)&&!cc.equals(cc1)) return false; } return true; @@ -407,11 +430,11 @@ public static List getTargetsInCone(World world, Vec3d start, Vec3d dirNorm = dir.normalize(); double radius = Math.tan(spreadAngle/2)*length; - Vec3d endLow = start.add(dir).subtract(radius,radius,radius); - Vec3d endHigh = start.add(dir).addVector(radius,radius,radius); + Vec3d endLow = start.add(dir).subtract(radius, radius, radius); + Vec3d endHigh = start.add(dir).addVector(radius, radius, radius); - AxisAlignedBB box = new AxisAlignedBB(minInArray(start.x,endLow.x,endHigh.x), minInArray(start.y,endLow.y,endHigh.y), minInArray(start.z,endLow.z,endHigh.z), - maxInArray(start.x,endLow.x,endHigh.x), maxInArray(start.y,endLow.y,endHigh.y), maxInArray(start.z,endLow.z,endHigh.z)); + AxisAlignedBB box = new AxisAlignedBB(minInArray(start.x, endLow.x, endHigh.x), minInArray(start.y, endLow.y, endHigh.y), minInArray(start.z, endLow.z, endHigh.z), + maxInArray(start.x, endLow.x, endHigh.x), maxInArray(start.y, endLow.y, endHigh.y), maxInArray(start.z, endLow.z, endHigh.z)); List list = world.getEntitiesWithinAABB(EntityLivingBase.class, box); Iterator iterator = list.iterator(); @@ -428,35 +451,39 @@ public static boolean isPointInConeByAngle(Vec3d start, Vec3d normDirection, dou { return isPointInCone(start, normDirection, Math.tan(aperture/2)*length, length, 0, relativePoint); } + public static boolean isPointInCone(Vec3d start, Vec3d normDirection, double radius, double length, Vec3d relativePoint) { return isPointInCone(start, normDirection, radius, length, 0, relativePoint); } + public static boolean isPointInConeByAngle(Vec3d start, Vec3d normDirection, float aperture, double length, float truncationLength, Vec3d relativePoint) { return isPointInCone(start, normDirection, Math.tan(aperture/2)*length, length, truncationLength, relativePoint); } + /** * Checks if point is contained within a cone in 3D space * - * @param start tip of the cone - * @param normDirection normalized (length==1) vector, direction of cone - * @param radius radius at the end of the cone - * @param length length of the cone + * @param start tip of the cone + * @param normDirection normalized (length==1) vector, direction of cone + * @param radius radius at the end of the cone + * @param length length of the cone * @param truncationLength optional lenght at which the cone is truncated (flat tip) - * @param relativePoint point to be checked, relative to {@code start} + * @param relativePoint point to be checked, relative to {@code start} */ public static boolean isPointInCone(Vec3d start, Vec3d normDirection, double radius, double length, float truncationLength, Vec3d relativePoint) { double projectedDist = relativePoint.dotProduct(normDirection); //Orthogonal projection, establishing point's distance on cone direction vector - if(projectedDistlength) //If projected distance is before truncation or beyond length, point not contained + if(projectedDist < truncationLength||projectedDist > length) //If projected distance is before truncation or beyond length, point not contained return false; - double radiusAtDist = projectedDist/length * radius; //Radius of the cone at the projected distance + double radiusAtDist = projectedDist/length*radius; //Radius of the cone at the projected distance Vec3d orthVec = relativePoint.subtract(normDirection.scale(projectedDist)); //Orthogonal vector between point and cone direction - return orthVec.lengthSquared()<(radiusAtDist*radiusAtDist); //Check if Vector's length is shorter than radius -> point in cone + return orthVec.lengthSquared() < (radiusAtDist*radiusAtDist); //Check if Vector's length is shorter than radius -> point in cone } + public static boolean isPointInTriangle(Vec3d tA, Vec3d tB, Vec3d tC, Vec3d point) { //Distance vectors to A (focuspoint of triangle) @@ -466,6 +493,7 @@ public static boolean isPointInTriangle(Vec3d tA, Vec3d tB, Vec3d tC, Vec3d poin return isPointInTriangle(v0, v1, v2); } + private static boolean isPointInTriangle(Vec3d leg0, Vec3d leg1, Vec3d targetVec) { //Dot products @@ -476,19 +504,20 @@ private static boolean isPointInTriangle(Vec3d leg0, Vec3d leg1, Vec3d targetVec double dot12 = leg1.dotProduct(targetVec); //Barycentric coordinates - double invDenom = 1 / (dot00 * dot11 - dot01 * dot01); - double u = (dot11 * dot02 - dot01 * dot12) * invDenom; - double v = (dot00 * dot12 - dot01 * dot02) * invDenom; + double invDenom = 1/(dot00*dot11-dot01*dot01); + double u = (dot11*dot02-dot01*dot12)*invDenom; + double v = (dot00*dot12-dot01*dot02)*invDenom; - return (u >= 0) && (v >= 0) && (u + v < 1); + return (u >= 0)&&(v >= 0)&&(u+v < 1); } + private static Vec3d getVectorForRotation(float pitch, float yaw) { - float f = MathHelper.cos(-yaw * 0.017453292F - (float)Math.PI); - float f1 = MathHelper.sin(-yaw * 0.017453292F - (float)Math.PI); - float f2 = -MathHelper.cos(-pitch * 0.017453292F); - float f3 = MathHelper.sin(-pitch * 0.017453292F); - return new Vec3d((double)(f1 * f2), (double)f3, (double)(f * f2)); + float f = MathHelper.cos(-yaw*0.017453292F-(float)Math.PI); + float f1 = MathHelper.sin(-yaw*0.017453292F-(float)Math.PI); + float f2 = -MathHelper.cos(-pitch*0.017453292F); + float f3 = MathHelper.sin(-pitch*0.017453292F); + return new Vec3d((double)(f1*f2), (double)f3, (double)(f*f2)); } public static boolean isHammer(ItemStack stack) @@ -507,10 +536,10 @@ public static boolean isWirecutter(ItemStack stack) public static boolean canBlockDamageSource(EntityLivingBase entity, DamageSource damageSourceIn) { - if(!damageSourceIn.isUnblockable() && entity.isActiveItemStackBlocking()) + if(!damageSourceIn.isUnblockable()&&entity.isActiveItemStackBlocking()) { Vec3d vec3d = damageSourceIn.getDamageLocation(); - if(vec3d != null) + if(vec3d!=null) { Vec3d vec3d1 = entity.getLook(1.0F); Vec3d vec3d2 = vec3d.subtractReverse(entity.getPositionVector()).normalize(); @@ -526,7 +555,7 @@ public static Vec3d getFlowVector(World world, BlockPos pos) IBlockState state = world.getBlockState(pos); if(state.getBlock() instanceof BlockFluidBase) return ((BlockFluidBase)state.getBlock()).getFlowVector(world, pos); - else if( !(state.getBlock() instanceof BlockLiquid)) + else if(!(state.getBlock() instanceof BlockLiquid)) return new Vec3d(0, 0, 0); BlockLiquid block = (BlockLiquid)state.getBlock(); @@ -538,31 +567,31 @@ else if( !(state.getBlock() instanceof BlockLiquid)) { BlockPos blockpos = pos.offset(enumfacing); int j = getEffectiveFlowDecay(world, blockpos, mat); - if(j<0) + if(j < 0) { if(!world.getBlockState(blockpos).getMaterial().blocksMovement()) { j = getEffectiveFlowDecay(world, blockpos.down(), mat); - if(j>=0) + if(j >= 0) { - int k = j - (i - 8); - vec3 = vec3.addVector((double)((blockpos.getX() - pos.getX()) * k), (double)((blockpos.getY() - pos.getY()) * k), (double)((blockpos.getZ() - pos.getZ()) * k)); + int k = j-(i-8); + vec3 = vec3.addVector((double)((blockpos.getX()-pos.getX())*k), (double)((blockpos.getY()-pos.getY())*k), (double)((blockpos.getZ()-pos.getZ())*k)); } } } - else if(j>=0) + else if(j >= 0) { - int l = j - i; - vec3 = vec3.addVector((double)((blockpos.getX() - pos.getX()) * l), (double)((blockpos.getY() - pos.getY()) * l), (double)((blockpos.getZ() - pos.getZ()) * l)); + int l = j-i; + vec3 = vec3.addVector((double)((blockpos.getX()-pos.getX())*l), (double)((blockpos.getY()-pos.getY())*l), (double)((blockpos.getZ()-pos.getZ())*l)); } } - if(state.getValue(BlockLiquid.LEVEL).intValue()>=8) + if(state.getValue(BlockLiquid.LEVEL).intValue() >= 8) { for(EnumFacing enumfacing1 : EnumFacing.Plane.HORIZONTAL) { BlockPos blockpos1 = pos.offset(enumfacing1); - if(block.causesDownwardCurrent(world, blockpos1, enumfacing1) || block.causesDownwardCurrent(world, blockpos1.up(), enumfacing1)) + if(block.causesDownwardCurrent(world, blockpos1, enumfacing1)||block.causesDownwardCurrent(world, blockpos1.up(), enumfacing1)) { vec3 = vec3.normalize().addVector(0.0D, -6.0D, 0.0D); break; @@ -571,43 +600,46 @@ else if(j>=0) } return vec3.normalize(); } + static int getEffectiveFlowDecay(IBlockAccess world, BlockPos pos, Material mat) { IBlockState state = world.getBlockState(pos); - if(state.getMaterial() != mat) + if(state.getMaterial()!=mat) return -1; int l = state.getBlock().getMetaFromState(state); - if (l >= 8) + if(l >= 8) l = 0; return l; } + public static Vec3d addVectors(Vec3d vec0, Vec3d vec1) { - return vec0.addVector(vec1.x,vec1.y,vec1.z); + return vec0.addVector(vec1.x, vec1.y, vec1.z); } public static double minInArray(double... f) { - if(f.length<1) + if(f.length < 1) return 0; double min = f[0]; - for(int i=1; i2) + if(j > 2) j++; - if(j>6) - j+=2; + if(j > 6) + j += 2; //no black, brown, light grey, grey or white colors[i] = ItemDye.DYE_COLORS[j]; } expl.setIntArray("Colors", colors); - int type = preType>=0?preType: rand.nextInt(4); - if(preType<0 && type==3) + int type = preType >= 0?preType: rand.nextInt(4); + if(preType < 0&&type==3) type = 4; - expl.setByte("Type", (byte) type); + expl.setByte("Type", (byte)type); NBTTagList list = new NBTTagList(); list.appendTag(expl); tag.setTag("Explosions", list); @@ -664,7 +696,7 @@ public static FluidStack drainFluidBlock(World world, BlockPos pos, boolean doDr if(b instanceof IFluidBlock) { if(((IFluidBlock)b).canDrain(world, pos)) - return ((IFluidBlock) b).drain(world, pos, doDrain); + return ((IFluidBlock)b).drain(world, pos, doDrain); else return null; } @@ -690,7 +722,7 @@ public static Fluid getRelatedFluid(World w, BlockPos pos) public static boolean placeFluidBlock(World world, BlockPos pos, FluidStack fluid) { - if(fluid==null || fluid.getFluid()==null) + if(fluid==null||fluid.getFluid()==null) return false; IBlockState state = world.getBlockState(pos); Block b = state.getBlock(); @@ -701,12 +733,12 @@ public static boolean placeFluidBlock(World world, BlockPos pos, FluidStack flui else if(Blocks.LAVA.equals(fluidBlock)) fluidBlock = Blocks.FLOWING_LAVA; - boolean canPlace = b==null||b.isAir(state,world,pos)||b.isReplaceable(world,pos); + boolean canPlace = b==null||b.isAir(state, world, pos)||b.isReplaceable(world, pos); - if(fluidBlock!=null && canPlace && fluid.amount>=1000) + if(fluidBlock!=null&&canPlace&&fluid.amount >= 1000) { boolean placed = false; - if ((fluidBlock instanceof BlockFluidBase)) + if((fluidBlock instanceof BlockFluidBase)) { BlockFluidBase blockFluid = (BlockFluidBase)fluidBlock; placed = world.setBlockState(pos, fluidBlock.getStateFromMeta(blockFluid.getMaxRenderHeightMeta())); @@ -750,6 +782,7 @@ public static IBlockState getStateFromItemStack(ItemStack stack) return block.getStateFromMeta(stack.getItemDamage()); return null; } + public static Block getBlockFromItem(Item item) { if(item==Items.CAULDRON) @@ -759,7 +792,7 @@ public static Block getBlockFromItem(Item item) public static boolean canInsertStackIntoInventory(TileEntity inventory, ItemStack stack, EnumFacing side) { - if(!stack.isEmpty() && inventory!=null && inventory.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) + if(!stack.isEmpty()&&inventory!=null&&inventory.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) { IItemHandler handler = inventory.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side); ItemStack temp = ItemHandlerHelper.insertItem(handler, stack.copy(), true); @@ -767,40 +800,44 @@ public static boolean canInsertStackIntoInventory(TileEntity inventory, ItemStac } return false; } + public static ItemStack insertStackIntoInventory(TileEntity inventory, ItemStack stack, EnumFacing side) { - if(!stack.isEmpty() && inventory!=null && inventory.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) + if(!stack.isEmpty()&&inventory!=null&&inventory.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) { IItemHandler handler = inventory.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side); ItemStack temp = ItemHandlerHelper.insertItem(handler, stack.copy(), true); - if(temp.isEmpty() || temp.getCount() < stack.getCount()) + if(temp.isEmpty()||temp.getCount() < stack.getCount()) return ItemHandlerHelper.insertItem(handler, stack, false); } return stack; } + public static ItemStack insertStackIntoInventory(TileEntity inventory, ItemStack stack, EnumFacing side, boolean simulate) { - if(inventory!=null && !stack.isEmpty() && inventory.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) + if(inventory!=null&&!stack.isEmpty()&&inventory.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) { IItemHandler handler = inventory.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side); return ItemHandlerHelper.insertItem(handler, stack.copy(), simulate); } return stack; } + public static void dropStackAtPos(World world, BlockPos pos, ItemStack stack, EnumFacing facing) { if(!stack.isEmpty()) { - EntityItem ei = new EntityItem(world, pos.getX()+.5,pos.getY()+.5,pos.getZ()+.5, stack.copy()); + EntityItem ei = new EntityItem(world, pos.getX()+.5, pos.getY()+.5, pos.getZ()+.5, stack.copy()); ei.motionY = 0.025000000372529D; if(facing!=null) { - ei.motionX = (0.075F * facing.getFrontOffsetX()); - ei.motionZ = (0.075F * facing.getFrontOffsetZ()); + ei.motionX = (0.075F*facing.getFrontOffsetX()); + ei.motionZ = (0.075F*facing.getFrontOffsetZ()); } world.spawnEntity(ei); } } + public static void dropStackAtPos(World world, BlockPos pos, ItemStack stack) { dropStackAtPos(world, pos, stack, null); @@ -849,18 +886,21 @@ public static void dropStackAtPos(World world, BlockPos pos, ItemStack stack) public static ItemStack addToEmptyInventorySlot(IInventory inventory, int slot, ItemStack stack) { - if (!inventory.isItemValidForSlot(slot, stack)) { + if(!inventory.isItemValidForSlot(slot, stack)) + { return stack; } int stackLimit = inventory.getInventoryStackLimit(); inventory.setInventorySlotContents(slot, copyStackWithAmount(stack, Math.min(stack.getCount(), stackLimit))); - return stackLimit >= stack.getCount() ? ItemStack.EMPTY : stack.splitStack(stack.getCount() - stackLimit); + return stackLimit >= stack.getCount()?ItemStack.EMPTY: stack.splitStack(stack.getCount()-stackLimit); } + public static ItemStack addToOccupiedSlot(IInventory inventory, int slot, ItemStack stack, ItemStack existingStack) { int stackLimit = Math.min(inventory.getInventoryStackLimit(), stack.getMaxStackSize()); - if (stack.getCount() + existingStack.getCount() > stackLimit) { - int stackDiff = stackLimit - existingStack.getCount(); + if(stack.getCount()+existingStack.getCount() > stackLimit) + { + int stackDiff = stackLimit-existingStack.getCount(); existingStack.setCount(stackLimit); stack.shrink(stackDiff); inventory.setInventorySlotContents(slot, existingStack); @@ -868,7 +908,7 @@ public static ItemStack addToOccupiedSlot(IInventory inventory, int slot, ItemSt } existingStack.grow(min(stack.getCount(), stackLimit)); inventory.setInventorySlotContents(slot, existingStack); - return stackLimit >= stack.getCount() ? ItemStack.EMPTY : stack.splitStack(stack.getCount() - stackLimit); + return stackLimit >= stack.getCount()?ItemStack.EMPTY: stack.splitStack(stack.getCount()-stackLimit); } @@ -916,45 +956,48 @@ public static ItemStack addToOccupiedSlot(IInventory inventory, int slot, ItemSt public static ItemStack fillFluidContainer(IFluidHandler handler, ItemStack containerIn, ItemStack containerOut, @Nullable EntityPlayer player) { - if(containerIn==null || containerIn.isEmpty()) + if(containerIn==null||containerIn.isEmpty()) return ItemStack.EMPTY; - if(containerIn.hasTagCompound() && containerIn.getTagCompound().hasNoTags()) + if(containerIn.hasTagCompound()&&containerIn.getTagCompound().hasNoTags()) containerIn.setTagCompound(null); FluidActionResult result = FluidUtil.tryFillContainer(containerIn, handler, Integer.MAX_VALUE, player, false); if(result.isSuccess()) { final ItemStack full = result.getResult(); - if((containerOut.isEmpty() || OreDictionary.itemMatches(containerOut, full,true))) + if((containerOut.isEmpty()||OreDictionary.itemMatches(containerOut, full, true))) { - if (!containerOut.isEmpty() && containerOut.getCount() + full.getCount() > containerOut.getMaxStackSize()) + if(!containerOut.isEmpty()&&containerOut.getCount()+full.getCount() > containerOut.getMaxStackSize()) return ItemStack.EMPTY; result = FluidUtil.tryFillContainer(containerIn, handler, Integer.MAX_VALUE, player, true); - if (result.isSuccess()) { + if(result.isSuccess()) + { return result.getResult(); } } } return ItemStack.EMPTY; } + public static ItemStack drainFluidContainer(IFluidHandler handler, ItemStack containerIn, ItemStack containerOut, @Nullable EntityPlayer player) { - if(containerIn==null || containerIn.isEmpty()) + if(containerIn==null||containerIn.isEmpty()) return ItemStack.EMPTY; - if(containerIn.hasTagCompound() && containerIn.getTagCompound().hasNoTags()) + if(containerIn.hasTagCompound()&&containerIn.getTagCompound().hasNoTags()) containerIn.setTagCompound(null); FluidActionResult result = FluidUtil.tryEmptyContainer(containerIn, handler, Integer.MAX_VALUE, player, false); if(result.isSuccess()) { ItemStack empty = result.getResult(); - if ((containerOut.isEmpty() || OreDictionary.itemMatches(containerOut,empty,true))) + if((containerOut.isEmpty()||OreDictionary.itemMatches(containerOut, empty, true))) { - if (!containerOut.isEmpty() && containerOut.getCount() + empty.getCount() > containerOut.getMaxStackSize()) + if(!containerOut.isEmpty()&&containerOut.getCount()+empty.getCount() > containerOut.getMaxStackSize()) return ItemStack.EMPTY; result = FluidUtil.tryEmptyContainer(containerIn, handler, Integer.MAX_VALUE, player, true); - if (result.isSuccess()) { + if(result.isSuccess()) + { return result.getResult(); } } @@ -972,7 +1015,7 @@ public static boolean isFluidContainerFull(ItemStack stack) return false; IFluidTankProperties[] tank = handler.getTankProperties(); for(IFluidTankProperties prop : tank) - if(prop.getContents()==null || prop.getContents().amount createNonNullItemStackListFromArray(ItemStack[] stacks) { NonNullList list = NonNullList.withSize(stacks.length, ItemStack.EMPTY); - for (int i = 0; i < stacks.length; i++) + for(int i = 0; i < stacks.length; i++) { list.set(i, stacks[i]); } @@ -1020,26 +1063,26 @@ public static NonNullList createNonNullItemStackListFromItemStack(Ite public static float[] rotateToFacing(float[] in, EnumFacing facing) { - for (int i = 0; i < in.length; i++) + for(int i = 0; i < in.length; i++) in[i] -= .5F; float[] ret = new float[in.length]; - for (int i = 0; i < in.length; i += 3) - for (int j = 0; j < 3; j++) + for(int i = 0; i < in.length; i += 3) + for(int j = 0; j < 3; j++) { - if (j == 0) - ret[i + j] = in[i + 0] * facing.getFrontOffsetZ() + - in[i + 1] * facing.getFrontOffsetX() + - in[i + 2] * facing.getFrontOffsetY(); - else if (j == 1) - ret[i + j] = in[i + 0] * facing.getFrontOffsetX() + - in[i + 1] * facing.getFrontOffsetY() + - in[i + 2] * facing.getFrontOffsetZ(); + if(j==0) + ret[i+j] = in[i+0]*facing.getFrontOffsetZ()+ + in[i+1]*facing.getFrontOffsetX()+ + in[i+2]*facing.getFrontOffsetY(); + else if(j==1) + ret[i+j] = in[i+0]*facing.getFrontOffsetX()+ + in[i+1]*facing.getFrontOffsetY()+ + in[i+2]*facing.getFrontOffsetZ(); else - ret[i + j] = in[i + 0] * facing.getFrontOffsetY() + - in[i + 1] * facing.getFrontOffsetZ() + - in[i + 2] * facing.getFrontOffsetX(); + ret[i+j] = in[i+0]*facing.getFrontOffsetY()+ + in[i+1]*facing.getFrontOffsetZ()+ + in[i+2]*facing.getFrontOffsetX(); } - for (int i = 0; i < in.length; i++) + for(int i = 0; i < in.length; i++) ret[i] += .5; return ret; } @@ -1048,20 +1091,20 @@ public static int hashBlockstate(IBlockState state, Set ignoredPropertie { int val = 0; final int prime = 31; - for (IProperty n : state.getPropertyKeys()) - if (!ignoredProperties.contains(n)) + for(IProperty n : state.getPropertyKeys()) + if(!ignoredProperties.contains(n)) { Object o = state.getValue(n); - val = prime * val + (o == null ? 0 : o.hashCode()); + val = prime*val+(o==null?0: o.hashCode()); } - if (includeExtended&&state instanceof IExtendedBlockState) + if(includeExtended&&state instanceof IExtendedBlockState) { - IExtendedBlockState ext = (IExtendedBlockState) state; - for (IUnlistedProperty n : ext.getUnlistedNames()) - if (!ignoredProperties.contains(n)) + IExtendedBlockState ext = (IExtendedBlockState)state; + for(IUnlistedProperty n : ext.getUnlistedNames()) + if(!ignoredProperties.contains(n)) { Object o = ext.getValue(n); - val = prime * val + (o == null ? 0 : o.hashCode()); + val = prime*val+(o==null?0: o.hashCode()); } } return val; @@ -1073,34 +1116,34 @@ public static boolean areStatesEqual(IBlockState state, IBlockState other, Set i : extState.getUnlistedNames()) + IExtendedBlockState extState = (IExtendedBlockState)state; + IExtendedBlockState extOther = (IExtendedBlockState)other; + for(IUnlistedProperty i : extState.getUnlistedNames()) { - if (!extOther.getUnlistedProperties().containsKey(i)) + if(!extOther.getUnlistedProperties().containsKey(i)) return false; - if (ignoredProperties.contains(i)) + if(ignoredProperties.contains(i)) continue; Object valThis = extState.getValue(i); Object valOther = extOther.getValue(i); - if (valThis == null && valOther == null) + if(valThis==null&&valOther==null) continue; - else if (valOther == null || !valOther.equals(valThis)) + else if(valOther==null||!valOther.equals(valThis)) return false; } } @@ -1110,25 +1153,25 @@ else if (valOther == null || !valOther.equals(valThis)) public static boolean areArraysEqualIncludingBlockstates(Object[] a, Object[] a2) { - if (a == a2) + if(a==a2) return true; - if (a == null || a2 == null) + if(a==null||a2==null) return false; int length = a.length; - if (a2.length != length) + if(a2.length!=length) return false; - for (int i = 0; i < length; i++) + for(int i = 0; i < length; i++) { Object o1 = a[i]; Object o2 = a2[i]; - if (o1 instanceof IBlockState && o2 instanceof IBlockState) + if(o1 instanceof IBlockState&&o2 instanceof IBlockState) { - if (!areStatesEqual((IBlockState)o1, (IBlockState) o2, ImmutableSet.of(), false)) + if(!areStatesEqual((IBlockState)o1, (IBlockState)o2, ImmutableSet.of(), false)) return false; } - else if (!(o1 == null ? o2 == null : o1.equals(o2))) + else if(!(o1==null?o2==null: o1.equals(o2))) return false; } return true; @@ -1151,7 +1194,7 @@ else if (!(o1 == null ? o2 == null : o1.equals(o2))) */ public static double getCoeffForMinDistance(Vec3d point, Vec3d line, Vec3d across) { - if (across.x==0&&across.z==0) + if(across.x==0&&across.z==0) { return (point.y-line.y)/across.y; } @@ -1164,11 +1207,11 @@ public static double getCoeffForMinDistance(Vec3d point, Vec3d line, Vec3d acros public static boolean isVecInBlock(Vec3d vec3d, BlockPos pos, BlockPos offset) { - return vec3d.x >= pos.getX()-offset.getX() && - vec3d.x <= pos.getX()-offset.getX()+1 && - vec3d.y >= pos.getY()-offset.getY() && - vec3d.y <= pos.getY()-offset.getY()+1 && - vec3d.z >= pos.getZ()-offset.getZ() && + return vec3d.x >= pos.getX()-offset.getX()&& + vec3d.x <= pos.getX()-offset.getX()+1&& + vec3d.y >= pos.getY()-offset.getY()&& + vec3d.y <= pos.getY()-offset.getY()+1&& + vec3d.z >= pos.getZ()-offset.getZ()&& vec3d.z <= pos.getZ()-offset.getZ()+1; } @@ -1177,13 +1220,17 @@ public static class InventoryCraftingFalse extends InventoryCrafting private static final Container nullContainer = new Container() { @Override - public void onCraftMatrixChanged(IInventory paramIInventory){} + public void onCraftMatrixChanged(IInventory paramIInventory) + { + } + @Override public boolean canInteractWith(@Nonnull EntityPlayer p_75145_1_) { return false; } }; + public InventoryCraftingFalse(int w, int h) { super(nullContainer, w, h); @@ -1192,7 +1239,7 @@ public InventoryCraftingFalse(int w, int h) public static InventoryCrafting createFilledCraftingInventory(int w, int h, NonNullList stacks) { InventoryCrafting invC = new Utils.InventoryCraftingFalse(w, h); - for(int j = 0; j < w * h; j++) + for(int j = 0; j < w*h; j++) if(!stacks.get(j).isEmpty()) invC.setInventorySlotContents(j, stacks.get(j).copy()); return invC; @@ -1201,32 +1248,34 @@ public static InventoryCrafting createFilledCraftingInventory(int w, int h, NonN public static HashSet rayTrace(Vec3d start, Vec3d end, World world) { - return rayTrace(start, end, world, (p)->{}); + return rayTrace(start, end, world, (p) -> { + }); } + public static HashSet rayTrace(Vec3d start, Vec3d end, World world, Consumer out) { HashSet ret = new HashSet(); HashSet checked = new HashSet(); // x - if (start.x>end.x) + if(start.x > end.x) { Vec3d tmp = start; start = end; end = tmp; } double min = start.x; - double dif =end.x-min; + double dif = end.x-min; double lengthAdd = Math.ceil(min)-start.x; Vec3d mov = start.subtract(end); - if (mov.x!=0) + if(mov.x!=0) { - mov = scalarProd(mov, 1 / mov.x); + mov = scalarProd(mov, 1/mov.x); ray(dif, mov, start, lengthAdd, ret, world, checked, out); } // y - if (mov.y!=0) + if(mov.y!=0) { - if (start.y>end.y) + if(start.y > end.y) { Vec3d tmp = start; start = end; @@ -1242,70 +1291,71 @@ public static HashSet rayTrace(Vec3d start, Vec3d end, World world, Co } // z - if (mov.z!=0) + if(mov.z!=0) { - if (start.z>end.z) + if(start.z > end.z) { Vec3d tmp = start; start = end; end = tmp; } min = start.z; - dif = end.z - min; + dif = end.z-min; lengthAdd = Math.ceil(min)-start.z; mov = start.subtract(end); - mov = scalarProd(mov, 1 / mov.z); + mov = scalarProd(mov, 1/mov.z); ray(dif, mov, start, lengthAdd, ret, world, checked, out); } - if (checked.isEmpty()) + if(checked.isEmpty()) { BlockPos pos = new BlockPos(start); IBlockState state = world.getBlockState(pos); Block b = state.getBlock(); - if (b.canCollideCheck(state, false) && state.collisionRayTrace(world, pos, start, end) != null) + if(b.canCollideCheck(state, false)&&state.collisionRayTrace(world, pos, start, end)!=null) ret.add(pos); checked.add(pos); out.accept(pos); } return ret; } + private static void ray(double dif, Vec3d mov, Vec3d start, double lengthAdd, HashSet ret, World world, HashSet checked, Consumer out) { //Do NOT set this to true unless for debugging. Causes blocks to be placed along the traced ray boolean place = false; double standartOff = .0625; - for (int i = 0; i < dif; i++) + for(int i = 0; i < dif; i++) { - Vec3d pos = addVectors(start, scalarProd(mov, i + lengthAdd+standartOff)); + Vec3d pos = addVectors(start, scalarProd(mov, i+lengthAdd+standartOff)); Vec3d posNext = addVectors(start, - scalarProd(mov, i + 1 + lengthAdd+standartOff)); + scalarProd(mov, i+1+lengthAdd+standartOff)); Vec3d posPrev = addVectors(start, - scalarProd(mov, i + lengthAdd-standartOff)); + scalarProd(mov, i+lengthAdd-standartOff)); Vec3d posVeryPrev = addVectors(start, - scalarProd(mov, i - 1 + lengthAdd-standartOff)); + scalarProd(mov, i-1+lengthAdd-standartOff)); - BlockPos blockPos = new BlockPos((int) Math.floor(pos.x), - (int) Math.floor(pos.y), (int) Math.floor(pos.z)); + BlockPos blockPos = new BlockPos((int)Math.floor(pos.x), + (int)Math.floor(pos.y), (int)Math.floor(pos.z)); Block b; IBlockState state; - if (!checked.contains(blockPos)&&i + lengthAdd+standartOff ignore) { HashSet trace = rayTrace(start, end, w); - for (BlockPos cc:ignore) + for(BlockPos cc : ignore) trace.remove(cc); - if (start.x!=end.x) - trace = findMinOrMax(trace, start.x>end.x, 0); - if (start.y!=end.y) - trace = findMinOrMax(trace, start.y>end.y, 0); - if (start.z!=end.z) - trace = findMinOrMax(trace, start.z>end.z, 0); - if (trace.size()>0) + if(start.x!=end.x) + trace = findMinOrMax(trace, start.x > end.x, 0); + if(start.y!=end.y) + trace = findMinOrMax(trace, start.y > end.y, 0); + if(start.z!=end.z) + trace = findMinOrMax(trace, start.z > end.z, 0); + if(trace.size() > 0) { BlockPos ret = trace.iterator().next(); return ret; } return null; } - public static HashSet findMinOrMax(HashSet in, boolean max, int coord) { + + public static HashSet findMinOrMax(HashSet in, boolean max, int coord) + { HashSet ret = new HashSet(); - int currMinMax = max?Integer.MIN_VALUE:Integer.MAX_VALUE; + int currMinMax = max?Integer.MIN_VALUE: Integer.MAX_VALUE; //find minimum - for (BlockPos cc:in) + for(BlockPos cc : in) { - int curr = (coord==0?cc.getX():(coord==1?cc.getY():cc.getY())); - if (max^(curr findMinOrMax(HashSet in, boolean max, /** * get tile entity without loading currently unloaded chunks + * * @return return value of {@link IBlockAccess#getTileEntity(BlockPos)} or always null if chunk is not loaded */ public static TileEntity getExistingTileEntity(World world, BlockPos pos) @@ -1366,23 +1421,25 @@ public static TileEntity getExistingTileEntity(World world, BlockPos pos) return world.getTileEntity(pos); return null; } + public static NonNullList readInventory(NBTTagList nbt, int size) { NonNullList inv = NonNullList.withSize(size, ItemStack.EMPTY); int max = nbt.tagCount(); - for (int i = 0;i=0 && slot= 0&&slot < size) inv.set(slot, new ItemStack(itemTag)); } return inv; } + public static NBTTagList writeInventory(ItemStack[] inv) { NBTTagList invList = new NBTTagList(); - for(int i=0; i inv) { NBTTagList invList = new NBTTagList(); @@ -1409,6 +1467,7 @@ public static NBTTagList writeInventory(Collection inv) } return invList; } + public static NonNullList loadItemStacksFromNBT(NBTBase nbt) { NonNullList itemStacks = NonNullList.create(); @@ -1428,7 +1487,7 @@ else if(nbt instanceof NBTTagList) public static void modifyInvStackSize(NonNullList inv, int slot, int amount) { - if(slot>=0&&slot< inv.size() && !inv.get(slot).isEmpty()) + if(slot >= 0&&slot < inv.size()&&!inv.get(slot).isEmpty()) { inv.get(slot).grow(amount); if(inv.get(slot).getCount() <= 0) @@ -1451,21 +1510,21 @@ else if(itemstack.getCount() > 1) iterator.remove(); } } - slotAmount = slotAmount - stacks.size(); - while(slotAmount>0 && list.size()>0) + slotAmount = slotAmount-stacks.size(); + while(slotAmount > 0&&list.size() > 0) { - ItemStack itemstack2 = list.remove(MathHelper.getInt(rand, 0, list.size() - 1)); - int i = MathHelper.getInt(rand, 1, itemstack2.getCount() / 2); + ItemStack itemstack2 = list.remove(MathHelper.getInt(rand, 0, list.size()-1)); + int i = MathHelper.getInt(rand, 1, itemstack2.getCount()/2); itemstack2.shrink(i); ItemStack itemstack1 = itemstack2.copy(); itemstack1.setCount(i); - if(itemstack2.getCount() > 1 && rand.nextBoolean()) + if(itemstack2.getCount() > 1&&rand.nextBoolean()) list.add(itemstack2); else stacks.add(itemstack2); - if(itemstack1.getCount() > 1 && rand.nextBoolean()) + if(itemstack1.getCount() > 1&&rand.nextBoolean()) list.add(itemstack1); else stacks.add(itemstack1); @@ -1473,10 +1532,12 @@ else if(itemstack.getCount() > 1) stacks.addAll(list); Collections.shuffle(stacks, rand); } + private static final Gson GSON_INSTANCE = (new GsonBuilder()).registerTypeAdapter(RandomValueRange.class, new RandomValueRange.Serializer()).registerTypeAdapter(LootPool.class, new LootPool.Serializer()).registerTypeAdapter(LootTable.class, new LootTable.Serializer()).registerTypeHierarchyAdapter(LootEntry.class, new LootEntry.Serializer()).registerTypeHierarchyAdapter(LootFunction.class, new LootFunctionManager.Serializer()).registerTypeHierarchyAdapter(LootCondition.class, new LootConditionManager.Serializer()).registerTypeHierarchyAdapter(LootContext.EntityTarget.class, new LootContext.EntityTarget.Serializer()).create(); + public static LootTable loadBuiltinLootTable(ResourceLocation resource, LootTableManager lootTableManager) { - URL url = Utils.class.getResource("/assets/" + resource.getResourceDomain() + "/loot_tables/" + resource.getResourcePath() + ".json"); + URL url = Utils.class.getResource("/assets/"+resource.getResourceDomain()+"/loot_tables/"+resource.getResourcePath()+".json"); if(url==null) return LootTable.EMPTY_LOOT_TABLE; else @@ -1511,19 +1572,19 @@ public static int calcRedstoneFromInventory(IIEInventory inv) else { int max = inv.getComparatedSize(); - int i=0; + int i = 0; float f = 0.0F; - for(int j = 0; j< max; ++j) + for(int j = 0; j < max; ++j) { ItemStack itemstack = inv.getInventory().get(j); if(!itemstack.isEmpty()) { - f += (float) itemstack.getCount() / (float)Math.min(inv.getSlotLimit(j), itemstack.getMaxStackSize()); + f += (float)itemstack.getCount()/(float)Math.min(inv.getSlotLimit(j), itemstack.getMaxStackSize()); ++i; } } - f = f/(float) max; - return MathHelper.floor(f * 14.0F) + (i > 0 ? 1 : 0); + f = f/(float)max; + return MathHelper.floor(f*14.0F)+(i > 0?1: 0); } } @@ -1548,12 +1609,12 @@ public static Map saveStack(ItemStack stack) public static Map saveFluidTank(FluidTank tank) { HashMap ret = new HashMap<>(); - if(tank != null && tank.getFluid() != null) + if(tank!=null&&tank.getFluid()!=null) { ret.put("name", tank.getFluid().getFluid().getUnlocalizedName()); ret.put("amount", tank.getFluidAmount()); ret.put("capacity", tank.getCapacity()); - ret.put("hasTag", tank.getFluid().tag != null); + ret.put("hasTag", tank.getFluid().tag!=null); } return ret; } @@ -1561,11 +1622,11 @@ public static Map saveFluidTank(FluidTank tank) public static Map saveFluidStack(FluidStack tank) { HashMap ret = new HashMap<>(); - if(tank != null && tank.getFluid() != null) + if(tank!=null&&tank.getFluid()!=null) { ret.put("name", tank.getFluid().getUnlocalizedName()); ret.put("amount", tank.amount); - ret.put("hasTag", tank.tag != null); + ret.put("hasTag", tank.tag!=null); } return ret; } @@ -1573,20 +1634,20 @@ public static Map saveFluidStack(FluidStack tank) public static void stateToNBT(NBTTagCompound out, IBlockState state) { out.setString("block", state.getBlock().getRegistryName().toString()); - for (IProperty prop:state.getPropertyKeys()) + for(IProperty prop : state.getPropertyKeys()) saveProp(state, prop, out); } public static IBlockState stateFromNBT(NBTTagCompound in) { Block b = Block.getBlockFromName(in.getString("block")); - if (b==null) + if(b==null) return Blocks.BOOKSHELF.getDefaultState(); IBlockState ret = b.getDefaultState(); - for (IProperty prop:ret.getPropertyKeys()) + for(IProperty prop : ret.getPropertyKeys()) { String name = prop.getName(); - if (in.hasKey(name, Constants.NBT.TAG_STRING)) + if(in.hasKey(name, Constants.NBT.TAG_STRING)) ret = setProp(ret, prop, in.getString(name)); } return ret; @@ -1608,7 +1669,7 @@ private static > void saveProp(IBlockState state, IPrope private static > IBlockState setProp(IBlockState state, IProperty prop, String value) { Optional valueParsed = prop.parseValue(value); - if (valueParsed.isPresent()) + if(valueParsed.isPresent()) return state.withProperty(prop, valueParsed.get()); return state; } @@ -1621,7 +1682,9 @@ public static IBlockAccess getSingleBlockWorldAccess(IBlockState state) private static class SingleBlockAcess implements IBlockAccess { IBlockState state; - public SingleBlockAcess(IBlockState state) { + + public SingleBlockAcess(IBlockState state) + { this.state = state; } @@ -1643,7 +1706,7 @@ public int getCombinedLight(@Nonnull BlockPos pos, int lightValue) @Override public IBlockState getBlockState(@Nonnull BlockPos pos) { - return pos.equals(BlockPos.ORIGIN)?state:Blocks.AIR.getDefaultState(); + return pos.equals(BlockPos.ORIGIN)?state: Blocks.AIR.getDefaultState(); } @Override diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/advancements/MultiblockTrigger.java b/src/main/java/blusunrize/immersiveengineering/common/util/advancements/MultiblockTrigger.java index 807f12f910..f5eb45a1cb 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/advancements/MultiblockTrigger.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/advancements/MultiblockTrigger.java @@ -46,7 +46,7 @@ public ResourceLocation getId() public void addListener(PlayerAdvancements playerAdvancements, ICriterionTrigger.Listener listener) { MultiblockTrigger.Listeners listeners = this.listeners.get(playerAdvancements); - if(listeners == null) + if(listeners==null) { listeners = new MultiblockTrigger.Listeners(playerAdvancements); this.listeners.put(playerAdvancements, listeners); @@ -59,7 +59,7 @@ public void removeListener(PlayerAdvancements playerAdvancements, ICriterionTrig { MultiblockTrigger.Listeners listeners = this.listeners.get(playerAdvancements); - if(listeners != null) + if(listeners!=null) { listeners.remove(listener); if(listeners.isEmpty()) diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/chickenbones/Matrix4.java b/src/main/java/blusunrize/immersiveengineering/common/util/chickenbones/Matrix4.java index bf3f0ea05b..3410b38147 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/chickenbones/Matrix4.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/chickenbones/Matrix4.java @@ -14,17 +14,17 @@ /** * Copyright (C) 2013 Chicken-Bones - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ //This file originally copied from CodeChickenLib, courtesy of Chicken-Bones. //This is a customized version created by Steven Blom (AtomicBlom) of the Steam and Steel development team. @@ -35,10 +35,12 @@ public class Matrix4 public static final Matrix4 IDENTITY = new Matrix4(); //m public double m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33; + public Matrix4() { m00 = m11 = m22 = m33 = 1; } + public Matrix4(double d00, double d01, double d02, double d03, double d10, double d11, double d12, double d13, double d20, double d21, double d22, double d23, @@ -61,10 +63,12 @@ public Matrix4(double d00, double d01, double d02, double d03, m32 = d32; m33 = d33; } + public Matrix4(Matrix4 mat) { set(mat); } + public Matrix4(Matrix4f mat) { m00 = mat.m00; @@ -111,28 +115,32 @@ public Matrix4(EnumFacing facing) } translate(-.5, -.5, -.5); } + public Matrix4 setIdentity() { m00 = m11 = m22 = m33 = 1; m01 = m02 = m03 = m10 = m12 = m13 = m20 = m21 = m23 = m30 = m31 = m32 = 0; return this; } + public Matrix4 translate(Vector3f vec) { - m03 += m00 * vec.x + m01 * vec.y + m02 * vec.z; - m13 += m10 * vec.x + m11 * vec.y + m12 * vec.z; - m23 += m20 * vec.x + m21 * vec.y + m22 * vec.z; - m33 += m30 * vec.x + m31 * vec.y + m32 * vec.z; + m03 += m00*vec.x+m01*vec.y+m02*vec.z; + m13 += m10*vec.x+m11*vec.y+m12*vec.z; + m23 += m20*vec.x+m21*vec.y+m22*vec.z; + m33 += m30*vec.x+m31*vec.y+m32*vec.z; return this; } + public Matrix4 translate(double x, double y, double z) { - m03 += m00 * x + m01 * y + m02 * z; - m13 += m10 * x + m11 * y + m12 * z; - m23 += m20 * x + m21 * y + m22 * z; - m33 += m30 * x + m31 * y + m32 * z; + m03 += m00*x+m01*y+m02*z; + m13 += m10*x+m11*y+m12*z; + m23 += m20*x+m21*y+m22*z; + m33 += m30*x+m31*y+m32*z; return this; } + public Matrix4 scale(Vector3f vec) { m00 *= vec.x; @@ -149,6 +157,7 @@ public Matrix4 scale(Vector3f vec) m32 *= vec.z; return this; } + public Matrix4 scale(double x, double y, double z) { m00 *= x; @@ -165,11 +174,12 @@ public Matrix4 scale(double x, double y, double z) m32 *= z; return this; } + public Matrix4 rotate(double angle, Vector3f axis) { double c = Math.cos(angle); double s = Math.sin(angle); - double mc = 1.0f - c; + double mc = 1.0f-c; double xy = axis.x*axis.y; double yz = axis.y*axis.z; double xz = axis.x*axis.z; @@ -185,18 +195,18 @@ public Matrix4 rotate(double angle, Vector3f axis) double f02 = xz*mc+ys; double f12 = yz*mc-xs; double f22 = axis.z*axis.z*mc+c; - double t00 = m00 * f00 + m01 * f10 + m02 * f20; - double t10 = m10 * f00 + m11 * f10 + m12 * f20; - double t20 = m20 * f00 + m21 * f10 + m22 * f20; - double t30 = m30 * f00 + m31 * f10 + m32 * f20; - double t01 = m00 * f01 + m01 * f11 + m02 * f21; - double t11 = m10 * f01 + m11 * f11 + m12 * f21; - double t21 = m20 * f01 + m21 * f11 + m22 * f21; - double t31 = m30 * f01 + m31 * f11 + m32 * f21; - m02 = m00 * f02 + m01 * f12 + m02 * f22; - m12 = m10 * f02 + m11 * f12 + m12 * f22; - m22 = m20 * f02 + m21 * f12 + m22 * f22; - m32 = m30 * f02 + m31 * f12 + m32 * f22; + double t00 = m00*f00+m01*f10+m02*f20; + double t10 = m10*f00+m11*f10+m12*f20; + double t20 = m20*f00+m21*f10+m22*f20; + double t30 = m30*f00+m31*f10+m32*f20; + double t01 = m00*f01+m01*f11+m02*f21; + double t11 = m10*f01+m11*f11+m12*f21; + double t21 = m20*f01+m21*f11+m22*f21; + double t31 = m30*f01+m31*f11+m32*f21; + m02 = m00*f02+m01*f12+m02*f22; + m12 = m10*f02+m11*f12+m12*f22; + m22 = m20*f02+m21*f12+m22*f22; + m32 = m30*f02+m31*f12+m32*f22; m00 = t00; m10 = t10; m20 = t20; @@ -207,11 +217,12 @@ public Matrix4 rotate(double angle, Vector3f axis) m31 = t31; return this; } + public Matrix4 rotate(double angle, double x, double y, double z) { double c = Math.cos(angle); double s = Math.sin(angle); - double mc = 1.0f - c; + double mc = 1.0f-c; double xy = x*y; double yz = y*z; double xz = x*z; @@ -227,18 +238,18 @@ public Matrix4 rotate(double angle, double x, double y, double z) double f02 = xz*mc+ys; double f12 = yz*mc-xs; double f22 = z*z*mc+c; - double t00 = m00 * f00 + m01 * f10 + m02 * f20; - double t10 = m10 * f00 + m11 * f10 + m12 * f20; - double t20 = m20 * f00 + m21 * f10 + m22 * f20; - double t30 = m30 * f00 + m31 * f10 + m32 * f20; - double t01 = m00 * f01 + m01 * f11 + m02 * f21; - double t11 = m10 * f01 + m11 * f11 + m12 * f21; - double t21 = m20 * f01 + m21 * f11 + m22 * f21; - double t31 = m30 * f01 + m31 * f11 + m32 * f21; - m02 = m00 * f02 + m01 * f12 + m02 * f22; - m12 = m10 * f02 + m11 * f12 + m12 * f22; - m22 = m20 * f02 + m21 * f12 + m22 * f22; - m32 = m30 * f02 + m31 * f12 + m32 * f22; + double t00 = m00*f00+m01*f10+m02*f20; + double t10 = m10*f00+m11*f10+m12*f20; + double t20 = m20*f00+m21*f10+m22*f20; + double t30 = m30*f00+m31*f10+m32*f20; + double t01 = m00*f01+m01*f11+m02*f21; + double t11 = m10*f01+m11*f11+m12*f21; + double t21 = m20*f01+m21*f11+m22*f21; + double t31 = m30*f01+m31*f11+m32*f21; + m02 = m00*f02+m01*f12+m02*f22; + m12 = m10*f02+m11*f12+m12*f22; + m22 = m20*f02+m21*f12+m22*f22; + m32 = m30*f02+m31*f12+m32*f22; m00 = t00; m10 = t10; m20 = t20; @@ -249,24 +260,25 @@ public Matrix4 rotate(double angle, double x, double y, double z) m31 = t31; return this; } + public Matrix4 leftMultiply(Matrix4 mat) { - double n00 = m00 * mat.m00 + m10 * mat.m01 + m20 * mat.m02 + m30 * mat.m03; - double n01 = m01 * mat.m00 + m11 * mat.m01 + m21 * mat.m02 + m31 * mat.m03; - double n02 = m02 * mat.m00 + m12 * mat.m01 + m22 * mat.m02 + m32 * mat.m03; - double n03 = m03 * mat.m00 + m13 * mat.m01 + m23 * mat.m02 + m33 * mat.m03; - double n10 = m00 * mat.m10 + m10 * mat.m11 + m20 * mat.m12 + m30 * mat.m13; - double n11 = m01 * mat.m10 + m11 * mat.m11 + m21 * mat.m12 + m31 * mat.m13; - double n12 = m02 * mat.m10 + m12 * mat.m11 + m22 * mat.m12 + m32 * mat.m13; - double n13 = m03 * mat.m10 + m13 * mat.m11 + m23 * mat.m12 + m33 * mat.m13; - double n20 = m00 * mat.m20 + m10 * mat.m21 + m20 * mat.m22 + m30 * mat.m23; - double n21 = m01 * mat.m20 + m11 * mat.m21 + m21 * mat.m22 + m31 * mat.m23; - double n22 = m02 * mat.m20 + m12 * mat.m21 + m22 * mat.m22 + m32 * mat.m23; - double n23 = m03 * mat.m20 + m13 * mat.m21 + m23 * mat.m22 + m33 * mat.m23; - double n30 = m00 * mat.m30 + m10 * mat.m31 + m20 * mat.m32 + m30 * mat.m33; - double n31 = m01 * mat.m30 + m11 * mat.m31 + m21 * mat.m32 + m31 * mat.m33; - double n32 = m02 * mat.m30 + m12 * mat.m31 + m22 * mat.m32 + m32 * mat.m33; - double n33 = m03 * mat.m30 + m13 * mat.m31 + m23 * mat.m32 + m33 * mat.m33; + double n00 = m00*mat.m00+m10*mat.m01+m20*mat.m02+m30*mat.m03; + double n01 = m01*mat.m00+m11*mat.m01+m21*mat.m02+m31*mat.m03; + double n02 = m02*mat.m00+m12*mat.m01+m22*mat.m02+m32*mat.m03; + double n03 = m03*mat.m00+m13*mat.m01+m23*mat.m02+m33*mat.m03; + double n10 = m00*mat.m10+m10*mat.m11+m20*mat.m12+m30*mat.m13; + double n11 = m01*mat.m10+m11*mat.m11+m21*mat.m12+m31*mat.m13; + double n12 = m02*mat.m10+m12*mat.m11+m22*mat.m12+m32*mat.m13; + double n13 = m03*mat.m10+m13*mat.m11+m23*mat.m12+m33*mat.m13; + double n20 = m00*mat.m20+m10*mat.m21+m20*mat.m22+m30*mat.m23; + double n21 = m01*mat.m20+m11*mat.m21+m21*mat.m22+m31*mat.m23; + double n22 = m02*mat.m20+m12*mat.m21+m22*mat.m22+m32*mat.m23; + double n23 = m03*mat.m20+m13*mat.m21+m23*mat.m22+m33*mat.m23; + double n30 = m00*mat.m30+m10*mat.m31+m20*mat.m32+m30*mat.m33; + double n31 = m01*mat.m30+m11*mat.m31+m21*mat.m32+m31*mat.m33; + double n32 = m02*mat.m30+m12*mat.m31+m22*mat.m32+m32*mat.m33; + double n33 = m03*mat.m30+m13*mat.m31+m23*mat.m32+m33*mat.m33; m00 = n00; m01 = n01; m02 = n02; @@ -285,24 +297,25 @@ public Matrix4 leftMultiply(Matrix4 mat) m33 = n33; return this; } + public Matrix4 multiply(Matrix4 mat) { - double n00 = m00 * mat.m00 + m01 * mat.m10 + m02 * mat.m20 + m03 * mat.m30; - double n01 = m00 * mat.m01 + m01 * mat.m11 + m02 * mat.m21 + m03 * mat.m31; - double n02 = m00 * mat.m02 + m01 * mat.m12 + m02 * mat.m22 + m03 * mat.m32; - double n03 = m00 * mat.m03 + m01 * mat.m13 + m02 * mat.m23 + m03 * mat.m33; - double n10 = m10 * mat.m00 + m11 * mat.m10 + m12 * mat.m20 + m13 * mat.m30; - double n11 = m10 * mat.m01 + m11 * mat.m11 + m12 * mat.m21 + m13 * mat.m31; - double n12 = m10 * mat.m02 + m11 * mat.m12 + m12 * mat.m22 + m13 * mat.m32; - double n13 = m10 * mat.m03 + m11 * mat.m13 + m12 * mat.m23 + m13 * mat.m33; - double n20 = m20 * mat.m00 + m21 * mat.m10 + m22 * mat.m20 + m23 * mat.m30; - double n21 = m20 * mat.m01 + m21 * mat.m11 + m22 * mat.m21 + m23 * mat.m31; - double n22 = m20 * mat.m02 + m21 * mat.m12 + m22 * mat.m22 + m23 * mat.m32; - double n23 = m20 * mat.m03 + m21 * mat.m13 + m22 * mat.m23 + m23 * mat.m33; - double n30 = m30 * mat.m00 + m31 * mat.m10 + m32 * mat.m20 + m33 * mat.m30; - double n31 = m30 * mat.m01 + m31 * mat.m11 + m32 * mat.m21 + m33 * mat.m31; - double n32 = m30 * mat.m02 + m31 * mat.m12 + m32 * mat.m22 + m33 * mat.m32; - double n33 = m30 * mat.m03 + m31 * mat.m13 + m32 * mat.m23 + m33 * mat.m33; + double n00 = m00*mat.m00+m01*mat.m10+m02*mat.m20+m03*mat.m30; + double n01 = m00*mat.m01+m01*mat.m11+m02*mat.m21+m03*mat.m31; + double n02 = m00*mat.m02+m01*mat.m12+m02*mat.m22+m03*mat.m32; + double n03 = m00*mat.m03+m01*mat.m13+m02*mat.m23+m03*mat.m33; + double n10 = m10*mat.m00+m11*mat.m10+m12*mat.m20+m13*mat.m30; + double n11 = m10*mat.m01+m11*mat.m11+m12*mat.m21+m13*mat.m31; + double n12 = m10*mat.m02+m11*mat.m12+m12*mat.m22+m13*mat.m32; + double n13 = m10*mat.m03+m11*mat.m13+m12*mat.m23+m13*mat.m33; + double n20 = m20*mat.m00+m21*mat.m10+m22*mat.m20+m23*mat.m30; + double n21 = m20*mat.m01+m21*mat.m11+m22*mat.m21+m23*mat.m31; + double n22 = m20*mat.m02+m21*mat.m12+m22*mat.m22+m23*mat.m32; + double n23 = m20*mat.m03+m21*mat.m13+m22*mat.m23+m23*mat.m33; + double n30 = m30*mat.m00+m31*mat.m10+m32*mat.m20+m33*mat.m30; + double n31 = m30*mat.m01+m31*mat.m11+m32*mat.m21+m33*mat.m31; + double n32 = m30*mat.m02+m31*mat.m12+m32*mat.m22+m33*mat.m32; + double n33 = m30*mat.m03+m31*mat.m13+m32*mat.m23+m33*mat.m33; m00 = n00; m01 = n01; m02 = n02; @@ -321,6 +334,7 @@ public Matrix4 multiply(Matrix4 mat) m33 = n33; return this; } + public Matrix4 transpose() { double n00 = m00; @@ -357,10 +371,12 @@ public Matrix4 transpose() m33 = n33; return this; } + public Matrix4 copy() { return new Matrix4(this); } + public Matrix4 set(Matrix4 mat) { m00 = mat.m00; @@ -381,19 +397,22 @@ public Matrix4 set(Matrix4 mat) m33 = mat.m33; return this; } + public void apply(Matrix4 mat) { mat.multiply(this); } + private void mult3x3(Vector3f vec) { - double x = m00 * vec.x + m01 * vec.y + m02 * vec.z; - double y = m10 * vec.x + m11 * vec.y + m12 * vec.z; - double z = m20 * vec.x + m21 * vec.y + m22 * vec.z; + double x = m00*vec.x+m01*vec.y+m02*vec.z; + double y = m10*vec.x+m11*vec.y+m12*vec.z; + double z = m20*vec.x+m21*vec.y+m22*vec.z; vec.x = (float)x; vec.y = (float)y; vec.z = (float)z; } + public void apply(Vector3f vec) { mult3x3(vec); @@ -401,13 +420,15 @@ public void apply(Vector3f vec) vec.y += m13; vec.z += m23; } + private Vec3d mult3x3(Vec3d vec) { - double x = m00 * vec.x + m01 * vec.y + m02 * vec.z; - double y = m10 * vec.x + m11 * vec.y + m12 * vec.z; - double z = m20 * vec.x + m21 * vec.y + m22 * vec.z; - return new Vec3d(x,y,z); + double x = m00*vec.x+m01*vec.y+m02*vec.z; + double y = m10*vec.x+m11*vec.y+m12*vec.z; + double z = m20*vec.x+m21*vec.y+m22*vec.z; + return new Vec3d(x, y, z); } + public Vec3d apply(Vec3d vec) { return mult3x3(vec).addVector(m03, m13, m23); @@ -415,9 +436,9 @@ public Vec3d apply(Vec3d vec) private org.lwjgl.util.vector.Vector3f mult3x3(org.lwjgl.util.vector.Vector3f vec) { - float x = (float) (m00 * vec.x + m01 * vec.y + m02 * vec.z); - float y = (float) (m10 * vec.x + m11 * vec.y + m12 * vec.z); - float z = (float) (m20 * vec.x + m21 * vec.y + m22 * vec.z); + float x = (float)(m00*vec.x+m01*vec.y+m02*vec.z); + float y = (float)(m10*vec.x+m11*vec.y+m12*vec.z); + float z = (float)(m20*vec.x+m21*vec.y+m22*vec.z); return new org.lwjgl.util.vector.Vector3f(x, y, z); } @@ -432,14 +453,27 @@ public org.lwjgl.util.vector.Vector3f apply(org.lwjgl.util.vector.Vector3f vec) public Matrix4f toMatrix4f() { - return new Matrix4f((float)m00,(float)m01,(float)m02,(float)m03, (float)m10,(float)m11,(float)m12,(float)m13, (float)m20,(float)m21,(float)m22,(float)m23, (float)m30,(float)m31,(float)m32,(float)m33); + return new Matrix4f((float)m00, (float)m01, (float)m02, (float)m03, (float)m10, (float)m11, (float)m12, (float)m13, (float)m20, (float)m21, (float)m22, (float)m23, (float)m30, (float)m31, (float)m32, (float)m33); } + public void fromMatrix4f(Matrix4f mat) { - m00 = mat.m00; m01 = mat.m01; m02 = mat.m02; m03 = mat.m03; - m10 = mat.m10; m11 = mat.m11; m12 = mat.m12; m13 = mat.m13; - m20 = mat.m20; m21 = mat.m21; m22 = mat.m22; m23 = mat.m23; - m30 = mat.m30; m31 = mat.m31; m32 = mat.m32; m33 = mat.m33; + m00 = mat.m00; + m01 = mat.m01; + m02 = mat.m02; + m03 = mat.m03; + m10 = mat.m10; + m11 = mat.m11; + m12 = mat.m12; + m13 = mat.m13; + m20 = mat.m20; + m21 = mat.m21; + m22 = mat.m22; + m23 = mat.m23; + m30 = mat.m30; + m31 = mat.m31; + m32 = mat.m32; + m33 = mat.m33; } public final void invert() @@ -467,7 +501,7 @@ public boolean equals(Object o) Matrix4 matrix4 = (Matrix4)o; - if(Double.compare(matrix4.m00, m00)!=0)return false; + if(Double.compare(matrix4.m00, m00)!=0) return false; if(Double.compare(matrix4.m01, m01)!=0) return false; if(Double.compare(matrix4.m02, m02)!=0) return false; if(Double.compare(matrix4.m03, m03)!=0) return false; @@ -492,43 +526,43 @@ public int hashCode() int result; long temp; temp = Double.doubleToLongBits(m00); - result = (int)(temp^(temp>>>32)); + result = (int)(temp^(temp >>> 32)); temp = Double.doubleToLongBits(m01); - result = 31*result+(int)(temp^(temp>>>32)); + result = 31*result+(int)(temp^(temp >>> 32)); temp = Double.doubleToLongBits(m02); - result = 31*result+(int)(temp^(temp>>>32)); + result = 31*result+(int)(temp^(temp >>> 32)); temp = Double.doubleToLongBits(m03); - result = 31*result+(int)(temp^(temp>>>32)); + result = 31*result+(int)(temp^(temp >>> 32)); temp = Double.doubleToLongBits(m10); - result = 31*result+(int)(temp^(temp>>>32)); + result = 31*result+(int)(temp^(temp >>> 32)); temp = Double.doubleToLongBits(m11); - result = 31*result+(int)(temp^(temp>>>32)); + result = 31*result+(int)(temp^(temp >>> 32)); temp = Double.doubleToLongBits(m12); - result = 31*result+(int)(temp^(temp>>>32)); + result = 31*result+(int)(temp^(temp >>> 32)); temp = Double.doubleToLongBits(m13); - result = 31*result+(int)(temp^(temp>>>32)); + result = 31*result+(int)(temp^(temp >>> 32)); temp = Double.doubleToLongBits(m20); - result = 31*result+(int)(temp^(temp>>>32)); + result = 31*result+(int)(temp^(temp >>> 32)); temp = Double.doubleToLongBits(m21); - result = 31*result+(int)(temp^(temp>>>32)); + result = 31*result+(int)(temp^(temp >>> 32)); temp = Double.doubleToLongBits(m22); - result = 31*result+(int)(temp^(temp>>>32)); + result = 31*result+(int)(temp^(temp >>> 32)); temp = Double.doubleToLongBits(m23); - result = 31*result+(int)(temp^(temp>>>32)); + result = 31*result+(int)(temp^(temp >>> 32)); temp = Double.doubleToLongBits(m30); - result = 31*result+(int)(temp^(temp>>>32)); + result = 31*result+(int)(temp^(temp >>> 32)); temp = Double.doubleToLongBits(m31); - result = 31*result+(int)(temp^(temp>>>32)); + result = 31*result+(int)(temp^(temp >>> 32)); temp = Double.doubleToLongBits(m32); - result = 31*result+(int)(temp^(temp>>>32)); + result = 31*result+(int)(temp^(temp >>> 32)); temp = Double.doubleToLongBits(m33); - result = 31*result+(int)(temp^(temp>>>32)); + result = 31*result+(int)(temp^(temp >>> 32)); return result; } public FloatBuffer toFloatBuffer(@Nullable FloatBuffer in) { - if (in==null) + if(in==null) in = GLAllocation.createDirectFloatBuffer(16); in.clear(); in.put((float)m00); diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/commands/CommandHandler.java b/src/main/java/blusunrize/immersiveengineering/common/util/commands/CommandHandler.java index bb9a81bb93..dffa883928 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/commands/CommandHandler.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/commands/CommandHandler.java @@ -23,9 +23,10 @@ public class CommandHandler extends CommandTreeBase { private final String name; + public CommandHandler(boolean client) { - if (client) + if(client) { addSubcommand(new CommandResetRenders()); name = "cie"; @@ -49,7 +50,7 @@ public String getName() @Override public int getRequiredPermissionLevel() { - return name.equals("cie")?0:4; + return name.equals("cie")?0: 4; } @Nonnull @@ -61,15 +62,17 @@ public String getUsage(@Nonnull ICommandSender sender) private static final String start = "<"; private static final String end = ">"; + @Nonnull @Override public List getTabCompletions(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, String[] args, @Nullable BlockPos pos) { List ret = super.getTabCompletions(server, sender, args, pos); - for (int i = 0;i=0) { + String curr = ret.get(i); + if(curr.indexOf(' ') >= 0) + { ret.set(i, start+curr+end); } } @@ -81,28 +84,28 @@ public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sen { List argsCleaned = new ArrayList<>(args.length); String currentPart = null; - for (String s:args) + for(String s : args) { - if (s.startsWith(start)) + if(s.startsWith(start)) { - if (currentPart!=null) + if(currentPart!=null) throw new CommandException("String opens twice (once \""+currentPart+"\", once \""+s+"\")"); currentPart = s; } - else if (currentPart!=null) + else if(currentPart!=null) currentPart += " "+s; else argsCleaned.add(s); - if (s.endsWith(end)) + if(s.endsWith(end)) { - if (currentPart==null) + if(currentPart==null) throw new CommandException("String closed without being openeed first! (\""+s+"\")"); - if (currentPart.length()>=2) + if(currentPart.length() >= 2) argsCleaned.add(currentPart.substring(1, currentPart.length()-1)); currentPart = null; } } - if (currentPart!=null) + if(currentPart!=null) throw new CommandException("Unclosed string ("+currentPart+")"); super.execute(server, sender, argsCleaned.toArray(new String[0])); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/commands/CommandMineral.java b/src/main/java/blusunrize/immersiveengineering/common/util/commands/CommandMineral.java index 38d1a93b8b..c82798832e 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/commands/CommandMineral.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/commands/CommandMineral.java @@ -39,6 +39,7 @@ public class CommandMineral extends CommandTreeBase addSubcommand(new CommandMineralSetDepletion()); addSubcommand(new CommandTreeHelp(this)); } + @Nonnull @Override public String getName() @@ -60,12 +61,12 @@ public List getTabCompletions(@Nonnull MinecraftServer server, @Nonnull { ArrayList list = new ArrayList<>(); // subcommand argument autocomplete - if(args.length>1) + if(args.length > 1) { - switch (args[0]) + switch(args[0]) { case "set": - if(args.length>2) + if(args.length > 2) break; for(MineralMix mineralMix : ExcavatorHandler.mineralList.keySet()) if(args[1].isEmpty()||mineralMix.name.toLowerCase(Locale.ENGLISH).startsWith(args[1].toLowerCase(Locale.ENGLISH))) @@ -100,12 +101,12 @@ public String getUsage(@Nonnull ICommandSender sender) } @Override - public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, @Nonnull String[] args) throws CommandException + public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, @Nonnull String[] args) { StringBuilder s = new StringBuilder(); - int i=0; + int i = 0; for(MineralMix mm : ExcavatorHandler.mineralList.keySet()) - s.append((i++) > 0 ? ", " : "").append(mm.name); + s.append((i++) > 0?", ": "").append(mm.name); sender.sendMessage(new TextComponentString(s.toString())); } } @@ -127,15 +128,15 @@ public String getUsage(@Nonnull ICommandSender sender) } @Override - public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, @Nonnull String[] args) throws CommandException + public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, @Nonnull String[] args) { MineralWorldInfo info = ExcavatorHandler.getMineralWorldInfo(sender.getEntityWorld(), - sender.getPosition().getX()>>4, sender.getPosition().getZ()>>4); + sender.getPosition().getX() >> 4, sender.getPosition().getZ() >> 4); sender.sendMessage(new TextComponentTranslation(Lib.CHAT_COMMAND+ CommandMineral.this.getName()+".get", - TextFormatting.GOLD+(info.mineral!=null?info.mineral.name:"null")+ TextFormatting.RESET, - TextFormatting.GOLD+(info.mineralOverride!=null?info.mineralOverride.name:"null")+ TextFormatting.RESET, - TextFormatting.GOLD+(""+info.depletion)+ TextFormatting.RESET)); + TextFormatting.GOLD+(info.mineral!=null?info.mineral.name: "null")+TextFormatting.RESET, + TextFormatting.GOLD+(info.mineralOverride!=null?info.mineralOverride.name: "null")+TextFormatting.RESET, + TextFormatting.GOLD+(""+info.depletion)+TextFormatting.RESET)); } } @@ -160,30 +161,31 @@ public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sen { MineralWorldInfo info = ExcavatorHandler.getMineralWorldInfo(sender.getEntityWorld(), - sender.getPosition().getX()>>4, sender.getPosition().getZ()>>4); - if(args.length<1) + sender.getPosition().getX() >> 4, sender.getPosition().getZ() >> 4); + if(args.length < 1) throw new CommandException("Need exactly one parameter"); StringBuilder name = new StringBuilder(); - for (int i = 0; i < args.length; i++) + for(int i = 0; i < args.length; i++) { name.append(args[i]); - if (i>4, sender.getPosition().getZ()>>4); + sender.getPosition().getX() >> 4, sender.getPosition().getZ() >> 4); if(args.length!=1) throw new CommandException("Need exactly one parameter"); int depl = parseInt(args[0].trim()); info.depletion = depl; - sender.sendMessage(new TextComponentTranslation(Lib.CHAT_COMMAND+CommandMineral.this.getName()+".setDepletion.sucess",(depl<0? I18n.translateToLocal(Lib.CHAT_INFO+"coreDrill.infinite"):Integer.toString(depl)))); + sender.sendMessage(new TextComponentTranslation(Lib.CHAT_COMMAND+CommandMineral.this.getName()+".setDepletion.sucess", (depl < 0?I18n.translateToLocal(Lib.CHAT_INFO+"coreDrill.infinite"): Integer.toString(depl)))); IESaveData.setDirty(sender.getEntityWorld().provider.getDimension()); } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/commands/CommandShaders.java b/src/main/java/blusunrize/immersiveengineering/common/util/commands/CommandShaders.java index 1b0c4395d5..a055f7e3c5 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/commands/CommandShaders.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/commands/CommandShaders.java @@ -39,11 +39,11 @@ public String getUsage(@Nonnull ICommandSender sender) @Override public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, @Nonnull String[] args) { - String player = args.length > 0 ? args[0].trim() : sender.getName(); - if (ShaderRegistry.receivedShaders.containsKey(player)) + String player = args.length > 0?args[0].trim(): sender.getName(); + if(ShaderRegistry.receivedShaders.containsKey(player)) ShaderRegistry.receivedShaders.get(player).clear(); ShaderRegistry.recalculatePlayerTotalWeight(player); - sender.sendMessage(new TextComponentTranslation(Lib.CHAT_COMMAND + "shaders.clear.sucess", player)); + sender.sendMessage(new TextComponentTranslation(Lib.CHAT_COMMAND+"shaders.clear.sucess", player)); } @Nonnull diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/ActuallyAdditionsHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/ActuallyAdditionsHelper.java index f85ed4e9bc..afb4faa39a 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/ActuallyAdditionsHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/ActuallyAdditionsHelper.java @@ -107,7 +107,7 @@ public FarmerResult tryHarvestPlant(World world, BlockPos pos, IFarmer farmer) if(farmer.getEnergy() >= use) { IBlockState state = world.getBlockState(pos); - if(IEContent.blockCrop==state.getBlock() && state.getBlock().getMetaFromState(state)==4)//Fully Grown + if(IEContent.blockCrop==state.getBlock()&&state.getBlock().getMetaFromState(state)==4)//Fully Grown { BlockPos up = pos.up(); IBlockState stateUp = world.getBlockState(up); diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/AlbedoHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/AlbedoHelper.java index 003577c269..5019202379 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/AlbedoHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/AlbedoHelper.java @@ -43,7 +43,7 @@ public void gatherLights(GatherLightsEvent event) Light.Builder builder = Light.builder(); builder.radius(2.5f); - builder.color(77/255f,74/255f,152/255f); + builder.color(77/255f, 74/255f, 152/255f); for(Vec3d point : animation.subPoints) { builder.pos(point); diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/AttainedDropsHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/AttainedDropsHelper.java index e4e783212d..66a3bf8773 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/AttainedDropsHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/AttainedDropsHelper.java @@ -48,7 +48,7 @@ public void init() final IBlockState blockstatePlant = blockPlant.getDefaultState(); IProperty propertyAge = null; for(IProperty prop : blockstatePlant.getPropertyKeys()) - if("age".equals(prop.getName()) && prop instanceof PropertyInteger) + if("age".equals(prop.getName())&&prop instanceof PropertyInteger) propertyAge = prop; final IProperty propertyAge_final = propertyAge; @@ -61,7 +61,7 @@ public void init() addType("prismarine", new ItemStack(Items.PRISMARINE_SHARD)); addType("blaze", new ItemStack(Items.BLAZE_ROD)); addType("gunpowder", new ItemStack(Items.GUNPOWDER)); - addType("witherskull", new ItemStack(Items.SKULL,1,1)); + addType("witherskull", new ItemStack(Items.SKULL, 1, 1)); addType("enderpearl", new ItemStack(Items.ENDER_PEARL)); BelljarHandler.registerHandler(new IPlantHandler() { @@ -70,16 +70,19 @@ public boolean isCorrectSoil(ItemStack seed, ItemStack soil) { return !soil.isEmpty()&&soilOutputMap.containsKey(new ComparableItemStack(soil, true, false)); } + @Override public float getGrowthStep(ItemStack seed, ItemStack soil, float growth, TileEntity tile, float fertilizer, boolean render) { - return (growth<.5?.003125f:.0015625f)*fertilizer; + return (growth < .5?.003125f: .0015625f)*fertilizer; } + @Override public float resetGrowth(ItemStack seed, ItemStack soil, float growth, TileEntity tile, boolean render) { return .5f; } + @Override public ItemStack[] getOutput(ItemStack seed, ItemStack soil, TileEntity tile) { @@ -88,10 +91,11 @@ public ItemStack[] getOutput(ItemStack seed, ItemStack soil, TileEntity tile) return new ItemStack[0]; return out; } + @Override public boolean isValid(ItemStack seed) { - return !seed.isEmpty() && seed.getItem()==itemSeed; + return !seed.isEmpty()&&seed.getItem()==itemSeed; } @Override @@ -100,22 +104,24 @@ public IBlockState[] getRenderedPlant(ItemStack seed, ItemStack soil, float grow { return new IBlockState[0]; } + @Override @SideOnly(Side.CLIENT) public float getRenderSize(ItemStack seed, ItemStack soil, float growth, TileEntity tile) { return .875f; } + @Override @SideOnly(Side.CLIENT) public boolean overrideRender(ItemStack seed, ItemStack soil, float growth, TileEntity tile, BlockRendererDispatcher blockRenderer) { - IBlockState state = blockstatePlant.withProperty(propertyAge_final, growth>=.5?7:Math.min(7,Math.round(7*growth*2))); + IBlockState state = blockstatePlant.withProperty(propertyAge_final, growth >= .5?7: Math.min(7, Math.round(7*growth*2))); IBakedModel model = blockRenderer.getModelForState(state); GlStateManager.pushMatrix(); blockRenderer.getBlockModelRenderer().renderModelBrightness(model, state, 1, true); GlStateManager.popMatrix(); - if(growth>=.5) + if(growth >= .5) { state = bulbMap.get(new ComparableItemStack(soil, true, false)); model = blockRenderer.getModelForState(state); @@ -135,7 +141,7 @@ static void addType(String type, ItemStack out) { Block soilBlock = Block.REGISTRY.getObject(new ResourceLocation("attaineddrops:"+type+"_soil")); Block bulbBlock = Block.REGISTRY.getObject(new ResourceLocation("attaineddrops:"+type+"_bulb")); - if(soilBlock!=null && bulbBlock!=null) + if(soilBlock!=null&&bulbBlock!=null) { ComparableItemStack comp = new ComparableItemStack(new ItemStack(soilBlock), true, true); soilOutputMap.put(comp, new ItemStack[]{out}); diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/BetterWithModsHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/BetterWithModsHelper.java index e870820bcf..46291db975 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/BetterWithModsHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/BetterWithModsHelper.java @@ -28,10 +28,10 @@ public void init() Item hempSeeds = Item.REGISTRY.getObject(new ResourceLocation("betterwithmods:hemp")); Item material = Item.REGISTRY.getObject(new ResourceLocation("betterwithmods:material")); Block hempBlock = Block.REGISTRY.getObject(new ResourceLocation("betterwithmods:hemp")); - if(hempSeeds!=null && material!=null && hempBlock!=null) - BelljarHandler.cropHandler.register(new ItemStack(hempSeeds), new ItemStack[]{new ItemStack(material,1,2),new ItemStack(hempSeeds,1)}, new ItemStack(Blocks.DIRT), hempBlock.getDefaultState()); + if(hempSeeds!=null&&material!=null&&hempBlock!=null) + BelljarHandler.cropHandler.register(new ItemStack(hempSeeds), new ItemStack[]{new ItemStack(material, 1, 2), new ItemStack(hempSeeds, 1)}, new ItemStack(Blocks.DIRT), hempBlock.getDefaultState()); if(material!=null) - BelljarHandler.registerBasicItemFertilizer(new ItemStack(material,1,5), 1.25f); + BelljarHandler.registerBasicItemFertilizer(new ItemStack(material, 1, 5), 1.25f); } @Override diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/BloodMagicHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/BloodMagicHelper.java index b7d2fce79f..054f4d7324 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/BloodMagicHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/BloodMagicHelper.java @@ -31,7 +31,7 @@ public void preInit() public void init() { Item crystal = Item.REGISTRY.getObject(new ResourceLocation("bloodmagic:item_demon_crystal")); - if(crystal != null) + if(crystal!=null) BlueprintCraftingRecipe.addRecipe("specialBullet", BulletHandler.getBulletStack("crystalwill"), new ItemStack(IEContent.itemBullet, 1, 0), Items.GUNPOWDER, crystal); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/BotaniaHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/BotaniaHelper.java index 2f4595053f..ef96073b11 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/BotaniaHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/BotaniaHelper.java @@ -68,14 +68,14 @@ public void init() makeShaderRelic("The Kindled"); makeShaderRelic("Dark Fire"); - ShaderRegistryEntry entry = ItemShader.addShader("Terra", 1, rariryRelic, 0xff3e2d14, 0xff2b1108, 0xff41bd1a, 0xff2e120a).setInfo(null,"Botania","terra"); - entry.getCase("immersiveengineering:revolver").addLayers(new ShaderLayer(new ResourceLocation("botania:blocks/livingwood5"),0xffffffff).setTextureBounds(17/128d,24/128d,33/128d,40/128d)); - entry.getCase("immersiveengineering:drill").addLayers(new ShaderLayer(new ResourceLocation("botania:blocks/alfheim_portal_swirl"),0xffffffff).setTextureBounds(14/64d,10/64d, 26/64d,22/64d)); - entry.getCase("immersiveengineering:railgun").addLayers(new ShaderLayer(new ResourceLocation("botania:blocks/storage1"),0xff9e83eb).setTextureBounds(55/64d,42/64d,1,58/64d).setCutoutBounds(.1875,0,.75,1)); - entry.getCase("immersiveengineering:shield").addLayers(new ShaderLayer(new ResourceLocation("botania:blocks/crate_open"),0xffffffff).setTextureBounds(0/32f,9/32f, 14/32f,26/32f).setCutoutBounds(.0625,0, .9375,1)); + ShaderRegistryEntry entry = ItemShader.addShader("Terra", 1, rariryRelic, 0xff3e2d14, 0xff2b1108, 0xff41bd1a, 0xff2e120a).setInfo(null, "Botania", "terra"); + entry.getCase("immersiveengineering:revolver").addLayers(new ShaderLayer(new ResourceLocation("botania:blocks/livingwood5"), 0xffffffff).setTextureBounds(17/128d, 24/128d, 33/128d, 40/128d)); + entry.getCase("immersiveengineering:drill").addLayers(new ShaderLayer(new ResourceLocation("botania:blocks/alfheim_portal_swirl"), 0xffffffff).setTextureBounds(14/64d, 10/64d, 26/64d, 22/64d)); + entry.getCase("immersiveengineering:railgun").addLayers(new ShaderLayer(new ResourceLocation("botania:blocks/storage1"), 0xff9e83eb).setTextureBounds(55/64d, 42/64d, 1, 58/64d).setCutoutBounds(.1875, 0, .75, 1)); + entry.getCase("immersiveengineering:shield").addLayers(new ShaderLayer(new ResourceLocation("botania:blocks/crate_open"), 0xffffffff).setTextureBounds(0/32f, 9/32f, 14/32f, 26/32f).setCutoutBounds(.0625, 0, .9375, 1)); } - if(FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) + if(FMLCommonHandler.instance().getEffectiveSide()==Side.CLIENT) MinecraftForge.EVENT_BUS.register(this); } @@ -94,13 +94,13 @@ public void postInit() @SubscribeEvent(priority = EventPriority.LOW) public void onLivingDrops(LivingDropsEvent event) { - if(!event.isCanceled() && event.getEntityLiving().getClass().getName().endsWith("EntityDoppleganger")) + if(!event.isCanceled()&&event.getEntityLiving().getClass().getName().endsWith("EntityDoppleganger")) { NBTTagCompound tag = new NBTTagCompound(); event.getEntityLiving().writeEntityToNBT(tag); if(tag.getBoolean("hardMode")) for(EntityItem item : event.getDrops()) - if(item != null && !item.getItem().isEmpty() && IEContent.itemShaderBag.equals(item.getItem().getItem())) + if(item!=null&&!item.getItem().isEmpty()&&IEContent.itemShaderBag.equals(item.getItem().getItem())) ItemNBTHelper.setString(item.getItem(), "rarity", "RELIC"); } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/ChiselsAndBitsHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/ChiselsAndBitsHelper.java index 47b903a5a3..bd51f180eb 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/ChiselsAndBitsHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/ChiselsAndBitsHelper.java @@ -50,15 +50,15 @@ public Boolean apply(@Nullable List list) list.add(IEContent.blockMetalDevice0.getStateFromMeta(BlockTypes_MetalDevice0.BARREL.getMeta())); for(EnumFacing f : EnumFacing.values()) { - list.add(IEContent.blockMetalDevice1.getStateFromMeta(BlockTypes_MetalDevice1.FURNACE_HEATER.getMeta()).withProperty(IEProperties.FACING_ALL,f)); - if(f.getAxis()!= Axis.Y) - list.add(IEContent.blockMetalDevice1.getStateFromMeta(BlockTypes_MetalDevice1.DYNAMO.getMeta()).withProperty(IEProperties.FACING_ALL,f)); + list.add(IEContent.blockMetalDevice1.getStateFromMeta(BlockTypes_MetalDevice1.FURNACE_HEATER.getMeta()).withProperty(IEProperties.FACING_ALL, f)); + if(f.getAxis()!=Axis.Y) + list.add(IEContent.blockMetalDevice1.getStateFromMeta(BlockTypes_MetalDevice1.DYNAMO.getMeta()).withProperty(IEProperties.FACING_ALL, f)); // if(f==EnumFacing.NORTH) // list.add(IEContent.blockMetalDevice1.getStateFromMeta(BlockTypes_MetalDevice1.THERMOELECTRIC_GEN.getMeta()).withProperty(IEProperties.FACING_ALL,f)); } - list.add(IEContent.blockMetalDevice1.getStateFromMeta(BlockTypes_MetalDevice1.THERMOELECTRIC_GEN.getMeta()).withProperty(IEProperties.FACING_ALL,EnumFacing.UP)); - list.add(IEContent.blockMetalDevice1.getStateFromMeta(BlockTypes_MetalDevice1.THERMOELECTRIC_GEN.getMeta()).withProperty(IEProperties.FACING_ALL,EnumFacing.DOWN)); - list.add(IEContent.blockMetalDevice1.getStateFromMeta(BlockTypes_MetalDevice1.THERMOELECTRIC_GEN.getMeta()).withProperty(IEProperties.FACING_ALL,EnumFacing.NORTH)); + list.add(IEContent.blockMetalDevice1.getStateFromMeta(BlockTypes_MetalDevice1.THERMOELECTRIC_GEN.getMeta()).withProperty(IEProperties.FACING_ALL, EnumFacing.UP)); + list.add(IEContent.blockMetalDevice1.getStateFromMeta(BlockTypes_MetalDevice1.THERMOELECTRIC_GEN.getMeta()).withProperty(IEProperties.FACING_ALL, EnumFacing.DOWN)); + list.add(IEContent.blockMetalDevice1.getStateFromMeta(BlockTypes_MetalDevice1.THERMOELECTRIC_GEN.getMeta()).withProperty(IEProperties.FACING_ALL, EnumFacing.NORTH)); list.add(IEContent.blockWoodenDevice0.getStateFromMeta(BlockTypes_WoodenDevice0.CRATE.getMeta())); diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/CoFHHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/CoFHHelper.java index 02c21ab82a..a27d80328e 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/CoFHHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/CoFHHelper.java @@ -24,7 +24,8 @@ public void preInit() @Override public void init() { - try{ + try + { final Class c_ingredientClass = Class.forName("cofh.core.util.crafting.FluidIngredientFactory$FluidIngredient"); final Field f_fluid = c_ingredientClass.getDeclaredField("fluid"); f_fluid.setAccessible(true); @@ -34,13 +35,18 @@ public void init() public RecipeQuery apply(Object o) { if(c_ingredientClass.isAssignableFrom(o.getClass())) - try { + try + { return new RecipeQuery(f_fluid.get(o), 10000); - } catch(Exception e) {} + } catch(Exception e) + { + } return null; } }); - }catch(Exception e){} + } catch(Exception e) + { + } } @Override diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/DenseOresHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/DenseOresHelper.java index e72cecd1f4..6ec68beed7 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/DenseOresHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/DenseOresHelper.java @@ -24,7 +24,7 @@ public class DenseOresHelper extends IECompatModule public void preInit() { } - + @Override public void init() { @@ -35,59 +35,64 @@ public void postInit() { HashMap map = null; Field f_baseOreDictionary = null; - try{ + try + { Class c_DenseOresRegistry = Class.forName("com.rwtema.denseores.DenseOresRegistry"); Class c_DenseOre = Class.forName("com.rwtema.denseores.DenseOre"); f_baseOreDictionary = c_DenseOre.getField("baseOreDictionaryEntry"); map = (HashMap)c_DenseOresRegistry.getField("ores").get(null); - }catch(Exception e) - {} - - if(map!=null && f_baseOreDictionary!=null) + } catch(Exception e) + { + } + + if(map!=null&&f_baseOreDictionary!=null) { ArrayList crushRecipes = new ArrayList(); ArrayList arcRecipes = new ArrayList(); for(Object o : map.values()) { - try{ + try + { String baseOre = (String)f_baseOreDictionary.get(o); String denseOre = "dense"+baseOre; boolean c = false; - for(CrusherRecipe recipe: CrusherRecipe.recipeList) - if(recipe.oreInputString!=null && recipe.oreInputString.equals(baseOre)) + for(CrusherRecipe recipe : CrusherRecipe.recipeList) + if(recipe.oreInputString!=null&&recipe.oreInputString.equals(baseOre)) { - ItemStack out = Utils.copyStackWithAmount(recipe.output, recipe.output.getCount() * 4); + ItemStack out = Utils.copyStackWithAmount(recipe.output, recipe.output.getCount()*4); CrusherRecipe r = new CrusherRecipe(out, denseOre, (int)(recipe.getTotalProcessEnergy()/CrusherRecipe.energyModifier)*2); if(recipe.secondaryOutput!=null) { Object[] newSec = new Object[recipe.secondaryOutput.length*2]; - for(int i=0; i validSeeds = new HashSet<>(); + @Override protected HashSet getSeedSet() { return validSeeds; } + @Override public float getGrowthStep(ItemStack seed, ItemStack soil, float growth, TileEntity tile, float fertilizer, boolean render) { - return !useFertilizer?growthStep:(growthStep*fertilizer); + return !useFertilizer?growthStep: (growthStep*fertilizer); } + @Override @SideOnly(Side.CLIENT) public IBlockState[] getRenderedPlant(ItemStack seed, ItemStack soil, float growth, TileEntity tile) diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/ForestryHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/ForestryHelper.java index 41bb160561..8b88a113cb 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/ForestryHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/ForestryHelper.java @@ -28,24 +28,26 @@ public class ForestryHelper extends IECompatModule public void preInit() { } + @Override public void init() { - FMLInterModComms.sendMessage("forestry", "add-backpack-items", "forestry.forester@" + ImmersiveEngineering.MODID+":seed:*"); + FMLInterModComms.sendMessage("forestry", "add-backpack-items", "forestry.forester@"+ImmersiveEngineering.MODID+":seed:*"); } + @Override public void postInit() { Fluid fluidHoney = FluidRegistry.getFluid("for.honey"); if(fluidHoney!=null) { - SqueezerRecipe.addRecipe(new FluidStack(fluidHoney,100), ItemStack.EMPTY, "dropHoney", 6400); - SqueezerRecipe.addRecipe(new FluidStack(fluidHoney,100), ItemStack.EMPTY, "dropHoneydew", 6400); + SqueezerRecipe.addRecipe(new FluidStack(fluidHoney, 100), ItemStack.EMPTY, "dropHoney", 6400); + SqueezerRecipe.addRecipe(new FluidStack(fluidHoney, 100), ItemStack.EMPTY, "dropHoneydew", 6400); } ChemthrowerHandler.registerFlammable("bio.ethanol"); - ChemthrowerHandler.registerEffect("for.honey", new ChemthrowerEffect_Potion(null,0, IEPotions.sticky,60,1)); - ChemthrowerHandler.registerEffect("juice", new ChemthrowerEffect_Potion(null,0, IEPotions.sticky,40,0)); - Item fertilizer = Item.REGISTRY.getObject(new ResourceLocation("forestry","fertilizer_compound")); + ChemthrowerHandler.registerEffect("for.honey", new ChemthrowerEffect_Potion(null, 0, IEPotions.sticky, 60, 1)); + ChemthrowerHandler.registerEffect("juice", new ChemthrowerEffect_Potion(null, 0, IEPotions.sticky, 40, 0)); + Item fertilizer = Item.REGISTRY.getObject(new ResourceLocation("forestry", "fertilizer_compound")); if(fertilizer!=null) BelljarHandler.registerBasicItemFertilizer(new ItemStack(fertilizer), 1.5f); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/FoundryHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/FoundryHelper.java index 40231e0920..0c9e5c4060 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/FoundryHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/FoundryHelper.java @@ -25,9 +25,9 @@ public void preInit() @Override public void init() { - ChemthrowerHandler.registerEffect("liquidenderpearl", new ChemthrowerEffect_RandomTeleport(null,0, .25f)); - ChemthrowerHandler.registerEffect("liquidredstone", new ChemthrowerEffect_Potion(null,0, IEPotions.conductive,100,1)); - ChemthrowerHandler.registerEffect("liquidglowstone", new ChemthrowerEffect_Potion(null,0, new PotionEffect(MobEffects.GLOWING,200,0),new PotionEffect(MobEffects.SPEED,200,0),new PotionEffect(MobEffects.JUMP_BOOST,200,0))); + ChemthrowerHandler.registerEffect("liquidenderpearl", new ChemthrowerEffect_RandomTeleport(null, 0, .25f)); + ChemthrowerHandler.registerEffect("liquidredstone", new ChemthrowerEffect_Potion(null, 0, IEPotions.conductive, 100, 1)); + ChemthrowerHandler.registerEffect("liquidglowstone", new ChemthrowerEffect_Potion(null, 0, new PotionEffect(MobEffects.GLOWING, 200, 0), new PotionEffect(MobEffects.SPEED, 200, 0), new PotionEffect(MobEffects.JUMP_BOOST, 200, 0))); } @Override diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/GeneralComputerHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/GeneralComputerHelper.java index 75b7ef4367..b42d83542f 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/GeneralComputerHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/GeneralComputerHelper.java @@ -22,7 +22,7 @@ public static void addComputerManualContent() if(added) return; added = true; - if(FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) + if(FMLCommonHandler.instance().getEffectiveSide()==Side.CLIENT) { ManualHelper.getManual().addEntry("computer.general", "computers", new ManualPages.Text(ManualHelper.getManual(), "computer.general0"), new ManualPages.Text(ManualHelper.getManual(), "computer.general1"), @@ -50,7 +50,7 @@ public static void addComputerManualContent() new ManualPages.Text(ManualHelper.getManual(), "computer.refinery1")); ManualHelper.getManual().addEntry("computer.assembler", "computers", new ManualPages.Text(ManualHelper.getManual(), "computer.assembler0"), new ManualPages.Text(ManualHelper.getManual(), "computer.assembler1")); - ManualHelper.getManual().addEntry("computer.mixer","computers", new ManualPages.Text(ManualHelper.getManual(), "computer.mixer0"), new ManualPages.Text(ManualHelper.getManual(), "computer.mixer1")); + ManualHelper.getManual().addEntry("computer.mixer", "computers", new ManualPages.Text(ManualHelper.getManual(), "computer.mixer0"), new ManualPages.Text(ManualHelper.getManual(), "computer.mixer1")); // ManualHelper.getManual().addEntry("computer.bottlingMachine", "computers", new ManualPages.Text(ManualHelper.getManual(), "computer.bottlingMachine0"), // new ManualPages.Text(ManualHelper.getManual(), "computer.bottlingMachine1"), // new ManualPages.Text(ManualHelper.getManual(), "computer.bottlingMachine2")); diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/HarvestcraftHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/HarvestcraftHelper.java index 19d2542fbd..f313271efc 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/HarvestcraftHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/HarvestcraftHelper.java @@ -41,7 +41,7 @@ public void init() if(!(o instanceof OreIngredient)) return null; if(((OreIngredient)o).apply(waterBucket)) - return new RecipeQuery(new FluidStack(FluidRegistry.WATER,1000), 1000); + return new RecipeQuery(new FluidStack(FluidRegistry.WATER, 1000), 1000); return null; }); final Fluid milk = FluidRegistry.getFluid("milk"); @@ -61,6 +61,7 @@ public void init() static HashMap seeds = new HashMap(); static HashMap foods = new HashMap(); static HashMap crops = new HashMap(); + @Override public void postInit() { @@ -69,8 +70,8 @@ public void postInit() Class c_Types = Class.forName("com.pam.harvestcraft.blocks.CropRegistry"); if(c_Types!=null) { - Field f_seeds = c_Types.getDeclaredField("seeds"); - Field f_foods = c_Types.getDeclaredField("foods"); + Field f_seeds = c_Types.getDeclaredField("seeds"); + Field f_foods = c_Types.getDeclaredField("foods"); Field f_crops = c_Types.getDeclaredField("crops"); f_seeds.setAccessible(true); f_foods.setAccessible(true); @@ -83,7 +84,8 @@ public void postInit() for(String type : (String[])f_cropNames.get(null)) addType(type); } - }catch(Exception e){ + } catch(Exception e) + { e.printStackTrace(); } } @@ -93,7 +95,7 @@ static void addType(String type) Item itemSeeds = seeds.get(type); Item itemFood = foods.get(type); Block blockCrop = crops.get(type); - if(itemSeeds!=null && itemFood!=null && blockCrop!=null) - BelljarHandler.cropHandler.register(new ItemStack(itemSeeds), new ItemStack[]{new ItemStack(itemFood,3),new ItemStack(itemSeeds)}, new ItemStack(Blocks.DIRT), blockCrop.getDefaultState()); + if(itemSeeds!=null&&itemFood!=null&&blockCrop!=null) + BelljarHandler.cropHandler.register(new ItemStack(itemSeeds), new ItemStack[]{new ItemStack(itemFood, 3), new ItemStack(itemSeeds)}, new ItemStack(Blocks.DIRT), blockCrop.getDefaultState()); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/IC2Helper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/IC2Helper.java index e2dd3df5b3..4d5aa37d45 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/IC2Helper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/IC2Helper.java @@ -34,10 +34,10 @@ public void init() public RecipeQuery[] getQueriedInputs(AdvRecipe recipe) { IRecipeInput[] in = recipe.input; - if (in!=null) + if(in!=null) { RecipeQuery[] ret = new RecipeQuery[in.length]; - for (int i = 0;i> moduleClasses = new HashMap>(); public static Set modules = new HashSet(); - public static Consumer jeiAddFunc = o -> {}; - public static Consumer jeiRemoveFunc = o -> {}; + public static Consumer jeiAddFunc = o -> { + }; + public static Consumer jeiRemoveFunc = o -> { + }; static { @@ -100,48 +102,72 @@ public static void doModulesPreInit() IELogger.logger.error("Compat module for "+e.getKey()+" could not be preInitialized. Report this and include the error message below!", exception); } } + public static void doModulesInit() { for(IECompatModule compat : IECompatModule.modules) - try{ + try + { compat.init(); - }catch (Exception exception){ + } catch(Exception exception) + { IELogger.logger.error("Compat module for "+compat+" could not be initialized. Report this and include the error message below!", exception); } } + public static void doModulesPostInit() { for(IECompatModule compat : IECompatModule.modules) - try{ + try + { compat.postInit(); - }catch (Exception exception){ + } catch(Exception exception) + { IELogger.logger.error("Compat module for "+compat+" could not be postInitialized. Report this and include the error message below!", exception); } } + //We don't want this to happen multiple times after all >_> public static boolean serverStartingDone = false; + public static void doModulesLoadComplete() { if(!serverStartingDone) { serverStartingDone = true; for(IECompatModule compat : IECompatModule.modules) - try{ + try + { compat.loadComplete(); - }catch (Exception exception){ + } catch(Exception exception) + { IELogger.logger.error("Compat module for "+compat+" could not be initialized. Report this and include the error message below!", exception); } } } public abstract void preInit(); + public abstract void init(); + public abstract void postInit(); - public void loadComplete(){} + + public void loadComplete() + { + } + @SideOnly(Side.CLIENT) - public void clientPreInit(){} + public void clientPreInit() + { + } + @SideOnly(Side.CLIENT) - public void clientInit(){} + public void clientInit() + { + } + @SideOnly(Side.CLIENT) - public void clientPostInit(){} + public void clientPostInit() + { + } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/MysticalAgricultureHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/MysticalAgricultureHelper.java index 75cee943ed..8aa18feb0a 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/MysticalAgricultureHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/MysticalAgricultureHelper.java @@ -33,25 +33,26 @@ public void init() @Override public void postInit() { - Item itemEssence = Item.REGISTRY.getObject(new ResourceLocation("mysticalagriculture","crafting")); + Item itemEssence = Item.REGISTRY.getObject(new ResourceLocation("mysticalagriculture", "crafting")); if(itemEssence!=null) - for(int i=1; i<=5; i++) + for(int i = 1; i <= 5; i++) { - Item itemSeeds = Item.REGISTRY.getObject(new ResourceLocation("mysticalagriculture","tier"+i+"_inferium_seeds")); - Block blockCrop = Block.REGISTRY.getObject(new ResourceLocation("mysticalagriculture","tier"+i+"_inferium_crop")); + Item itemSeeds = Item.REGISTRY.getObject(new ResourceLocation("mysticalagriculture", "tier"+i+"_inferium_seeds")); + Block blockCrop = Block.REGISTRY.getObject(new ResourceLocation("mysticalagriculture", "tier"+i+"_inferium_crop")); if(itemSeeds!=null&&blockCrop!=null) - BelljarHandler.cropHandler.register(new ItemStack(itemSeeds), new ItemStack[]{new ItemStack(itemEssence,i)}, new ItemStack(Blocks.DIRT), blockCrop.getDefaultState()); + BelljarHandler.cropHandler.register(new ItemStack(itemSeeds), new ItemStack[]{new ItemStack(itemEssence, i)}, new ItemStack(Blocks.DIRT), blockCrop.getDefaultState()); } try { Class c_Types = Class.forName("com.blakebr0.mysticalagriculture.lib.CropType$Type"); Method m_isEnabled = c_Types.getMethod("isEnabled"); - if(c_Types!=null && m_isEnabled!=null) + if(c_Types!=null&&m_isEnabled!=null) for(Object type : c_Types.getEnumConstants()) if((Boolean)m_isEnabled.invoke(type)) addType(((IStringSerializable)type).getName()); - }catch(Exception e){ + } catch(Exception e) + { e.printStackTrace(); } } @@ -61,7 +62,7 @@ static void addType(String type) Item itemSeeds = Item.REGISTRY.getObject(new ResourceLocation("mysticalagriculture:"+type+"_seeds")); Item itemEssence = Item.REGISTRY.getObject(new ResourceLocation("mysticalagriculture:"+type+"_essence")); Block blockCrop = Block.REGISTRY.getObject(new ResourceLocation("mysticalagriculture:"+type+"_crop")); - if(itemSeeds!=null && itemEssence!=null && blockCrop!=null) + if(itemSeeds!=null&&itemEssence!=null&&blockCrop!=null) BelljarHandler.cropHandler.register(new ItemStack(itemSeeds), new ItemStack[]{new ItemStack(itemEssence)}, new ItemStack(Blocks.DIRT), blockCrop.getDefaultState()); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/OneProbeHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/OneProbeHelper.java index 8a2713b146..226f7c6e43 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/OneProbeHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/OneProbeHelper.java @@ -75,23 +75,27 @@ public static class FluidInfoProvider implements IProbeInfoProvider { @Override - public String getID() { + public String getID() + { return ImmersiveEngineering.MODID+":"+"FluidInfo"; } @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) + { TileEntity te = world.getTileEntity(data.getPos()); - if(te instanceof TileEntitySheetmetalTank) { - TileEntitySheetmetalTank master = ((TileEntitySheetmetalTank) te).master(); + if(te instanceof TileEntitySheetmetalTank) + { + TileEntitySheetmetalTank master = ((TileEntitySheetmetalTank)te).master(); int current = master.tank.getFluidAmount(); int max = master.tank.getCapacity(); - if(current > 0) { + if(current > 0) + { probeInfo.progress(current, max, probeInfo.defaultProgressStyle() - .suffix("mB") - .numberFormat(NumberFormat.COMPACT)); + .suffix("mB") + .numberFormat(NumberFormat.COMPACT)); } } } @@ -123,7 +127,7 @@ else if(te instanceof IFluxProvider) cur = ((IFluxProvider)te).getEnergyStored(null); max = ((IFluxProvider)te).getMaxEnergyStored(null); } - if(max>0) + if(max > 0) { probeInfo.progress(cur, max, probeInfo.defaultProgressStyle() @@ -139,14 +143,16 @@ else if(te instanceof IFluxProvider) public void getProbeConfig(IProbeConfig config, EntityPlayer player, World world, Entity entity, IProbeHitEntityData data) { } + @Override public void getProbeConfig(IProbeConfig config, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) { TileEntity te = world.getTileEntity(data.getPos()); - if(te instanceof IFluxReceiver || te instanceof IFluxProvider) + if(te instanceof IFluxReceiver||te instanceof IFluxProvider) config.setRFMode(0); } } + public static class ProcessProvider implements IProbeInfoProvider { @@ -165,15 +171,16 @@ public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer play int[] curTicks = ((IEBlockInterfaces.IProcessTile)te).getCurrentProcessesStep(); int[] maxTicks = ((IEBlockInterfaces.IProcessTile)te).getCurrentProcessesMax(); int h = Math.max(4, (int)Math.ceil(12/(float)curTicks.length)); - for(int i=0; i0) + for(int i = 0; i < curTicks.length; i++) + if(maxTicks[i] > 0) { - float f = curTicks[i]/(float)maxTicks[i] * 100; - probeInfo.progress((int)f, 100, probeInfo.defaultProgressStyle().showText(h>=10).suffix("%").height(h)); + float f = curTicks[i]/(float)maxTicks[i]*100; + probeInfo.progress((int)f, 100, probeInfo.defaultProgressStyle().showText(h >= 10).suffix("%").height(h)); } } } } + public static class TeslaCoilProvider implements IProbeInfoProvider { @@ -189,24 +196,25 @@ public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer play TileEntity te = world.getTileEntity(data.getPos()); if(te instanceof TileEntityTeslaCoil) { - TileEntityTeslaCoil tc = (TileEntityTeslaCoil) te; + TileEntityTeslaCoil tc = (TileEntityTeslaCoil)te; if(tc.dummy) { te = world.getTileEntity(data.getPos().offset(tc.facing, -1)); if(te instanceof TileEntityTeslaCoil) - tc = (TileEntityTeslaCoil) te; + tc = (TileEntityTeslaCoil)te; else { probeInfo.text(""); return; } } - probeInfo.text(I18n.translateToLocal(Lib.CHAT_INFO+"rsControl."+(tc.redstoneControlInverted?"invertedOn":"invertedOff"))); - probeInfo.text(I18n.translateToLocal(Lib.CHAT_INFO+"tesla."+(tc.lowPower?"lowPower":"highPower"))); + probeInfo.text(I18n.translateToLocal(Lib.CHAT_INFO+"rsControl."+(tc.redstoneControlInverted?"invertedOn": "invertedOff"))); + probeInfo.text(I18n.translateToLocal(Lib.CHAT_INFO+"tesla."+(tc.lowPower?"lowPower": "highPower"))); } } } + public static class SideConfigProvider implements IProbeInfoProvider { @@ -220,7 +228,7 @@ public String getID() public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) { TileEntity te = world.getTileEntity(data.getPos()); - if(te instanceof IEBlockInterfaces.IConfigurableSides && data.getSideHit()!=null) + if(te instanceof IEBlockInterfaces.IConfigurableSides&&data.getSideHit()!=null) { boolean flip = player.isSneaking(); EnumFacing side = flip?data.getSideHit().getOpposite(): data.getSideHit(); @@ -230,13 +238,14 @@ public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer play } } } + public static class MultiblockDisplayOverride implements IBlockDisplayOverride { @Override public boolean overrideStandardInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) { TileEntity te = world.getTileEntity(data.getPos()); - if (te instanceof TileEntityMultiblockPart) + if(te instanceof TileEntityMultiblockPart) { ItemStack stack = new ItemStack(blockState.getBlock(), 1, blockState.getBlock().getMetaFromState(blockState)); if(Tools.show(mode, Config.getRealConfig().getShowModName())) @@ -246,7 +255,8 @@ public boolean overrideStandardInfo(ProbeMode mode, IProbeInfo probeInfo, Entity .vertical() .itemLabel(stack) .text(TextStyleClass.MODNAME+ImmersiveEngineering.MODNAME); - } else + } + else { probeInfo.horizontal(probeInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER)) .item(stack) diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/RailcraftHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/RailcraftHelper.java index b0ff51f0b0..e2f4e7e308 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/RailcraftHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/RailcraftHelper.java @@ -39,40 +39,41 @@ public void preInit() public void init() { Item itemRail = Item.REGISTRY.getObject(new ResourceLocation("railcraft:rail")); - RailgunHandler.registerProjectileProperties(new ItemStack(itemRail,1,0), 10,1.25).setColourMap(new int[][]{{0xa4a4a4,0x686868}}); - RailgunHandler.registerProjectileProperties(new ItemStack(itemRail,1,1), 9,1.375).setColourMap(new int[][]{{0xa4a4a4,0xa4a4a4,0x686868, 0xddb82c,0xc9901f}, {0xa4a4a4,0xa4a4a4,0x686868, 0xf5cc2d,0xddb82c},{0xa4a4a4,0xa4a4a4,0x686868, 0xf5cc2d,0xddb82c}, {0xa4a4a4,0xa4a4a4,0x686868, 0xddb82c,0xc9901f}}); - RailgunHandler.registerProjectileProperties(new ItemStack(itemRail,1,3), 10,1).setColourMap(new int[][]{{0x999999,0xa4a4a4,0xa4a4a4, 0xc9901f,0xc9901f,0xba851d}}); - RailgunHandler.registerProjectileProperties(new ItemStack(itemRail,1,4), 12,1.375).setColourMap(new int[][]{{0x686868,0x808080,0x808080, 0x3e2e60,0x3e2e60,0x31254d}}); - RailgunHandler.registerProjectileProperties(new ItemStack(itemRail,1,5), 10,1).setColourMap(new int[][]{{0x999999,0xa4a4a4,0xa4a4a4, 0x9a6033,0x9a6033,0xa86938}}); + RailgunHandler.registerProjectileProperties(new ItemStack(itemRail, 1, 0), 10, 1.25).setColourMap(new int[][]{{0xa4a4a4, 0x686868}}); + RailgunHandler.registerProjectileProperties(new ItemStack(itemRail, 1, 1), 9, 1.375).setColourMap(new int[][]{{0xa4a4a4, 0xa4a4a4, 0x686868, 0xddb82c, 0xc9901f}, {0xa4a4a4, 0xa4a4a4, 0x686868, 0xf5cc2d, 0xddb82c}, {0xa4a4a4, 0xa4a4a4, 0x686868, 0xf5cc2d, 0xddb82c}, {0xa4a4a4, 0xa4a4a4, 0x686868, 0xddb82c, 0xc9901f}}); + RailgunHandler.registerProjectileProperties(new ItemStack(itemRail, 1, 3), 10, 1).setColourMap(new int[][]{{0x999999, 0xa4a4a4, 0xa4a4a4, 0xc9901f, 0xc9901f, 0xba851d}}); + RailgunHandler.registerProjectileProperties(new ItemStack(itemRail, 1, 4), 12, 1.375).setColourMap(new int[][]{{0x686868, 0x808080, 0x808080, 0x3e2e60, 0x3e2e60, 0x31254d}}); + RailgunHandler.registerProjectileProperties(new ItemStack(itemRail, 1, 5), 10, 1).setColourMap(new int[][]{{0x999999, 0xa4a4a4, 0xa4a4a4, 0x9a6033, 0x9a6033, 0xa86938}}); Item itemRebar = Item.REGISTRY.getObject(new ResourceLocation("railcraft:rebar")); int[][] rebarColourMap = new int[8*3+1][]; - rebarColourMap[0] = new int[]{0x4a2700, 0x592f00,0x592f00,0x592f00, 0x4a2700}; - rebarColourMap[1] = new int[]{0x572e00, 0x673700,0x673700,0x673700, 0x572e00}; - for(int i=0; i<8; i++) + rebarColourMap[0] = new int[]{0x4a2700, 0x592f00, 0x592f00, 0x592f00, 0x4a2700}; + rebarColourMap[1] = new int[]{0x572e00, 0x673700, 0x673700, 0x673700, 0x572e00}; + for(int i = 0; i < 8; i++) { - rebarColourMap[1+ i*3] = rebarColourMap[1+ i*3+1] = rebarColourMap[1]; - rebarColourMap[1+ i*3+2] = rebarColourMap[0]; + rebarColourMap[1+i*3] = rebarColourMap[1+i*3+1] = rebarColourMap[1]; + rebarColourMap[1+i*3+2] = rebarColourMap[0]; } - RailgunHandler.registerProjectileProperties(new ItemStack(itemRebar), 10,1.25).setColourMap(rebarColourMap); + RailgunHandler.registerProjectileProperties(new ItemStack(itemRebar), 10, 1.25).setColourMap(rebarColourMap); Config.manual_bool.put("literalRailGun", true); } @Override public void postInit() { - if(FMLCommonHandler.instance().getEffectiveSide()== Side.CLIENT) + if(FMLCommonHandler.instance().getEffectiveSide()==Side.CLIENT) { - try{ + try + { Class c_CartModelManager = Class.forName("mods.railcraft.client.render.carts.CartModelManager"); Field f_modelMinecart = c_CartModelManager.getDeclaredField("modelMinecart"); f_modelMinecart.setAccessible(true); Field modifiersField = Field.class.getDeclaredField("modifiers"); modifiersField.setAccessible(true); - modifiersField.set(f_modelMinecart, f_modelMinecart.getModifiers() & ~Modifier.FINAL); + modifiersField.set(f_modelMinecart, f_modelMinecart.getModifiers()&~Modifier.FINAL); ModelMinecart wrapped = (ModelMinecart)f_modelMinecart.get(null); f_modelMinecart.set(null, new ModelShaderMinecart(wrapped)); - modifiersField.set(f_modelMinecart, f_modelMinecart.getModifiers() | Modifier.FINAL); + modifiersField.set(f_modelMinecart, f_modelMinecart.getModifiers()|Modifier.FINAL); Field f_modelsCore = c_CartModelManager.getDeclaredField("modelsCore"); Map modelMap = (Map)f_modelsCore.get(null); @@ -82,7 +83,8 @@ public void postInit() ShaderCaseMinecart.invalidMinecartClasses.add((Class)Class.forName("mods.railcraft.common.carts.EntityLocomotive")); ShaderCaseMinecart.invalidMinecartClasses.add((Class)Class.forName("mods.railcraft.common.carts.EntityTunnelBore")); - }catch(Exception e){ + } catch(Exception e) + { e.printStackTrace(); } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/TConstructHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/TConstructHelper.java index bc42991920..43c7cd1dc9 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/TConstructHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/TConstructHelper.java @@ -43,8 +43,6 @@ import slimeknights.tconstruct.library.utils.HarvestLevels; import slimeknights.tconstruct.tools.TinkerTraits; -import java.util.Locale; - public class TConstructHelper extends IECompatModule { public static final Material treatedWood = new Material("treatedwood", 0x653522); diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/ThaumcraftHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/ThaumcraftHelper.java index fd2c00bb32..5e0e74488b 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/ThaumcraftHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/ThaumcraftHelper.java @@ -37,13 +37,16 @@ public void init() // else if(potion!=null && potion.getName().equals("potion.visexhaust")) // ChemthrowerHandler.registerEffect("fluxgoo", new ChemthrowerEffect_Potion(null,0, potion,100,0)); - FMLInterModComms.sendMessage("thaumcraft", "harvestStackedCrop", new ItemStack(IEContent.blockCrop,5)); - - try{ + FMLInterModComms.sendMessage("thaumcraft", "harvestStackedCrop", new ItemStack(IEContent.blockCrop, 5)); + + try + { Class c_TileSmelter = Class.forName("thaumcraft.common.tiles.crafting.TileSmelter"); if(c_TileSmelter!=null) ExternalHeaterHandler.registerHeatableAdapter(c_TileSmelter, new AlchemyFurnaceAdapter()); - }catch(Exception e){} + } catch(Exception e) + { + } } @Override @@ -58,9 +61,11 @@ public static class AlchemyFurnaceAdapter extends ExternalHeaterHandler.Heatable Field f_furnaceBurnTime; Method m_isEnabled; Method m_setFurnaceState; + public AlchemyFurnaceAdapter() { - try{ + try + { c_TileSmelter = Class.forName("thaumcraft.common.tiles.crafting.TileSmelter"); m_canSmelt = c_TileSmelter.getDeclaredMethod("canSmelt"); m_canSmelt.setAccessible(true); @@ -69,8 +74,11 @@ public AlchemyFurnaceAdapter() m_isEnabled = c_BlockStateUtils.getMethod("isEnabled", IBlockState.class); Class c_BlockSmelter = Class.forName("thaumcraft.common.blocks.devices.BlockSmelter"); m_setFurnaceState = c_BlockSmelter.getMethod("setFurnaceState", World.class, BlockPos.class, boolean.class); - }catch(Exception e){} + } catch(Exception e) + { + } } + boolean canSmelt(TileEntity tileEntity) throws Exception { if(m_canSmelt!=null) @@ -82,29 +90,32 @@ boolean canSmelt(TileEntity tileEntity) throws Exception public int doHeatTick(TileEntity tileEntity, int energyAvailable, boolean redstone) { int energyConsumed = 0; - try{ + try + { int time = f_furnaceBurnTime.getInt(tileEntity); - boolean canSmelt = redstone || canSmelt(tileEntity); + boolean canSmelt = redstone||canSmelt(tileEntity); if(canSmelt) { - if(time<200) + if(time < 200) { int heatAttempt = Math.min(4, 200-time); int heatEnergyRatio = Math.max(1, ExternalHeaterHandler.defaultFurnaceEnergyCost); int energyToUse = Math.min(energyAvailable, heatAttempt*heatEnergyRatio); int heat = energyToUse/heatEnergyRatio; - if(heat>0) + if(heat > 0) { time += heat; energyConsumed += heat*heatEnergyRatio; boolean enabled = (Boolean)m_isEnabled.invoke(null, tileEntity.getWorld().getBlockState(tileEntity.getPos())); if(!enabled) - m_setFurnaceState.invoke(null, tileEntity.getWorld(),tileEntity.getPos(),true); + m_setFurnaceState.invoke(null, tileEntity.getWorld(), tileEntity.getPos(), true); } } f_furnaceBurnTime.setInt(tileEntity, time); } - }catch(Exception e){} + } catch(Exception e) + { + } return energyConsumed; } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/ThermalFoundationHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/ThermalFoundationHelper.java index 1ebe8be2c7..3c71cb13d5 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/ThermalFoundationHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/ThermalFoundationHelper.java @@ -47,23 +47,23 @@ public void preInit() public void init() { //TE Compat for smelter recipes. Not worth a separate module. - OreDictionary.registerOre("crystalSlag", new ItemStack(IEContent.itemMaterial,1,7)); + OreDictionary.registerOre("crystalSlag", new ItemStack(IEContent.itemMaterial, 1, 7)); - ChemthrowerHandler.registerEffect("coal", new ChemthrowerEffect_Potion(null,0, IEPotions.flammable,100,0)); + ChemthrowerHandler.registerEffect("coal", new ChemthrowerEffect_Potion(null, 0, IEPotions.flammable, 100, 0)); ChemthrowerHandler.registerFlammable("coal"); - ChemthrowerHandler.registerEffect("crude_oil", new ChemthrowerEffect_Potion(null,0, new PotionEffect(IEPotions.flammable,140,0),new PotionEffect(MobEffects.BLINDNESS,80,1))); + ChemthrowerHandler.registerEffect("crude_oil", new ChemthrowerEffect_Potion(null, 0, new PotionEffect(IEPotions.flammable, 140, 0), new PotionEffect(MobEffects.BLINDNESS, 80, 1))); ChemthrowerHandler.registerFlammable("crude_oil"); - ChemthrowerHandler.registerEffect("refined_oil", new ChemthrowerEffect_Potion(null,0, IEPotions.flammable,100,1)); + ChemthrowerHandler.registerEffect("refined_oil", new ChemthrowerEffect_Potion(null, 0, IEPotions.flammable, 100, 1)); ChemthrowerHandler.registerFlammable("refined_oil"); - ChemthrowerHandler.registerEffect("resin", new ChemthrowerEffect_Potion(null,0, IEPotions.sticky,100,1)); - ChemthrowerHandler.registerEffect("tree_oil", new ChemthrowerEffect_Potion(null,0, IEPotions.flammable,120,0)); + ChemthrowerHandler.registerEffect("resin", new ChemthrowerEffect_Potion(null, 0, IEPotions.sticky, 100, 1)); + ChemthrowerHandler.registerEffect("tree_oil", new ChemthrowerEffect_Potion(null, 0, IEPotions.flammable, 120, 0)); ChemthrowerHandler.registerFlammable("tree_oil"); - ChemthrowerHandler.registerEffect("redstone", new ChemthrowerEffect_Potion(null,0, IEPotions.conductive,100,1)); - ChemthrowerHandler.registerEffect("glowstone", new ChemthrowerEffect_Potion(null,0, new PotionEffect(MobEffects.GLOWING,120,0),new PotionEffect(MobEffects.SPEED,120,0),new PotionEffect(MobEffects.JUMP_BOOST,120,0))); - ChemthrowerHandler.registerEffect("ender", new ChemthrowerEffect_RandomTeleport(null,0, 1)); + ChemthrowerHandler.registerEffect("redstone", new ChemthrowerEffect_Potion(null, 0, IEPotions.conductive, 100, 1)); + ChemthrowerHandler.registerEffect("glowstone", new ChemthrowerEffect_Potion(null, 0, new PotionEffect(MobEffects.GLOWING, 120, 0), new PotionEffect(MobEffects.SPEED, 120, 0), new PotionEffect(MobEffects.JUMP_BOOST, 120, 0))); + ChemthrowerHandler.registerEffect("ender", new ChemthrowerEffect_RandomTeleport(null, 0, 1)); try { Class c_DamageHelper = Class.forName("cofh.lib.util.helpers.DamageHelper"); @@ -72,28 +72,29 @@ public void init() Field f_explodeCreepers = Class.forName("cofh.thermalfoundation.fluid.BlockFluidPyrotheum").getDeclaredField("effect"); f_explodeCreepers.setAccessible(true); if((boolean)f_explodeCreepers.get(null)) - ChemthrowerHandler.registerEffect("pyrotheum", new ChemthrowerEffect_Damage(pyrotheum,3){ + ChemthrowerHandler.registerEffect("pyrotheum", new ChemthrowerEffect_Damage(pyrotheum, 3) + { @Override public void applyToEntity(EntityLivingBase target, @Nullable EntityPlayer shooter, ItemStack thrower, Fluid fluid) { super.applyToEntity(target, shooter, thrower, fluid); if(target instanceof EntityCreeper) { - target.getEntityWorld().createExplosion(target, target.posX,target.posY,target.posZ, 6.0F, target.getEntityWorld().getGameRules().getBoolean("mobGriefing")); + target.getEntityWorld().createExplosion(target, target.posX, target.posY, target.posZ, 6.0F, target.getEntityWorld().getGameRules().getBoolean("mobGriefing")); target.setDead(); } } }); else - ChemthrowerHandler.registerEffect("pyrotheum", new ChemthrowerEffect_Damage(pyrotheum,3)); + ChemthrowerHandler.registerEffect("pyrotheum", new ChemthrowerEffect_Damage(pyrotheum, 3)); DamageSource cryotheum = (DamageSource)c_DamageHelper.getDeclaredField("cryotheum").get(null); - ChemthrowerHandler.registerEffect("cryotheum", new ChemthrowerEffect_Potion(cryotheum,2, MobEffects.SLOWNESS,50,3)); + ChemthrowerHandler.registerEffect("cryotheum", new ChemthrowerEffect_Potion(cryotheum, 2, MobEffects.SLOWNESS, 50, 3)); } catch(Exception e) { } - ChemthrowerHandler.registerEffect("aerotheum", new ChemthrowerEffect_Potion(null,0, new PotionEffect(MobEffects.INVISIBILITY,60,0),new PotionEffect(MobEffects.WATER_BREATHING,300,0))); - ChemthrowerHandler.registerEffect("petrotheum", new ChemthrowerEffect_Potion(null,0, new PotionEffect(MobEffects.HASTE,300,2),new PotionEffect(MobEffects.NIGHT_VISION,300,0),new PotionEffect(MobEffects.RESISTANCE,300,1)) + ChemthrowerHandler.registerEffect("aerotheum", new ChemthrowerEffect_Potion(null, 0, new PotionEffect(MobEffects.INVISIBILITY, 60, 0), new PotionEffect(MobEffects.WATER_BREATHING, 300, 0))); + ChemthrowerHandler.registerEffect("petrotheum", new ChemthrowerEffect_Potion(null, 0, new PotionEffect(MobEffects.HASTE, 300, 2), new PotionEffect(MobEffects.NIGHT_VISION, 300, 0), new PotionEffect(MobEffects.RESISTANCE, 300, 1)) { @Override public void applyToBlock(World world, RayTraceResult mop, @Nullable EntityPlayer shooter, ItemStack thrower, Fluid fluid) @@ -103,7 +104,7 @@ public void applyToBlock(World world, RayTraceResult mop, @Nullable EntityPlayer world.setBlockState(mop.getBlockPos(), Blocks.GRAVEL.getDefaultState()); } }); - ChemthrowerHandler.registerEffect("mana", new ChemthrowerEffect_RandomTeleport(null,0, .01f)); + ChemthrowerHandler.registerEffect("mana", new ChemthrowerEffect_RandomTeleport(null, 0, .01f)); final Item itemPhyto = Item.REGISTRY.getObject(new ResourceLocation("thermalfoundation:fertilizer")); if(itemPhyto!=null) @@ -114,6 +115,7 @@ public boolean isValid(@Nullable ItemStack fertilizer) { return !fertilizer.isEmpty()&&fertilizer.getItem()==itemPhyto; } + @Override public float getGrowthMultiplier(ItemStack fertilizer, ItemStack seed, ItemStack soil, TileEntity tile) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/AlloySmelter.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/AlloySmelter.java index 094089ba5c..fc4c369647 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/AlloySmelter.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/AlloySmelter.java @@ -23,68 +23,68 @@ @ZenClass("mods.immersiveengineering.AlloySmelter") public class AlloySmelter { - @ZenMethod - public static void addRecipe(IItemStack output, IIngredient first, IIngredient second, int time) - { - Object oFirst = CraftTweakerHelper.toObject(first), oSecond = CraftTweakerHelper.toObject(second); - if(oFirst == null || oSecond == null) - return; + @ZenMethod + public static void addRecipe(IItemStack output, IIngredient first, IIngredient second, int time) + { + Object oFirst = CraftTweakerHelper.toObject(first), oSecond = CraftTweakerHelper.toObject(second); + if(oFirst==null||oSecond==null) + return; - AlloyRecipe r = new AlloyRecipe(CraftTweakerHelper.toStack(output), oFirst, oSecond, time); - CraftTweakerAPI.apply(new Add(r)); - } + AlloyRecipe r = new AlloyRecipe(CraftTweakerHelper.toStack(output), oFirst, oSecond, time); + CraftTweakerAPI.apply(new Add(r)); + } - private static class Add implements IAction - { - private final AlloyRecipe recipe; + private static class Add implements IAction + { + private final AlloyRecipe recipe; - public Add(AlloyRecipe recipe) - { - this.recipe = recipe; - } + public Add(AlloyRecipe recipe) + { + this.recipe = recipe; + } - @Override - public void apply() - { - AlloyRecipe.recipeList.add(recipe); - IECompatModule.jeiAddFunc.accept(recipe); - } + @Override + public void apply() + { + AlloyRecipe.recipeList.add(recipe); + IECompatModule.jeiAddFunc.accept(recipe); + } - @Override - public String describe() - { - return "Adding Alloy Smelter Recipe for " + recipe.output.getDisplayName(); - } - } + @Override + public String describe() + { + return "Adding Alloy Smelter Recipe for "+recipe.output.getDisplayName(); + } + } - @ZenMethod - public static void removeRecipe(IItemStack output) - { - CraftTweakerAPI.apply(new Remove(CraftTweakerHelper.toStack(output))); - } + @ZenMethod + public static void removeRecipe(IItemStack output) + { + CraftTweakerAPI.apply(new Remove(CraftTweakerHelper.toStack(output))); + } - private static class Remove implements IAction - { - private final ItemStack output; - List removedRecipes; + private static class Remove implements IAction + { + private final ItemStack output; + List removedRecipes; - public Remove(ItemStack output) - { - this.output = output; - } + public Remove(ItemStack output) + { + this.output = output; + } - @Override - public void apply() - { - removedRecipes = AlloyRecipe.removeRecipes(output); - for(AlloyRecipe recipe : removedRecipes) - IECompatModule.jeiRemoveFunc.accept(recipe); - } + @Override + public void apply() + { + removedRecipes = AlloyRecipe.removeRecipes(output); + for(AlloyRecipe recipe : removedRecipes) + IECompatModule.jeiRemoveFunc.accept(recipe); + } - @Override - public String describe() - { - return "Removing Alloy Smelter Recipe for " + output.getDisplayName(); - } - } + @Override + public String describe() + { + return "Removing Alloy Smelter Recipe for "+output.getDisplayName(); + } + } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/ArcFurnace.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/ArcFurnace.java index c6c4321501..ccd2c4960a 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/ArcFurnace.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/ArcFurnace.java @@ -28,17 +28,17 @@ public class ArcFurnace public static void addRecipe(IItemStack output, IIngredient input, IItemStack slag, int time, int energyPerTick, @Optional IIngredient[] additives, @Optional String specialRecipeType) { Object oInput = CraftTweakerHelper.toObject(input); - if(oInput == null) + if(oInput==null) return; Object[] adds = null; - if(additives != null) + if(additives!=null) { adds = new Object[additives.length]; for(int i = 0; i < additives.length; i++) adds[i] = CraftTweakerHelper.toObject(additives[i]); } ArcFurnaceRecipe r = new ArcFurnaceRecipe(CraftTweakerHelper.toStack(output), oInput, CraftTweakerHelper.toStack(slag), time, energyPerTick, adds); - if(specialRecipeType != null) + if(specialRecipeType!=null) r.setSpecialRecipeType(specialRecipeType); CraftTweakerAPI.apply(new Add(r)); } @@ -62,7 +62,7 @@ public void apply() @Override public String describe() { - return "Adding ArcFurnace Recipe for " + recipe.output.getDisplayName(); + return "Adding ArcFurnace Recipe for "+recipe.output.getDisplayName(); } } @@ -93,7 +93,7 @@ public void apply() @Override public String describe() { - return "Removing ArcFurnace Recipe for " + output.getDisplayName(); + return "Removing ArcFurnace Recipe for "+output.getDisplayName(); } } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/BlastFurnace.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/BlastFurnace.java index a99134c0c7..a4a36ca9e3 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/BlastFurnace.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/BlastFurnace.java @@ -30,7 +30,7 @@ public class BlastFurnace public static void addRecipe(IItemStack output, IIngredient input, int time, @Optional IItemStack slag) { Object oInput = CraftTweakerHelper.toObject(input); - if(oInput == null) + if(oInput==null) return; BlastFurnaceRecipe r = new BlastFurnaceRecipe(CraftTweakerHelper.toStack(output), oInput, time, CraftTweakerHelper.toStack(slag)); @@ -56,7 +56,7 @@ public void apply() @Override public String describe() { - return "Adding Blast Furnace Recipe for " + recipe.output.getDisplayName(); + return "Adding Blast Furnace Recipe for "+recipe.output.getDisplayName(); } } @@ -87,7 +87,7 @@ public void apply() @Override public String describe() { - return "Removing Blast Furnace Recipe for " + output.getDisplayName(); + return "Removing Blast Furnace Recipe for "+output.getDisplayName(); } } @@ -96,7 +96,7 @@ public String describe() public static void addFuel(IIngredient input, int time) { Object oInput = CraftTweakerHelper.toObject(input); - if(oInput == null) + if(oInput==null) return; CraftTweakerAPI.apply(new AddFuel(oInput, time)); @@ -124,7 +124,7 @@ public void apply() @Override public String describe() { - return "Adding " + (fuel instanceof ItemStack ? ((ItemStack)fuel).getDisplayName() : (String)fuel) + " as Blast Furnace Fuel"; + return "Adding "+(fuel instanceof ItemStack?((ItemStack)fuel).getDisplayName(): (String)fuel)+" as Blast Furnace Fuel"; } } @@ -164,7 +164,7 @@ public void apply() @Override public String describe() { - return "Removing " + stack + " as Blast Furnace Fuel"; + return "Removing "+stack+" as Blast Furnace Fuel"; } } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Blueprint.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Blueprint.java index cd49579ffd..12192432c4 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Blueprint.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Blueprint.java @@ -30,8 +30,8 @@ public class Blueprint public static void addRecipe(String category, IItemStack output, IIngredient[] inputs) { Object[] oInputs = new Object[inputs.length]; - for(int i = 0; i < inputs.length; i++) - oInputs[i] = CraftTweakerHelper.toObject(inputs[i]); + for(int i = 0; i < inputs.length; i++) + oInputs[i] = CraftTweakerHelper.toObject(inputs[i]); BlueprintCraftingRecipe r = new BlueprintCraftingRecipe(category, CraftTweakerHelper.toStack(output), oInputs); CraftTweakerAPI.apply(new Add(r)); } @@ -58,7 +58,7 @@ public void apply() @Override public String describe() { - return "Adding Blueprint Recipe for " + recipe.output.getDisplayName(); + return "Adding Blueprint Recipe for "+recipe.output.getDisplayName(); } } @@ -106,7 +106,7 @@ public void apply() @Override public String describe() { - return "Removing Blueprint Recipe for " + output.getDisplayName(); + return "Removing Blueprint Recipe for "+output.getDisplayName(); } } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/BottlingMachine.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/BottlingMachine.java index d8e99d0ba7..2c809759e7 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/BottlingMachine.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/BottlingMachine.java @@ -28,7 +28,7 @@ public class BottlingMachine public static void addRecipe(IItemStack output, IIngredient input, ILiquidStack fluid) { Object oInput = CraftTweakerHelper.toObject(input); - if(oInput == null || output == null || fluid == null) + if(oInput==null||output==null||fluid==null) return; BottlingMachineRecipe r = new BottlingMachineRecipe(CraftTweakerHelper.toStack(output), oInput, CraftTweakerHelper.toFluidStack(fluid)); @@ -54,7 +54,7 @@ public void apply() @Override public String describe() { - return "Adding Bottling Machine Recipe for " + recipe.output.getDisplayName(); + return "Adding Bottling Machine Recipe for "+recipe.output.getDisplayName(); } } @@ -85,7 +85,7 @@ public void apply() @Override public String describe() { - return "Removing Bottling Machine Recipe for " + output.getDisplayName(); + return "Removing Bottling Machine Recipe for "+output.getDisplayName(); } } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/CokeOven.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/CokeOven.java index d8c227aa94..a439e1392c 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/CokeOven.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/CokeOven.java @@ -27,7 +27,7 @@ public class CokeOven public static void addRecipe(IItemStack output, int fuelOutput, IIngredient input, int time) { Object oInput = CraftTweakerHelper.toObject(input); - if(oInput == null) + if(oInput==null) return; CokeOvenRecipe r = new CokeOvenRecipe(CraftTweakerHelper.toStack(output), oInput, time, fuelOutput); @@ -53,7 +53,7 @@ public void apply() @Override public String describe() { - return "Adding Coke Oven Recipe for " + recipe.output.getDisplayName(); + return "Adding Coke Oven Recipe for "+recipe.output.getDisplayName(); } } @@ -84,7 +84,7 @@ public void apply() @Override public String describe() { - return "Removing Coke Oven Recipe for " + output.getDisplayName(); + return "Removing Coke Oven Recipe for "+output.getDisplayName(); } } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/CraftTweakerHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/CraftTweakerHelper.java index ed76272ee8..ef2411c35d 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/CraftTweakerHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/CraftTweakerHelper.java @@ -57,14 +57,14 @@ public void postInit() */ public static ItemStack toStack(IItemStack iStack) { - if(iStack == null) + if(iStack==null) return ItemStack.EMPTY; - return (ItemStack) iStack.getInternal(); + return (ItemStack)iStack.getInternal(); } public static Object toObject(IIngredient iStack) { - if(iStack == null) + if(iStack==null) return null; else { @@ -76,18 +76,19 @@ else if(iStack instanceof IngredientStack) { IIngredient ingr = ReflectionHelper.getPrivateValue(IngredientStack.class, (IngredientStack)iStack, "ingredient"); Object o = toObject(ingr); - if (o instanceof String) - return new blusunrize.immersiveengineering.api.crafting.IngredientStack((String) o, iStack.getAmount()); + if(o instanceof String) + return new blusunrize.immersiveengineering.api.crafting.IngredientStack((String)o, iStack.getAmount()); else return o; - } else + } + else return null; } } public static blusunrize.immersiveengineering.api.crafting.IngredientStack toIEIngredientStack(IIngredient iStack) { - if(iStack == null) + if(iStack==null) return null; else { @@ -101,7 +102,8 @@ else if(iStack instanceof IngredientStack) blusunrize.immersiveengineering.api.crafting.IngredientStack ingrStack = toIEIngredientStack(ingr); ingrStack.inputSize = iStack.getAmount(); return ingrStack; - } else + } + else return null; } } @@ -116,9 +118,10 @@ public static Object[] toObjects(IIngredient[] iStacks) public static FluidStack toFluidStack(ILiquidStack iStack) { - if (iStack == null) { + if(iStack==null) + { return null; } - return (FluidStack) iStack.getInternal(); + return (FluidStack)iStack.getInternal(); } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Crusher.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Crusher.java index 5cf7f54304..5552c69aea 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Crusher.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Crusher.java @@ -28,19 +28,19 @@ public class Crusher public static void addRecipe(IItemStack output, IIngredient input, int energy, @Optional IItemStack secondaryOutput, @Optional double secondaryChance) { Object oInput = CraftTweakerHelper.toObject(input); - if(oInput == null) + if(oInput==null) { - CraftTweakerAPI.getLogger().logError("Did not add crusher recipe for " + output.getDisplayName() + ", input was null"); + CraftTweakerAPI.getLogger().logError("Did not add crusher recipe for "+output.getDisplayName()+", input was null"); return; } CrusherRecipe r = new CrusherRecipe(CraftTweakerHelper.toStack(output), oInput, energy); - if(r.input == null) + if(r.input==null) { - CraftTweakerAPI.getLogger().logError("Did not add crusher recipe for " + output.getDisplayName() + ", converted input was null"); + CraftTweakerAPI.getLogger().logError("Did not add crusher recipe for "+output.getDisplayName()+", converted input was null"); return; } - if(secondaryOutput != null) + if(secondaryOutput!=null) r.addToSecondaryOutput(CraftTweakerHelper.toStack(secondaryOutput), (float)secondaryChance); CraftTweakerAPI.apply(new Add(r)); } @@ -64,7 +64,7 @@ public void apply() @Override public String describe() { - return "Adding Crusher Recipe for " + recipe.output.getDisplayName(); + return "Adding Crusher Recipe for "+recipe.output.getDisplayName(); } } @@ -95,7 +95,7 @@ public void apply() @Override public String describe() { - return "Removing Crusher Recipe for output: " + output.getDisplayName(); + return "Removing Crusher Recipe for output: "+output.getDisplayName(); } } @@ -126,7 +126,7 @@ public void apply() @Override public String describe() { - return "Removing Crusher Recipe for input: " + input.getDisplayName(); + return "Removing Crusher Recipe for input: "+input.getDisplayName(); } } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/DieselHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/DieselHelper.java index c49e3fbf00..a0219c74ba 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/DieselHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/DieselHelper.java @@ -20,122 +20,124 @@ @ZenClass("mods.immersiveengineering.DieselHandler") public class DieselHelper { - @ZenMethod - public static void addFuel(ILiquidStack fuel, int time) - { - - CraftTweakerAPI.apply(new AddFuel(fuel, time)); - } - - private static class AddFuel implements IAction - { - private final ILiquidStack fuel; - private final int time; - - public AddFuel(ILiquidStack fuel, int time) - { - this.fuel = fuel; - this.time = time; - } - - @Override - public void apply() - { - Fluid fuelFluid = FluidRegistry.getFluid(fuel.getName()); - DieselHandler.registerFuel(fuelFluid, time); - } - - @Override - public String describe() - { - return "Registering Diesel Generator Fuel " + fuel.getDisplayName(); - } - } - - @ZenMethod - public static void addDrillFuel(ILiquidStack fuel) - { - CraftTweakerAPI.apply(new AddDrillFuel(fuel)); - } - - private static class AddDrillFuel implements IAction - { - private final ILiquidStack fuel; - - public AddDrillFuel(ILiquidStack fuel) - { - this.fuel = fuel; - } - - @Override - public void apply() - { - Fluid fuelFluid = FluidRegistry.getFluid(fuel.getName()); - DieselHandler.registerDrillFuel(fuelFluid); - } - - @Override - public String describe() - { - return "Registering Drill Fuel " + fuel.getDisplayName(); - } - } - - @ZenMethod - public static void removeFuel(ILiquidStack fuel){ - CraftTweakerAPI.apply(new RemoveFuel(fuel)); - } - - private static class RemoveFuel implements IAction - { - private final ILiquidStack fuel; - - public RemoveFuel(ILiquidStack fuel) - { - this.fuel = fuel; - } - - @Override - public void apply() - { - Fluid fuelFluid = FluidRegistry.getFluid(fuel.getName()); - DieselHandler.removeFuel(fuelFluid); - } - - @Override - public String describe() - { - return "Removing Fuel " + fuel.getDisplayName(); - } - } - - @ZenMethod - public static void removeDrillFuel(ILiquidStack fuel){ - CraftTweakerAPI.apply(new RemoveDrillFuel(fuel)); - } - - private static class RemoveDrillFuel implements IAction - { - private final ILiquidStack fuel; - - public RemoveDrillFuel(ILiquidStack fuel) - { - this.fuel = fuel; - } - - @Override - public void apply() - { - Fluid fuelFluid = FluidRegistry.getFluid(fuel.getName()); - DieselHandler.removeDrillFuel(fuelFluid); - } - - @Override - public String describe() - { - return "Removing Drill Fuel " + fuel.getDisplayName(); - } - } + @ZenMethod + public static void addFuel(ILiquidStack fuel, int time) + { + + CraftTweakerAPI.apply(new AddFuel(fuel, time)); + } + + private static class AddFuel implements IAction + { + private final ILiquidStack fuel; + private final int time; + + public AddFuel(ILiquidStack fuel, int time) + { + this.fuel = fuel; + this.time = time; + } + + @Override + public void apply() + { + Fluid fuelFluid = FluidRegistry.getFluid(fuel.getName()); + DieselHandler.registerFuel(fuelFluid, time); + } + + @Override + public String describe() + { + return "Registering Diesel Generator Fuel "+fuel.getDisplayName(); + } + } + + @ZenMethod + public static void addDrillFuel(ILiquidStack fuel) + { + CraftTweakerAPI.apply(new AddDrillFuel(fuel)); + } + + private static class AddDrillFuel implements IAction + { + private final ILiquidStack fuel; + + public AddDrillFuel(ILiquidStack fuel) + { + this.fuel = fuel; + } + + @Override + public void apply() + { + Fluid fuelFluid = FluidRegistry.getFluid(fuel.getName()); + DieselHandler.registerDrillFuel(fuelFluid); + } + + @Override + public String describe() + { + return "Registering Drill Fuel "+fuel.getDisplayName(); + } + } + + @ZenMethod + public static void removeFuel(ILiquidStack fuel) + { + CraftTweakerAPI.apply(new RemoveFuel(fuel)); + } + + private static class RemoveFuel implements IAction + { + private final ILiquidStack fuel; + + public RemoveFuel(ILiquidStack fuel) + { + this.fuel = fuel; + } + + @Override + public void apply() + { + Fluid fuelFluid = FluidRegistry.getFluid(fuel.getName()); + DieselHandler.removeFuel(fuelFluid); + } + + @Override + public String describe() + { + return "Removing Fuel "+fuel.getDisplayName(); + } + } + + @ZenMethod + public static void removeDrillFuel(ILiquidStack fuel) + { + CraftTweakerAPI.apply(new RemoveDrillFuel(fuel)); + } + + private static class RemoveDrillFuel implements IAction + { + private final ILiquidStack fuel; + + public RemoveDrillFuel(ILiquidStack fuel) + { + this.fuel = fuel; + } + + @Override + public void apply() + { + Fluid fuelFluid = FluidRegistry.getFluid(fuel.getName()); + DieselHandler.removeDrillFuel(fuelFluid); + } + + @Override + public String describe() + { + return "Removing Drill Fuel "+fuel.getDisplayName(); + } + } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Excavator.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Excavator.java index 30cf0f1091..8f36956514 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Excavator.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Excavator.java @@ -58,7 +58,7 @@ public AddMineral(String name, int mineralWeight, float failChance, String[] ore public void apply() { this.mineral = ExcavatorHandler.addMineral(name, mineralWeight, failChance, ores, chances); - if(dimensions != null) + if(dimensions!=null) if(blacklist) this.mineral.dimensionBlacklist = dimensions; else @@ -68,7 +68,7 @@ public void apply() @Override public String describe() { - return "Adding MineralMix: " + name + " with weight " + mineralWeight; + return "Adding MineralMix: "+name+" with weight "+mineralWeight; } } @@ -101,7 +101,7 @@ public void apply() while(it.hasNext()) { Entry e = it.next(); - if(e.getKey().name.equalsIgnoreCase(name) && !mix.contains(e.getKey())) + if(e.getKey().name.equalsIgnoreCase(name)&&!mix.contains(e.getKey())) { mix.add(e.getKey()); weight.add(e.getValue()); @@ -113,7 +113,7 @@ public void apply() @Override public String describe() { - return "Removing MineralMix: " + name; + return "Removing MineralMix: "+name; } } @@ -153,7 +153,7 @@ public void setFailChance(double chance) @ZenMethod public void addOre(String ore, double chance) { - String[] newOres = new String[mix.ores.length + 1]; + String[] newOres = new String[mix.ores.length+1]; float[] newChances = new float[newOres.length]; System.arraycopy(mix.ores, 0, newOres, 0, mix.ores.length); System.arraycopy(mix.chances, 0, newChances, 0, mix.chances.length); diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Fermenter.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Fermenter.java index 7293c629dc..9cae00b19e 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Fermenter.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Fermenter.java @@ -30,10 +30,10 @@ public class Fermenter @ZenMethod public static void addRecipe(IItemStack output, ILiquidStack fluid, IIngredient input, int energy) { - if(CraftTweakerHelper.toObject(input) == null) + if(CraftTweakerHelper.toObject(input)==null) return; //Either output or fluid must not be null. - if(CraftTweakerHelper.toStack(output).isEmpty() && (CraftTweakerHelper.toFluidStack(fluid) == null || CraftTweakerHelper.toFluidStack(fluid).getFluid() == null)) + if(CraftTweakerHelper.toStack(output).isEmpty()&&(CraftTweakerHelper.toFluidStack(fluid)==null||CraftTweakerHelper.toFluidStack(fluid).getFluid()==null)) return; FermenterRecipe r = new FermenterRecipe(CraftTweakerHelper.toFluidStack(fluid), CraftTweakerHelper.toStack(output), CraftTweakerHelper.toObject(input), energy); @@ -59,16 +59,16 @@ public void apply() @Override public String describe() { - String fluid = recipe.fluidOutput != null ? recipe.fluidOutput.getLocalizedName() : "null"; - String out = !recipe.itemOutput.isEmpty() ? recipe.itemOutput.getDisplayName() : "null"; - return "Adding Fermenter Recipe for Fluid " + fluid + " and Item " + out; + String fluid = recipe.fluidOutput!=null?recipe.fluidOutput.getLocalizedName(): "null"; + String out = !recipe.itemOutput.isEmpty()?recipe.itemOutput.getDisplayName(): "null"; + return "Adding Fermenter Recipe for Fluid "+fluid+" and Item "+out; } } @ZenMethod public static void removeFluidRecipe(ILiquidStack fluid) { - if(CraftTweakerHelper.toFluidStack(fluid) != null) + if(CraftTweakerHelper.toFluidStack(fluid)!=null) CraftTweakerAPI.apply(new RemoveFluid(CraftTweakerHelper.toFluidStack(fluid))); } @@ -89,7 +89,7 @@ public void apply() while(it.hasNext()) { FermenterRecipe r = it.next(); - if(r != null && r.fluidOutput != null && r.fluidOutput.isFluidEqual(output)) + if(r!=null&&r.fluidOutput!=null&&r.fluidOutput.isFluidEqual(output)) { removedRecipes.add(r); IECompatModule.jeiRemoveFunc.accept(r); @@ -101,7 +101,7 @@ public void apply() @Override public String describe() { - return "Removing Fermenter Recipes for Fluid " + output.getLocalizedName(); + return "Removing Fermenter Recipes for Fluid "+output.getLocalizedName(); } } @@ -129,7 +129,7 @@ public void apply() while(it.hasNext()) { FermenterRecipe r = it.next(); - if(r != null && OreDictionary.itemMatches(output, r.itemOutput, false)) + if(r!=null&&OreDictionary.itemMatches(output, r.itemOutput, false)) { removedRecipes.add(r); IECompatModule.jeiRemoveFunc.accept(r); @@ -141,14 +141,14 @@ public void apply() @Override public String describe() { - return "Removing Fermenter Recipes for ItemStack " + output.getDisplayName(); + return "Removing Fermenter Recipes for ItemStack "+output.getDisplayName(); } } @ZenMethod public static void removeByInput(IItemStack stack) { - if(CraftTweakerHelper.toStack(stack) != null) + if(CraftTweakerHelper.toStack(stack)!=null) CraftTweakerAPI.apply(new RemoveByInput(CraftTweakerHelper.toStack(stack))); } @@ -169,7 +169,7 @@ public void apply() while(it.hasNext()) { FermenterRecipe r = it.next(); - if(r != null && r.input.matchesItemStack(input)) + if(r!=null&&r.input.matchesItemStack(input)) { removedRecipes.add(r); IECompatModule.jeiRemoveFunc.accept(r); @@ -181,7 +181,7 @@ public void apply() @Override public String describe() { - return "Removing Fermenter Recipes for input " + input.getDisplayName(); + return "Removing Fermenter Recipes for input "+input.getDisplayName(); } } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/MetalPress.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/MetalPress.java index 020c52286e..6b09597cf4 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/MetalPress.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/MetalPress.java @@ -31,11 +31,11 @@ public class MetalPress public static void addRecipe(IItemStack output, IIngredient input, IItemStack mold, int energy, @Optional int inputSize) { Object oInput = CraftTweakerHelper.toObject(input); - if(oInput == null) + if(oInput==null) return; ItemStack sOut = CraftTweakerHelper.toStack(output); ItemStack sMold = CraftTweakerHelper.toStack(mold); - if(!sOut.isEmpty() && !sMold.isEmpty()) + if(!sOut.isEmpty()&&!sMold.isEmpty()) { MetalPressRecipe r = new MetalPressRecipe(sOut, oInput, ApiUtils.createComparableItemStack(sMold, true), energy); if(inputSize > 0) @@ -63,7 +63,7 @@ public void apply() @Override public String describe() { - return "Adding Metal Press Recipe for " + recipe.output.getDisplayName(); + return "Adding Metal Press Recipe for "+recipe.output.getDisplayName(); } } @@ -94,7 +94,7 @@ public void apply() @Override public String describe() { - return "Removing Metal Press Recipes for " + output.getDisplayName(); + return "Removing Metal Press Recipes for "+output.getDisplayName(); } } @@ -126,7 +126,7 @@ public void apply() @Override public String describe() { - return "Removing Metal Press Recipes for Mold: " + mold.stack.getDisplayName(); + return "Removing Metal Press Recipes for Mold: "+mold.stack.getDisplayName(); } } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Mixer.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Mixer.java index 4ed7a26e50..2dccef5c4a 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Mixer.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Mixer.java @@ -28,7 +28,7 @@ public class Mixer public static void addRecipe(ILiquidStack output, ILiquidStack fluidInput, IIngredient[] itemInputs, int energy) { Object[] adds = null; - if(itemInputs != null) + if(itemInputs!=null) { adds = new Object[itemInputs.length]; for(int i = 0; i < itemInputs.length; i++) @@ -58,14 +58,14 @@ public void apply() @Override public String describe() { - return "Adding Fermenter Recipe for Fluid " + recipe.fluidOutput.getLocalizedName(); + return "Adding Fermenter Recipe for Fluid "+recipe.fluidOutput.getLocalizedName(); } } @ZenMethod public static void removeRecipe(ILiquidStack output) { - if(CraftTweakerHelper.toFluidStack(output) != null) + if(CraftTweakerHelper.toFluidStack(output)!=null) CraftTweakerAPI.apply(new RemoveFluid(CraftTweakerHelper.toFluidStack(output))); } @@ -86,7 +86,7 @@ public void apply() while(it.hasNext()) { MixerRecipe r = it.next(); - if(r != null && r.fluidOutput != null && r.fluidOutput.isFluidEqual(output)) + if(r!=null&&r.fluidOutput!=null&&r.fluidOutput.isFluidEqual(output)) { removedRecipes.add(r); IECompatModule.jeiRemoveFunc.accept(r); @@ -98,7 +98,7 @@ public void apply() @Override public String describe() { - return "Removing Mixer Recipes for Fluid " + output.getLocalizedName(); + return "Removing Mixer Recipes for Fluid "+output.getLocalizedName(); } } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Refinery.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Refinery.java index d8095bec36..1f80e1eb12 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Refinery.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Refinery.java @@ -56,14 +56,14 @@ public void apply() @Override public String describe() { - return "Adding Refinery Recipe for " + recipe.output.getLocalizedName(); + return "Adding Refinery Recipe for "+recipe.output.getLocalizedName(); } } @ZenMethod public static void removeRecipe(ILiquidStack output) { - if(CraftTweakerHelper.toFluidStack(output) != null) + if(CraftTweakerHelper.toFluidStack(output)!=null) CraftTweakerAPI.apply(new Remove(CraftTweakerHelper.toFluidStack(output))); } @@ -84,7 +84,7 @@ public void apply() while(it.hasNext()) { RefineryRecipe r = it.next(); - if(r != null && r.output.isFluidEqual(output)) + if(r!=null&&r.output.isFluidEqual(output)) { removedRecipes.add(r); IECompatModule.jeiRemoveFunc.accept(r); @@ -96,7 +96,7 @@ public void apply() @Override public String describe() { - return "Removing Refinery Recipes for " + output.getLocalizedName(); + return "Removing Refinery Recipes for "+output.getLocalizedName(); } } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Squeezer.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Squeezer.java index af80e2abe5..19b1f9c750 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Squeezer.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/crafttweaker/Squeezer.java @@ -30,10 +30,10 @@ public class Squeezer @ZenMethod public static void addRecipe(IItemStack output, ILiquidStack fluid, IIngredient input, int energy) { - if(CraftTweakerHelper.toObject(input) == null) + if(CraftTweakerHelper.toObject(input)==null) return; //Either output or fluid must not be null. - if(CraftTweakerHelper.toStack(output).isEmpty() && (CraftTweakerHelper.toFluidStack(fluid) == null || CraftTweakerHelper.toFluidStack(fluid).getFluid() == null)) + if(CraftTweakerHelper.toStack(output).isEmpty()&&(CraftTweakerHelper.toFluidStack(fluid)==null||CraftTweakerHelper.toFluidStack(fluid).getFluid()==null)) return; SqueezerRecipe r = new SqueezerRecipe(CraftTweakerHelper.toFluidStack(fluid), CraftTweakerHelper.toStack(output), CraftTweakerHelper.toObject(input), energy); @@ -59,16 +59,16 @@ public void apply() @Override public String describe() { - String fluid = recipe.fluidOutput != null ? recipe.fluidOutput.getLocalizedName() : "null"; - String out = !recipe.itemOutput.isEmpty() ? recipe.itemOutput.getDisplayName() : "null"; - return "Adding Squeezer Recipe for Fluid " + fluid + " and Item " + out; + String fluid = recipe.fluidOutput!=null?recipe.fluidOutput.getLocalizedName(): "null"; + String out = !recipe.itemOutput.isEmpty()?recipe.itemOutput.getDisplayName(): "null"; + return "Adding Squeezer Recipe for Fluid "+fluid+" and Item "+out; } } @ZenMethod public static void removeFluidRecipe(ILiquidStack fluid) { - if(CraftTweakerHelper.toFluidStack(fluid) != null) + if(CraftTweakerHelper.toFluidStack(fluid)!=null) CraftTweakerAPI.apply(new RemoveFluid(CraftTweakerHelper.toFluidStack(fluid))); } @@ -89,7 +89,7 @@ public void apply() while(it.hasNext()) { SqueezerRecipe r = it.next(); - if(r != null && r.fluidOutput != null && r.fluidOutput.isFluidEqual(output)) + if(r!=null&&r.fluidOutput!=null&&r.fluidOutput.isFluidEqual(output)) { removedRecipes.add(r); IECompatModule.jeiRemoveFunc.accept(r); @@ -101,7 +101,7 @@ public void apply() @Override public String describe() { - return "Removing Squeezer Recipes for Fluid " + output.getLocalizedName(); + return "Removing Squeezer Recipes for Fluid "+output.getLocalizedName(); } } @@ -129,7 +129,7 @@ public void apply() while(it.hasNext()) { SqueezerRecipe r = it.next(); - if(r != null && OreDictionary.itemMatches(output, r.itemOutput, false)) + if(r!=null&&OreDictionary.itemMatches(output, r.itemOutput, false)) { removedRecipes.add(r); IECompatModule.jeiRemoveFunc.accept(r); @@ -141,14 +141,14 @@ public void apply() @Override public String describe() { - return "Removing Squeezer Recipes for ItemStack " + output.getDisplayName(); + return "Removing Squeezer Recipes for ItemStack "+output.getDisplayName(); } } @ZenMethod public static void removeByInput(IItemStack stack) { - if(CraftTweakerHelper.toStack(stack) != null) + if(CraftTweakerHelper.toStack(stack)!=null) CraftTweakerAPI.apply(new RemoveByInput(CraftTweakerHelper.toStack(stack))); } @@ -169,7 +169,7 @@ public void apply() while(it.hasNext()) { SqueezerRecipe r = it.next(); - if(r != null && r.input.matchesItemStack(input)) + if(r!=null&&r.input.matchesItemStack(input)) { removedRecipes.add(r); IECompatModule.jeiRemoveFunc.accept(r); @@ -181,7 +181,7 @@ public void apply() @Override public String describe() { - return "Removing Squeezer Recipes for input " + input.getDisplayName(); + return "Removing Squeezer Recipes for input "+input.getDisplayName(); } } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/AssemblerRecipeTransferHandler.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/AssemblerRecipeTransferHandler.java index e5bb02a698..0d44e16d16 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/AssemblerRecipeTransferHandler.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/AssemblerRecipeTransferHandler.java @@ -44,27 +44,27 @@ public Class getContainerClass() public IRecipeTransferError transferRecipe(@Nonnull ContainerAssembler container, @Nonnull IRecipeLayout recipeLayout, @Nonnull EntityPlayer player, boolean maxTransfer, boolean doTransfer) { for(int i = 0; i < 3; i++) - if(container.tile.patterns[i].recipe == null) + if(container.tile.patterns[i].recipe==null) { if(doTransfer) { IGuiItemStackGroup stacks = recipeLayout.getItemStacks(); NBTTagList tagList = new NBTTagList(); - NonNullList convertedInput = NonNullList.withSize(stacks.getGuiIngredients().size() - 1, ItemStack.EMPTY); + NonNullList convertedInput = NonNullList.withSize(stacks.getGuiIngredients().size()-1, ItemStack.EMPTY); int j = 0; for(IGuiIngredient ingr : stacks.getGuiIngredients().values()) { if(j > 0) { List list = ingr.getAllIngredients(); - if(list != null && list.size() > 0) - convertedInput.set(j - 1, list.get(0)); + if(list!=null&&list.size() > 0) + convertedInput.set(j-1, list.get(0)); } j++; } for(int slot = 0; slot < Math.min(convertedInput.size(), 9); slot++) { - container.putStackInSlot(i * 10 + slot, convertedInput.get(slot)); + container.putStackInSlot(i*10+slot, convertedInput.get(slot)); NBTTagCompound itemTag = new NBTTagCompound(); if(!convertedInput.get(slot).isEmpty()) convertedInput.get(slot).writeToNBT(itemTag); @@ -78,6 +78,6 @@ public IRecipeTransferError transferRecipe(@Nonnull ContainerAssembler container } return null; } - return JEIHelper.jeiHelpers.recipeTransferHandlerHelper().createUserErrorWithTooltip(I18n.translateToLocal(Lib.GUI + "assembler.nospace")); + return JEIHelper.jeiHelpers.recipeTransferHandlerHelper().createUserErrorWithTooltip(I18n.translateToLocal(Lib.GUI+"assembler.nospace")); } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/IEFluidTooltipCallback.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/IEFluidTooltipCallback.java index 88d4f344d9..6ab9bc683a 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/IEFluidTooltipCallback.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/IEFluidTooltipCallback.java @@ -23,11 +23,11 @@ public class IEFluidTooltipCallback implements ITooltipCallback @Override public void onTooltip(int slotIndex, boolean input, FluidStack ingredient, List tooltip) { - if(ingredient!=null && ingredient.getFluid() instanceof IEFluid) + if(ingredient!=null&&ingredient.getFluid() instanceof IEFluid) { ArrayList fluidInfo = new ArrayList(); ((IEFluid)ingredient.getFluid()).addTooltipInfo(ingredient, null, fluidInfo); - if(tooltip.size()>1) + if(tooltip.size() > 1) tooltip.addAll(1, fluidInfo); else tooltip.addAll(fluidInfo); diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/IERecipeCategory.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/IERecipeCategory.java index 8adcc94550..e0e819fe18 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/IERecipeCategory.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/IERecipeCategory.java @@ -81,19 +81,19 @@ public List getTooltipStrings(int mouseX, int mouseY) return Collections.emptyList(); } -// @Override + // @Override public Class getRecipeClass() { return this.recipeClass; } -// @Override + // @Override public String getRecipeCategoryUid() { return "ie."+uniqueName; } -// @Override + // @Override public boolean isRecipeValid(T recipe) { return true; diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/MultiblockRecipeWrapper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/MultiblockRecipeWrapper.java index cadb448a8e..bd1db71f33 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/MultiblockRecipeWrapper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/MultiblockRecipeWrapper.java @@ -24,6 +24,7 @@ public class MultiblockRecipeWrapper implements IRecipeWrapper protected List outputs; protected List fluidInputs; protected List fluidOutputs; + public MultiblockRecipeWrapper(MultiblockRecipe recipe) { recipe.setupJEI(); @@ -52,14 +53,17 @@ public List getItemIn() { return inputs; } + public List getItemOut() { return outputs; } + public List getFluidIn() { return fluidInputs; } + public List getFluidOut() { return fluidOutputs; diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/alloysmelter/AlloySmelterRecipeCategory.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/alloysmelter/AlloySmelterRecipeCategory.java index cb3176df02..2df0a38712 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/alloysmelter/AlloySmelterRecipeCategory.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/alloysmelter/AlloySmelterRecipeCategory.java @@ -26,7 +26,7 @@ public class AlloySmelterRecipeCategory extends IERecipeCategory0) + if(ingredients.getOutputs(ItemStack.class).size() > 0) guiItemStacks.set(2, ingredients.getOutputs(ItemStack.class).get(0)); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/alloysmelter/AlloySmelterRecipeWrapper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/alloysmelter/AlloySmelterRecipeWrapper.java index 060df460e8..a60889dff1 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/alloysmelter/AlloySmelterRecipeWrapper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/alloysmelter/AlloySmelterRecipeWrapper.java @@ -22,9 +22,10 @@ public class AlloySmelterRecipeWrapper implements IRecipeWrapper { private final List> inputs; private final ItemStack output; + public AlloySmelterRecipeWrapper(AlloyRecipe recipe) { - this.inputs = Arrays.asList(recipe.input0.getSizedStackList(),recipe.input1.getSizedStackList()); + this.inputs = Arrays.asList(recipe.input0.getSizedStackList(), recipe.input1.getSizedStackList()); this.output = recipe.output; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/arcfurnace/ArcFurnaceRecipeWrapper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/arcfurnace/ArcFurnaceRecipeWrapper.java index a738391054..c34a32879c 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/arcfurnace/ArcFurnaceRecipeWrapper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/arcfurnace/ArcFurnaceRecipeWrapper.java @@ -24,12 +24,13 @@ public class ArcFurnaceRecipeWrapper extends MultiblockRecipeWrapper public String specialRecipeType; int time; int energy; + public ArcFurnaceRecipeWrapper(ArcFurnaceRecipe recipe) { super(recipe); String name = this.getClass().getName(); int idx = name.indexOf("ArcFurnaceRecipeWrapper"); - if(idx>=0 && idx+"ArcFurnaceRecipeWrapper".length()= 0&&idx+"ArcFurnaceRecipeWrapper".length() < name.length()) specialRecipeType = name.substring(idx+"ArcFurnaceRecipeWrapper".length()); time = recipe.getTotalProcessTime(); energy = recipe.getTotalProcessEnergy()/time; @@ -39,9 +40,9 @@ public ArcFurnaceRecipeWrapper(ArcFurnaceRecipe recipe) public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { String s = energy+" RF/t"; - minecraft.fontRenderer.drawString(s, 54,38, 0x777777); + minecraft.fontRenderer.drawString(s, 54, 38, 0x777777); s = time+" ticks"; - minecraft.fontRenderer.drawString(s, 54,48, 0x777777); + minecraft.fontRenderer.drawString(s, 54, 48, 0x777777); } public static ArcFurnaceRecipeWrapper getWrapper(ArcFurnaceRecipe recipe) @@ -50,9 +51,11 @@ public static ArcFurnaceRecipeWrapper getWrapper(ArcFurnaceRecipe recipe) return new ArcFurnaceRecipeWrapper(recipe); else { - try { + try + { return getWrapperClass(recipe.specialRecipeType).getConstructor(ArcFurnaceRecipe.class).newInstance(recipe); - } catch (Exception e) { + } catch(Exception e) + { IELogger.error("Adding an ArcFurnaceRecipe: "+recipe.specialRecipeType+", threw an error! Report this!"); e.printStackTrace(); } @@ -61,6 +64,7 @@ public static ArcFurnaceRecipeWrapper getWrapper(ArcFurnaceRecipe recipe) } private static HashMap> dynamicSubclasses = new HashMap(); + public static Class getWrapperClass(String subtype) { if(subtype==null) @@ -92,33 +96,36 @@ private static Class createSubWrapper(String String entitySuperClassName = Type.getInternalName(ArcFurnaceRecipeWrapper.class); String entityProxySubClassName = ArcFurnaceRecipeWrapper.class.getSimpleName().concat(subtype); ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); - cw.visit(Opcodes.V1_6,Opcodes.ACC_PUBLIC+Opcodes.ACC_SUPER,entityProxySubClassName,null,entitySuperClassName,null); - cw.visitSource(entityProxySubClassName.concat(".java"),null); + cw.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC+Opcodes.ACC_SUPER, entityProxySubClassName, null, entitySuperClassName, null); + cw.visitSource(entityProxySubClassName.concat(".java"), null); //create constructor String methodDescriptor = "(L"+Type.getInternalName(ArcFurnaceRecipe.class)+";)V"; - MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC,"",methodDescriptor,null,null); + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "", methodDescriptor, null, null); mv.visitCode(); - mv.visitVarInsn(Opcodes.ALOAD,0); - mv.visitVarInsn(Opcodes.ALOAD,1); - mv.visitMethodInsn(Opcodes.INVOKESPECIAL,entitySuperClassName,"",methodDescriptor, false); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitVarInsn(Opcodes.ALOAD, 1); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, entitySuperClassName, "", methodDescriptor, false); mv.visitInsn(Opcodes.RETURN); - mv.visitMaxs(0,0); + mv.visitMaxs(0, 0); mv.visitEnd(); cw.visitEnd(); - return (Class) new ProxyClassLoader(Thread.currentThread().getContextClassLoader(),cw.toByteArray()).loadClass(entityProxySubClassName.replaceAll("/",".")); + return (Class)new ProxyClassLoader(Thread.currentThread().getContextClassLoader(), cw.toByteArray()).loadClass(entityProxySubClassName.replaceAll("/", ".")); } + public static class ProxyClassLoader extends ClassLoader { private byte[] rawClassBytes; - public ProxyClassLoader(ClassLoader parentClassLoader,byte[] classBytes) + + public ProxyClassLoader(ClassLoader parentClassLoader, byte[] classBytes) { super(parentClassLoader); this.rawClassBytes = classBytes; } + @Override public Class findClass(String name) { - return defineClass(name,this.rawClassBytes, 0,this.rawClassBytes.length); + return defineClass(name, this.rawClassBytes, 0, this.rawClassBytes.length); } } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/arcfurnace/package-info.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/arcfurnace/package-info.java index 785009273b..9051d38334 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/arcfurnace/package-info.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/arcfurnace/package-info.java @@ -3,4 +3,5 @@ package blusunrize.immersiveengineering.common.util.compat.jei.arcfurnace; import mcp.MethodsReturnNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/blastfurnace/BlastFurnaceFuelCategory.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/blastfurnace/BlastFurnaceFuelCategory.java index 8282efa355..6b3a14f2fa 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/blastfurnace/BlastFurnaceFuelCategory.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/blastfurnace/BlastFurnaceFuelCategory.java @@ -29,7 +29,7 @@ public class BlastFurnaceFuelCategory extends IERecipeCategory inputs; private final ItemStack output; private final ItemStack slag; + public BlastFurnaceRecipeWrapper(BlastFurnaceRecipe recipe) { this.inputs = (List)(recipe.input instanceof List?recipe.input: Arrays.asList((ItemStack)recipe.input)); @@ -42,11 +43,12 @@ public ItemStack getSmeltingOutput() { return output; } + public ItemStack getSlagOutput() { return slag; } - + @Override public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/blastfurnace/package-info.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/blastfurnace/package-info.java index 11a8a01eb4..b291e9ccd2 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/blastfurnace/package-info.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/blastfurnace/package-info.java @@ -3,4 +3,5 @@ package blusunrize.immersiveengineering.common.util.compat.jei.blastfurnace; import mcp.MethodsReturnNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/bottlingmachine/BottlingMachineRecipeCategory.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/bottlingmachine/BottlingMachineRecipeCategory.java index 784b35567b..0d60b4a831 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/bottlingmachine/BottlingMachineRecipeCategory.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/bottlingmachine/BottlingMachineRecipeCategory.java @@ -32,9 +32,9 @@ public class BottlingMachineRecipeCategory extends IERecipeCategory0) + if(ingredients.getOutputs(ItemStack.class).size() > 0) guiItemStacks.set(1, ingredients.getOutputs(ItemStack.class).get(0)); - if(ingredients.getOutputs(FluidStack.class).size()>0) + if(ingredients.getOutputs(FluidStack.class).size() > 0) { IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks(); guiFluidStacks.init(0, false, 121, 7, 16, 47, 12000, false, tankOverlay); diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/cokeoven/CokeOvenRecipeWrapper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/cokeoven/CokeOvenRecipeWrapper.java index 9d7ad107fd..e5b62cd38e 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/cokeoven/CokeOvenRecipeWrapper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/cokeoven/CokeOvenRecipeWrapper.java @@ -25,11 +25,12 @@ public class CokeOvenRecipeWrapper implements IRecipeWrapper private final List inputs; private final ItemStack output; private final FluidStack creosote; + public CokeOvenRecipeWrapper(CokeOvenRecipe recipe) { this.inputs = (List)(recipe.input instanceof List?recipe.input: Arrays.asList((ItemStack)recipe.input)); this.output = recipe.output; - this.creosote = new FluidStack(IEContent.fluidCreosote,recipe.creosoteOutput); + this.creosote = new FluidStack(IEContent.fluidCreosote, recipe.creosoteOutput); } @Override diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/cokeoven/package-info.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/cokeoven/package-info.java index 673927c099..ebb1999ebd 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/cokeoven/package-info.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/cokeoven/package-info.java @@ -3,4 +3,5 @@ package blusunrize.immersiveengineering.common.util.compat.jei.cokeoven; import mcp.MethodsReturnNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/crusher/CrusherRecipeCategory.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/crusher/CrusherRecipeCategory.java index 4bc6c0a51b..1c379f7b68 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/crusher/CrusherRecipeCategory.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/crusher/CrusherRecipeCategory.java @@ -24,13 +24,15 @@ public class CrusherRecipeCategory extends IERecipeCategory { static ItemStack crusherStack; + public CrusherRecipeCategory(IGuiHelper helper) { - super("crusher","tile.immersiveengineering.metal_multiblock.crusher.name", helper.createBlankDrawable(140,50), CrusherRecipe.class, new ItemStack(IEContent.blockMetalMultiblock,1,BlockTypes_MetalMultiblock.CRUSHER.getMeta())); - crusherStack = new ItemStack(IEContent.blockMetalMultiblock,1, BlockTypes_MetalMultiblock.CRUSHER.getMeta()); + super("crusher", "tile.immersiveengineering.metal_multiblock.crusher.name", helper.createBlankDrawable(140, 50), CrusherRecipe.class, new ItemStack(IEContent.blockMetalMultiblock, 1, BlockTypes_MetalMultiblock.CRUSHER.getMeta())); + crusherStack = new ItemStack(IEContent.blockMetalMultiblock, 1, BlockTypes_MetalMultiblock.CRUSHER.getMeta()); } int[][] outputSlots; + @Override public void setRecipe(IRecipeLayout recipeLayout, CrusherRecipeWrapper recipeWrapper, IIngredients ingredients) { @@ -40,11 +42,11 @@ public void setRecipe(IRecipeLayout recipeLayout, CrusherRecipeWrapper recipeWra outputSlots = new int[recipeWrapper.recipeOutputs.length][]; guiItemStacks.set(0, recipeWrapper.getItemIn()); guiItemStacks.set(1, recipeWrapper.recipeOutputs[0]); - outputSlots[0] = new int[]{82,3}; - for(int i=1; i0) + if(ingredients.getOutputs(ItemStack.class).size() > 0) guiItemStacks.set(1, ingredients.getOutputs(ItemStack.class).get(0)); - if(ingredients.getOutputs(FluidStack.class).size()>0) + if(ingredients.getOutputs(FluidStack.class).size() > 0) { IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks(); guiFluidStacks.init(0, false, 106, 9, 16, 47, 24000, false, tankOverlay); diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/fermenter/package-info.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/fermenter/package-info.java index 74b18f2f9d..e15a302d3e 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/fermenter/package-info.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/fermenter/package-info.java @@ -3,4 +3,5 @@ package blusunrize.immersiveengineering.common.util.compat.jei.fermenter; import mcp.MethodsReturnNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/metalpress/MetalPressRecipeCategory.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/metalpress/MetalPressRecipeCategory.java index 4d249381b7..8e6d826d1f 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/metalpress/MetalPressRecipeCategory.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/metalpress/MetalPressRecipeCategory.java @@ -24,10 +24,11 @@ public class MetalPressRecipeCategory extends IERecipeCategory { static ItemStack metalPressStack; + public MetalPressRecipeCategory(IGuiHelper helper) { - super("metalPress","tile.immersiveengineering.metal_multiblock.metal_press.name", helper.createBlankDrawable(140,50), MetalPressRecipe.class, new ItemStack(IEContent.blockMetalMultiblock,1,BlockTypes_MetalMultiblock.METAL_PRESS.getMeta())); - metalPressStack = new ItemStack(IEContent.blockMetalMultiblock,1, BlockTypes_MetalMultiblock.METAL_PRESS.getMeta()); + super("metalPress", "tile.immersiveengineering.metal_multiblock.metal_press.name", helper.createBlankDrawable(140, 50), MetalPressRecipe.class, new ItemStack(IEContent.blockMetalMultiblock, 1, BlockTypes_MetalMultiblock.METAL_PRESS.getMeta())); + metalPressStack = new ItemStack(IEContent.blockMetalMultiblock, 1, BlockTypes_MetalMultiblock.METAL_PRESS.getMeta()); } @Override diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/metalpress/package-info.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/metalpress/package-info.java index de18fed1a9..86822b0973 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/metalpress/package-info.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/metalpress/package-info.java @@ -3,4 +3,5 @@ package blusunrize.immersiveengineering.common.util.compat.jei.metalpress; import mcp.MethodsReturnNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/mixer/MixerRecipeCategory.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/mixer/MixerRecipeCategory.java index 27191973ea..12f0b92022 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/mixer/MixerRecipeCategory.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/mixer/MixerRecipeCategory.java @@ -35,28 +35,28 @@ public class MixerRecipeCategory extends IERecipeCategory> inputs = ingredients.getInputs(FluidStack.class); IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks(); - if(inputs.size()>0) + if(inputs.size() > 0) { - guiFluidStacks.init(0, true, 7,10, 16,47, 6000, false, tankOverlay); + guiFluidStacks.init(0, true, 7, 10, 16, 47, 6000, false, tankOverlay); guiFluidStacks.set(0, inputs.get(0)); - if(inputs.size()>1) + if(inputs.size() > 1) { - guiFluidStacks.init(1, true, 55,10, 16,47, 6000, false, tankOverlay); + guiFluidStacks.init(1, true, 55, 10, 16, 47, 6000, false, tankOverlay); guiFluidStacks.set(1, inputs.get(1)); } } - guiFluidStacks.init(2, false, 103,10, 16,47, 6000, false, tankOverlay); + guiFluidStacks.init(2, false, 103, 10, 16, 47, 6000, false, tankOverlay); guiFluidStacks.set(2, ingredients.getOutputs(FluidStack.class).get(0)); guiFluidStacks.addTooltipCallback(JEIHelper.fluidTooltipCallback); diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/refinery/package-info.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/refinery/package-info.java index 1bdaeec1dc..5a9d4d6861 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/refinery/package-info.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/refinery/package-info.java @@ -3,4 +3,5 @@ package blusunrize.immersiveengineering.common.util.compat.jei.refinery; import mcp.MethodsReturnNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/squeezer/SqueezerRecipeCategory.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/squeezer/SqueezerRecipeCategory.java index 0912823944..442b831fd7 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/squeezer/SqueezerRecipeCategory.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/squeezer/SqueezerRecipeCategory.java @@ -31,8 +31,8 @@ public class SqueezerRecipeCategory extends IERecipeCategory0) + if(ingredients.getOutputs(ItemStack.class).size() > 0) guiItemStacks.set(1, ingredients.getOutputs(ItemStack.class).get(0)); - if(ingredients.getOutputs(FluidStack.class).size()>0) + if(ingredients.getOutputs(FluidStack.class).size() > 0) { IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks(); guiFluidStacks.init(0, false, 106, 9, 16, 47, 24000, false, tankOverlay); diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/squeezer/package-info.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/squeezer/package-info.java index 984235a41a..523ac19665 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/squeezer/package-info.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/squeezer/package-info.java @@ -3,4 +3,5 @@ package blusunrize.immersiveengineering.common.util.compat.jei.squeezer; import mcp.MethodsReturnNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/workbench/WorkbenchRecipeCategory.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/workbench/WorkbenchRecipeCategory.java index 5d1fdb3163..d37c9651b5 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/workbench/WorkbenchRecipeCategory.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/jei/workbench/WorkbenchRecipeCategory.java @@ -27,9 +27,10 @@ public class WorkbenchRecipeCategory extends IERecipeCategory { public static ResourceLocation background = new ResourceLocation("immersiveengineering:textures/gui/workbench.png"); + public WorkbenchRecipeCategory(IGuiHelper helper) { - super("workbench","tile.immersiveengineering.wooden_device0.workbench.name", helper.createDrawable(background, 0,0, 176,74), BlueprintCraftingRecipe.class, new ItemStack(IEContent.blockWoodenDevice0,1,BlockTypes_WoodenDevice0.WORKBENCH.getMeta()),new ItemStack(IEContent.blockMetalMultiblock,1, BlockTypes_MetalMultiblock.AUTO_WORKBENCH.getMeta())); + super("workbench", "tile.immersiveengineering.wooden_device0.workbench.name", helper.createDrawable(background, 0, 0, 176, 74), BlueprintCraftingRecipe.class, new ItemStack(IEContent.blockWoodenDevice0, 1, BlockTypes_WoodenDevice0.WORKBENCH.getMeta()), new ItemStack(IEContent.blockMetalMultiblock, 1, BlockTypes_MetalMultiblock.AUTO_WORKBENCH.getMeta())); } @Override @@ -38,7 +39,7 @@ public void setRecipe(IRecipeLayout recipeLayout, WorkbenchRecipeWrapper recipeW IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks(); guiItemStacks.init(0, true, 24, 16); guiItemStacks.set(0, Lists.newArrayList(BlueprintCraftingRecipe.getTypedBlueprint(recipeWrapper.blueprintCategory))); - for(int i=0; i 12) + if(slot < 1||slot > 12) throw new IllegalArgumentException("Input slots are 1-12"); TileEntityArcFurnace master = getTileEntity(); - Map stack = Utils.saveStack(master.inventory.get(slot - 1)); + Map stack = Utils.saveStack(master.inventory.get(slot-1)); mainLoop: for(MultiblockProcess p : master.processQueue) - for(int i : ((MultiblockProcessInMachine) p).getInputSlots()) - if(i == slot - 1) + for(int i : ((MultiblockProcessInMachine)p).getInputSlots()) + if(i==slot-1) { stack.put("progress", p.processTick); stack.put("maxProgress", p.maxTicks); @@ -112,18 +111,18 @@ public Object[] getInputStack(Context context, Arguments args) public Object[] getOutputStack(Context context, Arguments args) { int slot = args.checkInteger(0); - if(slot < 1 || slot > 6) + if(slot < 1||slot > 6) throw new IllegalArgumentException("Output slots are 1-6"); - return new Object[]{getTileEntity().inventory.get(slot + 15)}; + return new Object[]{getTileEntity().inventory.get(slot+15)}; } @Callback(doc = "function(stack:int):table -- returns the specified additive stack") public Object[] getAdditiveStack(Context context, Arguments args) { int slot = args.checkInteger(0); - if(slot < 1 || slot > 4) + if(slot < 1||slot > 4) throw new IllegalArgumentException("Additive slots are 1-4"); - return new Object[]{getTileEntity().inventory.get(slot + 11)}; + return new Object[]{getTileEntity().inventory.get(slot+11)}; } @Callback(doc = "function():table -- returns the slag stack") @@ -143,21 +142,23 @@ public Object[] hasElectrodes(Context context, Arguments args) public Object[] getElectrode(Context context, Arguments args) { int slot = args.checkInteger(0); - if(slot < 1 || slot > 3) + if(slot < 1||slot > 3) throw new IllegalArgumentException("Electrode slots are 1-3"); - ItemStack stack = getTileEntity().inventory.get(slot + 22); + ItemStack stack = getTileEntity().inventory.get(slot+22); Map map = Utils.saveStack(stack); - if(!stack.isEmpty() && stack.getItem() instanceof ItemGraphiteElectrode) + if(!stack.isEmpty()&&stack.getItem() instanceof ItemGraphiteElectrode) map.put("damage", ItemNBTHelper.getInt(stack, "graphDmg")); return new Object[]{map}; } + @Override @Callback(doc = "function(enabled:bool):nil -- Enables or disables computer control for the attached machine") public Object[] enableComputerControl(Context context, Arguments args) { return super.enableComputerControl(context, args); } + @Override @Callback(doc = "function(enabled:bool):nil -- Enables or disables the machine. Call \"enableComputerControl(true)\" before using this and disable computer control before removing the computer") public Object[] setEnabled(Context context, Arguments args) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/AssemblerDriver.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/AssemblerDriver.java index 6e045ab0a5..3cee321a13 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/AssemblerDriver.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/AssemblerDriver.java @@ -7,7 +7,6 @@ import li.cil.oc.api.machine.Callback; import li.cil.oc.api.machine.Context; import li.cil.oc.api.network.ManagedEnvironment; -import li.cil.oc.api.network.Node; import li.cil.oc.api.prefab.DriverSidedTileEntity; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -27,9 +26,9 @@ public ManagedEnvironment createEnvironment(World w, BlockPos bp, EnumFacing s) TileEntity te = w.getTileEntity(bp); if(te instanceof TileEntityAssembler) { - TileEntityAssembler assembler = (TileEntityAssembler) te; + TileEntityAssembler assembler = (TileEntityAssembler)te; TileEntityAssembler master = assembler.master(); - if(master != null && assembler.isRedstonePos()) + if(master!=null&&assembler.isRedstonePos()) return new AssemblerEnvironment(w, master.getPos(), TileEntityAssembler.class); } return null; @@ -65,29 +64,29 @@ public AssemblerEnvironment(World w, BlockPos bp, Class 3 || recipe < 1) + if(recipe > 3||recipe < 1) throw new IllegalArgumentException("Only recipes 1-3 are available"); TileEntityAssembler master = getTileEntity(); - if(master.patterns[recipe - 1].inv.get(9).isEmpty()) + if(master.patterns[recipe-1].inv.get(9).isEmpty()) throw new IllegalArgumentException("The requested recipe is invalid"); ArrayList queryList = new ArrayList<>(); for(ItemStack stack : master.inventory) if(!stack.isEmpty()) queryList.add(stack.copy()); - return new Object[]{master.hasIngredients(master.patterns[recipe - 1], queryList)}; + return new Object[]{master.hasIngredients(master.patterns[recipe-1], queryList)}; } @Callback(doc = "function(recipe:int):table -- get the recipe in the specified position") public Object[] getRecipe(Context context, Arguments args) { int recipe = args.checkInteger(0); - if(recipe > 3 || recipe < 1) + if(recipe > 3||recipe < 1) throw new IllegalArgumentException("Only recipes 1-3 are available"); TileEntityAssembler te = getTileEntity(); HashMap ret = new HashMap<>(); for(int i = 0; i < 9; i++) - ret.put("in" + (i + 1), te.patterns[recipe - 1].inv.get(i)); - ret.put("out", te.patterns[recipe - 1].inv.get(9)); + ret.put("in"+(i+1), te.patterns[recipe-1].inv.get(i)); + ret.put("out", te.patterns[recipe-1].inv.get(9)); return new Object[]{ret}; } @@ -95,18 +94,18 @@ public Object[] getRecipe(Context context, Arguments args) public Object[] isValidRecipe(Context context, Arguments args) { int recipe = args.checkInteger(0); - if(recipe > 3 || recipe < 1) + if(recipe > 3||recipe < 1) throw new IllegalArgumentException("Only recipes 1-3 are available"); - return new Object[]{!getTileEntity().patterns[recipe - 1].inv.get(9).isEmpty()}; + return new Object[]{!getTileEntity().patterns[recipe-1].inv.get(9).isEmpty()}; } @Callback(doc = "function(tank:int):table -- gets the specified tank") public Object[] getTank(Context context, Arguments args) { int tank = args.checkInteger(0); - if(tank > 3 || tank < 1) + if(tank > 3||tank < 1) throw new IllegalArgumentException("Only tanks 1-3 are available"); - return new Object[]{Utils.saveFluidTank(getTileEntity().tanks[tank - 1])}; + return new Object[]{Utils.saveFluidTank(getTileEntity().tanks[tank-1])}; } @Callback(doc = "function():int -- returns the maximum amount of energy that can be stored") @@ -125,38 +124,40 @@ public Object[] getEnergyStored(Context context, Arguments args) public Object[] getStackInSlot(Context context, Arguments args) { int slot = args.checkInteger(0); - if(slot < 1 || slot > 18) + if(slot < 1||slot > 18) throw new IllegalArgumentException("Only slots 1-18 are available"); - return new Object[]{getTileEntity().inventory.get(slot - 1)}; + return new Object[]{getTileEntity().inventory.get(slot-1)}; } @Callback(doc = "function(slot:int):table -- returns the stack in the output slot of the specified recipe") public Object[] getBufferStack(Context context, Arguments args) { int slot = args.checkInteger(0); - if(slot < 1 || slot > 3) + if(slot < 1||slot > 3) throw new IllegalArgumentException("Only recipes 1-3 are available"); - return new Object[]{getTileEntity().inventory.get(17 + slot)}; + return new Object[]{getTileEntity().inventory.get(17+slot)}; } + @Override @Callback(doc = "function(enabled:bool):nil -- Enables or disables computer control for the attached machine") public Object[] enableComputerControl(Context context, Arguments args) { TileEntityAssembler te = getTileEntity(); te.isComputerControlled = args.checkBoolean(0); - for (int i = 0; i < 3; i++) + for(int i = 0; i < 3; i++) te.computerOn[i] = true; return null; } + @Override @Callback(doc = "function(recipe:int) -- enables or disables the specified recipe") public Object[] setEnabled(Context context, Arguments args) { boolean on = args.checkBoolean(1); int recipe = args.checkInteger(0); - if(recipe > 3 || recipe < 1) + if(recipe > 3||recipe < 1) throw new IllegalArgumentException("Only recipes 1-3 are available"); - getTileEntity().computerOn[recipe - 1] = on; + getTileEntity().computerOn[recipe-1] = on; return null; } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/BottlingMachineDriver.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/BottlingMachineDriver.java index 564de3851e..02468942ab 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/BottlingMachineDriver.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/BottlingMachineDriver.java @@ -1,23 +1,16 @@ package blusunrize.immersiveengineering.common.util.compat.opencomputers; -import blusunrize.immersiveengineering.api.crafting.BottlingMachineRecipe; import blusunrize.immersiveengineering.common.blocks.TileEntityIEBase; import blusunrize.immersiveengineering.common.blocks.metal.TileEntityBottlingMachine; import li.cil.oc.api.machine.Arguments; import li.cil.oc.api.machine.Callback; import li.cil.oc.api.machine.Context; import li.cil.oc.api.network.ManagedEnvironment; -import li.cil.oc.api.network.Node; import li.cil.oc.api.prefab.DriverSidedTileEntity; -import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; - -import java.util.HashMap; public class BottlingMachineDriver extends DriverSidedTileEntity { @@ -28,9 +21,9 @@ public ManagedEnvironment createEnvironment(World w, BlockPos bp, EnumFacing fac TileEntity te = w.getTileEntity(bp); if(te instanceof TileEntityBottlingMachine) { - TileEntityBottlingMachine ref = (TileEntityBottlingMachine) te; + TileEntityBottlingMachine ref = (TileEntityBottlingMachine)te; TileEntityBottlingMachine master = ref.master(); - if(master != null && ref.isRedstonePos()) + if(master!=null&&ref.isRedstonePos()) return new BottlingMachineEnvironment(w, master.getPos(), TileEntityBottlingMachine.class); } return null; @@ -75,12 +68,14 @@ public Object[] getTank(Context context, Arguments args) } + @Override @Callback(doc = "function(enabled:bool):nil -- Enables or disables computer control for the attached machine") public Object[] enableComputerControl(Context context, Arguments args) { return super.enableComputerControl(context, args); } + @Override @Callback(doc = "function(enabled:bool):nil -- Enables or disables the machine. Call \"enableComputerControl(true)\" before using this and disable computer control before removing the computer") public Object[] setEnabled(Context context, Arguments args) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/CapacitorDriver.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/CapacitorDriver.java index b7f97f9537..20ce3afb49 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/CapacitorDriver.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/CapacitorDriver.java @@ -59,7 +59,7 @@ public CapacitorEnvironment(World w, BlockPos bp, String name) @Override public String preferredName() { - return "ie_" + prefix + "_capacitor"; + return "ie_"+prefix+"_capacitor"; } @Override diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/CrusherDriver.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/CrusherDriver.java index fa2dbb4945..9ce77d933f 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/CrusherDriver.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/CrusherDriver.java @@ -10,7 +10,6 @@ import li.cil.oc.api.machine.Callback; import li.cil.oc.api.machine.Context; import li.cil.oc.api.network.ManagedEnvironment; -import li.cil.oc.api.network.Node; import li.cil.oc.api.prefab.DriverSidedTileEntity; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -32,9 +31,9 @@ public ManagedEnvironment createEnvironment(World w, BlockPos bp, EnumFacing fac TileEntity te = w.getTileEntity(bp); if(te instanceof TileEntityCrusher) { - TileEntityCrusher crush = (TileEntityCrusher) te; + TileEntityCrusher crush = (TileEntityCrusher)te; TileEntityCrusher master = crush.master(); - if(master != null && crush.isRedstonePos()) + if(master!=null&&crush.isRedstonePos()) return new CrusherEnvironment(w, master.getPos(), TileEntityCrusher.class); } return null; @@ -78,12 +77,12 @@ public Object[] getInputQueue(Context context, Arguments args) TileEntityCrusher master = getTileEntity(); Map ret = new HashMap<>(); List> queue = master.processQueue; - for (int i = 0;i currTmp = queue.get(i); - if (currTmp instanceof MultiblockProcessInWorld) + if(currTmp instanceof MultiblockProcessInWorld) { - MultiblockProcessInWorld curr = (MultiblockProcessInWorld) currTmp; + MultiblockProcessInWorld curr = (MultiblockProcessInWorld)currTmp; Map recipe = new HashMap<>(); recipe.put("progress", curr.processTick); recipe.put("maxProgress", curr.maxTicks); @@ -98,12 +97,14 @@ public Object[] getInputQueue(Context context, Arguments args) return new Object[]{ret}; } + @Override @Callback(doc = "function(enabled:bool):nil -- Enables or disables computer control for the attached machine") public Object[] enableComputerControl(Context context, Arguments args) { return super.enableComputerControl(context, args); } + @Override @Callback(doc = "function(enabled:bool):nil -- Enables or disables the machine. Call \"enableComputerControl(true)\" before using this and disable computer control before removing the computer") public Object[] setEnabled(Context context, Arguments args) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/DieselGenDriver.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/DieselGenDriver.java index a0da6b76b1..60e363321f 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/DieselGenDriver.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/DieselGenDriver.java @@ -5,7 +5,6 @@ import li.cil.oc.api.machine.Callback; import li.cil.oc.api.machine.Context; import li.cil.oc.api.network.ManagedEnvironment; -import li.cil.oc.api.network.Node; import li.cil.oc.api.prefab.DriverSidedTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; @@ -20,9 +19,9 @@ public ManagedEnvironment createEnvironment(World w, BlockPos bp, EnumFacing f) TileEntity te = w.getTileEntity(bp); if(te instanceof TileEntityDieselGenerator) { - TileEntityDieselGenerator gen = ((TileEntityDieselGenerator) te); + TileEntityDieselGenerator gen = ((TileEntityDieselGenerator)te); TileEntityDieselGenerator master = gen.master(); - if(master != null && gen.isRedstonePos()) + if(master!=null&&gen.isRedstonePos()) return new DieselEnvironment(w, master.getPos()); } return null; @@ -54,12 +53,14 @@ public Object[] getTankInfo(Context context, Arguments args) return new Object[]{getTileEntity().tanks[0].getInfo()}; } + @Override @Callback(doc = "function(enabled:bool):nil -- Enables or disables computer control for the attached machine") public Object[] enableComputerControl(Context context, Arguments args) { return super.enableComputerControl(context, args); } + @Override @Callback(doc = "function(enabled:bool):nil -- Enables or disables the machine. Call \"enableComputerControl(true)\" before using this and disable computer control before removing the computer") public Object[] setEnabled(Context context, Arguments args) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/EnergyMeterDriver.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/EnergyMeterDriver.java index 9bffe80209..f95e6376d1 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/EnergyMeterDriver.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/EnergyMeterDriver.java @@ -19,7 +19,7 @@ public class EnergyMeterDriver extends DriverSidedTileEntity public ManagedEnvironment createEnvironment(World w, BlockPos bp, EnumFacing facing) { TileEntity te = w.getTileEntity(bp); - if(te instanceof TileEntityEnergyMeter && ((TileEntityEnergyMeter) te).lower) + if(te instanceof TileEntityEnergyMeter&&((TileEntityEnergyMeter)te).lower) { return new EnergyMeterEnvironment(w, bp); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/ExcavatorDriver.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/ExcavatorDriver.java index 2b7e4ef973..1bcb95a408 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/ExcavatorDriver.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/ExcavatorDriver.java @@ -5,7 +5,6 @@ import li.cil.oc.api.machine.Callback; import li.cil.oc.api.machine.Context; import li.cil.oc.api.network.ManagedEnvironment; -import li.cil.oc.api.network.Node; import li.cil.oc.api.prefab.DriverSidedTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; @@ -20,9 +19,9 @@ public ManagedEnvironment createEnvironment(World w, BlockPos pos, EnumFacing fa TileEntity te = w.getTileEntity(pos); if(te instanceof TileEntityExcavator) { - TileEntityExcavator exc = (TileEntityExcavator) te; + TileEntityExcavator exc = (TileEntityExcavator)te; TileEntityExcavator master = exc.master(); - if(master != null && exc.isRedstonePos()) + if(master!=null&&exc.isRedstonePos()) return new ExcavatorEnvironment(w, master.getPos()); } return null; @@ -61,12 +60,14 @@ public Object[] isActive(Context context, Arguments args) return new Object[]{getTileEntity().active}; } + @Override @Callback(doc = "function(enabled:bool):nil -- Enables or disables computer control for the attached machine") public Object[] enableComputerControl(Context context, Arguments args) { return super.enableComputerControl(context, args); } + @Override @Callback(doc = "function(enabled:bool):nil -- Enables or disables the machine. Call \"enableComputerControl(true)\" before using this and disable computer control before removing the computer") public Object[] setEnabled(Context context, Arguments args) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/FermenterDriver.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/FermenterDriver.java index f09d61c8df..031c1d0255 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/FermenterDriver.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/FermenterDriver.java @@ -7,7 +7,6 @@ import li.cil.oc.api.machine.Callback; import li.cil.oc.api.machine.Context; import li.cil.oc.api.network.ManagedEnvironment; -import li.cil.oc.api.network.Node; import li.cil.oc.api.prefab.DriverSidedTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; @@ -23,9 +22,9 @@ public ManagedEnvironment createEnvironment(World w, BlockPos bp, EnumFacing fac TileEntity te = w.getTileEntity(bp); if(te instanceof TileEntityFermenter) { - TileEntityFermenter ferment = (TileEntityFermenter) te; + TileEntityFermenter ferment = (TileEntityFermenter)te; TileEntityFermenter master = ferment.master(); - if(master != null && ferment.isRedstonePos()) + if(master!=null&&ferment.isRedstonePos()) return new FermenterEnvironment(w, master.getPos()); } return null; @@ -51,12 +50,12 @@ public FermenterEnvironment(World w, BlockPos bp) public Object[] getRecipe(Context context, Arguments args) { int slot = args.checkInteger(0); - if(slot < 1 || slot > 8) + if(slot < 1||slot > 8) throw new IllegalArgumentException("Input slots are 1-8"); TileEntityFermenter master = getTileEntity(); - FermenterRecipe recipe = FermenterRecipe.findRecipe(master.inventory.get(slot - 1)); - if(recipe != null) - return new Object[]{master.inventory.get(slot - 1), recipe.itemOutput, recipe.fluidOutput, recipe.getTotalProcessTime()}; + FermenterRecipe recipe = FermenterRecipe.findRecipe(master.inventory.get(slot-1)); + if(recipe!=null) + return new Object[]{master.inventory.get(slot-1), recipe.itemOutput, recipe.fluidOutput, recipe.getTotalProcessTime()}; else return null; } @@ -65,9 +64,9 @@ public Object[] getRecipe(Context context, Arguments args) public Object[] getInputStack(Context context, Arguments args) { int slot = args.checkInteger(0); - if(slot < 1 || slot > 8) + if(slot < 1||slot > 8) throw new IllegalArgumentException("Input slots are 1-8"); - return new Object[]{getTileEntity().inventory.get(slot - 1)}; + return new Object[]{getTileEntity().inventory.get(slot-1)}; } @Callback(doc = "function():table -- returns the stack in the output slot") @@ -112,12 +111,14 @@ public Object[] isActive(Context context, Arguments args) return new Object[]{getTileEntity().shouldRenderAsActive()}; } + @Override @Callback(doc = "function(enabled:bool):nil -- Enables or disables computer control for the attached machine") public Object[] enableComputerControl(Context context, Arguments args) { return super.enableComputerControl(context, args); } + @Override @Callback(doc = "function(enabled:bool):nil -- Enables or disables the machine. Call \"enableComputerControl(true)\" before using this and disable computer control before removing the computer") public Object[] setEnabled(Context context, Arguments args) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/FloodlightDriver.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/FloodlightDriver.java index 8388610616..593d9a3620 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/FloodlightDriver.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/FloodlightDriver.java @@ -1,4 +1,3 @@ - package blusunrize.immersiveengineering.common.util.compat.opencomputers; import blusunrize.immersiveengineering.common.blocks.metal.TileEntityFloodlight; @@ -65,7 +64,7 @@ public void onConnect(Node node) public void onDisconnect(Node node) { TileEntityFloodlight te = getTileEntity(); - if(te != null) + if(te!=null) te.controllingComputers--; } @@ -115,16 +114,16 @@ public Object[] isActive(Context context, Arguments args) { return new Object[]{getTileEntity().active}; } - + @Callback(direct = false, doc = "function():nil -- waits until the floodlightn can turn again") public Object[] waitForCooldown(Context context, Arguments args) { TileEntityFloodlight te = getTileEntity(); - if (te.turnCooldown>0) + if(te.turnCooldown > 0) context.pause(te.turnCooldown/20F); return null; } - - + + } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/ManagedEnvironmentIE.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/ManagedEnvironmentIE.java index 9ec30b79c7..f911eff649 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/ManagedEnvironmentIE.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/ManagedEnvironmentIE.java @@ -5,7 +5,6 @@ import li.cil.oc.api.Network; import li.cil.oc.api.driver.NamedBlock; import li.cil.oc.api.machine.Arguments; -import li.cil.oc.api.machine.Callback; import li.cil.oc.api.machine.Context; import li.cil.oc.api.network.Visibility; import li.cil.oc.api.prefab.AbstractManagedEnvironment; @@ -34,12 +33,12 @@ public ManagedEnvironmentIE(World w, BlockPos p, Class> extends ManagedEnvironmentIE + public abstract static class ManagedEnvMultiblock> extends ManagedEnvironmentIE { public ManagedEnvMultiblock(World w, BlockPos p, Class teClass) @@ -50,7 +49,7 @@ public ManagedEnvMultiblock(World w, BlockPos p, Class te = getTileEntity(); - if (!te.computerOn.isPresent()) + if(!te.computerOn.isPresent()) throw new IllegalStateException("Computer control must be enabled to enable or disable the machine"); te.computerOn = Optional.of(enabled); return null; diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/MixerDriver.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/MixerDriver.java index 9b9cc76459..9198a2472f 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/MixerDriver.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/MixerDriver.java @@ -5,15 +5,12 @@ import blusunrize.immersiveengineering.common.blocks.metal.TileEntityMixer; import blusunrize.immersiveengineering.common.blocks.metal.TileEntityMultiblockMetal.MultiblockProcess; import blusunrize.immersiveengineering.common.blocks.metal.TileEntityMultiblockMetal.MultiblockProcessInMachine; -import blusunrize.immersiveengineering.common.util.ItemNBTHelper; import blusunrize.immersiveengineering.common.util.Utils; import li.cil.oc.api.machine.Arguments; import li.cil.oc.api.machine.Callback; import li.cil.oc.api.machine.Context; import li.cil.oc.api.network.ManagedEnvironment; -import li.cil.oc.api.network.Node; import li.cil.oc.api.prefab.DriverSidedTileEntity; -import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; @@ -30,9 +27,9 @@ public ManagedEnvironment createEnvironment(World w, BlockPos bp, EnumFacing fac TileEntity te = w.getTileEntity(bp); if(te instanceof TileEntityMixer) { - TileEntityMixer arc = (TileEntityMixer) te; + TileEntityMixer arc = (TileEntityMixer)te; TileEntityMixer master = arc.master(); - if(master != null && arc.isRedstonePos()) + if(master!=null&&arc.isRedstonePos()) return new MixerEnvironment(w, master.getPos(), TileEntityMixer.class); } return null; @@ -75,14 +72,14 @@ public Object[] isActive(Context context, Arguments args) public Object[] getInputStack(Context context, Arguments args) { int slot = args.checkInteger(0); - if(slot < 1 || slot > 12) + if(slot < 1||slot > 12) throw new IllegalArgumentException("Input slots are 1-12"); TileEntityMixer master = getTileEntity(); - Map stack = Utils.saveStack(master.inventory.get(slot - 1)); + Map stack = Utils.saveStack(master.inventory.get(slot-1)); mainLoop: for(MultiblockProcess p : master.processQueue) - for(int i : ((MultiblockProcessInMachine) p).getInputSlots()) - if(i == slot - 1) + for(int i : ((MultiblockProcessInMachine)p).getInputSlots()) + if(i==slot-1) { stack.put("progress", p.processTick); stack.put("maxProgress", p.maxTicks); @@ -95,27 +92,29 @@ public Object[] getInputStack(Context context, Arguments args) } return new Object[]{stack}; } - + // Only wants to return info on the bottom fluid. Might be able to force displaying all fluids, not sure yet. @Callback(doc = "function():table -- get bottom fluid in tank") public Object[] getTank(Context context, Arguments args) { return new Object[]{getTileEntity().tank.getInfo()}; } - + // Only returns true if machine is set to active. Don't think that's fixable from here. @Callback(doc = "function():boolean -- check whether a valid recipe exists for the current inputs") public Object[] isValidRecipe(Context context, Arguments args) { - return new Object[]{getTileEntity().processQueue.get(0).recipe != null}; + return new Object[]{getTileEntity().processQueue.get(0).recipe!=null}; } + @Override @Callback(doc = "function(enabled:bool):nil -- Enables or disables computer control for the attached machine") public Object[] enableComputerControl(Context context, Arguments args) { return super.enableComputerControl(context, args); } + @Override @Callback(doc = "function(enabled:bool):nil -- Enables or disables the machine. Call \"enableComputerControl(true)\" before using this and disable computer control before removing the computer") public Object[] setEnabled(Context context, Arguments args) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/RefineryDriver.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/RefineryDriver.java index d1e046dc1c..5f41b1b705 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/RefineryDriver.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/RefineryDriver.java @@ -7,7 +7,6 @@ import li.cil.oc.api.machine.Callback; import li.cil.oc.api.machine.Context; import li.cil.oc.api.network.ManagedEnvironment; -import li.cil.oc.api.network.Node; import li.cil.oc.api.prefab.DriverSidedTileEntity; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -28,9 +27,9 @@ public ManagedEnvironment createEnvironment(World w, BlockPos bp, EnumFacing fac TileEntity te = w.getTileEntity(bp); if(te instanceof TileEntityRefinery) { - TileEntityRefinery ref = (TileEntityRefinery) te; + TileEntityRefinery ref = (TileEntityRefinery)te; TileEntityRefinery master = ref.master(); - if(master != null && ref.isRedstonePos()) + if(master!=null&&ref.isRedstonePos()) return new RefineryEnvironment(w, master.getPos(), TileEntityRefinery.class); } return null; @@ -82,7 +81,7 @@ public Object[] getOutputTank(Context context, Arguments args) public Object[] getRecipe(Context context, Arguments args) { RefineryRecipe recipe = getTileEntity().processQueue.get(0).recipe; - if(recipe == null) + if(recipe==null) throw new IllegalArgumentException("The recipe of the refinery is invalid"); HashMap ret = new HashMap<>(3); ret.put("input1", recipe.input0); @@ -94,7 +93,7 @@ public Object[] getRecipe(Context context, Arguments args) @Callback(doc = "function():boolean -- check whether a valid recipe exists for the current inputs") public Object[] isValidRecipe(Context context, Arguments args) { - return new Object[]{getTileEntity().processQueue.get(0).recipe != null}; + return new Object[]{getTileEntity().processQueue.get(0).recipe!=null}; } @Callback(doc = "function():table -- return item input slot contents for both input and output tanks") @@ -119,12 +118,14 @@ public Object[] getFullCannisters(Context context, Arguments args) return new Object[]{ret}; } + @Override @Callback(doc = "function(enabled:bool):nil -- Enables or disables computer control for the attached machine") public Object[] enableComputerControl(Context context, Arguments args) { return super.enableComputerControl(context, args); } + @Override @Callback(doc = "function(enabled:bool):nil -- Enables or disables the machine. Call \"enableComputerControl(true)\" before using this and disable computer control before removing the computer") public Object[] setEnabled(Context context, Arguments args) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/SampleDrillDriver.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/SampleDrillDriver.java index e357f9853c..fefcb2be2d 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/SampleDrillDriver.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/SampleDrillDriver.java @@ -21,8 +21,8 @@ public ManagedEnvironment createEnvironment(World w, BlockPos bp, EnumFacing fac TileEntity te = w.getTileEntity(bp); if(te instanceof TileEntitySampleDrill) { - TileEntitySampleDrill drill = (TileEntitySampleDrill) te; - if(drill.dummy == 0) + TileEntitySampleDrill drill = (TileEntitySampleDrill)te; + if(drill.dummy==0) return new SampleDrillEnvironment(w, bp); } return null; @@ -75,6 +75,7 @@ public Object[] getVeinUnlocalizedName(Context context, Arguments args) return new Object[]{te.getVein()}; return new Object[0]; } + @Callback public Object[] getVeinLocalizedName(Context context, Arguments args) { @@ -83,6 +84,7 @@ public Object[] getVeinLocalizedName(Context context, Arguments args) return new Object[]{te.getVeinLocalizedName()}; return new Object[0]; } + @Callback public Object[] getVeinIntegrity(Context context, Arguments args) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/SqueezerDriver.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/SqueezerDriver.java index 2bea273bbd..b05b8c6745 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/SqueezerDriver.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/SqueezerDriver.java @@ -7,7 +7,6 @@ import li.cil.oc.api.machine.Callback; import li.cil.oc.api.machine.Context; import li.cil.oc.api.network.ManagedEnvironment; -import li.cil.oc.api.network.Node; import li.cil.oc.api.prefab.DriverSidedTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; @@ -23,9 +22,9 @@ public ManagedEnvironment createEnvironment(World w, BlockPos bp, EnumFacing fac TileEntity te = w.getTileEntity(bp); if(te instanceof TileEntitySqueezer) { - TileEntitySqueezer ferment = (TileEntitySqueezer) te; + TileEntitySqueezer ferment = (TileEntitySqueezer)te; TileEntitySqueezer master = ferment.master(); - if(master != null && ferment.isRedstonePos()) + if(master!=null&&ferment.isRedstonePos()) return new FermenterEnvironment(w, master.getPos()); } return null; @@ -51,12 +50,12 @@ public FermenterEnvironment(World w, BlockPos bp) public Object[] getRecipe(Context context, Arguments args) { int slot = args.checkInteger(0); - if(slot < 1 || slot > 8) + if(slot < 1||slot > 8) throw new IllegalArgumentException("Input slots are 1-8"); TileEntitySqueezer master = getTileEntity(); - SqueezerRecipe recipe = SqueezerRecipe.findRecipe(master.inventory.get(slot - 1)); - if(recipe != null) - return new Object[]{master.inventory.get(slot - 1), recipe.itemOutput, recipe.fluidOutput, recipe.getTotalProcessTime()}; + SqueezerRecipe recipe = SqueezerRecipe.findRecipe(master.inventory.get(slot-1)); + if(recipe!=null) + return new Object[]{master.inventory.get(slot-1), recipe.itemOutput, recipe.fluidOutput, recipe.getTotalProcessTime()}; else return null; } @@ -65,9 +64,9 @@ public Object[] getRecipe(Context context, Arguments args) public Object[] getInputStack(Context context, Arguments args) { int slot = args.checkInteger(0); - if(slot < 1 || slot > 8) + if(slot < 1||slot > 8) throw new IllegalArgumentException("Input slots are 1-8"); - return new Object[]{getTileEntity().inventory.get(slot - 1)}; + return new Object[]{getTileEntity().inventory.get(slot-1)}; } @Callback(doc = "function():table -- returns the stack in the output slot") @@ -112,12 +111,14 @@ public Object[] isActive(Context context, Arguments args) return new Object[]{getTileEntity().shouldRenderAsActive()}; } + @Override @Callback(doc = "function(enabled:bool):nil -- Enables or disables computer control for the attached machine") public Object[] enableComputerControl(Context context, Arguments args) { return super.enableComputerControl(context, args); } + @Override @Callback(doc = "function(enabled:bool):nil -- Enables or disables the machine. Call \"enableComputerControl(true)\" before using this and disable computer control before removing the computer") public Object[] setEnabled(Context context, Arguments args) { diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/TeslaCoilDriver.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/TeslaCoilDriver.java index e52b197c02..dd6a191f5b 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/TeslaCoilDriver.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/opencomputers/TeslaCoilDriver.java @@ -20,7 +20,7 @@ public class TeslaCoilDriver extends DriverSidedTileEntity public ManagedEnvironment createEnvironment(World w, BlockPos bp, EnumFacing facing) { TileEntity te = w.getTileEntity(bp); - if(te instanceof TileEntityTeslaCoil && !((TileEntityTeslaCoil) te).isDummy()) + if(te instanceof TileEntityTeslaCoil&&!((TileEntityTeslaCoil)te).isDummy()) { return new EnergyMeterEnvironment(w, bp); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/waila/IEWailaDataProvider.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/waila/IEWailaDataProvider.java index 863ea17c4b..1e1c5f0d61 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/waila/IEWailaDataProvider.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/waila/IEWailaDataProvider.java @@ -37,7 +37,7 @@ public static void callbackRegister(IWailaRegistrar registrar) registrar.registerBodyProvider(dataProvider, TileEntityWoodenBarrel.class); registrar.registerNBTProvider(dataProvider, TileEntityWoodenBarrel.class); registrar.registerStackProvider(dataProvider, TileEntityMultiblockPart.class); - + registrar.registerBodyProvider(dataProvider, IFluxReceiver.class); registrar.registerNBTProvider(dataProvider, IFluxReceiver.class); registrar.registerBodyProvider(dataProvider, IFluxProvider.class); @@ -52,11 +52,13 @@ public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler return new ItemStack(accessor.getBlock(), 1, accessor.getMetadata()); return ItemStack.EMPTY; } + @Override public List getWailaHead(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { return currenttip; } + @Override public List getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { @@ -94,14 +96,14 @@ else if(tile instanceof TileEntityWoodenBarrel) { int cur = accessor.getNBTInteger(accessor.getNBTData(), "Energy"); int max = accessor.getNBTInteger(accessor.getNBTData(), "MaxStorage"); - if(max>0 && ((ITaggedList)currenttip).getEntries("IFEnergyStorage").size()==0) - ((ITaggedList)currenttip).add(String.format("%d / %d IF", cur,max), "IFEnergyStorage"); - if (tile instanceof TileEntityTeslaCoil && ((ITaggedList)currenttip).getEntries("teslaCoil").size()==0) + if(max > 0&&((ITaggedList)currenttip).getEntries("IFEnergyStorage").size()==0) + ((ITaggedList)currenttip).add(String.format("%d / %d IF", cur, max), "IFEnergyStorage"); + if(tile instanceof TileEntityTeslaCoil&&((ITaggedList)currenttip).getEntries("teslaCoil").size()==0) { boolean rsInv = accessor.getNBTData().getBoolean("redstoneInverted"); boolean lowPower = accessor.getNBTData().getBoolean("lowPower"); - ((ITaggedList)currenttip).add(I18n.format(Lib.CHAT_INFO+"rsControl."+(rsInv?"invertedOn":"invertedOff")), "teslaCoil"); - currenttip.add(I18n.format(Lib.CHAT_INFO+"tesla."+(lowPower?"lowPower":"highPower"))); + ((ITaggedList)currenttip).add(I18n.format(Lib.CHAT_INFO+"rsControl."+(rsInv?"invertedOn": "invertedOff")), "teslaCoil"); + currenttip.add(I18n.format(Lib.CHAT_INFO+"tesla."+(lowPower?"lowPower": "highPower"))); } } return currenttip; @@ -112,6 +114,7 @@ public List getWailaTail(ItemStack itemStack, List currenttip, I { return currenttip; } + @Override public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) { @@ -127,20 +130,20 @@ else if(te instanceof IFluxProvider) cur = ((IFluxProvider)te).getEnergyStored(null); max = ((IFluxProvider)te).getMaxEnergyStored(null); } - if (cur!=-1) + if(cur!=-1) { tag.setInteger("Energy", cur); tag.setInteger("MaxStorage", max); } - if (te instanceof TileEntityTeslaCoil) + if(te instanceof TileEntityTeslaCoil) { - if (((TileEntityTeslaCoil) te).dummy) - te = te.getWorld().getTileEntity(te.getPos().offset(((TileEntityTeslaCoil) te).facing, -1)); - tag.setBoolean("redstoneInverted", ((TileEntityTeslaCoil) te).redstoneControlInverted); - tag.setBoolean("lowPower", ((TileEntityTeslaCoil) te).lowPower); + if(((TileEntityTeslaCoil)te).dummy) + te = te.getWorld().getTileEntity(te.getPos().offset(((TileEntityTeslaCoil)te).facing, -1)); + tag.setBoolean("redstoneInverted", ((TileEntityTeslaCoil)te).redstoneControlInverted); + tag.setBoolean("lowPower", ((TileEntityTeslaCoil)te).lowPower); } - else if (te instanceof TileEntityWoodenBarrel) - tag.setTag("tank", ((TileEntityWoodenBarrel) te).tank.writeToNBT(new NBTTagCompound())); + else if(te instanceof TileEntityWoodenBarrel) + tag.setTag("tank", ((TileEntityWoodenBarrel)te).tank.writeToNBT(new NBTTagCompound())); return tag; } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/compat/waila/WailaHelper.java b/src/main/java/blusunrize/immersiveengineering/common/util/compat/waila/WailaHelper.java index 8567f9138c..6d6c2752d9 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/compat/waila/WailaHelper.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/compat/waila/WailaHelper.java @@ -17,11 +17,11 @@ public class WailaHelper extends IECompatModule public void preInit() { } - + @Override public void init() { - FMLInterModComms.sendMessage("waila", "register", "blusunrize.immersiveengineering.common.util.compat.waila.IEWailaDataProvider.callbackRegister"); + FMLInterModComms.sendMessage("waila", "register", "blusunrize.immersiveengineering.common.util.compat.waila.IEWailaDataProvider.callbackRegister"); } @Override diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/inventory/IEInventoryHandler.java b/src/main/java/blusunrize/immersiveengineering/common/util/inventory/IEInventoryHandler.java index 13a706819e..560ff270a1 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/inventory/IEInventoryHandler.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/inventory/IEInventoryHandler.java @@ -30,16 +30,18 @@ public IEInventoryHandler(int slots, IIEInventory inventory, int slotOffset, boo this.canInsert = canInsert; this.canExtract = canExtract; } + public IEInventoryHandler(int slots, IIEInventory inventory) { - this(slots,inventory,0, new boolean[slots], new boolean[slots]); - for(int i=0; i{}; - public void setTile(TileEntity tile) { - if (tile!=null) { + private Runnable onChange = () -> { + }; + + public void setTile(TileEntity tile) + { + if(tile!=null) + { onChange = tile::markDirty; - } else { - onChange = ()->{}; + } + else + { + onChange = () -> { + }; } } - public void setInventoryForUpdate(IInventory inv) { - if (inv!=null) { + + public void setInventoryForUpdate(IInventory inv) + { + if(inv!=null) + { onChange = inv::markDirty; - } else { - onChange = ()->{}; + } + else + { + onChange = () -> { + }; } } + @Override protected void onContentsChanged(int slot) { @@ -56,24 +73,25 @@ protected void onContentsChanged(int slot) @Override public boolean hasCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { - return capability== CapabilityItemHandler.ITEM_HANDLER_CAPABILITY; + return capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY; } @Nullable @Override public T getCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { - if (first) { + if(first) + { int idealSize = ((ItemInternalStorage)stack.getItem()).getSlotCount(stack); NonNullList newList = NonNullList.withSize(idealSize, ItemStack.EMPTY); - for (int i = 0; i < Math.min(stacks.size(), idealSize); i++) + for(int i = 0; i < Math.min(stacks.size(), idealSize); i++) newList.set(i, stacks.get(i)); stacks = newList; stack = ItemStack.EMPTY; first = false; } - if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) - return (T) this; + if(capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) + return (T)this; return null; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/inventory/IIEInventory.java b/src/main/java/blusunrize/immersiveengineering/common/util/inventory/IIEInventory.java index 3329c57605..b31e08c665 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/inventory/IIEInventory.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/inventory/IIEInventory.java @@ -14,9 +14,20 @@ public interface IIEInventory { NonNullList getInventory(); + boolean isStackValid(int slot, ItemStack stack); + int getSlotLimit(int slot); + void doGraphicalUpdates(int slot); - default NonNullList getDroppedItems(){return getInventory();} - default int getComparatedSize(){return getInventory()!=null?getInventory().size():0;} + + default NonNullList getDroppedItems() + { + return getInventory(); + } + + default int getComparatedSize() + { + return getInventory()!=null?getInventory().size(): 0; + } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/inventory/MultiFluidTank.java b/src/main/java/blusunrize/immersiveengineering/common/util/inventory/MultiFluidTank.java index e62362f310..ee2dbc65db 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/inventory/MultiFluidTank.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/inventory/MultiFluidTank.java @@ -39,8 +39,8 @@ public MultiFluidTank readFromNBT(NBTTagCompound nbt) if(nbt.hasKey("fluids")) { fluids.clear(); - NBTTagList tagList = nbt.getTagList("fluids",10); - for(int i=0; i0?fluids.get(fluids.size()-1):null; + return fluids.size() > 0?fluids.get(fluids.size()-1): null; } @Override @@ -94,7 +95,7 @@ public FluidTankInfo getInfo() int capacity = this.capacity-getFluidAmount(); if(fs!=null) capacity += fs.amount; - return new FluidTankInfo(fs,capacity); + return new FluidTankInfo(fs, capacity); } @Override @@ -136,8 +137,8 @@ public FluidStack drain(FluidStack resource, boolean doDrain) int amount = Math.min(resource.amount, fs.amount); if(doDrain) { - fs.amount-=amount; - if(fs.amount<=0) + fs.amount -= amount; + if(fs.amount <= 0) it.remove(); } return Utils.copyFluidStackWithAmount(resource, amount, true); @@ -151,9 +152,9 @@ public static FluidStack drain(int remove, FluidStack removeFrom, Iterator { ItemStack equipped = player.getHeldItem(EnumHand.MAIN_HAND); - if(equipped.getItem() instanceof ItemChemthrower&& ((ItemChemthrower)equipped.getItem()).getUpgrades(equipped).getBoolean("multitank")) + if(equipped.getItem() instanceof ItemChemthrower&&((ItemChemthrower)equipped.getItem()).getUpgrades(equipped).getBoolean("multitank")) ((ItemChemthrower)equipped.getItem()).switchTank(equipped, message.forward); }); return null; diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageMagnetEquip.java b/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageMagnetEquip.java index f71d077f04..7808b19852 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageMagnetEquip.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageMagnetEquip.java @@ -20,10 +20,12 @@ public class MessageMagnetEquip implements IMessage { int fetchSlot; + public MessageMagnetEquip(int fetch) { this.fetchSlot = fetch; } + public MessageMagnetEquip() { } @@ -48,7 +50,7 @@ public IMessage onMessage(MessageMagnetEquip message, MessageContext ctx) EntityPlayerMP player = ctx.getServerHandler().player; player.getServerWorld().addScheduledTask(() -> { ItemStack held = player.getHeldItem(EnumHand.OFF_HAND); - if(message.fetchSlot>=0) + if(message.fetchSlot >= 0) { ItemStack s = player.inventory.mainInventory.get(message.fetchSlot); if(!s.isEmpty()&&s.getItem() instanceof ItemIEShield&&((ItemIEShield)s.getItem()).getUpgrades(s).getBoolean("magnet")) diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageMinecartShaderSync.java b/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageMinecartShaderSync.java index 067043a534..f767be7404 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageMinecartShaderSync.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageMinecartShaderSync.java @@ -27,8 +27,9 @@ public class MessageMinecartShaderSync implements IMessage { int entityID; - boolean request=false; + boolean request = false; ItemStack shader; + public MessageMinecartShaderSync(Entity entity, Object o) { this.entityID = entity.getEntityId(); @@ -37,6 +38,7 @@ public MessageMinecartShaderSync(Entity entity, Object o) else request = true; } + public MessageMinecartShaderSync() { } @@ -56,7 +58,7 @@ public void toBytes(ByteBuf buf) buf.writeInt(this.entityID); buf.writeBoolean(this.request); if(!request) - ByteBufUtils.writeItemStack(buf,this.shader); + ByteBufUtils.writeItemStack(buf, this.shader); } public static class HandlerServer implements IMessageHandler @@ -67,7 +69,7 @@ public IMessage onMessage(MessageMinecartShaderSync message, MessageContext ctx) WorldServer world = ctx.getServerHandler().player.getServerWorld(); world.addScheduledTask(() -> { Entity entity = world.getEntityByID(message.entityID); - if(entity!=null && entity.hasCapability(CapabilityShader.SHADER_CAPABILITY, null)) + if(entity!=null&&entity.hasCapability(CapabilityShader.SHADER_CAPABILITY, null)) { ShaderWrapper handler = entity.getCapability(CapabilityShader.SHADER_CAPABILITY, null); if(handler!=null) @@ -77,6 +79,7 @@ public IMessage onMessage(MessageMinecartShaderSync message, MessageContext ctx) return null; } } + public static class HandlerClient implements IMessageHandler { @Override diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageMineralListSync.java b/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageMineralListSync.java index 95ba3ae313..010b4fcc85 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageMineralListSync.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageMineralListSync.java @@ -24,11 +24,13 @@ public class MessageMineralListSync implements IMessage { - HashMap map = new HashMap(); - public MessageMineralListSync(HashMap map) + HashMap map = new HashMap(); + + public MessageMineralListSync(HashMap map) { this.map = map; } + public MessageMineralListSync() { } @@ -37,13 +39,13 @@ public MessageMineralListSync() public void fromBytes(ByteBuf buf) { int size = buf.readInt(); - for(int i=0; i e: map.entrySet()) + for(Map.Entry e : map.entrySet()) { NBTTagCompound tag = e.getKey().writeToNBT(); tag.setInteger("weight", e.getValue()); - ByteBufUtils.writeTag(buf,tag); + ByteBufUtils.writeTag(buf, tag); } } @@ -64,9 +66,10 @@ public static class Handler implements IMessageHandleronMessageMain(message)); + Minecraft.getMinecraft().addScheduledTask(() -> onMessageMain(message)); return null; } + private void onMessageMain(MessageMineralListSync message) { ExcavatorHandler.mineralList.clear(); diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageNoSpamChatComponents.java b/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageNoSpamChatComponents.java index 5f3e743826..83ad558e56 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageNoSpamChatComponents.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageNoSpamChatComponents.java @@ -20,10 +20,12 @@ public class MessageNoSpamChatComponents implements IMessage { ITextComponent[] chatMessages; + public MessageNoSpamChatComponents(ITextComponent... chatMessages) { this.chatMessages = chatMessages; } + public MessageNoSpamChatComponents() { } @@ -33,7 +35,7 @@ public void fromBytes(ByteBuf buf) { int l = buf.readInt(); chatMessages = new ITextComponent[l]; - for(int i=0; i(message.blocking, new AtomicInteger(200))); + new ImmutablePair<>(message.blocking, new AtomicInteger(200))); }); return null; } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageRequestBlockUpdate.java b/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageRequestBlockUpdate.java index cfd911ed68..148b5ced76 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageRequestBlockUpdate.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageRequestBlockUpdate.java @@ -20,10 +20,12 @@ public class MessageRequestBlockUpdate implements IMessage { BlockPos pos; + public MessageRequestBlockUpdate(BlockPos pos) { this.pos = pos; } + public MessageRequestBlockUpdate() { } @@ -47,7 +49,8 @@ public IMessage onMessage(MessageRequestBlockUpdate message, MessageContext ctx) { WorldServer world = ctx.getServerHandler().player.getServerWorld(); world.addScheduledTask(() -> { - if (world.isBlockLoaded(message.pos)) { + if(world.isBlockLoaded(message.pos)) + { int dim = world.provider.getDimension(); EventHandler.requestedBlockUpdates.offer(new ImmutablePair<>(dim, message.pos)); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageShaderManual.java b/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageShaderManual.java index cef22c105f..a4414d0d64 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageShaderManual.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageShaderManual.java @@ -29,11 +29,13 @@ public class MessageShaderManual implements IMessage { MessageType key; String[] args; + public MessageShaderManual(MessageType key, String... args) { this.key = key; this.args = args; } + public MessageShaderManual() { } @@ -44,7 +46,7 @@ public void fromBytes(ByteBuf buf) this.key = MessageType.values()[buf.readInt()]; int l = buf.readInt(); args = new String[l]; - for(int i=0; i received = ShaderRegistry.receivedShaders.get(playerName); String[] ss = received.toArray(new String[received.size()]); - ImmersiveEngineering.packetHandler.sendTo(new MessageShaderManual(MessageType.SYNC,ss), player); + ImmersiveEngineering.packetHandler.sendTo(new MessageShaderManual(MessageType.SYNC, ss), player); } - else if(message.key==MessageType.UNLOCK && message.args.length>0) + else if(message.key==MessageType.UNLOCK&&message.args.length > 0) { ShaderRegistry.receivedShaders.put(playerName, message.args[0]); } - else if(message.key==MessageType.SPAWN && message.args.length>0) + else if(message.key==MessageType.SPAWN&&message.args.length > 0) { if(!player.capabilities.isCreativeMode) ApiUtils.consumePlayerIngredient(player, ShaderRegistry.shaderRegistry.get(playerName).replicationCost); ItemStack shaderStack = new ItemStack(ShaderRegistry.itemShader); ItemNBTHelper.setString(shaderStack, "shader_name", message.args[0]); EntityItem entityitem = player.dropItem(shaderStack, false); - if(entityitem != null) + if(entityitem!=null) { entityitem.setNoPickupDelay(); entityitem.setOwner(player.getName()); @@ -104,6 +106,7 @@ else if(message.key==MessageType.SPAWN && message.args.length>0) return null; } } + public static class HandlerClient implements IMessageHandler { @Override @@ -113,7 +116,7 @@ public IMessage onMessage(MessageShaderManual message, MessageContext ctx) if(message.key==MessageType.SYNC) { String name = ClientUtils.mc().player.getName(); - for (String shader : message.args) + for(String shader : message.args) if(shader!=null) ShaderRegistry.receivedShaders.put(name, shader); } diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageSkyhookSync.java b/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageSkyhookSync.java index 2f2fd70a4e..82bd3c8bd4 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageSkyhookSync.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/network/MessageSkyhookSync.java @@ -39,6 +39,7 @@ public MessageSkyhookSync(EntitySkylineHook entity) subPoints = entity.subPoints; targetPoint = entity.targetPoint; } + public MessageSkyhookSync() { } @@ -52,7 +53,7 @@ public void fromBytes(ByteBuf buf) target = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt()); int l = buf.readInt(); subPoints = new Vec3d[l]; - for(int i=0; i { - if (world.isBlockLoaded(message.pos)) { + if(world.isBlockLoaded(message.pos)) + { TileEntity tile = world.getTileEntity(message.pos); if(tile instanceof TileEntityIEBase) ((TileEntityIEBase)tile).receiveMessageFromClient(message.nbt); @@ -65,6 +68,7 @@ public IMessage onMessage(MessageTileSync message, MessageContext ctx) return null; } } + public static class HandlerClient implements IMessageHandler { @Override diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/sound/IEMuffledSound.java b/src/main/java/blusunrize/immersiveengineering/common/util/sound/IEMuffledSound.java index 1d25cd0aa8..76cb37d018 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/sound/IEMuffledSound.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/sound/IEMuffledSound.java @@ -40,11 +40,13 @@ public SoundEventAccessor createAccessor(SoundHandler handler) { return originalSound.createAccessor(handler); } + @Override public Sound getSound() { return originalSound.getSound(); } + @Override public SoundCategory getCategory() { @@ -56,36 +58,43 @@ public boolean canRepeat() { return originalSound.canRepeat(); } + @Override public int getRepeatDelay() { return originalSound.getRepeatDelay(); } + @Override public float getVolume() { return originalSound.getVolume()*volumeMod; } + @Override public float getPitch() { return originalSound.getPitch(); } + @Override public float getXPosF() { return originalSound.getXPosF(); } + @Override public float getYPosF() { return originalSound.getYPosF(); } + @Override public float getZPosF() { return originalSound.getZPosF(); } + @Override public AttenuationType getAttenuationType() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/sound/IEMuffledTickableSound.java b/src/main/java/blusunrize/immersiveengineering/common/util/sound/IEMuffledTickableSound.java index e115832abf..67050b333d 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/sound/IEMuffledTickableSound.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/sound/IEMuffledTickableSound.java @@ -34,11 +34,13 @@ public SoundEventAccessor createAccessor(SoundHandler handler) { return this.originalSound.createAccessor(handler); } + @Override public Sound getSound() { return originalSound.getSound(); } + @Override public SoundCategory getCategory() { @@ -50,51 +52,61 @@ public ResourceLocation getSoundLocation() { return originalSound.getSoundLocation(); } + @Override public boolean canRepeat() { return originalSound.canRepeat(); } + @Override public int getRepeatDelay() { return originalSound.getRepeatDelay(); } + @Override public float getVolume() { return originalSound.getVolume()*volumeMod; } + @Override public float getPitch() { return originalSound.getPitch(); } + @Override public float getXPosF() { return originalSound.getXPosF(); } + @Override public float getYPosF() { return originalSound.getYPosF(); } + @Override public float getZPosF() { return originalSound.getZPosF(); } + @Override public AttenuationType getAttenuationType() { return originalSound.getAttenuationType(); } + @Override public void update() { originalSound.update(); } + @Override public boolean isDonePlaying() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/util/sound/IETileSound.java b/src/main/java/blusunrize/immersiveengineering/common/util/sound/IETileSound.java index 3c7c4b5db2..e4889ae197 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/util/sound/IETileSound.java +++ b/src/main/java/blusunrize/immersiveengineering/common/util/sound/IETileSound.java @@ -43,13 +43,14 @@ public class IETileSound implements ITickableSound public int tileZ; public boolean canRepeat; public int repeatDelay; - public float volumeAjustment=1; + public float volumeAjustment = 1; public IETileSound(SoundEvent event, float volume, float pitch, boolean repeat, int repeatDelay, int x, int y, int z, AttenuationType attenuation, SoundCategory category) { this(event.getSoundName(), volume, pitch, repeat, repeatDelay, x, y, z, attenuation, category); } + public IETileSound(ResourceLocation sound, float volume, float pitch, boolean repeat, int repeatDelay, int x, int y, int z, AttenuationType attenuation, SoundCategory category) { this.attenuation = attenuation; @@ -61,16 +62,18 @@ public IETileSound(ResourceLocation sound, float volume, float pitch, boolean re this.tileZ = z; this.canRepeat = repeat; this.repeatDelay = repeatDelay; - origPos = new float[]{(float)x,(float)y,(float)z}; + origPos = new float[]{(float)x, (float)y, (float)z}; this.category = category; } + public IETileSound(SoundEvent event, float volume, float pitch, boolean repeat, int repeatDelay, BlockPos pos, AttenuationType attenuation, SoundCategory category) { - this(event.getSoundName(), volume, pitch, repeat, repeatDelay, pos.getX(),pos.getY(),pos.getZ(), attenuation, category); + this(event.getSoundName(), volume, pitch, repeat, repeatDelay, pos.getX(), pos.getY(), pos.getZ(), attenuation, category); } + public IETileSound(ResourceLocation sound, float volume, float pitch, boolean repeat, int repeatDelay, BlockPos pos, AttenuationType attenuation, SoundCategory category) { - this(sound, volume, pitch, repeat, repeatDelay, pos.getX(),pos.getY(),pos.getZ(), attenuation, category); + this(sound, volume, pitch, repeat, repeatDelay, pos.getX(), pos.getY(), pos.getZ(), attenuation, category); } public float[] origPos; @@ -80,6 +83,7 @@ public AttenuationType getAttenuationType() { return attenuation; } + @Override public ResourceLocation getSoundLocation() { @@ -91,17 +95,19 @@ public ResourceLocation getSoundLocation() public SoundEventAccessor createAccessor(SoundHandler handler) { this.soundEvent = handler.getAccessor(this.resource); - if(this.soundEvent == null) + if(this.soundEvent==null) this.sound = SoundHandler.MISSING_SOUND; else this.sound = this.soundEvent.cloneEntry(); return this.soundEvent; } + @Override public Sound getSound() { return sound; } + @Override public SoundCategory getCategory() { @@ -113,31 +119,37 @@ public float getVolume() { return volume*volumeAjustment; } + @Override public float getPitch() { return pitch; } + @Override public float getXPosF() { return tileX; } + @Override public float getYPosF() { return tileY; } + @Override public float getZPosF() { return tileZ; } + @Override public boolean canRepeat() { return canRepeat; } + @Override public int getRepeatDelay() { @@ -153,34 +165,34 @@ public int getRepeatDelay() public void evaluateVolume() { - volumeAjustment=1f; - if(ClientUtils.mc().player!=null && !ClientUtils.mc().player.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty()) + volumeAjustment = 1f; + if(ClientUtils.mc().player!=null&&!ClientUtils.mc().player.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty()) { ItemStack stack = ClientUtils.mc().player.getItemStackFromSlot(EntityEquipmentSlot.HEAD); - if(ItemNBTHelper.hasKey(stack,"IE:Earmuffs")) + if(ItemNBTHelper.hasKey(stack, "IE:Earmuffs")) stack = ItemNBTHelper.getItemStack(stack, "IE:Earmuffs"); - if(!stack.isEmpty() && IEContent.itemEarmuffs.equals(stack.getItem())) + if(!stack.isEmpty()&&IEContent.itemEarmuffs.equals(stack.getItem())) volumeAjustment = ItemEarmuffs.getVolumeMod(stack); } - if(volumeAjustment>.1f) - for(int dx = (int)Math.floor(tileX-8)>>4; dx<=(int)Math.floor(tileX+8)>>4; dx++) - for(int dz = (int)Math.floor(tileZ-8)>>4; dz<=(int)Math.floor(tileZ+8)>>4; dz++) + if(volumeAjustment > .1f) + for(int dx = (int)Math.floor(tileX-8) >> 4; dx <= (int)Math.floor(tileX+8) >> 4; dx++) + for(int dz = (int)Math.floor(tileZ-8) >> 4; dz <= (int)Math.floor(tileZ+8) >> 4; dz++) { Iterator it = ClientUtils.mc().player.world.getChunkFromChunkCoords(dx, dz).getTileEntityMap().values().iterator(); - while (it.hasNext()) + while(it.hasNext()) { TileEntity tile = (TileEntity)it.next(); - if(tile!=null && tile.getClass().getName().endsWith("TileEntitySoundMuffler")) + if(tile!=null&&tile.getClass().getName().endsWith("TileEntitySoundMuffler")) if(tile.getBlockMetadata()!=1) { double d = tile.getDistanceSq(tileX, tileY, tileZ); - if(d<=64 && d>0) - volumeAjustment=.1f; + if(d <= 64&&d > 0) + volumeAjustment = .1f; } } } - TileEntity tile = ClientUtils.mc().player.world.getTileEntity(new BlockPos(tileX,tileY,tileZ)); + TileEntity tile = ClientUtils.mc().player.world.getTileEntity(new BlockPos(tileX, tileY, tileZ)); if(!(tile instanceof ISoundTile)) donePlaying = true; else @@ -191,11 +203,12 @@ public void evaluateVolume() @Override public void update() { - if(ClientUtils.mc().player!=null && ClientUtils.mc().player.world.getTotalWorldTime()%40==0) + if(ClientUtils.mc().player!=null&&ClientUtils.mc().player.world.getTotalWorldTime()%40==0) evaluateVolume(); } - public boolean donePlaying=false; + public boolean donePlaying = false; + @Override public boolean isDonePlaying() { diff --git a/src/main/java/blusunrize/immersiveengineering/common/world/IEWorldGen.java b/src/main/java/blusunrize/immersiveengineering/common/world/IEWorldGen.java index 5997b48bfe..50c6641060 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/world/IEWorldGen.java +++ b/src/main/java/blusunrize/immersiveengineering/common/world/IEWorldGen.java @@ -43,31 +43,34 @@ public static class OreGen int maxY; int chunkOccurence; int weight; - public OreGen(String name, IBlockState state, int maxVeinSize, Block replaceTarget, int minY, int maxY,int chunkOccurence, int weight) + + public OreGen(String name, IBlockState state, int maxVeinSize, Block replaceTarget, int minY, int maxY, int chunkOccurence, int weight) { this.name = name; this.mineableGen = new WorldGenMinable(state, maxVeinSize, BlockMatcher.forBlock(replaceTarget)); - this.minY=minY; - this.maxY=maxY; - this.chunkOccurence=chunkOccurence; - this.weight=weight; + this.minY = minY; + this.maxY = maxY; + this.chunkOccurence = chunkOccurence; + this.weight = weight; } public void generate(World world, Random rand, int x, int z) { BlockPos pos; - for(int i=0; i orespawnList = new ArrayList(); public static ArrayList oreDimBlacklist = new ArrayList(); public static HashMap retrogenMap = new HashMap(); - public static OreGen addOreGen(String name, IBlockState state, int maxVeinSize, int minY, int maxY,int chunkOccurence,int weight) + + public static OreGen addOreGen(String name, IBlockState state, int maxVeinSize, int minY, int maxY, int chunkOccurence, int weight) { OreGen gen = new OreGen(name, state, maxVeinSize, Blocks.STONE, minY, maxY, chunkOccurence, weight); orespawnList.add(gen); @@ -84,7 +87,7 @@ public void generateOres(Random random, int chunkX, int chunkZ, World world, boo { if(!oreDimBlacklist.contains(world.provider.getDimension())) for(OreGen gen : orespawnList) - if(newGeneration || retrogenMap.get("retrogen_"+gen.name)) + if(newGeneration||retrogenMap.get("retrogen_"+gen.name)) gen.generate(world, random, chunkX*16, chunkZ*16); } @@ -100,7 +103,7 @@ public void chunkSave(ChunkDataEvent.Save event) public void chunkLoad(ChunkDataEvent.Load event) { int dimension = event.getWorld().provider.getDimension(); - if((!event.getData().getCompoundTag("ImmersiveEngineering").hasKey(IEConfig.Ores.retrogen_key)) && (IEConfig.Ores.retrogen_copper|| IEConfig.Ores.retrogen_bauxite|| IEConfig.Ores.retrogen_lead|| IEConfig.Ores.retrogen_silver|| IEConfig.Ores.retrogen_nickel|| IEConfig.Ores.retrogen_uranium)) + if((!event.getData().getCompoundTag("ImmersiveEngineering").hasKey(IEConfig.Ores.retrogen_key))&&(IEConfig.Ores.retrogen_copper||IEConfig.Ores.retrogen_bauxite||IEConfig.Ores.retrogen_lead||IEConfig.Ores.retrogen_silver||IEConfig.Ores.retrogen_nickel||IEConfig.Ores.retrogen_uranium)) { if(IEConfig.Ores.retrogen_log_flagChunk) IELogger.info("Chunk "+event.getChunk().getPos()+" has been flagged for Ore RetroGeneration by IE."); @@ -109,31 +112,32 @@ public void chunkLoad(ChunkDataEvent.Load event) } public static ArrayListMultimap retrogenChunks = ArrayListMultimap.create(); + @SubscribeEvent public void serverWorldTick(TickEvent.WorldTickEvent event) { - if(event.side==Side.CLIENT || event.phase==TickEvent.Phase.START) + if(event.side==Side.CLIENT||event.phase==TickEvent.Phase.START) return; int dimension = event.world.provider.getDimension(); int counter = 0; List chunks = retrogenChunks.get(dimension); - if(chunks!=null && chunks.size()>0) - for(int i=0; i<2; i++) + if(chunks!=null&&chunks.size() > 0) + for(int i = 0; i < 2; i++) { chunks = retrogenChunks.get(dimension); - if(chunks == null || chunks.size()<= 0) + if(chunks==null||chunks.size() <= 0) break; counter++; ChunkPos loc = chunks.get(0); long worldSeed = event.world.getSeed(); Random fmlRandom = new Random(worldSeed); - long xSeed = (fmlRandom.nextLong()>>3); - long zSeed = (fmlRandom.nextLong()>>3); - fmlRandom.setSeed(xSeed * loc.x + zSeed * loc.z ^ worldSeed); + long xSeed = (fmlRandom.nextLong() >> 3); + long zSeed = (fmlRandom.nextLong() >> 3); + fmlRandom.setSeed(xSeed*loc.x+zSeed*loc.z^worldSeed); this.generateOres(fmlRandom, loc.x, loc.z, event.world, false); chunks.remove(0); } - if(counter>0 && IEConfig.Ores.retrogen_log_remaining) - IELogger.info("Retrogen was performed on "+counter+" Chunks, "+Math.max(0,chunks.size())+" chunks remaining"); + if(counter > 0&&IEConfig.Ores.retrogen_log_remaining) + IELogger.info("Retrogen was performed on "+counter+" Chunks, "+Math.max(0, chunks.size())+" chunks remaining"); } } \ No newline at end of file diff --git a/src/main/java/blusunrize/immersiveengineering/common/world/VillageEngineersHouse.java b/src/main/java/blusunrize/immersiveengineering/common/world/VillageEngineersHouse.java index e2956c6539..794214e7d5 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/world/VillageEngineersHouse.java +++ b/src/main/java/blusunrize/immersiveengineering/common/world/VillageEngineersHouse.java @@ -47,9 +47,11 @@ public class VillageEngineersHouse extends Village { public static ResourceLocation woodenCrateLoot = new ResourceLocation(ImmersiveEngineering.MODID, "chests/engineers_house"); + public VillageEngineersHouse() { } + public VillageEngineersHouse(Start villagePiece, int par2, Random par3Random, StructureBoundingBox par4StructureBoundingBox, EnumFacing facing) { super(villagePiece, par2); @@ -59,155 +61,157 @@ public VillageEngineersHouse(Start villagePiece, int par2, Random par3Random, St static List framesHung = new ArrayList(); private int groundLevel = -1; + @Override public boolean addComponentParts(World world, Random rand, StructureBoundingBox box) { if(groundLevel < 0) { groundLevel = this.getAverageGroundLevel(world, box); - if(groundLevel<0) + if(groundLevel < 0) return true; - boundingBox.offset(0, groundLevel - boundingBox.maxY+10-1, 0); + boundingBox.offset(0, groundLevel-boundingBox.maxY+10-1, 0); } //Clear Space - this.fillWithBlocks(world, box, 0,0,0, 10,9,8, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false); + this.fillWithBlocks(world, box, 0, 0, 0, 10, 9, 8, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false); //Cobble - this.fillWithBlocks(world, box, 1,0,1, 9,0,8, Blocks.COBBLESTONE.getDefaultState(), Blocks.COBBLESTONE.getDefaultState(), false); - this.fillWithBlocks(world, box, 6,0,1, 9,0,2, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false); + this.fillWithBlocks(world, box, 1, 0, 1, 9, 0, 8, Blocks.COBBLESTONE.getDefaultState(), Blocks.COBBLESTONE.getDefaultState(), false); + this.fillWithBlocks(world, box, 6, 0, 1, 9, 0, 2, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false); //Stair - this.setBlockState(world, Blocks.STONE_STAIRS.getDefaultState().withProperty(BlockStairs.FACING,EnumFacing.NORTH), 4,0,0, box); + this.setBlockState(world, Blocks.STONE_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, EnumFacing.NORTH), 4, 0, 0, box); //Pillars - this.fillWithBlocks(world, box, 1,1,3, 1,4,3, IEContent.blockTreatedWood.getDefaultState(), IEContent.blockTreatedWood.getDefaultState(), false); - this.fillWithBlocks(world, box, 1,1,8, 1,6,8, IEContent.blockTreatedWood.getDefaultState(), IEContent.blockTreatedWood.getDefaultState(), false); - this.fillWithBlocks(world, box, 9,1,3, 9,6,3, IEContent.blockTreatedWood.getDefaultState(), IEContent.blockTreatedWood.getDefaultState(), false); - this.fillWithBlocks(world, box, 9,1,8, 9,6,8, IEContent.blockTreatedWood.getDefaultState(), IEContent.blockTreatedWood.getDefaultState(), false); - this.fillWithBlocks(world, box, 1,4,3, 9,4,8, IEContent.blockTreatedWood.getDefaultState(), IEContent.blockTreatedWood.getDefaultState(), false); - this.fillWithBlocks(world, box, 6,5,3, 6,7,3, IEContent.blockTreatedWood.getDefaultState(), IEContent.blockTreatedWood.getDefaultState(), false); - this.fillWithBlocks(world, box, 1,5,5, 1,6,5, IEContent.blockTreatedWood.getDefaultState(), IEContent.blockTreatedWood.getDefaultState(), false); + this.fillWithBlocks(world, box, 1, 1, 3, 1, 4, 3, IEContent.blockTreatedWood.getDefaultState(), IEContent.blockTreatedWood.getDefaultState(), false); + this.fillWithBlocks(world, box, 1, 1, 8, 1, 6, 8, IEContent.blockTreatedWood.getDefaultState(), IEContent.blockTreatedWood.getDefaultState(), false); + this.fillWithBlocks(world, box, 9, 1, 3, 9, 6, 3, IEContent.blockTreatedWood.getDefaultState(), IEContent.blockTreatedWood.getDefaultState(), false); + this.fillWithBlocks(world, box, 9, 1, 8, 9, 6, 8, IEContent.blockTreatedWood.getDefaultState(), IEContent.blockTreatedWood.getDefaultState(), false); + this.fillWithBlocks(world, box, 1, 4, 3, 9, 4, 8, IEContent.blockTreatedWood.getDefaultState(), IEContent.blockTreatedWood.getDefaultState(), false); + this.fillWithBlocks(world, box, 6, 5, 3, 6, 7, 3, IEContent.blockTreatedWood.getDefaultState(), IEContent.blockTreatedWood.getDefaultState(), false); + this.fillWithBlocks(world, box, 1, 5, 5, 1, 6, 5, IEContent.blockTreatedWood.getDefaultState(), IEContent.blockTreatedWood.getDefaultState(), false); - this.fillWithBlocks(world, box, 2,4,5, 8,4,7, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false); + this.fillWithBlocks(world, box, 2, 4, 5, 8, 4, 7, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false); //Wool - this.fillWithBlocks(world, box, 2,0,3, 5,0,4, Blocks.WOOL.getStateFromMeta(13), Blocks.WOOL.getStateFromMeta(13), false); - this.fillWithBlocks(world, box, 2,0,4, 8,0,7, Blocks.WOOL.getStateFromMeta(13), Blocks.WOOL.getStateFromMeta(13), false); - this.fillWithBlocks(world, box, 6,4,4, 8,4,4, Blocks.WOOL.getStateFromMeta(13), Blocks.WOOL.getStateFromMeta(13), false); - this.fillWithBlocks(world, box, 2,4,5, 7,4,5, Blocks.WOOL.getStateFromMeta(13), Blocks.WOOL.getStateFromMeta(13), false); - this.fillWithBlocks(world, box, 2,4,6, 6,4,6, Blocks.WOOL.getStateFromMeta(13), Blocks.WOOL.getStateFromMeta(13), false); - this.fillWithBlocks(world, box, 2,4,7, 4,4,7, Blocks.WOOL.getStateFromMeta(13), Blocks.WOOL.getStateFromMeta(13), false); + this.fillWithBlocks(world, box, 2, 0, 3, 5, 0, 4, Blocks.WOOL.getStateFromMeta(13), Blocks.WOOL.getStateFromMeta(13), false); + this.fillWithBlocks(world, box, 2, 0, 4, 8, 0, 7, Blocks.WOOL.getStateFromMeta(13), Blocks.WOOL.getStateFromMeta(13), false); + this.fillWithBlocks(world, box, 6, 4, 4, 8, 4, 4, Blocks.WOOL.getStateFromMeta(13), Blocks.WOOL.getStateFromMeta(13), false); + this.fillWithBlocks(world, box, 2, 4, 5, 7, 4, 5, Blocks.WOOL.getStateFromMeta(13), Blocks.WOOL.getStateFromMeta(13), false); + this.fillWithBlocks(world, box, 2, 4, 6, 6, 4, 6, Blocks.WOOL.getStateFromMeta(13), Blocks.WOOL.getStateFromMeta(13), false); + this.fillWithBlocks(world, box, 2, 4, 7, 4, 4, 7, Blocks.WOOL.getStateFromMeta(13), Blocks.WOOL.getStateFromMeta(13), false); //Walls //Front - this.fillWithBlocks(world, box, 2,1,3, 8,3,3, Blocks.PLANKS.getDefaultState(),Blocks.PLANKS.getDefaultState(), false); - this.fillWithBlocks(world, box, 7,5,3, 8,6,3, Blocks.PLANKS.getDefaultState(),Blocks.PLANKS.getDefaultState(), false); - this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 7,7,3, box); - this.fillWithBlocks(world, box, 6,5,4, 6,7,4, Blocks.PLANKS.getDefaultState(),Blocks.PLANKS.getDefaultState(), false); - this.fillWithBlocks(world, box, 2,5,5, 5,6,5, Blocks.PLANKS.getDefaultState(),Blocks.PLANKS.getDefaultState(), false); - this.fillWithBlocks(world, box, 3,7,5, 5,7,5, Blocks.PLANKS.getDefaultState(),Blocks.PLANKS.getDefaultState(), false); - this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 5,8,5, box); + this.fillWithBlocks(world, box, 2, 1, 3, 8, 3, 3, Blocks.PLANKS.getDefaultState(), Blocks.PLANKS.getDefaultState(), false); + this.fillWithBlocks(world, box, 7, 5, 3, 8, 6, 3, Blocks.PLANKS.getDefaultState(), Blocks.PLANKS.getDefaultState(), false); + this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 7, 7, 3, box); + this.fillWithBlocks(world, box, 6, 5, 4, 6, 7, 4, Blocks.PLANKS.getDefaultState(), Blocks.PLANKS.getDefaultState(), false); + this.fillWithBlocks(world, box, 2, 5, 5, 5, 6, 5, Blocks.PLANKS.getDefaultState(), Blocks.PLANKS.getDefaultState(), false); + this.fillWithBlocks(world, box, 3, 7, 5, 5, 7, 5, Blocks.PLANKS.getDefaultState(), Blocks.PLANKS.getDefaultState(), false); + this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 5, 8, 5, box); //Back - this.fillWithBlocks(world, box, 2,1,8, 8,3,8, Blocks.PLANKS.getDefaultState(),Blocks.PLANKS.getDefaultState(), false); - this.fillWithBlocks(world, box, 2,5,8, 8,6,8, Blocks.PLANKS.getDefaultState(),Blocks.PLANKS.getDefaultState(), false); - this.fillWithBlocks(world, box, 3,7,8, 7,7,8, Blocks.PLANKS.getDefaultState(),Blocks.PLANKS.getDefaultState(), false); - this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 5,8,8, box); + this.fillWithBlocks(world, box, 2, 1, 8, 8, 3, 8, Blocks.PLANKS.getDefaultState(), Blocks.PLANKS.getDefaultState(), false); + this.fillWithBlocks(world, box, 2, 5, 8, 8, 6, 8, Blocks.PLANKS.getDefaultState(), Blocks.PLANKS.getDefaultState(), false); + this.fillWithBlocks(world, box, 3, 7, 8, 7, 7, 8, Blocks.PLANKS.getDefaultState(), Blocks.PLANKS.getDefaultState(), false); + this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 5, 8, 8, box); //Left - this.fillWithBlocks(world, box, 1,1,4, 1,3,7, Blocks.PLANKS.getDefaultState(),Blocks.PLANKS.getDefaultState(), false); - this.fillWithBlocks(world, box, 1,5,6, 1,5,7, Blocks.PLANKS.getDefaultState(),Blocks.PLANKS.getDefaultState(), false); + this.fillWithBlocks(world, box, 1, 1, 4, 1, 3, 7, Blocks.PLANKS.getDefaultState(), Blocks.PLANKS.getDefaultState(), false); + this.fillWithBlocks(world, box, 1, 5, 6, 1, 5, 7, Blocks.PLANKS.getDefaultState(), Blocks.PLANKS.getDefaultState(), false); //Right - this.fillWithBlocks(world, box, 9,1,4, 9,3,7, Blocks.PLANKS.getDefaultState(),Blocks.PLANKS.getDefaultState(), false); - this.fillWithBlocks(world, box, 9,5,4, 9,6,7, Blocks.PLANKS.getDefaultState(),Blocks.PLANKS.getDefaultState(), false); + this.fillWithBlocks(world, box, 9, 1, 4, 9, 3, 7, Blocks.PLANKS.getDefaultState(), Blocks.PLANKS.getDefaultState(), false); + this.fillWithBlocks(world, box, 9, 5, 4, 9, 6, 7, Blocks.PLANKS.getDefaultState(), Blocks.PLANKS.getDefaultState(), false); //Windows //Front - this.setBlockState(world, Blocks.GLASS_PANE.getDefaultState(), 2,2,3, box); - this.setBlockState(world, Blocks.GLASS_PANE.getDefaultState(), 6,2,3, box); - this.setBlockState(world, Blocks.GLASS_PANE.getDefaultState(), 8,2,3, box); - this.fillWithBlocks(world, box, 7,6,3, 8,6,3, Blocks.GLASS_PANE.getDefaultState(),Blocks.GLASS_PANE.getDefaultState(), false); + this.setBlockState(world, Blocks.GLASS_PANE.getDefaultState(), 2, 2, 3, box); + this.setBlockState(world, Blocks.GLASS_PANE.getDefaultState(), 6, 2, 3, box); + this.setBlockState(world, Blocks.GLASS_PANE.getDefaultState(), 8, 2, 3, box); + this.fillWithBlocks(world, box, 7, 6, 3, 8, 6, 3, Blocks.GLASS_PANE.getDefaultState(), Blocks.GLASS_PANE.getDefaultState(), false); //Back - this.fillWithBlocks(world, box, 3,2,8, 5,2,8, Blocks.GLASS_PANE.getDefaultState(),Blocks.GLASS_PANE.getDefaultState(), false); - this.fillWithBlocks(world, box, 3,6,8, 4,6,8, Blocks.GLASS_PANE.getDefaultState(),Blocks.GLASS_PANE.getDefaultState(), false); - this.fillWithBlocks(world, box, 6,6,8, 7,6,8, Blocks.GLASS_PANE.getDefaultState(),Blocks.GLASS_PANE.getDefaultState(), false); + this.fillWithBlocks(world, box, 3, 2, 8, 5, 2, 8, Blocks.GLASS_PANE.getDefaultState(), Blocks.GLASS_PANE.getDefaultState(), false); + this.fillWithBlocks(world, box, 3, 6, 8, 4, 6, 8, Blocks.GLASS_PANE.getDefaultState(), Blocks.GLASS_PANE.getDefaultState(), false); + this.fillWithBlocks(world, box, 6, 6, 8, 7, 6, 8, Blocks.GLASS_PANE.getDefaultState(), Blocks.GLASS_PANE.getDefaultState(), false); //Left - this.fillWithBlocks(world, box, 1,2,5, 1,2,6, Blocks.GLASS_PANE.getDefaultState(),Blocks.GLASS_PANE.getDefaultState(), false); - this.fillWithBlocks(world, box, 1,6,6, 1,6,7, Blocks.GLASS_PANE.getDefaultState(),Blocks.GLASS_PANE.getDefaultState(), false); + this.fillWithBlocks(world, box, 1, 2, 5, 1, 2, 6, Blocks.GLASS_PANE.getDefaultState(), Blocks.GLASS_PANE.getDefaultState(), false); + this.fillWithBlocks(world, box, 1, 6, 6, 1, 6, 7, Blocks.GLASS_PANE.getDefaultState(), Blocks.GLASS_PANE.getDefaultState(), false); //Right - this.fillWithBlocks(world, box, 9,2,5, 9,2,6, Blocks.GLASS_PANE.getDefaultState(),Blocks.GLASS_PANE.getDefaultState(), false); - this.fillWithBlocks(world, box, 9,6,5, 9,6,6, Blocks.GLASS_PANE.getDefaultState(),Blocks.GLASS_PANE.getDefaultState(), false); + this.fillWithBlocks(world, box, 9, 2, 5, 9, 2, 6, Blocks.GLASS_PANE.getDefaultState(), Blocks.GLASS_PANE.getDefaultState(), false); + this.fillWithBlocks(world, box, 9, 6, 5, 9, 6, 6, Blocks.GLASS_PANE.getDefaultState(), Blocks.GLASS_PANE.getDefaultState(), false); //Fences - this.fillWithBlocks(world, box, 1,1,1, 1,1,2, IEContent.blockWoodenDecoration.getStateFromMeta(0),IEContent.blockWoodenDecoration.getStateFromMeta(0), false); - this.fillWithBlocks(world, box, 2,1,1, 3,1,1, IEContent.blockWoodenDecoration.getStateFromMeta(0),IEContent.blockWoodenDecoration.getStateFromMeta(0), false); - this.fillWithBlocks(world, box, 5,1,1, 5,1,2, IEContent.blockWoodenDecoration.getStateFromMeta(0),IEContent.blockWoodenDecoration.getStateFromMeta(0), false); - this.fillWithBlocks(world, box, 1,5,3, 1,5,4, IEContent.blockWoodenDecoration.getStateFromMeta(0),IEContent.blockWoodenDecoration.getStateFromMeta(0), false); - this.fillWithBlocks(world, box, 2,5,3, 5,5,3, IEContent.blockWoodenDecoration.getStateFromMeta(0),IEContent.blockWoodenDecoration.getStateFromMeta(0), false); - this.fillWithBlocks(world, box, 7,1,6, 7,5,6, IEContent.blockWoodenDecoration.getStateFromMeta(0),IEContent.blockWoodenDecoration.getStateFromMeta(0), false); + this.fillWithBlocks(world, box, 1, 1, 1, 1, 1, 2, IEContent.blockWoodenDecoration.getStateFromMeta(0), IEContent.blockWoodenDecoration.getStateFromMeta(0), false); + this.fillWithBlocks(world, box, 2, 1, 1, 3, 1, 1, IEContent.blockWoodenDecoration.getStateFromMeta(0), IEContent.blockWoodenDecoration.getStateFromMeta(0), false); + this.fillWithBlocks(world, box, 5, 1, 1, 5, 1, 2, IEContent.blockWoodenDecoration.getStateFromMeta(0), IEContent.blockWoodenDecoration.getStateFromMeta(0), false); + this.fillWithBlocks(world, box, 1, 5, 3, 1, 5, 4, IEContent.blockWoodenDecoration.getStateFromMeta(0), IEContent.blockWoodenDecoration.getStateFromMeta(0), false); + this.fillWithBlocks(world, box, 2, 5, 3, 5, 5, 3, IEContent.blockWoodenDecoration.getStateFromMeta(0), IEContent.blockWoodenDecoration.getStateFromMeta(0), false); + this.fillWithBlocks(world, box, 7, 1, 6, 7, 5, 6, IEContent.blockWoodenDecoration.getStateFromMeta(0), IEContent.blockWoodenDecoration.getStateFromMeta(0), false); //Doors this.generateDoor(world, box, rand, 4, 1, 3, EnumFacing.NORTH, Blocks.OAK_DOOR); - if(getCoordBaseMode()==EnumFacing.SOUTH || getCoordBaseMode()==EnumFacing.WEST) + if(getCoordBaseMode()==EnumFacing.SOUTH||getCoordBaseMode()==EnumFacing.WEST) { - this.placeDoor(world, box, rand, 3,5,5, EnumFacing.NORTH, EnumHingePosition.LEFT); - this.placeDoor(world, box, rand, 4,5,5, EnumFacing.NORTH, EnumHingePosition.RIGHT); + this.placeDoor(world, box, rand, 3, 5, 5, EnumFacing.NORTH, EnumHingePosition.LEFT); + this.placeDoor(world, box, rand, 4, 5, 5, EnumFacing.NORTH, EnumHingePosition.RIGHT); } else { - this.placeDoor(world, box, rand, 3,5,5, EnumFacing.NORTH, EnumHingePosition.LEFT); - this.placeDoor(world, box, rand, 4,5,5, EnumFacing.NORTH, EnumHingePosition.RIGHT); + this.placeDoor(world, box, rand, 3, 5, 5, EnumFacing.NORTH, EnumHingePosition.LEFT); + this.placeDoor(world, box, rand, 4, 5, 5, EnumFacing.NORTH, EnumHingePosition.RIGHT); } //Lanterns - this.placeLantern(world, box, 5,3,6, 0); - this.placeLantern(world, box, 5,7,6, 0); + this.placeLantern(world, box, 5, 3, 6, 0); + this.placeLantern(world, box, 5, 7, 6, 0); //Stairs IBlockState stairs = Blocks.OAK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, EnumFacing.NORTH); - setBlockState(world, stairs, 8,1,6, box); + setBlockState(world, stairs, 8, 1, 6, box); stairs = stairs.withRotation(Rotation.COUNTERCLOCKWISE_90); // stairMeta = this.getMetadataWithOffset(Blocks.OAK_STAIRS, 1); - setBlockState(world, Blocks.PLANKS.getDefaultState(), 8,1,7, box); - setBlockState(world, stairs, 7,2,7, box); - setBlockState(world, stairs, 6,3,7, box); - setBlockState(world, stairs, 5,4,7, box); + setBlockState(world, Blocks.PLANKS.getDefaultState(), 8, 1, 7, box); + setBlockState(world, stairs, 7, 2, 7, box); + setBlockState(world, stairs, 6, 3, 7, box); + setBlockState(world, stairs, 5, 4, 7, box); //Roof IBlockState brickSlab = Blocks.STONE_SLAB.getDefaultState().withProperty(BlockStoneSlab.VARIANT, BlockStoneSlab.EnumType.BRICK); IBlockState brickSlabInverted = brickSlab.withProperty(BlockSlab.HALF, EnumBlockHalf.TOP); - this.fillWithBlocks(world, box, 0,6,4, 0,6,8, brickSlabInverted,brickSlabInverted, false); - this.fillWithBlocks(world, box, 1,7,4, 1,7,8, brickSlab,brickSlab, false); - this.fillWithBlocks(world, box, 3,8,4, 3,8,8, brickSlab,brickSlab, false); - this.fillWithBlocks(world, box, 5,9,2, 5,9,8, brickSlab,brickSlab, false); - this.fillWithBlocks(world, box, 7,8,2, 7,8,8, brickSlab,brickSlab, false); - this.fillWithBlocks(world, box, 9,7,2, 9,7,8, brickSlab,brickSlab, false); - this.fillWithBlocks(world, box, 10,6,2, 10,6,8, brickSlabInverted,brickSlabInverted, false); + this.fillWithBlocks(world, box, 0, 6, 4, 0, 6, 8, brickSlabInverted, brickSlabInverted, false); + this.fillWithBlocks(world, box, 1, 7, 4, 1, 7, 8, brickSlab, brickSlab, false); + this.fillWithBlocks(world, box, 3, 8, 4, 3, 8, 8, brickSlab, brickSlab, false); + this.fillWithBlocks(world, box, 5, 9, 2, 5, 9, 8, brickSlab, brickSlab, false); + this.fillWithBlocks(world, box, 7, 8, 2, 7, 8, 8, brickSlab, brickSlab, false); + this.fillWithBlocks(world, box, 9, 7, 2, 9, 7, 8, brickSlab, brickSlab, false); + this.fillWithBlocks(world, box, 10, 6, 2, 10, 6, 8, brickSlabInverted, brickSlabInverted, false); IBlockState brickStairs = Blocks.BRICK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, EnumFacing.EAST); - this.fillWithBlocks(world, box, 2,7,4, 2,7,8, brickStairs,brickStairs, false); - this.fillWithBlocks(world, box, 4,8,4, 4,8,8, brickStairs,brickStairs, false); + this.fillWithBlocks(world, box, 2, 7, 4, 2, 7, 8, brickStairs, brickStairs, false); + this.fillWithBlocks(world, box, 4, 8, 4, 4, 8, 8, brickStairs, brickStairs, false); brickStairs = brickStairs.withRotation(Rotation.CLOCKWISE_180); - this.fillWithBlocks(world, box, 6,8,2, 6,8,8, brickStairs,brickStairs, false); - this.fillWithBlocks(world, box, 8,7,2, 8,7,8, brickStairs,brickStairs, false); + this.fillWithBlocks(world, box, 6, 8, 2, 6, 8, 8, brickStairs, brickStairs, false); + this.fillWithBlocks(world, box, 8, 7, 2, 8, 7, 8, brickStairs, brickStairs, false); - this.fillWithBlocks(world, box, 2,7,5, 2,8,5, Blocks.BRICK_BLOCK.getDefaultState(),Blocks.BRICK_BLOCK.getDefaultState(), false); - this.fillWithBlocks(world, box, 7,8,4, 7,9,4, Blocks.BRICK_BLOCK.getDefaultState(),Blocks.BRICK_BLOCK.getDefaultState(), false); + this.fillWithBlocks(world, box, 2, 7, 5, 2, 8, 5, Blocks.BRICK_BLOCK.getDefaultState(), Blocks.BRICK_BLOCK.getDefaultState(), false); + this.fillWithBlocks(world, box, 7, 8, 4, 7, 9, 4, Blocks.BRICK_BLOCK.getDefaultState(), Blocks.BRICK_BLOCK.getDefaultState(), false); //Details - try{ - this.placeCrate(world,box,rand, 6,0,1); - this.placeCrate(world,box,rand, 8,0,2); - this.placeCrate(world,box,rand, 5,1,7); - this.placeItemframe(rand, world, 4,3,2, getCoordBaseMode().getOpposite(), new ItemStack(IEContent.itemTool,1,0)); - }catch(Exception e) + try + { + this.placeCrate(world, box, rand, 6, 0, 1); + this.placeCrate(world, box, rand, 8, 0, 2); + this.placeCrate(world, box, rand, 5, 1, 7); + this.placeItemframe(rand, world, 4, 3, 2, getCoordBaseMode().getOpposite(), new ItemStack(IEContent.itemTool, 1, 0)); + } catch(Exception e) { e.printStackTrace(); } - for(int zz=0; zz<=9; zz++) - for(int xx=0; xx<=10; xx++) + for(int zz = 0; zz <= 9; zz++) + for(int xx = 0; xx <= 10; xx++) { - this.clearCurrentPositionBlocksUpwards(world, xx,10,zz, box); - this.replaceAirAndLiquidDownwards(world, Blocks.COBBLESTONE.getDefaultState(), xx, -1,zz, box); + this.clearCurrentPositionBlocksUpwards(world, xx, 10, zz, box); + this.replaceAirAndLiquidDownwards(world, Blocks.COBBLESTONE.getDefaultState(), xx, -1, zz, box); } if(IEConfig.enableVillagers) @@ -220,8 +224,8 @@ protected boolean placeCrate(World world, StructureBoundingBox box, Random rand, int i1 = this.getXWithOffset(x, z); int j1 = this.getYWithOffset(y); int k1 = this.getZWithOffset(x, z); - BlockPos pos = new BlockPos(i1,j1,k1); - if(box.isVecInside(pos) && (world.getBlockState(pos)!=IEContent.blockWoodenDevice0.getStateFromMeta(0))) + BlockPos pos = new BlockPos(i1, j1, k1); + if(box.isVecInside(pos)&&(world.getBlockState(pos)!=IEContent.blockWoodenDevice0.getStateFromMeta(0))) { world.setBlockState(pos, IEContent.blockWoodenDevice0.getStateFromMeta(0), 2); TileEntity tile = world.getTileEntity(pos); @@ -236,7 +240,7 @@ protected boolean placeCrate(World world, StructureBoundingBox box, Random rand, protected void placeDoor(World worldIn, StructureBoundingBox boundingBoxIn, Random rand, int x, int y, int z, EnumFacing facing, EnumHingePosition hinge) { this.setBlockState(worldIn, Blocks.OAK_DOOR.getDefaultState().withProperty(BlockDoor.FACING, facing).withProperty(BlockDoor.HINGE, hinge), x, y, z, boundingBoxIn); - this.setBlockState(worldIn, Blocks.OAK_DOOR.getDefaultState().withProperty(BlockDoor.FACING, facing).withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER).withProperty(BlockDoor.HINGE, hinge), x, y + 1, z, boundingBoxIn); + this.setBlockState(worldIn, Blocks.OAK_DOOR.getDefaultState().withProperty(BlockDoor.FACING, facing).withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER).withProperty(BlockDoor.HINGE, hinge), x, y+1, z, boundingBoxIn); } protected boolean placeLantern(World world, StructureBoundingBox box, int x, int y, int z, int facing) @@ -244,22 +248,23 @@ protected boolean placeLantern(World world, StructureBoundingBox box, int x, int int i1 = this.getXWithOffset(x, z); int j1 = this.getYWithOffset(y); int k1 = this.getZWithOffset(x, z); - BlockPos pos = new BlockPos(i1,j1,k1); + BlockPos pos = new BlockPos(i1, j1, k1); // world.setBlock(pos, IEContent.blockMetalDecoration0,BlockMetalDecoration1.META_lantern, 2); // TileEntity tile = world.getTileEntity(pos); // if(tile instanceof TileEntityLantern) // ((TileEntityLantern)tile).facing = facing; return box.isVecInside(pos); } + public void placeItemframe(Random random, World world, int x, int y, int z, EnumFacing side, ItemStack stack) { int i1 = this.getXWithOffset(x, z); int j1 = this.getYWithOffset(y); int k1 = this.getZWithOffset(x, z); - EntityItemFrame e = new EntityItemFrame(world, new BlockPos(i1,j1,k1), side); + EntityItemFrame e = new EntityItemFrame(world, new BlockPos(i1, j1, k1), side); e.setDisplayedItem(stack); - if(e.onValidSurface() && world.getEntitiesWithinAABB(EntityHanging.class, new AxisAlignedBB(i1-.125,j1,k1-.125,i1+1.125,j1+1,k1+1.125)).isEmpty()) + if(e.onValidSurface()&&world.getEntitiesWithinAABB(EntityHanging.class, new AxisAlignedBB(i1-.125, j1, k1-.125, i1+1.125, j1+1, k1+1.125)).isEmpty()) if(!world.isRemote) world.spawnEntity(e); } @@ -282,13 +287,15 @@ public static class VillageManager implements IVillageCreationHandler public Village buildComponent(PieceWeight villagePiece, Start startPiece, List pieces, Random random, int p1, int p2, int p3, EnumFacing facing, int p5) { StructureBoundingBox box = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, 11, 10, 9, facing); - return (!canVillageGoDeeper(box)) || (StructureComponent.findIntersecting(pieces, box) != null) ? null : new VillageEngineersHouse(startPiece, p5, random, box, facing); + return (!canVillageGoDeeper(box))||(StructureComponent.findIntersecting(pieces, box)!=null)?null: new VillageEngineersHouse(startPiece, p5, random, box, facing); } + @Override public PieceWeight getVillagePieceWeight(Random random, int i) { - return new PieceWeight(VillageEngineersHouse.class, 15, MathHelper.getInt(random, 0 + i, 1 + i)); + return new PieceWeight(VillageEngineersHouse.class, 15, MathHelper.getInt(random, 0+i, 1+i)); } + @Override public Class getComponentClass() { diff --git a/src/main/java/blusunrize/lib/manual/IManualPage.java b/src/main/java/blusunrize/lib/manual/IManualPage.java index 9700085d82..c45c324c3c 100644 --- a/src/main/java/blusunrize/lib/manual/IManualPage.java +++ b/src/main/java/blusunrize/lib/manual/IManualPage.java @@ -17,16 +17,24 @@ public interface IManualPage { ManualInstance getManualHelper(); + void initPage(GuiManual gui, int x, int y, List pageButtons); + void renderPage(GuiManual gui, int x, int y, int mx, int my); + void buttonPressed(GuiManual gui, GuiButton button); + void mouseDragged(int x, int y, int clickX, int clickY, int mx, int my, int lastX, int lastY, int button); + boolean listForSearch(String searchTag); + void recalculateCraftingRecipes(); + default ItemStack[] getProvidedRecipes() { return new ItemStack[0]; } + default ItemStack getHighlightedStack() { return ItemStack.EMPTY; diff --git a/src/main/java/blusunrize/lib/manual/ManualInstance.java b/src/main/java/blusunrize/lib/manual/ManualInstance.java index a347fd31ca..48db479c6e 100644 --- a/src/main/java/blusunrize/lib/manual/ManualInstance.java +++ b/src/main/java/blusunrize/lib/manual/ManualInstance.java @@ -22,6 +22,7 @@ public abstract class ManualInstance { public FontRenderer fontRenderer; public String texture; + public ManualInstance(FontRenderer fontRenderer, String texture) { this.fontRenderer = fontRenderer; @@ -31,35 +32,74 @@ public ManualInstance(FontRenderer fontRenderer, String texture) public abstract String getManualName(); public abstract String[] getSortedCategoryList(); + public abstract String formatCategoryName(String s); + public abstract String formatEntryName(String s); + public abstract String formatEntrySubtext(String s); + public abstract String formatLink(ManualLink link); + public abstract String formatText(String s); + public abstract boolean showCategoryInList(String category); + public abstract boolean showEntryInList(ManualEntry entry); public abstract int getTitleColour(); + public abstract int getSubTitleColour(); + public abstract int getTextColour(); + public abstract int getHighlightColour(); + public abstract int getPagenumberColour(); + public abstract boolean allowGuiRescale(); + public abstract boolean improveReadability(); - public void openManual(){} - public void closeManual(){} - public void openEntry(String entry){} - public void titleRenderPre(){} - public void titleRenderPost(){} - public void entryRenderPre(){} - public void entryRenderPost(){} - public void tooltipRenderPre(){} - public void tooltipRenderPost(){} + public void openManual() + { + } + + public void closeManual() + { + } + + public void openEntry(String entry) + { + } + + public void titleRenderPre() + { + } + + public void titleRenderPost() + { + } + + public void entryRenderPre() + { + } + + public void entryRenderPost() + { + } + + public void tooltipRenderPre() + { + } + + public void tooltipRenderPost() + { + } public GuiManual getGui() { - if(GuiManual.activeManual!=null && GuiManual.activeManual.getManual()==this) + if(GuiManual.activeManual!=null&&GuiManual.activeManual.getManual()==this) return GuiManual.activeManual; return new GuiManual(this, texture); } @@ -68,8 +108,9 @@ public GuiManual getGui() public void addEntry(String name, String category, IManualPage... pages) { - manualContents.put(category, new ManualEntry(name,category,pages)); + manualContents.put(category, new ManualEntry(name, category, pages)); } + public ManualEntry getEntry(String name) { for(ManualEntry e : manualContents.values()) @@ -77,30 +118,35 @@ public ManualEntry getEntry(String name) return e; return null; } + public static class ManualEntry { String name; String category; IManualPage[] pages; + public ManualEntry(String name, String category, IManualPage... pages) { - this.name=name; - this.category=category; - this.pages=pages; + this.name = name; + this.category = category; + this.pages = pages; } public String getName() { return name; } + public String getCategory() { return category; } + public IManualPage[] getPages() { return pages; } + public void setPages(IManualPage[] pages) { this.pages = pages; @@ -108,6 +154,7 @@ public void setPages(IManualPage[] pages) } public HashMap itemLinks = Maps.newHashMap(); + public void indexRecipes() { itemLinks.clear(); @@ -118,11 +165,12 @@ public void indexRecipes() { p.recalculateCraftingRecipes(); for(ItemStack s : p.getProvidedRecipes()) - itemLinks.put(getItemHash(s), new ManualLink(entry.getName(),iP)); + itemLinks.put(getItemHash(s), new ManualLink(entry.getName(), iP)); iP++; } } } + public ManualLink getManualLink(ItemStack stack) { int hash = getItemHash(stack); @@ -131,19 +179,20 @@ public ManualLink getManualLink(ItemStack stack) int getItemHash(ItemStack stack) { - if (stack.isEmpty()) + if(stack.isEmpty()) return 0; int ret = ForgeRegistries.ITEMS.getKey(stack.getItem()).hashCode(); - if (stack.getHasSubtypes()) + if(stack.getHasSubtypes()) ret = ret*31+stack.getMetadata(); - if (stack.hasTagCompound()) + if(stack.hasTagCompound()) { NBTTagCompound nbt = stack.getTagCompound(); - if (!nbt.hasNoTags()) - ret = ret * 31 + nbt.hashCode(); + if(!nbt.hasNoTags()) + ret = ret*31+nbt.hashCode(); } return ret; } + public static class ManualLink { private final String key; diff --git a/src/main/java/blusunrize/lib/manual/ManualPages.java b/src/main/java/blusunrize/lib/manual/ManualPages.java index b7a99e880e..84bc2c28c4 100644 --- a/src/main/java/blusunrize/lib/manual/ManualPages.java +++ b/src/main/java/blusunrize/lib/manual/ManualPages.java @@ -97,6 +97,7 @@ public void addProvidedItem(ItemStack s) providedItems = new ArrayList<>(1); providedItems.add(s); } + @Override public ItemStack[] getProvidedRecipes() { @@ -297,7 +298,7 @@ public void renderPage(GuiManual gui, int x, int y, int mx, int my) int yOff = 0; for(String[] line : localizedTable) - if(line !=null) + if(line!=null) { int height = 0; for(int j = 0; j < line.length; j++) @@ -316,9 +317,9 @@ public void renderPage(GuiManual gui, int x, int y, int mx, int my) { float scale = .5f; GlStateManager.scale(1, scale, 1); - int barHeight = (int) ((y+textHeight+yOff+height*manual.fontRenderer.FONT_HEIGHT)/scale); + int barHeight = (int)((y+textHeight+yOff+height*manual.fontRenderer.FONT_HEIGHT)/scale); gui.drawGradientRect(x, barHeight, x+120, barHeight+1, - manual.getTextColour() | 0xff000000, manual.getTextColour() | 0xff000000); + manual.getTextColour()|0xff000000, manual.getTextColour()|0xff000000); GlStateManager.scale(1, 1/scale, 1); } @@ -506,15 +507,18 @@ void checkRecipe(IRecipe rec, Object key, Object stack, int iStack) { w = ingredientsPre.size() > 6?3: ingredientsPre.size() > 1?2: 1; h = ingredientsPre.size() > 4?3: ingredientsPre.size() > 2?2: 1; - } else if(rec instanceof ShapedOreRecipe) + } + else if(rec instanceof ShapedOreRecipe) { w = ((ShapedOreRecipe)rec).getWidth(); h = ((ShapedOreRecipe)rec).getHeight(); - } else if(rec instanceof ShapedRecipes) + } + else if(rec instanceof ShapedRecipes) { w = ((ShapedRecipes)rec).recipeWidth; h = ((ShapedRecipes)rec).recipeHeight; - } else + } + else return; PositionedItemStack[] pIngredients = new PositionedItemStack[ingredientsPre.size()+1]; @@ -648,11 +652,13 @@ public boolean listForSearch(String searchTag) for(ItemStack subStack : (ItemStack[])stack) if(subStack.getDisplayName().toLowerCase(Locale.ENGLISH).contains(searchTag)) return true; - } else if(stack instanceof ItemStack) + } + else if(stack instanceof ItemStack) { if(((ItemStack)stack).getDisplayName().toLowerCase(Locale.ENGLISH).contains(searchTag)) return true; - } else if(stack instanceof String) + } + else if(stack instanceof String) { if(ManualUtils.isExistingOreName((String)stack)) for(ItemStack subStack : OreDictionary.getOres((String)stack)) @@ -686,7 +692,7 @@ public void recalculateCraftingRecipes() if(providedItems!=null) this.providedItems.clear(); - for(int iStack = 0; iStack < stacks.length ; iStack++) + for(int iStack = 0; iStack < stacks.length; iStack++) if(stacks[iStack] instanceof PositionedItemStack[]) { for(PositionedItemStack[] pisA : (PositionedItemStack[][])stacks) @@ -727,19 +733,22 @@ private void handleRecipe(IRecipe recipe, int iStack) NonNullList ingredientsPre = recipe.getIngredients(); int w; int h; - if(recipe instanceof ShapelessRecipes || recipe instanceof ShapelessOreRecipe) + if(recipe instanceof ShapelessRecipes||recipe instanceof ShapelessOreRecipe) { w = ingredientsPre.size() > 6?3: ingredientsPre.size() > 1?2: 1; h = ingredientsPre.size() > 4?3: ingredientsPre.size() > 2?2: 1; - } else if(recipe instanceof ShapedOreRecipe) + } + else if(recipe instanceof ShapedOreRecipe) { w = ((ShapedOreRecipe)recipe).getWidth(); h = ((ShapedOreRecipe)recipe).getHeight(); - } else if(recipe instanceof ShapedRecipes) + } + else if(recipe instanceof ShapedRecipes) { w = ((ShapedRecipes)recipe).getWidth(); h = ((ShapedRecipes)recipe).getHeight(); - } else + } + else return; PositionedItemStack[] pIngredients = new PositionedItemStack[ingredientsPre.size()+1]; @@ -852,7 +861,8 @@ public boolean listForSearch(String searchTag) for(ItemStack subStack : (ItemStack[])stack.stack) if(subStack.getDisplayName().toLowerCase(Locale.ENGLISH).contains(searchTag)) return true; - } else if(stack.stack instanceof List) + } + else if(stack.stack instanceof List) for(ItemStack subStack : (List)stack.stack) { if(subStack.getDisplayName().toLowerCase(Locale.ENGLISH).contains(searchTag)) @@ -862,7 +872,8 @@ else if(stack.stack instanceof ItemStack) { if(((ItemStack)stack.stack).getDisplayName().toLowerCase(Locale.ENGLISH).contains(searchTag)) return true; - } else if(stack.stack instanceof String) + } + else if(stack.stack instanceof String) { if(ManualUtils.isExistingOreName((String)stack.stack)) for(ItemStack subStack : OreDictionary.getOres((String)stack.stack)) @@ -890,12 +901,12 @@ public static String addLinks(ManualInstance helper, GuiManual gui, String text, String page = segment.length > 3?segment[3]: "0"; String[] resultParts = segment[2].split(" "); String result = ""; - for(int iPart=0; iPart0?" ":"")+part; + result += (iPart > 0?" ": "")+part; } text = text.replaceFirst(rep, result); } @@ -912,7 +923,7 @@ public static String addLinks(ManualInstance helper, GuiManual gui, String text, String s = list.get(yOff); if((start = s.indexOf(rep[0])) >= 0) { - String formatIdent = rep[0].substring(0,2); + String formatIdent = rep[0].substring(0, 2); rep[0] = rep[0].substring(2); int bx = helper.fontRenderer.getStringWidth(s.substring(0, start)); int by = yOff*helper.fontRenderer.FONT_HEIGHT; @@ -962,9 +973,11 @@ public ItemStack getStack() ((ItemStack)stack).getItem().getSubItems(((ItemStack)stack).getItem().getCreativeTab(), list); if(list.size() > 0) displayList.addAll(list); - } else + } + else displayList.add((ItemStack)stack); - } else if(stack instanceof Ingredient) + } + else if(stack instanceof Ingredient) { for(ItemStack subStack : ((Ingredient)stack).getMatchingStacks()) { @@ -974,7 +987,8 @@ public ItemStack getStack() subStack.getItem().getSubItems(subStack.getItem().getCreativeTab(), list); if(list.size() > 0) displayList.addAll(list); - } else + } + else displayList.add(subStack); } } @@ -988,7 +1002,8 @@ else if(stack instanceof List&&!((List)stack).isEmpty()) subStack.getItem().getSubItems(subStack.getItem().getCreativeTab(), list); if(list.size() > 0) displayList.addAll(list); - } else + } + else displayList.add(subStack); } } diff --git a/src/main/java/blusunrize/lib/manual/ManualUtils.java b/src/main/java/blusunrize/lib/manual/ManualUtils.java index e53d3ffbc4..e191ff19de 100644 --- a/src/main/java/blusunrize/lib/manual/ManualUtils.java +++ b/src/main/java/blusunrize/lib/manual/ManualUtils.java @@ -34,7 +34,7 @@ public static boolean stackMatchesObject(ItemStack stack, Object o) { if(!OreDictionary.itemMatches((ItemStack)o, stack, false)) return false; - if(stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) + if(stack.getItemDamage()==OreDictionary.WILDCARD_VALUE) return true; if(((ItemStack)o).hasTagCompound()) return ((ItemStack)o).getTagCompound().equals(stack.getTagCompound()); @@ -42,6 +42,7 @@ public static boolean stackMatchesObject(ItemStack stack, Object o) } return false; } + public static boolean compareToOreName(ItemStack stack, String oreName) { for(int oid : OreDictionary.getOreIDs(stack)) @@ -49,6 +50,7 @@ public static boolean compareToOreName(ItemStack stack, String oreName) return true; return false; } + public static boolean isExistingOreName(String name) { if(!OreDictionary.doesOreNameExist(name)) @@ -73,20 +75,22 @@ public static ArrayList getPrimitiveSpellingCorrections(String query, St { ArrayList list = new ArrayList(); for(String s : valid) - if(s!=null && !s.trim().isEmpty()) - if(getSpellingDistanceBetweenStrings(query,s)(){ + Collections.sort(list, new Comparator() + { @Override public int compare(String s0, String s1) { - return getSpellingDistanceBetweenStrings(s1,s0); + return getSpellingDistanceBetweenStrings(s1, s0); } }); return list; } + public static int getSpellingDistanceBetweenStrings(String query, String target) { query = query.toLowerCase(Locale.ENGLISH); @@ -95,26 +99,26 @@ public static int getSpellingDistanceBetweenStrings(String query, String target) String[] queryWords = query.split(" "); String[] targetWords = target.split(" "); int distance = 0; - for(int iWord=0; iWord=targetWords.length) + if(iWord >= targetWords.length) distance++; else { int wordDistance = 0; - for(int iChar=0; iChar=targetWords[iWord].length()) + for(int iChar = 0; iChar < queryWords[iWord].length(); iChar++) + if(iChar >= targetWords[iWord].length()) distance++; else { - if(queryWords[iWord].charAt(iChar) != targetWords[iWord].charAt(iChar)) + if(queryWords[iWord].charAt(iChar)!=targetWords[iWord].charAt(iChar)) { wordDistance++; - if(iChar>0 && queryWords[iWord].charAt(iChar-1)==targetWords[iWord].charAt(iChar) && queryWords[iWord].charAt(iChar)==targetWords[iWord].charAt(iChar-1)) - wordDistance-=2;//switched letters don't increase distance + if(iChar > 0&&queryWords[iWord].charAt(iChar-1)==targetWords[iWord].charAt(iChar)&&queryWords[iWord].charAt(iChar)==targetWords[iWord].charAt(iChar-1)) + wordDistance -= 2;//switched letters don't increase distance } } - if(wordDistance>0) + if(wordDistance > 0) wordDistance += targetWords[iWord].length()-queryWords[iWord].length(); distance += wordDistance; } @@ -135,21 +139,21 @@ public static void drawSplitString(FontRenderer fontRenderer, String string, int for(Iterator iterator = list.iterator(); iterator.hasNext(); y += fontRenderer.FONT_HEIGHT) { String next = iterator.next(); - if(line>0) + if(line > 0) { int currentColour = fontRenderer.textColor; GL11.glGetFloat(GL11.GL_CURRENT_COLOR, currentGLColor); //Resetting colour if GL colour differs from textColor //that case happens because the formatting reset does not reset textColor - int glColourRGBA = ((int)(currentGLColor.get(0) * 255) << 16) + ((int)(currentGLColor.get(1) * 255) << 8) + ((int)(currentGLColor.get(2) * 255)); - if(glColourRGBA != currentColour) + int glColourRGBA = ((int)(currentGLColor.get(0)*255)<<16)+((int)(currentGLColor.get(1)*255)<<8)+((int)(currentGLColor.get(2)*255)); + if(glColourRGBA!=currentColour) { int j = 0; for(; j < fontRenderer.colorCode.length; j++) - if(fontRenderer.colorCode[j] == glColourRGBA) + if(fontRenderer.colorCode[j]==glColourRGBA) { - String code = Integer.toHexString(j % 16); - next = '\u00a7' + code + next; + String code = Integer.toHexString(j%16); + next = '\u00a7'+code+next; break; } } @@ -168,25 +172,30 @@ public static String attemptStringTranslation(String tranlationKey, String arg) } static HashMap resourceMap = new HashMap(); + public static Tessellator tes() { return Tessellator.getInstance(); } + public static Minecraft mc() { return Minecraft.getMinecraft(); } + public static void bindTexture(String path) { mc().getTextureManager().bindTexture(getResource(path)); } + public static ResourceLocation getResource(String path) { - ResourceLocation rl = resourceMap.containsKey(path) ? resourceMap.get(path) : new ResourceLocation(path); + ResourceLocation rl = resourceMap.containsKey(path)?resourceMap.get(path): new ResourceLocation(path); if(!resourceMap.containsKey(path)) resourceMap.put(path, rl); return rl; } + public static RenderItem renderItem() { return mc().getRenderItem(); diff --git a/src/main/java/blusunrize/lib/manual/gui/GuiButtonManual.java b/src/main/java/blusunrize/lib/manual/gui/GuiButtonManual.java index b46d0ff745..6a4390eec9 100644 --- a/src/main/java/blusunrize/lib/manual/gui/GuiButtonManual.java +++ b/src/main/java/blusunrize/lib/manual/gui/GuiButtonManual.java @@ -21,38 +21,41 @@ public class GuiButtonManual extends GuiButton { public GuiManual gui; - public int[] colour = {0x33000000,0x33cb7f32}; - public int[] textColour = {0xffe0e0e0,0xffffffa0}; + public int[] colour = {0x33000000, 0x33cb7f32}; + public int[] textColour = {0xffe0e0e0, 0xffffffa0}; + public GuiButtonManual(GuiManual gui, int id, int x, int y, int w, int h, String text) { super(id, x, y, w, h, text); this.gui = gui; } + public GuiButtonManual setColour(int normal, int hovered) { - colour = new int[]{normal,hovered}; + colour = new int[]{normal, hovered}; return this; } + public GuiButtonManual setTextColour(int normal, int hovered) { - textColour = new int[]{normal,hovered}; + textColour = new int[]{normal, hovered}; return this; } @Override public void drawButton(Minecraft mc, int mx, int my, float partialTicks) { - if (this.visible) + if(this.visible) { ManualUtils.bindTexture(gui.texture); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - this.hovered = mx>=this.x&&mx<(this.x+this.width) && my>=this.y&&my<(this.y+this.height); + this.hovered = mx >= this.x&&mx < (this.x+this.width)&&my >= this.y&&my < (this.y+this.height); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(SRC_ALPHA, ONE_MINUS_SRC_ALPHA, ONE, ZERO); - int col = colour[hovered?1:0]; - this.drawGradientRect(x,y, x+width,y+height, col,col); - int txtCol = textColour[hovered?1:0]; + int col = colour[hovered?1: 0]; + this.drawGradientRect(x, y, x+width, y+height, col, col); + int txtCol = textColour[hovered?1: 0]; boolean uni = gui.manual.fontRenderer.getUnicodeFlag(); gui.manual.fontRenderer.setUnicodeFlag(true); int sw = gui.manual.fontRenderer.getStringWidth(displayString); diff --git a/src/main/java/blusunrize/lib/manual/gui/GuiButtonManualLink.java b/src/main/java/blusunrize/lib/manual/gui/GuiButtonManualLink.java index decb06ba53..1b7c5bfd7e 100644 --- a/src/main/java/blusunrize/lib/manual/gui/GuiButtonManualLink.java +++ b/src/main/java/blusunrize/lib/manual/gui/GuiButtonManualLink.java @@ -22,9 +22,10 @@ public class GuiButtonManualLink extends GuiButton public String localized; public ManualLink link; GuiManual gui; + public GuiButtonManualLink(GuiManual gui, int id, int x, int y, int w, int h, ManualLink link, String localized) { - super(id, x,y, w,h, ""); + super(id, x, y, w, h, ""); this.gui = gui; this.link = link; this.localized = localized; @@ -33,15 +34,15 @@ public GuiButtonManualLink(GuiManual gui, int id, int x, int y, int w, int h, Ma } @Override - public boolean mousePressed(Minecraft mc, int mx, int my) - { - return super.mousePressed(mc, mx, my); - } + public boolean mousePressed(Minecraft mc, int mx, int my) + { + return super.mousePressed(mc, mx, my); + } @Override public void drawButton(Minecraft mc, int mx, int my, float partialTicks) { - this.hovered = mx >= this.x && my >= this.y && mx < this.x + this.width && my < this.y + this.height; + this.hovered = mx >= this.x&&my >= this.y&&mx < this.x+this.width&&my < this.y+this.height; if(hovered) { // FontRenderer font = gui.manual.fontRenderer; @@ -50,10 +51,10 @@ public void drawButton(Minecraft mc, int mx, int my, float partialTicks) font.setUnicodeFlag(true); font.drawString(localized, x, y, gui.manual.getHighlightColour()); font.setUnicodeFlag(false); - gui.drawHoveringText(Collections.singletonList(gui.manual.formatLink(link)), mx+8,my+4, font); + gui.drawHoveringText(Collections.singletonList(gui.manual.formatLink(link)), mx+8, my+4, font); font.setUnicodeFlag(uni); GlStateManager.enableBlend(); } - + } } \ No newline at end of file diff --git a/src/main/java/blusunrize/lib/manual/gui/GuiButtonManualNavigation.java b/src/main/java/blusunrize/lib/manual/gui/GuiButtonManualNavigation.java index 3d5f26115b..1b0072f140 100644 --- a/src/main/java/blusunrize/lib/manual/gui/GuiButtonManualNavigation.java +++ b/src/main/java/blusunrize/lib/manual/gui/GuiButtonManualNavigation.java @@ -22,9 +22,10 @@ public class GuiButtonManualNavigation extends GuiButton { public int type; public GuiManual gui; + public GuiButtonManualNavigation(GuiManual gui, int id, int x, int y, int w, int h, int type) { - super(id, x, y, type>=4?10:Math.min(type<2?16:10, w), type>=4?10:Math.min(type<2?10:16, h), ""); + super(id, x, y, type >= 4?10: Math.min(type < 2?16: 10, w), type >= 4?10: Math.min(type < 2?10: 16, h), ""); this.gui = gui; this.type = type; } @@ -32,17 +33,17 @@ public GuiButtonManualNavigation(GuiManual gui, int id, int x, int y, int w, int @Override public void drawButton(Minecraft mc, int mx, int my, float partialTicks) { - if (this.visible) + if(this.visible) { ManualUtils.bindTexture(gui.texture); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - this.hovered = mx>=this.x&&mx<(this.x+this.width) && my>=this.y&&my<(this.y+this.height); + this.hovered = mx >= this.x&&mx < (this.x+this.width)&&my >= this.y&&my < (this.y+this.height); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(SRC_ALPHA, ONE_MINUS_SRC_ALPHA, ONE, ZERO); - int u = type==5?46: type==4||type==6?36: (type<2?0:type<3?16:26)+ (type>1?(10-width): type==1?(16-width): 0); - int v = 216+( type==0?0: type==1?10: type==2?(16-height): type==3?0: type==4||type==5?10: 0 ); + int u = type==5?46: type==4||type==6?36: (type < 2?0: type < 3?16: 26)+(type > 1?(10-width): type==1?(16-width): 0); + int v = 216+(type==0?0: type==1?10: type==2?(16-height): type==3?0: type==4||type==5?10: 0); if(hovered) - v+=20; + v += 20; this.drawTexturedModalRect(this.x, this.y, u, v, width, height); this.mouseDragged(mc, mx, my); } diff --git a/src/main/java/blusunrize/lib/manual/gui/GuiClickableList.java b/src/main/java/blusunrize/lib/manual/gui/GuiClickableList.java index dd0a35b078..ced8a66caf 100644 --- a/src/main/java/blusunrize/lib/manual/gui/GuiClickableList.java +++ b/src/main/java/blusunrize/lib/manual/gui/GuiClickableList.java @@ -35,14 +35,15 @@ public GuiClickableList(GuiManual gui, int id, int x, int y, int w, int h, float this.translationType = translationType; perPage = (h-8)/getFontHeight(); - if(perPage=x&&mx=y&&my= x&&mx < x+width&&my >= y&&my < y+height; + for(int i = 0; i < Math.min(perPage, entries.length); i++) { int col = gui.manual.getTextColour(); - if(hovered && mmY>=i*getFontHeight() && mmY<(i+1)*getFontHeight()) + if(hovered&&mmY >= i*getFontHeight()&&mmY < (i+1)*getFontHeight()) col = gui.manual.getHighlightColour(); if(i!=0) GlStateManager.translate(0, getFontHeight(), 0); int j = offset+i; - if(j>entries.length-1) - j=entries.length-1; - String s = translationType==-1?entries[j]: translationType==0?gui.manual.formatCategoryName(entries[j]):gui.manual.formatEntryName(entries[j]); - fr.drawString(s, 0,0, col, false); + if(j > entries.length-1) + j = entries.length-1; + String s = translationType==-1?entries[j]: translationType==0?gui.manual.formatCategoryName(entries[j]): gui.manual.formatEntryName(entries[j]); + fr.drawString(s, 0, 0, col, false); } - GlStateManager.scale(1/textScale,1/textScale,1/textScale); + GlStateManager.scale(1/textScale, 1/textScale, 1/textScale); GlStateManager.popMatrix(); - if(maxOffset>0) + if(maxOffset > 0) { int h1 = offset*getFontHeight(); int h2 = height-8-maxOffset*getFontHeight(); @@ -90,28 +91,29 @@ public void drawButton(Minecraft mc, int mx, int my, float partialTicks) //Handle DWheel int mouseWheel = Mouse.getEventDWheel(); - if(mouseWheel!=0 && maxOffset>0 && Mouse.getEventNanoseconds()!=prevWheelNano) + if(mouseWheel!=0&&maxOffset > 0&&Mouse.getEventNanoseconds()!=prevWheelNano) { prevWheelNano = Mouse.getEventNanoseconds(); - if(mouseWheel<0 && offset0 && offset>0) + if(mouseWheel > 0&&offset > 0) offset--; } } - public int selectedOption=-1; + public int selectedOption = -1; + @Override public boolean mousePressed(Minecraft mc, int mx, int my) { boolean b = super.mousePressed(mc, mx, my); - selectedOption=-1; + selectedOption = -1; if(b) { int mmY = my-this.y; - for(int i=0; i=i*getFontHeight() && mmY<(i+1)*getFontHeight()) - selectedOption=offset+i; + for(int i = 0; i < Math.min(perPage, entries.length); i++) + if(mmY >= i*getFontHeight()&&mmY < (i+1)*getFontHeight()) + selectedOption = offset+i; } return selectedOption!=-1; } diff --git a/src/main/java/blusunrize/lib/manual/gui/GuiManual.java b/src/main/java/blusunrize/lib/manual/gui/GuiManual.java index 9749b5c955..77f5b6152e 100644 --- a/src/main/java/blusunrize/lib/manual/gui/GuiManual.java +++ b/src/main/java/blusunrize/lib/manual/gui/GuiManual.java @@ -30,7 +30,7 @@ public class GuiManual extends GuiScreen int ySize = 198; int guiLeft; int guiTop; - int manualTick=0; + int manualTick = 0; List pageButtons = new ArrayList(); public String selectedCategory; @@ -57,10 +57,11 @@ public GuiManual(ManualInstance manual, String texture) this.texture = texture; prevGuiScale = Minecraft.getMinecraft().gameSettings.guiScale; - if(prevGuiScale!=0 && prevGuiScale!=2 && manual.allowGuiRescale()) - Minecraft.getMinecraft().gameSettings.guiScale=2; - activeManual=this; + if(prevGuiScale!=0&&prevGuiScale!=2&&manual.allowGuiRescale()) + Minecraft.getMinecraft().gameSettings.guiScale = 2; + activeManual = this; } + @Override public boolean doesGuiPauseGame() { @@ -71,12 +72,14 @@ public String getSelectedEntry() { return selectedEntry; } + public void setSelectedEntry(String string) { selectedEntry = string; if(string!=null) manual.openEntry(string); } + public ManualInstance getManual() { return this.manual; @@ -87,39 +90,39 @@ public void initGui() { if(Minecraft.getMinecraft().gameSettings.guiScale==1) { - Minecraft.getMinecraft().gameSettings.guiScale=2; + Minecraft.getMinecraft().gameSettings.guiScale = 2; ScaledResolution res = new ScaledResolution(this.mc); this.width = res.getScaledWidth(); this.height = res.getScaledHeight(); - Minecraft.getMinecraft().gameSettings.guiScale=1; + Minecraft.getMinecraft().gameSettings.guiScale = 1; } this.manual.openManual(); - guiLeft = (this.width - this.xSize) / 2; - guiTop = (this.height - this.ySize) / 2; + guiLeft = (this.width-this.xSize)/2; + guiTop = (this.height-this.ySize)/2; boolean textField = false; this.buttonList.clear(); this.pageButtons.clear(); - headers=new String[0]; - suggestionHeaders=new String[0]; + headers = new String[0]; + suggestionHeaders = new String[0]; hasSuggestions = -1; if(manual.getEntry(selectedEntry)!=null) { ManualEntry entry = manual.getEntry(selectedEntry); - IManualPage mPage = (page<0||page>=entry.getPages().length)?null: entry.getPages()[page]; + IManualPage mPage = (page < 0||page >= entry.getPages().length)?null: entry.getPages()[page]; if(mPage!=null) - mPage.initPage(this, guiLeft+32,guiTop+28, pageButtons); + mPage.initPage(this, guiLeft+32, guiTop+28, pageButtons); buttonList.addAll(pageButtons); } - else if(manual.getSortedCategoryList()==null||manual.getSortedCategoryList().length<=1) + else if(manual.getSortedCategoryList()==null||manual.getSortedCategoryList().length <= 1) { ArrayList lHeaders = new ArrayList(); for(ManualEntry e : manual.manualContents.values()) if(manual.showEntryInList(e)) lHeaders.add(e.getName()); headers = lHeaders.toArray(new String[lHeaders.size()]); - this.buttonList.add(new GuiClickableList(this, 0, guiLeft + 40, guiTop + 20, 100, 168, 1f, 1, headers)); + this.buttonList.add(new GuiClickableList(this, 0, guiLeft+40, guiTop+20, 100, 168, 1f, 1, headers)); textField = true; } else if(manual.manualContents.containsKey(selectedCategory)) @@ -129,7 +132,7 @@ else if(manual.manualContents.containsKey(selectedCategory)) if(manual.showEntryInList(e)) lHeaders.add(e.getName()); headers = lHeaders.toArray(new String[lHeaders.size()]); - this.buttonList.add(new GuiClickableList(this, 0, guiLeft + 40, guiTop + 20, 100, 168, 1f, 1, headers)); + this.buttonList.add(new GuiClickableList(this, 0, guiLeft+40, guiTop+20, 100, 168, 1f, 1, headers)); textField = true; } else @@ -139,11 +142,11 @@ else if(manual.manualContents.containsKey(selectedCategory)) if(manual.showCategoryInList(cat)) lHeaders.add(cat); headers = lHeaders.toArray(new String[lHeaders.size()]); - this.buttonList.add(new GuiClickableList(this, 0, guiLeft + 40, guiTop + 20, 100, 168, 1f, 0, headers)); + this.buttonList.add(new GuiClickableList(this, 0, guiLeft+40, guiTop+20, 100, 168, 1f, 0, headers)); textField = true; } - if(manual.manualContents.containsKey(selectedCategory) || manual.getEntry(selectedEntry)!=null) - this.buttonList.add(new GuiButtonManualNavigation(this, 1, guiLeft+24,guiTop+10, 10,10, 0)); + if(manual.manualContents.containsKey(selectedCategory)||manual.getEntry(selectedEntry)!=null) + this.buttonList.add(new GuiButtonManualNavigation(this, 1, guiLeft+24, guiTop+10, 10, 10, 0)); if(textField) { @@ -170,32 +173,32 @@ public void drawScreen(int mx, int my, float f) manual.entryRenderPre(); ManualUtils.bindTexture(texture); - this.drawTexturedModalRect(guiLeft,guiTop, 0,0, xSize,ySize); + this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); if(this.searchField!=null) { - int l = searchField.getText()!=null?searchField.getText().length()*6:0; - if(l>20) - this.drawTexturedModalRect(guiLeft+166,guiTop+74, 136+(120-l),238, l,18); - if(this.hasSuggestions!=-1 && this.hasSuggestions 20) + this.drawTexturedModalRect(guiLeft+166, guiTop+74, 136+(120-l), 238, l, 18); + if(this.hasSuggestions!=-1&&this.hasSuggestions < this.buttonList.size()) { - this.drawTexturedModalRect(guiLeft+174,guiTop+100, 214,212, 16,26); - int h = ((GuiClickableList)this.buttonList.get(hasSuggestions)).getFontHeight() * Math.min( ((GuiClickableList)this.buttonList.get(hasSuggestions)).perPage, ((GuiClickableList)this.buttonList.get(hasSuggestions)).entries.length); + this.drawTexturedModalRect(guiLeft+174, guiTop+100, 214, 212, 16, 26); + int h = ((GuiClickableList)this.buttonList.get(hasSuggestions)).getFontHeight()*Math.min(((GuiClickableList)this.buttonList.get(hasSuggestions)).perPage, ((GuiClickableList)this.buttonList.get(hasSuggestions)).entries.length); int w = 76; - this.drawTexturedModalRect(guiLeft+174,guiTop+116, 230,212, 16,16);//Top Left - this.drawTexturedModalRect(guiLeft+174,guiTop+132+h, 230,228, 16,10);//Bottom Left - this.drawTexturedModalRect(guiLeft+190+w,guiTop+116, 246,212, 10,16);//Top Right - this.drawTexturedModalRect(guiLeft+190+w,guiTop+132+h, 246,228, 10,10);//Bottom Right - for(int hh=0; hh32&&mx<32+17 && my>179&&my<179+10; - boolean b1 = mx>135&&mx<135+17 && my>179&&my<179+10; + mx -= guiLeft; + my -= guiTop; + boolean b0 = mx > 32&&mx < 32+17&&my > 179&&my < 179+10; + boolean b1 = mx > 135&&mx < 135+17&&my > 179&&my < 179+10; GlStateManager.enableBlend(); - if(page>0) - this.drawTexturedModalRect(guiLeft+ 32,guiTop+179, 0,216+(b0?20:0), 16,10); - if(page 0) + this.drawTexturedModalRect(guiLeft+32, guiTop+179, 0, 216+(b0?20: 0), 16, 10); + if(page < entry.getPages().length-1) + this.drawTexturedModalRect(guiLeft+136, guiTop+179, 0, 226+(b1?20: 0), 16, 10); manual.titleRenderPre(); //Title - this.drawCenteredStringScaled(manual.fontRenderer, TextFormatting.BOLD+manual.formatEntryName(entry.getName()), guiLeft+xSize/2,guiTop+14, manual.getTitleColour(), 1, true); - this.drawCenteredStringScaled(manual.fontRenderer, manual.formatEntrySubtext(entry.getName()), guiLeft+xSize/2,guiTop+22, manual.getSubTitleColour(), 1, true); + this.drawCenteredStringScaled(manual.fontRenderer, TextFormatting.BOLD+manual.formatEntryName(entry.getName()), guiLeft+xSize/2, guiTop+14, manual.getTitleColour(), 1, true); + this.drawCenteredStringScaled(manual.fontRenderer, manual.formatEntrySubtext(entry.getName()), guiLeft+xSize/2, guiTop+22, manual.getSubTitleColour(), 1, true); //Page Number - this.drawCenteredStringScaled(manual.fontRenderer, TextFormatting.BOLD.toString()+(page+1), guiLeft+xSize/2,guiTop+183, manual.getPagenumberColour(), 1, false); + this.drawCenteredStringScaled(manual.fontRenderer, TextFormatting.BOLD.toString()+(page+1), guiLeft+xSize/2, guiTop+183, manual.getPagenumberColour(), 1, false); manual.titleRenderPost(); - GlStateManager.color(1,1,1); - IManualPage mPage = (page<0||page>=entry.getPages().length)?null: entry.getPages()[page]; + GlStateManager.color(1, 1, 1); + IManualPage mPage = (page < 0||page >= entry.getPages().length)?null: entry.getPages()[page]; if(mPage!=null) - mPage.renderPage(this, guiLeft+32,guiTop+28, mx+guiLeft,my+guiTop); + mPage.renderPage(this, guiLeft+32, guiTop+28, mx+guiLeft, my+guiTop); - mx+=guiLeft; - my+=guiTop; + mx += guiLeft; + my += guiTop; } else { - String title = manual.manualContents.containsKey(selectedCategory)?manual.formatCategoryName(selectedCategory) : manual.getManualName(); + String title = manual.manualContents.containsKey(selectedCategory)?manual.formatCategoryName(selectedCategory): manual.getManualName(); manual.titleRenderPre(); - this.drawCenteredStringScaled(manual.fontRenderer, TextFormatting.BOLD+title, guiLeft+xSize/2,guiTop+12, manual.getTitleColour(), 1, true); + this.drawCenteredStringScaled(manual.fontRenderer, TextFormatting.BOLD+title, guiLeft+xSize/2, guiTop+12, manual.getTitleColour(), 1, true); manual.titleRenderPost(); } if(this.searchField!=null) { manual.fontRenderer.setUnicodeFlag(true); this.searchField.drawTextBox(); - if(this.hasSuggestions!=-1 && this.hasSuggestions=0&&sel= 0&&sel < headers.length) { if(((GuiClickableList)button).translationType==0) selectedCategory = headers[sel]; @@ -278,44 +281,44 @@ public void actionPerformed(GuiButton button) setSelectedEntry(headers[sel]); } } - ((GuiClickableList)button).selectedOption=-1; + ((GuiClickableList)button).selectedOption = -1; this.initGui(); } - else if(button.id == 11) + else if(button.id==11) { int sel = ((GuiClickableList)button).selectedOption; - if(sel>=0&&sel= 0&&sel < suggestionHeaders.length) setSelectedEntry(suggestionHeaders[sel]); - ((GuiClickableList)button).selectedOption=-1; + ((GuiClickableList)button).selectedOption = -1; this.initGui(); } - else if(button.id == 1) + else if(button.id==1) { if(selectedEntry!=null) - setSelectedEntry(previousSelectedEntry.isEmpty()?null:previousSelectedEntry.pop()); + setSelectedEntry(previousSelectedEntry.isEmpty()?null: previousSelectedEntry.pop()); else if(selectedCategory!=null) - selectedCategory=null; - page=0; + selectedCategory = null; + page = 0; this.initGui(); } - else if(pageButtons.contains(button) && manual.getEntry(selectedEntry)!=null) + else if(pageButtons.contains(button)&&manual.getEntry(selectedEntry)!=null) { ManualEntry entry = manual.getEntry(selectedEntry); - IManualPage mPage = (page<0||page>=entry.getPages().length)?null: entry.getPages()[page]; + IManualPage mPage = (page < 0||page >= entry.getPages().length)?null: entry.getPages()[page]; if(mPage!=null) mPage.buttonPressed(this, button); } - buttonHeld=true; + buttonHeld = true; } public void drawCenteredStringScaled(FontRenderer fr, String s, int x, int y, int colour, float scale, boolean shadow) { - int xx = (int)Math.floor(x/scale - (fr.getStringWidth(s)/2)); - int yy = (int)Math.floor(y/scale - (fr.FONT_HEIGHT/2)); + int xx = (int)Math.floor(x/scale-(fr.getStringWidth(s)/2)); + int yy = (int)Math.floor(y/scale-(fr.FONT_HEIGHT/2)); if(scale!=1) GlStateManager.scale(scale, scale, scale); - fr.drawString(s, xx,yy, colour, shadow); + fr.drawString(s, xx, yy, colour, shadow); if(scale!=1) GlStateManager.scale(1/scale, 1/scale, 1/scale); } @@ -326,11 +329,13 @@ public void drawGradientRect(int x1, int y1, int x2, int y2, int colour1, int co super.drawGradientRect(x1, y1, x2, y2, colour1, colour2); GlStateManager.enableBlend(); } + @Override public void renderToolTip(ItemStack stack, int x, int y) { super.renderToolTip(stack, x, y); } + @Override public List getItemToolTip(ItemStack stack) { @@ -339,7 +344,7 @@ public List getItemToolTip(ItemStack stack) if(entry!=null) { IManualPage mPage = (page < 0||page >= entry.getPages().length)?null: entry.getPages()[page]; - if(mPage!=null && mPage.getHighlightedStack()==stack) + if(mPage!=null&&mPage.getHighlightedStack()==stack) { ManualLink link = this.manual.getManualLink(stack); if(link!=null) @@ -348,11 +353,12 @@ public List getItemToolTip(ItemStack stack) } return tooltip; } + @Override public void drawHoveringText(List text, int x, int y, FontRenderer font) { manual.tooltipRenderPre(); - super.drawHoveringText(text,x,y,font); + super.drawHoveringText(text, x, y, font); manual.tooltipRenderPost(); } @@ -361,43 +367,44 @@ public void handleMouseInput() throws IOException { super.handleMouseInput(); int wheel = Mouse.getEventDWheel(); - if(wheel!=0 && manual.getEntry(selectedEntry)!=null) + if(wheel!=0&&manual.getEntry(selectedEntry)!=null) { ManualEntry entry = manual.getEntry(selectedEntry); - if(wheel>0 && page>0) + if(wheel > 0&&page > 0) { page--; this.initGui(); } - else if(wheel<0 && page0 && mx>32&&mx<32+17 && my>179&&my<179+10) + if(page > 0&&mx > 32&&mx < 32+17&&my > 179&&my < 179+10) { page--; this.initGui(); } - else if(page135&&mx<135+17 && my>179&&my<179+10) + else if(page < entry.getPages().length-1&&mx > 135&&mx < 135+17&&my > 179&&my < 179+10) { page++; this.initGui(); } else { - IManualPage mPage = (page<0||page>=entry.getPages().length)?null: entry.getPages()[page]; + IManualPage mPage = (page < 0||page >= entry.getPages().length)?null: entry.getPages()[page]; if(mPage!=null) { ItemStack highlighted = mPage.getHighlightedStack(); @@ -412,47 +419,50 @@ else if(page135&&mx<135+17 && my>179&&my<179+10 } else if(button==1) { - if(searchField!=null && searchField.getText()!=null && !searchField.getText().isEmpty()) + if(searchField!=null&&searchField.getText()!=null&&!searchField.getText().isEmpty()) searchField.setText(""); else if(selectedEntry!=null) - setSelectedEntry(previousSelectedEntry.isEmpty()?null:previousSelectedEntry.pop()); + setSelectedEntry(previousSelectedEntry.isEmpty()?null: previousSelectedEntry.pop()); else if(selectedCategory!=null) - selectedCategory=null; - page=0; + selectedCategory = null; + page = 0; this.initGui(); } - lastClick = new int[]{mx,my}; + lastClick = new int[]{mx, my}; if(this.searchField!=null) this.searchField.mouseClicked(mx, my, button); } + @Override protected void mouseReleased(int mx, int my, int action) { super.mouseReleased(mx, my, action); - if(buttonHeld && (action==0||action==1)) - buttonHeld=false; + if(buttonHeld&&(action==0||action==1)) + buttonHeld = false; lastClick = null; lastDrag = null; } + @Override protected void mouseClickMove(int mx, int my, int button, long time) { - if(lastClick!=null && manual.getEntry(selectedEntry)!=null && page-1+L4|~n!2Km_Re9Rp{4K6`Xu!|f8BAkPHRW%nypq0TdqA3&0c#| z-r)KgpU_%nl>^2nC(J&pD8NwlKIiD>kE+ei^O^s&thbpgnrv_?bm}vvh6xky7a0Vd z$!Q4xFM6tTlICpJvbd?;k+afN-f{nCR0!EPySL`*{E)~qXY%izUcIyb=jGco)IPEN ZV2ZYEXv(w+JOFevgQu&X%Q~loCII9Ua998U literal 0 HcmV?d00001