From d5559044118c2048d02a421ee5455f28ba1e1899 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 30 Jan 2019 16:03:41 +0100 Subject: [PATCH] display the amount of items in the adept hopper --- .../blocks/tiles/TileEntityGratedChute.java | 10 +++++++--- .../ellpeck/naturesaura/events/ClientEvents.java | 14 ++++++++++++-- .../resources/assets/naturesaura/lang/en_US.lang | 1 + .../book/en_us/entries/devices/grated_chute.json | 2 +- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGratedChute.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGratedChute.java index b291ae72..e2f85cd2 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGratedChute.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGratedChute.java @@ -19,7 +19,7 @@ import java.util.List; public class TileEntityGratedChute extends TileEntityImpl implements ITickable { - private final ItemStackHandlerNA items = new ItemStackHandlerNA(1, this, false) { + private final ItemStackHandlerNA items = new ItemStackHandlerNA(1, this, true) { @Override protected boolean canExtract(ItemStack stack, int slot, int amount) { return TileEntityGratedChute.this.redstonePower <= 0; @@ -124,15 +124,19 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickable { @Override public void writeNBT(NBTTagCompound compound, SaveType type) { super.writeNBT(compound, type); - if (type != SaveType.BLOCK) + if (type != SaveType.BLOCK) { compound.setInteger("cooldown", this.cooldown); + compound.setTag("items", this.items.serializeNBT()); + } } @Override public void readNBT(NBTTagCompound compound, SaveType type) { super.readNBT(compound, type); - if (type != SaveType.BLOCK) + if (type != SaveType.BLOCK) { this.cooldown = compound.getInteger("cooldown"); + this.items.deserializeNBT(compound.getCompoundTag("items")); + } } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java index 1bdfed3e..68af98e5 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java @@ -9,13 +9,13 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.render.IVisualizable; +import de.ellpeck.naturesaura.blocks.tiles.TileEntityGratedChute; import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar; import de.ellpeck.naturesaura.blocks.tiles.TileEntityRFConverter; import de.ellpeck.naturesaura.compat.Compat; import de.ellpeck.naturesaura.items.ItemRangeVisualizer; import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.particles.ParticleHandler; -import de.ellpeck.naturesaura.particles.ParticleMagic; import net.minecraft.block.Block; import net.minecraft.block.IGrowable; import net.minecraft.block.state.IBlockState; @@ -37,7 +37,6 @@ import net.minecraft.world.biome.BiomeColorHelper; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.common.IPlantable; import net.minecraftforge.energy.EnergyStorage; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -365,6 +364,17 @@ public class ClientEvents { this.drawContainerInfo(storage.getEnergyStored(), storage.getMaxEnergyStored(), 0xcc4916, mc, res, 35, I18n.format("tile.naturesaura.rf_converter.name"), storage.getEnergyStored() + " / " + storage.getMaxEnergyStored() + " RF"); + } else if (tile instanceof TileEntityGratedChute) { + ItemStack stack = ((TileEntityGratedChute) tile).getItemHandler(null).getStackInSlot(0); + + int x = res.getScaledWidth() / 2; + int y = res.getScaledHeight() / 2; + if (stack.isEmpty()) + mc.fontRenderer.drawString( + TextFormatting.GRAY.toString() + TextFormatting.ITALIC + I18n.format("info.naturesaura.empty"), + x + 5, y - 11, 0xFFFFFF, true); + else + Helper.renderItemInGui(stack, x + 2, y - 18, 1F); } } } diff --git a/src/main/resources/assets/naturesaura/lang/en_US.lang b/src/main/resources/assets/naturesaura/lang/en_US.lang index 4fb6a28b..4ec75a3c 100644 --- a/src/main/resources/assets/naturesaura/lang/en_US.lang +++ b/src/main/resources/assets/naturesaura/lang/en_US.lang @@ -91,6 +91,7 @@ info.naturesaura.connected=You made a connection info.naturesaura.same_position=This seems to be the position from your notes... info.naturesaura.too_far=The distance seems too great... info.naturesaura.stored_pos_gone=Your notes seem out of date... +info.naturesaura.empty=Empty advancement.naturesaura.root=Nature's Aura advancement.naturesaura.root.desc=Becoming a magical botanist diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/devices/grated_chute.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/devices/grated_chute.json index 8e7fd0ee..4f880922 100644 --- a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/devices/grated_chute.json +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/devices/grated_chute.json @@ -14,7 +14,7 @@ }, { "type": "crafting", - "text": "Creating the $(item)Adept Hopper$()", + "text": "Creating the $(item)Adept Hopper$()$(p)It should be noted that, when equipping an $(l:items/eye)Environmental Eye$(), the amount of items currently stored in the hopper can be seen.", "recipe": "naturesaura:grated_chute" } ]