From 6713cd6296bd0767fb9068c924748e30ed861673 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Tue, 25 Sep 2018 17:51:25 +0100 Subject: [PATCH] Initial removal of itemblocks, wrench now drops the item with the nbt of the tile. This is still WIP but mostly seems to work --- .../java/techreborn/client/gui/TRBuilder.java | 2 +- .../techreborn/events/StackToolTipEvent.java | 12 +- src/main/java/techreborn/init/TRContent.java | 118 +++--------------- .../itemblocks/ItemBlockAdjustableSU.java | 104 --------------- .../itemblocks/ItemBlockDigitalChest.java | 72 ----------- .../itemblocks/ItemBlockQuantumChest.java | 72 ----------- .../itemblocks/ItemBlockQuantumTank.java | 58 --------- .../tiles/TileIndustrialCentrifuge.java | 4 +- src/main/java/techreborn/tiles/TilePump.java | 4 +- .../techreborn/tiles/TileQuantumTank.java | 4 +- .../techreborn/tiles/TileTechStorageBase.java | 4 +- .../techreborn/tiles/cable/TileCable.java | 2 +- .../tiles/generator/TileSolarPanel.java | 2 +- .../tiles/transformers/TileTransformer.java | 2 +- 14 files changed, 39 insertions(+), 421 deletions(-) delete mode 100644 src/main/java/techreborn/itemblocks/ItemBlockAdjustableSU.java delete mode 100644 src/main/java/techreborn/itemblocks/ItemBlockDigitalChest.java delete mode 100644 src/main/java/techreborn/itemblocks/ItemBlockQuantumChest.java delete mode 100644 src/main/java/techreborn/itemblocks/ItemBlockQuantumTank.java diff --git a/src/main/java/techreborn/client/gui/TRBuilder.java b/src/main/java/techreborn/client/gui/TRBuilder.java index cbbd94f6d..4d6d273c4 100644 --- a/src/main/java/techreborn/client/gui/TRBuilder.java +++ b/src/main/java/techreborn/client/gui/TRBuilder.java @@ -89,7 +89,7 @@ public class TRBuilder extends GuiBuilder { list.add(powerColour + PowerSystem.getLocaliszedPowerFormattedNoSuffix(energyStored) + "/" + PowerSystem.getLocaliszedPowerFormattedNoSuffix(maxEnergyStored) + " " + PowerSystem.getDisplayPower().abbreviation); list.add(getPercentageColour(percentage) + "" + percentage + "%" + TextFormatting.GRAY + " Charged"); if(gui.tile instanceof TilePowerAcceptor && GuiScreen.isShiftKeyDown()){ - ((TilePowerAcceptor) gui.tile).addInfo(list, true); + ((TilePowerAcceptor) gui.tile).addInfo(list, true, false); list.add(""); list.add(TextFormatting.BLUE + "Click to change display unit"); } else { diff --git a/src/main/java/techreborn/events/StackToolTipEvent.java b/src/main/java/techreborn/events/StackToolTipEvent.java index 641d96960..8f2537f25 100644 --- a/src/main/java/techreborn/events/StackToolTipEvent.java +++ b/src/main/java/techreborn/events/StackToolTipEvent.java @@ -29,6 +29,7 @@ import net.minecraft.block.BlockContainer; import net.minecraft.block.ITileEntityProvider; import net.minecraft.client.Minecraft; import net.minecraft.item.Item; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.energy.CapabilityEnergy; @@ -55,7 +56,7 @@ public class StackToolTipEvent { } Item item = event.getItemStack().getItem(); if (item instanceof IListInfoProvider) { - ((IListInfoProvider) item).addInfo(event.getToolTip(), false); + ((IListInfoProvider) item).addInfo(event.getToolTip(), false, false); } else if (event.getItemStack().getItem() instanceof IEnergyItemInfo) { IEnergyStorage capEnergy = event.getItemStack().getCapability(CapabilityEnergy.ENERGY, null); event.getToolTip().add(1, @@ -87,8 +88,15 @@ public class StackToolTipEvent { && block.getRegistryName().getNamespace().contains("techreborn")) { TileEntity tile = block.createTileEntity(Minecraft.getMinecraft().world, block.getStateFromMeta(event.getItemStack().getItemDamage())); + boolean hasData = false; + if(event.getItemStack().hasTagCompound() && event.getItemStack().getTagCompound().hasKey("tile_data")){ + NBTTagCompound tileData = event.getItemStack().getTagCompound().getCompoundTag("tile_data"); + tile.readFromNBT(tileData); + hasData = true; + event.getToolTip().add(TextFormatting.DARK_GREEN + "Block data contained"); + } if (tile instanceof IListInfoProvider) { - ((IListInfoProvider) tile).addInfo(event.getToolTip(), false); + ((IListInfoProvider) tile).addInfo(event.getToolTip(), false, hasData); } } } catch (NullPointerException e) { diff --git a/src/main/java/techreborn/init/TRContent.java b/src/main/java/techreborn/init/TRContent.java index 82538d6d4..76d76f31a 100644 --- a/src/main/java/techreborn/init/TRContent.java +++ b/src/main/java/techreborn/init/TRContent.java @@ -1,5 +1,6 @@ package techreborn.init; +import com.google.common.collect.Maps; import net.minecraft.block.Block; import net.minecraft.block.BlockSlab; import net.minecraft.block.properties.IProperty; @@ -27,99 +28,27 @@ import reborncore.common.registration.impl.ConfigRegistry; import reborncore.common.util.BucketHandler; import techreborn.TechReborn; import techreborn.api.Reference; -import techreborn.blocks.BlockAlarm; -import techreborn.blocks.BlockComputerCube; -import techreborn.blocks.BlockMachineCasing; -import techreborn.blocks.BlockMachineFrame; -import techreborn.blocks.BlockNuke; -import techreborn.blocks.BlockOre; -import techreborn.blocks.BlockRefinedIronFence; -import techreborn.blocks.BlockReinforcedGlass; -import techreborn.blocks.BlockRubberLeaves; -import techreborn.blocks.BlockRubberLog; -import techreborn.blocks.BlockRubberPlank; -import techreborn.blocks.BlockRubberPlankSlab; -import techreborn.blocks.BlockRubberPlankStair; -import techreborn.blocks.BlockRubberSapling; -import techreborn.blocks.BlockStorage; +import techreborn.blocks.*; import techreborn.blocks.cable.BlockCable; -import techreborn.blocks.generator.BlockDieselGenerator; -import techreborn.blocks.generator.BlockDragonEggSyphon; -import techreborn.blocks.generator.BlockFusionCoil; -import techreborn.blocks.generator.BlockFusionControlComputer; -import techreborn.blocks.generator.BlockGasTurbine; -import techreborn.blocks.generator.BlockLightningRod; -import techreborn.blocks.generator.BlockMagicEnergyAbsorber; -import techreborn.blocks.generator.BlockMagicEnergyConverter; -import techreborn.blocks.generator.BlockPlasmaGenerator; -import techreborn.blocks.generator.BlockSemiFluidGenerator; -import techreborn.blocks.generator.BlockSolarPanel; -import techreborn.blocks.generator.BlockSolidFuelGenerator; -import techreborn.blocks.generator.BlockThermalGenerator; -import techreborn.blocks.generator.BlockWaterMill; -import techreborn.blocks.generator.BlockWindMill; +import techreborn.blocks.generator.*; import techreborn.blocks.lighting.BlockLamp; -import techreborn.blocks.storage.BlockAdjustableSU; -import techreborn.blocks.storage.BlockHighVoltageSU; -import techreborn.blocks.storage.BlockInterdimensionalSU; -import techreborn.blocks.storage.BlockLSUStorage; -import techreborn.blocks.storage.BlockLapotronicSU; -import techreborn.blocks.storage.BlockLowVoltageSU; -import techreborn.blocks.storage.BlockMediumVoltageSU; +import techreborn.blocks.storage.*; import techreborn.blocks.tier0.BlockIronAlloyFurnace; import techreborn.blocks.tier0.BlockIronFurnace; -import techreborn.blocks.tier1.BlockAlloySmelter; -import techreborn.blocks.tier1.BlockAssemblingMachine; -import techreborn.blocks.tier1.BlockAutoCraftingTable; -import techreborn.blocks.tier1.BlockCompressor; -import techreborn.blocks.tier1.BlockElectricFurnace; -import techreborn.blocks.tier1.BlockExtractor; -import techreborn.blocks.tier1.BlockGrinder; -import techreborn.blocks.tier1.BlockPlayerDetector; -import techreborn.blocks.tier1.BlockRecycler; -import techreborn.blocks.tier1.BlockRollingMachine; -import techreborn.blocks.tier1.BlockScrapboxinator; -import techreborn.blocks.tier2.BlockChargeOMat; -import techreborn.blocks.tier2.BlockChemicalReactor; -import techreborn.blocks.tier2.BlockDigitalChest; -import techreborn.blocks.tier2.BlockDistillationTower; -import techreborn.blocks.tier2.BlockImplosionCompressor; -import techreborn.blocks.tier2.BlockIndustrialBlastFurnace; -import techreborn.blocks.tier2.BlockIndustrialCentrifuge; -import techreborn.blocks.tier2.BlockIndustrialElectrolyzer; -import techreborn.blocks.tier2.BlockIndustrialGrinder; -import techreborn.blocks.tier2.BlockIndustrialSawmill; -import techreborn.blocks.tier2.BlockVacuumFreezer; -import techreborn.blocks.tier3.BlockChunkLoader; -import techreborn.blocks.tier3.BlockCreativeQuantumChest; -import techreborn.blocks.tier3.BlockCreativeQuantumTank; -import techreborn.blocks.tier3.BlockFluidReplicator; -import techreborn.blocks.tier3.BlockMatterFabricator; -import techreborn.blocks.tier3.BlockQuantumChest; -import techreborn.blocks.tier3.BlockQuantumTank; +import techreborn.blocks.tier1.*; +import techreborn.blocks.tier2.*; +import techreborn.blocks.tier3.*; import techreborn.blocks.transformers.BlockHVTransformer; import techreborn.blocks.transformers.BlockLVTransformer; import techreborn.blocks.transformers.BlockMVTransformer; import techreborn.config.ConfigTechReborn; -import techreborn.itemblocks.ItemBlockAdjustableSU; -import techreborn.itemblocks.ItemBlockDigitalChest; -import techreborn.itemblocks.ItemBlockQuantumChest; -import techreborn.itemblocks.ItemBlockQuantumTank; import techreborn.itemblocks.ItemBlockRubberSapling; -import techreborn.items.DynamicCell; -import techreborn.items.ItemFrequencyTransmitter; -import techreborn.items.ItemManual; -import techreborn.items.ItemScrapBox; -import techreborn.items.ItemUpgrade; +import techreborn.items.*; import techreborn.items.armor.ItemCloakingDevice; import techreborn.items.armor.ItemLapotronicOrbpack; import techreborn.items.armor.ItemLithiumIonBatpack; import techreborn.items.armor.ItemTRArmour; -import techreborn.items.battery.ItemEnergyCrystal; -import techreborn.items.battery.ItemLapotronCrystal; -import techreborn.items.battery.ItemLapotronicOrb; -import techreborn.items.battery.ItemLithiumIonBattery; -import techreborn.items.battery.ItemRedCellBattery; +import techreborn.items.battery.*; import techreborn.items.tool.ItemDebugTool; import techreborn.items.tool.ItemTreeTap; import techreborn.items.tool.ItemWrench; @@ -131,24 +60,17 @@ import techreborn.items.tool.basic.ItemBasicChainsaw; import techreborn.items.tool.basic.ItemBasicDrill; import techreborn.items.tool.basic.ItemBasicJackhammer; import techreborn.items.tool.basic.ItemElectricTreetap; -import techreborn.items.tool.industrial.ItemIndustrialChainsaw; -import techreborn.items.tool.industrial.ItemIndustrialDrill; -import techreborn.items.tool.industrial.ItemIndustrialJackhammer; -import techreborn.items.tool.industrial.ItemNanosaber; -import techreborn.items.tool.industrial.ItemOmniTool; +import techreborn.items.tool.industrial.*; import techreborn.items.tool.vanilla.ItemTRAxe; import techreborn.items.tool.vanilla.ItemTRHoe; import techreborn.items.tool.vanilla.ItemTRSpade; import techreborn.items.tool.vanilla.ItemTRSword; import techreborn.utils.InitUtils; +import javax.annotation.Nullable; import java.util.Arrays; import java.util.Map; -import javax.annotation.Nullable; - -import com.google.common.collect.Maps; - @RebornRegister(modID = TechReborn.MOD_ID) public class TRContent { @@ -461,13 +383,13 @@ public class TRContent { WATER_MILL(new BlockWaterMill()), WIND_MILL(new BlockWindMill()), - CREATIVE_QUANTUM_CHEST(new BlockCreativeQuantumChest(), ItemBlockQuantumChest.class), - CREATIVE_QUANTUM_TANK(new BlockCreativeQuantumTank(), ItemBlockQuantumTank.class), - DIGITAL_CHEST(new BlockDigitalChest(), ItemBlockDigitalChest.class), - QUANTUM_CHEST(new BlockQuantumChest(), ItemBlockQuantumChest.class), - QUANTUM_TANK(new BlockQuantumTank(), ItemBlockQuantumTank.class), + CREATIVE_QUANTUM_CHEST(new BlockCreativeQuantumChest()), + CREATIVE_QUANTUM_TANK(new BlockCreativeQuantumTank()), + DIGITAL_CHEST(new BlockDigitalChest()), + QUANTUM_CHEST(new BlockQuantumChest()), + QUANTUM_TANK(new BlockQuantumTank()), - ADJUSTABLE_SU(new BlockAdjustableSU(), ItemBlockAdjustableSU.class), + ADJUSTABLE_SU(new BlockAdjustableSU()), CHARGE_O_MAT(new BlockChargeOMat()), INTERDIMENSIONAL_SU(new BlockInterdimensionalSU()), LAPOTRONIC_SU(new BlockLapotronicSU()), @@ -494,12 +416,6 @@ public class TRContent { InitUtils.setup(block, name); } - private Machine(B block, Class itemBlock) { - this.name = this.toString().toLowerCase(); - this.block = block; - InitUtils.setup(block, name); - } - public ItemStack getStack() { return new ItemStack(block); } diff --git a/src/main/java/techreborn/itemblocks/ItemBlockAdjustableSU.java b/src/main/java/techreborn/itemblocks/ItemBlockAdjustableSU.java deleted file mode 100644 index 50d7aad4c..000000000 --- a/src/main/java/techreborn/itemblocks/ItemBlockAdjustableSU.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * This file is part of TechReborn, licensed under the MIT License (MIT). - * - * Copyright (c) 2018 TechReborn - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package techreborn.itemblocks; - -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import reborncore.common.powerSystem.PowerSystem; -import techreborn.init.TRContent; -import techreborn.tiles.storage.TileAdjustableSU; - -import java.util.List; - -public class ItemBlockAdjustableSU extends ItemBlock { - - public ItemBlockAdjustableSU(Block p_i45328_1_) { - super(p_i45328_1_); - } - - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List list, ITooltipFlag flag) { - if (!stack.isEmpty() && stack.hasTagCompound()) { - if (stack.getTagCompound().getCompoundTag("tileEntity") != null) - list.add(PowerSystem - .getLocaliszedPower(stack.getTagCompound().getCompoundTag("tileEntity").getInteger("energy"))); - } - } - - @Override - public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, - float hitX, float hitY, float hitZ, IBlockState newState) { - if (!world.setBlockState(pos, newState)) { - return false; - } - if (world.getBlockState(pos).getBlock() == block) { - world.getBlockState(pos).getBlock().onBlockPlacedBy(world, pos, newState, player, stack); - } - if (!stack.isEmpty() && stack.hasTagCompound()) { - ((TileAdjustableSU) world.getTileEntity(pos)) - .readFromNBTWithoutCoords(stack.getTagCompound().getCompoundTag("tileEntity")); - } - return true; - } - - @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs par2CreativeTabs, NonNullList itemList) { - itemList.add(getDropWithNBT(0)); - itemList.add(getDropWithNBT(1000000000)); - } - - public ItemStack getDropWithNBT(double energy) { - NBTTagCompound tileEntity = new NBTTagCompound(); - ItemStack dropStack = TRContent.Machine.ADJUSTABLE_SU.getStack(); - writeToNBTWithoutCoords(tileEntity, energy); - dropStack.setTagCompound(new NBTTagCompound()); - dropStack.getTagCompound().setTag("tileEntity", tileEntity); - return dropStack; - } - - public void writeToNBTWithoutCoords(NBTTagCompound tagCompound, double energy) { - NBTTagCompound data = new NBTTagCompound(); - data.setDouble("energy", energy); - tagCompound.setTag("TilePowerAcceptor", data); - tagCompound.setDouble("energy", energy); - tagCompound.setDouble("euChange", 0); - tagCompound.setDouble("euLastTick", 0); - tagCompound.setBoolean("active", false); - } -} diff --git a/src/main/java/techreborn/itemblocks/ItemBlockDigitalChest.java b/src/main/java/techreborn/itemblocks/ItemBlockDigitalChest.java deleted file mode 100644 index 6840b9784..000000000 --- a/src/main/java/techreborn/itemblocks/ItemBlockDigitalChest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This file is part of TechReborn, licensed under the MIT License (MIT). - * - * Copyright (c) 2018 TechReborn - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package techreborn.itemblocks; - -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import techreborn.tiles.TileDigitalChest; - -import java.util.List; - -public class ItemBlockDigitalChest extends ItemBlock { - - public ItemBlockDigitalChest(Block block) { - super(block); - } - - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List list, ITooltipFlag flag) { - if (!stack.isEmpty() && stack.hasTagCompound()) { - if (stack.getTagCompound().getCompoundTag("tileEntity") != null) - list.add(stack.getTagCompound().getCompoundTag("tileEntity").getInteger("storedQuantity") + " items"); - } - } - - @Override - public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, - float hitX, float hitY, float hitZ, IBlockState newState) { - if (!world.setBlockState(pos, newState)) { - return false; - } - if (world.getBlockState(pos).getBlock() == block) { - world.getBlockState(pos).getBlock().onBlockPlacedBy(world, pos, newState, player, stack); - } - if (!stack.isEmpty() && stack.hasTagCompound()) { - ((TileDigitalChest) world.getTileEntity(pos)) - .readFromNBTWithoutCoords(stack.getTagCompound().getCompoundTag("tileEntity")); - } - return true; - } -} diff --git a/src/main/java/techreborn/itemblocks/ItemBlockQuantumChest.java b/src/main/java/techreborn/itemblocks/ItemBlockQuantumChest.java deleted file mode 100644 index b55d99c82..000000000 --- a/src/main/java/techreborn/itemblocks/ItemBlockQuantumChest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This file is part of TechReborn, licensed under the MIT License (MIT). - * - * Copyright (c) 2018 TechReborn - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package techreborn.itemblocks; - -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import techreborn.tiles.TileQuantumChest; - -import java.util.List; - -public class ItemBlockQuantumChest extends ItemBlock { - - public ItemBlockQuantumChest(Block block) { - super(block); - } - - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List list, ITooltipFlag flag) { - if (!stack.isEmpty() && stack.hasTagCompound()) { - if (stack.getTagCompound().getCompoundTag("tileEntity") != null) - list.add(stack.getTagCompound().getCompoundTag("tileEntity").getInteger("storedQuantity") + " items"); - } - } - - @Override - public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, - float hitX, float hitY, float hitZ, IBlockState newState) { - if (!world.setBlockState(pos, newState)) { - return false; - } - if (world.getBlockState(pos).getBlock() == block) { - world.getBlockState(pos).getBlock().onBlockPlacedBy(world, pos, newState, player, stack); - } - if (!stack.isEmpty() && stack.hasTagCompound()) { - ((TileQuantumChest) world.getTileEntity(pos)) - .readFromNBTWithoutCoords(stack.getTagCompound().getCompoundTag("tileEntity")); - } - return true; - } -} diff --git a/src/main/java/techreborn/itemblocks/ItemBlockQuantumTank.java b/src/main/java/techreborn/itemblocks/ItemBlockQuantumTank.java deleted file mode 100644 index 4a8ac54cc..000000000 --- a/src/main/java/techreborn/itemblocks/ItemBlockQuantumTank.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file is part of TechReborn, licensed under the MIT License (MIT). - * - * Copyright (c) 2018 TechReborn - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package techreborn.itemblocks; - -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import techreborn.tiles.TileQuantumTank; - -public class ItemBlockQuantumTank extends ItemBlock { - - public ItemBlockQuantumTank(Block block) { - super(block); - } - - @Override - public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, - float hitX, float hitY, float hitZ, IBlockState newState) { - if (!world.setBlockState(pos, newState)) { - return false; - } - if (world.getBlockState(pos).getBlock() == block) { - world.getBlockState(pos).getBlock().onBlockPlacedBy(world, pos, newState, player, stack); - } - if (!stack.isEmpty() && stack.hasTagCompound()) { - ((TileQuantumTank) world.getTileEntity(pos)) - .readFromNBTWithoutCoords(stack.getTagCompound().getCompoundTag("tileEntity")); - } - return true; - } -} diff --git a/src/main/java/techreborn/tiles/TileIndustrialCentrifuge.java b/src/main/java/techreborn/tiles/TileIndustrialCentrifuge.java index 297309e5c..d478c0fdd 100644 --- a/src/main/java/techreborn/tiles/TileIndustrialCentrifuge.java +++ b/src/main/java/techreborn/tiles/TileIndustrialCentrifuge.java @@ -71,8 +71,8 @@ public class TileIndustrialCentrifuge extends TileGenericMachine implements ICon // IListInfoProvider @Override - public void addInfo(final List info, final boolean isRealTile) { - super.addInfo(info, isRealTile); + public void addInfo(final List info, final boolean isRealTile, boolean hasData) { + super.addInfo(info, isRealTile, hasData); info.add("Round and round it goes"); } } \ No newline at end of file diff --git a/src/main/java/techreborn/tiles/TilePump.java b/src/main/java/techreborn/tiles/TilePump.java index 72d6a90fd..2d092bd0b 100644 --- a/src/main/java/techreborn/tiles/TilePump.java +++ b/src/main/java/techreborn/tiles/TilePump.java @@ -75,8 +75,8 @@ public class TilePump extends TilePowerAcceptor { } @Override - public void addInfo(List info, boolean isRealTile) { - super.addInfo(info, isRealTile); + public void addInfo(List info, boolean isRealTile, boolean hasData) { + super.addInfo(info, isRealTile, hasData); info.add(TextFormatting.LIGHT_PURPLE + "Eu per extract " + TextFormatting.GREEN + PowerSystem.getLocaliszedPower(pumpExtractEU)); info.add(TextFormatting.LIGHT_PURPLE + "Speed: " + TextFormatting.GREEN diff --git a/src/main/java/techreborn/tiles/TileQuantumTank.java b/src/main/java/techreborn/tiles/TileQuantumTank.java index d54254e6d..ea9d78288 100644 --- a/src/main/java/techreborn/tiles/TileQuantumTank.java +++ b/src/main/java/techreborn/tiles/TileQuantumTank.java @@ -125,8 +125,8 @@ public class TileQuantumTank extends TileMachineBase // IListInfoProvider @Override - public void addInfo(final List info, final boolean isRealTile) { - if (isRealTile) { + public void addInfo(final List info, final boolean isRealTile, boolean hasData) { + if (isRealTile | hasData) { if (this.tank.getFluid() != null) { info.add(this.tank.getFluidAmount() + " of " + this.tank.getFluidType().getName()); } else { diff --git a/src/main/java/techreborn/tiles/TileTechStorageBase.java b/src/main/java/techreborn/tiles/TileTechStorageBase.java index bc21df67f..474ab9497 100644 --- a/src/main/java/techreborn/tiles/TileTechStorageBase.java +++ b/src/main/java/techreborn/tiles/TileTechStorageBase.java @@ -240,8 +240,8 @@ public class TileTechStorageBase extends TileMachineBase // IListInfoProvider @Override - public void addInfo(List info, boolean isRealTile) { - if (isRealTile) { + public void addInfo(List info, boolean isRealTile, boolean hasData) { + if (isRealTile || hasData) { int size = 0; String name = "of nothing"; if (!storedItem.isEmpty()) { diff --git a/src/main/java/techreborn/tiles/cable/TileCable.java b/src/main/java/techreborn/tiles/cable/TileCable.java index 688e4b5d5..e127d9cc7 100644 --- a/src/main/java/techreborn/tiles/cable/TileCable.java +++ b/src/main/java/techreborn/tiles/cable/TileCable.java @@ -238,7 +238,7 @@ public class TileCable extends TileEntity // IListInfoProvider @Override - public void addInfo(List info, boolean isRealTile) { + public void addInfo(List info, boolean isRealTile, boolean hasData) { if (isRealTile) { info.add(TextFormatting.GRAY + StringUtils.t("techreborn.tooltip.transferRate") + ": " + TextFormatting.GOLD diff --git a/src/main/java/techreborn/tiles/generator/TileSolarPanel.java b/src/main/java/techreborn/tiles/generator/TileSolarPanel.java index 4785fc027..4a525dec1 100644 --- a/src/main/java/techreborn/tiles/generator/TileSolarPanel.java +++ b/src/main/java/techreborn/tiles/generator/TileSolarPanel.java @@ -123,7 +123,7 @@ public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop { // TODO: Translate @Override - public void addInfo(List info, boolean isRealTile) { + public void addInfo(List info, boolean isRealTile, boolean hasData) { info.add(TextFormatting.GRAY + "Internal Energy Storage: " + TextFormatting.GOLD + PowerSystem.getLocaliszedPowerFormatted((int) getMaxPower())); diff --git a/src/main/java/techreborn/tiles/transformers/TileTransformer.java b/src/main/java/techreborn/tiles/transformers/TileTransformer.java index eac49be0c..4f595bc8c 100644 --- a/src/main/java/techreborn/tiles/transformers/TileTransformer.java +++ b/src/main/java/techreborn/tiles/transformers/TileTransformer.java @@ -140,7 +140,7 @@ public class TileTransformer extends TilePowerAcceptor // IListInfoProvider @Override - public void addInfo(List info, boolean isRealTile) { + public void addInfo(List info, boolean isRealTile, boolean hasData) { info.add(TextFormatting.GRAY + "Input Rate: " + TextFormatting.GOLD + PowerSystem.getLocaliszedPowerFormatted((int) getMaxInput())); info.add(TextFormatting.GRAY + "Input Tier: " + TextFormatting.GOLD + StringUtils.toFirstCapitalAllLowercase(inputTier.toString())); info.add(TextFormatting.GRAY + "Output Rate: " + TextFormatting.GOLD + PowerSystem.getLocaliszedPowerFormatted((int) getMaxOutput()));