From 70abf74ce63eecabe2fa0eea6d688732b6102feb Mon Sep 17 00:00:00 2001 From: Buuz135 Date: Wed, 17 Aug 2022 14:01:52 +0200 Subject: [PATCH] Added GUI display to drawers --- src/generated/resources/.cache/cache | 6 +- .../assets/functionalstorage/lang/en_us.json | 3 + .../functionalstorage/tags/items/drawer.json | 20 ++-- .../minecraft/tags/blocks/mineable/axe.json | 20 ++-- .../functionalstorage/FunctionalStorage.java | 23 +++- .../functionalstorage/block/DrawerBlock.java | 12 +-- .../block/tile/CompactingDrawerTile.java | 23 +++- .../block/tile/DrawerTile.java | 19 +++- .../block/tile/EnderDrawerTile.java | 18 +++- .../block/tile/FramedDrawerTile.java | 4 +- .../client/gui/DrawerInfoGuiAddon.java | 98 ++++++++++++++++++ .../data/FunctionalStorageLangProvider.java | 3 + .../textures/blocks/ender_front.png | Bin 0 -> 9354 bytes 13 files changed, 206 insertions(+), 43 deletions(-) create mode 100644 src/main/java/com/buuz135/functionalstorage/client/gui/DrawerInfoGuiAddon.java create mode 100644 src/main/resources/assets/functionalstorage/textures/blocks/ender_front.png diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index fa7e5a7..d1189e7 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -30,7 +30,7 @@ a50aeb3877dd4003bb3ed359fccde1f3674bc028 assets/functionalstorage/blockstates/sp fbf8ebd85350f3b4ad0bf6faf51f9ecf0677bf5b assets/functionalstorage/blockstates/warped_1.json bcd4b5e128d5175bea44ecae340aeec86cd5a123 assets/functionalstorage/blockstates/warped_2.json ebc4aebffb44baa4dd507078b9fd3c74e881f4c1 assets/functionalstorage/blockstates/warped_4.json -5dc7383bb1c5687debef79e8a194c6e74be6ffd5 assets/functionalstorage/lang/en_us.json +501d78f87031a9873b503d2542b9f980aa00dbae assets/functionalstorage/lang/en_us.json 68c3f6a8fe55202f83c0fcdd6c8ca10ef88019ef assets/functionalstorage/models/block/acacia_1_locked.json c7d0376ba2a080ba12c344369ad11538899db176 assets/functionalstorage/models/block/acacia_2_locked.json 79b86baeec4aa6784aa52028d2f3bc98ddab8c14 assets/functionalstorage/models/block/acacia_4_locked.json @@ -152,7 +152,7 @@ d6b02c345edd356b8e4b7421bdd453f454c6ed7f data/functionalstorage/recipes/storage_ bcb281904eac23183c45786e3d703d24bba92be6 data/functionalstorage/recipes/warped_1.json 91e56e4558ed55571e9972bca1e8a1772655abdd data/functionalstorage/recipes/warped_2.json 344de1ec16ecf9095fd5790c1c60a4014520829e data/functionalstorage/recipes/warped_4.json -a69dc275c6fb31a41441bbc2360001c68ec44281 data/functionalstorage/tags/items/drawer.json +86b5ec941de135e069cb9bc2720818dc03a7e09c data/functionalstorage/tags/items/drawer.json 486a80437ce84b27a3d93db5134ea1fb4f66401f data/functionalstorage/tags/items/ignore_crafting_check.json -a69dc275c6fb31a41441bbc2360001c68ec44281 data/minecraft/tags/blocks/mineable/axe.json +86b5ec941de135e069cb9bc2720818dc03a7e09c data/minecraft/tags/blocks/mineable/axe.json 38cb2a5ac786b577b097edc345083f9a1322b65e data/minecraft/tags/blocks/mineable/pickaxe.json diff --git a/src/generated/resources/assets/functionalstorage/lang/en_us.json b/src/generated/resources/assets/functionalstorage/lang/en_us.json index d13f233..117efaa 100644 --- a/src/generated/resources/assets/functionalstorage/lang/en_us.json +++ b/src/generated/resources/assets/functionalstorage/lang/en_us.json @@ -39,6 +39,9 @@ "configurationtool.use": "Sneak + Right Click in the air to change modes. Right click a drawer to toggle the option.", "drawer.block.contents": "Contents: ", "frameddrawer.use": "How 2 Change Texture: \nInside a crafting window place the block you want use the texture of for the outside of the drawer in the first slot of the crafting window, on the second slot put the block that will be used for the texture on the inside of the framed drawer and on the third slot put a framed drawer. \n", + "gui.functionalstorage.amount": "Amount: ", + "gui.functionalstorage.item": "Item: ", + "gui.functionalstorage.slot": "Slot: ", "item.functionalstorage.collector_upgrade": "Collector Upgrade", "item.functionalstorage.configuration_tool": "Configuration Tool", "item.functionalstorage.copper_upgrade": "Copper Upgrade", diff --git a/src/generated/resources/data/functionalstorage/tags/items/drawer.json b/src/generated/resources/data/functionalstorage/tags/items/drawer.json index 2ba6b2a..2fa78ec 100644 --- a/src/generated/resources/data/functionalstorage/tags/items/drawer.json +++ b/src/generated/resources/data/functionalstorage/tags/items/drawer.json @@ -10,15 +10,6 @@ "functionalstorage:crimson_1", "functionalstorage:warped_1", "functionalstorage:framed_1", - "functionalstorage:oak_2", - "functionalstorage:spruce_2", - "functionalstorage:birch_2", - "functionalstorage:jungle_2", - "functionalstorage:acacia_2", - "functionalstorage:dark_oak_2", - "functionalstorage:crimson_2", - "functionalstorage:warped_2", - "functionalstorage:framed_2", "functionalstorage:oak_4", "functionalstorage:spruce_4", "functionalstorage:birch_4", @@ -27,6 +18,15 @@ "functionalstorage:dark_oak_4", "functionalstorage:crimson_4", "functionalstorage:warped_4", - "functionalstorage:framed_4" + "functionalstorage:framed_4", + "functionalstorage:oak_2", + "functionalstorage:spruce_2", + "functionalstorage:birch_2", + "functionalstorage:jungle_2", + "functionalstorage:acacia_2", + "functionalstorage:dark_oak_2", + "functionalstorage:crimson_2", + "functionalstorage:warped_2", + "functionalstorage:framed_2" ] } \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json b/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json index 2ba6b2a..2fa78ec 100644 --- a/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json +++ b/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json @@ -10,15 +10,6 @@ "functionalstorage:crimson_1", "functionalstorage:warped_1", "functionalstorage:framed_1", - "functionalstorage:oak_2", - "functionalstorage:spruce_2", - "functionalstorage:birch_2", - "functionalstorage:jungle_2", - "functionalstorage:acacia_2", - "functionalstorage:dark_oak_2", - "functionalstorage:crimson_2", - "functionalstorage:warped_2", - "functionalstorage:framed_2", "functionalstorage:oak_4", "functionalstorage:spruce_4", "functionalstorage:birch_4", @@ -27,6 +18,15 @@ "functionalstorage:dark_oak_4", "functionalstorage:crimson_4", "functionalstorage:warped_4", - "functionalstorage:framed_4" + "functionalstorage:framed_4", + "functionalstorage:oak_2", + "functionalstorage:spruce_2", + "functionalstorage:birch_2", + "functionalstorage:jungle_2", + "functionalstorage:acacia_2", + "functionalstorage:dark_oak_2", + "functionalstorage:crimson_2", + "functionalstorage:warped_2", + "functionalstorage:framed_2" ] } \ No newline at end of file diff --git a/src/main/java/com/buuz135/functionalstorage/FunctionalStorage.java b/src/main/java/com/buuz135/functionalstorage/FunctionalStorage.java index f13b103..6c9e7cf 100644 --- a/src/main/java/com/buuz135/functionalstorage/FunctionalStorage.java +++ b/src/main/java/com/buuz135/functionalstorage/FunctionalStorage.java @@ -77,6 +77,7 @@ import java.awt.*; import java.util.List; import java.util.*; import java.util.function.Consumer; +import java.util.function.Function; import java.util.stream.Collectors; // The value here should match an entry in the META-INF/mods.toml file @@ -194,18 +195,28 @@ public class FunctionalStorage extends ModuleController { } public enum DrawerType { - X_1(1, 32 * 64, "1x1"), - X_2(2, 16 * 64, "1x2"), - X_4(4, 8 * 64, "2x2"); + X_1(1, 32 * 64, "1x1", integer -> Pair.of(16, 16)), + X_2(2, 16 * 64, "1x2", integer -> { + if (integer == 0) return Pair.of(16, 28); + return Pair.of(16, 4); + }), + X_4(4, 8 * 64, "2x2", integer -> { + if (integer == 0) return Pair.of(28, 28); + if (integer == 1) return Pair.of(4, 28); + if (integer == 2) return Pair.of(28, 4); + return Pair.of(4, 4); + }); private final int slots; private final int slotAmount; private final String displayName; + private final Function> slotPosition; - private DrawerType(int slots, int slotAmount, String displayName) { + private DrawerType(int slots, int slotAmount, String displayName, Function> slotPosition) { this.slots = slots; this.slotAmount = slotAmount; this.displayName = displayName; + this.slotPosition = slotPosition; } public int getSlots() { @@ -219,6 +230,10 @@ public class FunctionalStorage extends ModuleController { public String getDisplayName() { return displayName; } + + public Function> getSlotPosition() { + return slotPosition; + } } @OnlyIn(Dist.CLIENT) diff --git a/src/main/java/com/buuz135/functionalstorage/block/DrawerBlock.java b/src/main/java/com/buuz135/functionalstorage/block/DrawerBlock.java index e171352..0d91f32 100644 --- a/src/main/java/com/buuz135/functionalstorage/block/DrawerBlock.java +++ b/src/main/java/com/buuz135/functionalstorage/block/DrawerBlock.java @@ -12,7 +12,6 @@ import com.google.common.collect.Multimap; import com.google.common.collect.MultimapBuilder; import com.hrznstudio.titanium.block.RotatableBlock; import com.hrznstudio.titanium.datagenerator.loot.block.BasicBlockLootTables; -import com.hrznstudio.titanium.module.DeferredRegistryHelper; import com.hrznstudio.titanium.recipe.generator.TitaniumShapedRecipeBuilder; import com.hrznstudio.titanium.util.RayTraceUtils; import com.hrznstudio.titanium.util.TileUtil; @@ -25,14 +24,12 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.tooltip.TooltipComponent; import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.level.BlockGetter; @@ -61,10 +58,11 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.annotation.Nonnull; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; import java.util.function.Consumer; -import java.util.function.Supplier; -import java.util.stream.Collectors; public class DrawerBlock extends RotatableBlock { @@ -144,7 +142,7 @@ public class DrawerBlock extends RotatableBlock { @Override public BlockEntityType.BlockEntitySupplier getTileEntityFactory() { - return (blockPos, state) -> new DrawerTile(this, (BlockEntityType) FunctionalStorage.DRAWER_TYPES.get(type).stream().filter(registryObjectRegistryObjectPair -> registryObjectRegistryObjectPair.getLeft().get().equals(this)).map(Pair::getRight).findFirst().get().get(), blockPos, state, type); + return (blockPos, state) -> new DrawerTile(this, (BlockEntityType) FunctionalStorage.DRAWER_TYPES.get(type).stream().filter(registryObjectRegistryObjectPair -> registryObjectRegistryObjectPair.getLeft().get().equals(this)).map(Pair::getRight).findFirst().get().get(), blockPos, state, type, woodType); } @Override diff --git a/src/main/java/com/buuz135/functionalstorage/block/tile/CompactingDrawerTile.java b/src/main/java/com/buuz135/functionalstorage/block/tile/CompactingDrawerTile.java index aed3e89..76fd2f4 100644 --- a/src/main/java/com/buuz135/functionalstorage/block/tile/CompactingDrawerTile.java +++ b/src/main/java/com/buuz135/functionalstorage/block/tile/CompactingDrawerTile.java @@ -1,12 +1,14 @@ package com.buuz135.functionalstorage.block.tile; import com.buuz135.functionalstorage.FunctionalStorage; +import com.buuz135.functionalstorage.client.gui.DrawerInfoGuiAddon; import com.buuz135.functionalstorage.inventory.CompactingInventoryHandler; import com.buuz135.functionalstorage.util.CompactingUtil; import com.hrznstudio.titanium.annotation.Save; import com.hrznstudio.titanium.block.BasicTileBlock; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; @@ -18,6 +20,7 @@ import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; +import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull; @@ -68,11 +71,27 @@ public class CompactingDrawerTile extends ControllableDrawerTile new DrawerInfoGuiAddon(64, 16, + new ResourceLocation(FunctionalStorage.MOD_ID, "textures/blocks/compacting_drawer_front.png"), + 3, + integer -> { + if (integer == 0) return Pair.of(28, 28); + if (integer == 1) return Pair.of(4, 28); + return Pair.of(16, 4); + }, + integer -> getStorage().getStackInSlot(integer), + integer -> getStorage().getSlotLimit(integer) + )); + } + @Override public void serverTick(Level level, BlockPos pos, BlockState state, CompactingDrawerTile blockEntity) { super.serverTick(level, pos, state, blockEntity); - if (!hasCheckedRecipes){ - if (!handler.getParent().isEmpty()){ + if (!hasCheckedRecipes) { + if (!handler.getParent().isEmpty()) { CompactingUtil compactingUtil = new CompactingUtil(this.level); compactingUtil.setup(handler.getParent()); handler.setup(compactingUtil); diff --git a/src/main/java/com/buuz135/functionalstorage/block/tile/DrawerTile.java b/src/main/java/com/buuz135/functionalstorage/block/tile/DrawerTile.java index ba6aa28..43c4e71 100644 --- a/src/main/java/com/buuz135/functionalstorage/block/tile/DrawerTile.java +++ b/src/main/java/com/buuz135/functionalstorage/block/tile/DrawerTile.java @@ -1,11 +1,14 @@ package com.buuz135.functionalstorage.block.tile; import com.buuz135.functionalstorage.FunctionalStorage; +import com.buuz135.functionalstorage.client.gui.DrawerInfoGuiAddon; import com.buuz135.functionalstorage.inventory.BigInventoryHandler; +import com.buuz135.functionalstorage.util.IWoodType; import com.hrznstudio.titanium.annotation.Save; import com.hrznstudio.titanium.block.BasicTileBlock; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; @@ -27,10 +30,12 @@ public class DrawerTile extends ControllableDrawerTile { public BigInventoryHandler handler; private final LazyOptional lazyStorage; private FunctionalStorage.DrawerType type; + private IWoodType woodType; - public DrawerTile(BasicTileBlock base, BlockEntityType blockEntityType, BlockPos pos, BlockState state, FunctionalStorage.DrawerType type) { + public DrawerTile(BasicTileBlock base, BlockEntityType blockEntityType, BlockPos pos, BlockState state, FunctionalStorage.DrawerType type, IWoodType woodType) { super(base, blockEntityType, pos, state); this.type = type; + this.woodType = woodType; this.handler = new BigInventoryHandler(type) { @Override public void onChange() { @@ -67,6 +72,18 @@ public class DrawerTile extends ControllableDrawerTile { lazyStorage = LazyOptional.of(() -> this.handler); } + @Override + public void initClient() { + super.initClient(); + addGuiAddonFactory(() -> new DrawerInfoGuiAddon(64, 16, + new ResourceLocation(FunctionalStorage.MOD_ID, "textures/blocks/" + woodType.getName() + "_front_" + type.getSlots() + ".png"), + type.getSlots(), + type.getSlotPosition(), + integer -> getHandler().getStackInSlot(integer), + integer -> getHandler().getSlotLimit(integer) + )); + } + @Nonnull @Override public LazyOptional getCapability(@Nonnull Capability cap, @Nullable Direction side) { diff --git a/src/main/java/com/buuz135/functionalstorage/block/tile/EnderDrawerTile.java b/src/main/java/com/buuz135/functionalstorage/block/tile/EnderDrawerTile.java index 1a2bb04..03c3fc9 100644 --- a/src/main/java/com/buuz135/functionalstorage/block/tile/EnderDrawerTile.java +++ b/src/main/java/com/buuz135/functionalstorage/block/tile/EnderDrawerTile.java @@ -1,17 +1,16 @@ package com.buuz135.functionalstorage.block.tile; import com.buuz135.functionalstorage.FunctionalStorage; -import com.buuz135.functionalstorage.block.DrawerBlock; -import com.buuz135.functionalstorage.inventory.BigInventoryHandler; +import com.buuz135.functionalstorage.client.gui.DrawerInfoGuiAddon; import com.buuz135.functionalstorage.inventory.EnderInventoryHandler; import com.buuz135.functionalstorage.network.EnderDrawerSyncMessage; import com.buuz135.functionalstorage.world.EnderSavedData; import com.hrznstudio.titanium.annotation.Save; import com.hrznstudio.titanium.block.BasicTileBlock; -import com.mojang.datafixers.types.Func; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; @@ -24,7 +23,6 @@ import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; -import net.minecraftforge.network.NetworkDirection; import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull; @@ -50,6 +48,18 @@ public class EnderDrawerTile extends ControllableDrawerTile { this.lazyStorage = LazyOptional.of(() -> EnderSavedData.getInstance(this.level).getFrequency(this.frequency)); } + @Override + public void initClient() { + super.initClient(); + addGuiAddonFactory(() -> new DrawerInfoGuiAddon(64, 16, + new ResourceLocation(FunctionalStorage.MOD_ID, "textures/blocks/ender_front.png"), + 1, + FunctionalStorage.DrawerType.X_1.getSlotPosition(), + integer -> getStorage().getStackInSlot(integer), + integer -> getStorage().getSlotLimit(integer) + )); + } + @Nonnull @Override public LazyOptional getCapability(@Nonnull Capability cap, @Nullable Direction side) { diff --git a/src/main/java/com/buuz135/functionalstorage/block/tile/FramedDrawerTile.java b/src/main/java/com/buuz135/functionalstorage/block/tile/FramedDrawerTile.java index e6ecd12..108f9e3 100644 --- a/src/main/java/com/buuz135/functionalstorage/block/tile/FramedDrawerTile.java +++ b/src/main/java/com/buuz135/functionalstorage/block/tile/FramedDrawerTile.java @@ -2,10 +2,10 @@ package com.buuz135.functionalstorage.block.tile; import com.buuz135.functionalstorage.FunctionalStorage; import com.buuz135.functionalstorage.client.model.FramedDrawerModelData; +import com.buuz135.functionalstorage.util.DrawerWoodType; import com.hrznstudio.titanium.annotation.Save; import com.hrznstudio.titanium.block.BasicTileBlock; import net.minecraft.core.BlockPos; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.client.model.data.IModelData; @@ -19,7 +19,7 @@ public class FramedDrawerTile extends DrawerTile{ private FramedDrawerModelData framedDrawerModelData; public FramedDrawerTile(BasicTileBlock base, BlockEntityType blockEntityType, BlockPos pos, BlockState state, FunctionalStorage.DrawerType type) { - super(base, blockEntityType, pos, state, type); + super(base, blockEntityType, pos, state, type, DrawerWoodType.FRAMED); this.framedDrawerModelData = new FramedDrawerModelData(new HashMap<>()); } diff --git a/src/main/java/com/buuz135/functionalstorage/client/gui/DrawerInfoGuiAddon.java b/src/main/java/com/buuz135/functionalstorage/client/gui/DrawerInfoGuiAddon.java new file mode 100644 index 0000000..92e902d --- /dev/null +++ b/src/main/java/com/buuz135/functionalstorage/client/gui/DrawerInfoGuiAddon.java @@ -0,0 +1,98 @@ +package com.buuz135.functionalstorage.client.gui; + +import com.buuz135.functionalstorage.util.NumberUtils; +import com.hrznstudio.titanium.client.screen.addon.BasicScreenAddon; +import com.hrznstudio.titanium.client.screen.asset.IAssetProvider; +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import org.apache.commons.lang3.tuple.Pair; + +import java.util.ArrayList; +import java.util.Optional; +import java.util.function.Function; + +public class DrawerInfoGuiAddon extends BasicScreenAddon { + + private final ResourceLocation gui; + private final int slotAmount; + private final Function> slotPosition; + private final Function slotStack; + private final Function slotMaxAmount; + + public DrawerInfoGuiAddon(int posX, int posY, ResourceLocation gui, int slotAmount, Function> slotPosition, Function slotStack, Function slotMaxAmount) { + super(posX, posY); + this.gui = gui; + this.slotAmount = slotAmount; + this.slotPosition = slotPosition; + this.slotStack = slotStack; + this.slotMaxAmount = slotMaxAmount; + } + + @Override + public int getXSize() { + return 0; + } + + @Override + public int getYSize() { + return 0; + } + + @Override + public void drawBackgroundLayer(PoseStack stack, Screen screen, IAssetProvider provider, int guiX, int guiY, int mouseX, int mouseY, float partialTicks) { + RenderSystem.setShaderTexture(0, gui); + var size = 16 * 2 + 16; + Screen.blit(stack, guiX + getPosX(), guiY + getPosY(), 0, 0, size, size, size, size); + for (var i = 0; i < slotAmount; i++) { + var itemStack = slotStack.apply(i); + if (!itemStack.isEmpty()) { + var x = guiX + slotPosition.apply(i).getLeft() + getPosX(); + var y = guiY + slotPosition.apply(i).getRight() + getPosY(); + Minecraft.getInstance().getItemRenderer().renderGuiItem(slotStack.apply(i), x, y); + var amount = NumberUtils.getFormatedBigNumber(itemStack.getCount()) + "/" + NumberUtils.getFormatedBigNumber(slotMaxAmount.apply(i)); + var scale = 0.5f; + stack.translate(0, 0, 200); + stack.scale(scale, scale, scale); + Minecraft.getInstance().font.drawShadow(stack, amount, (x + 17 - Minecraft.getInstance().font.width(amount) / 2) * (1 / scale), (y + 12) * (1 / scale), 0xFFFFFF); + stack.scale(1 / scale, 1 / scale, 1 / scale); + stack.translate(0, 0, -200); + } + } + } + + @Override + public void drawForegroundLayer(PoseStack stack, Screen screen, IAssetProvider provider, int guiX, int guiY, int mouseX, int mouseY, float partialTicks) { + for (var i = 0; i < slotAmount; i++) { + var x = slotPosition.apply(i).getLeft() + getPosX() + guiX; + var y = slotPosition.apply(i).getRight() + getPosY() + guiY; + if (mouseX > x && mouseX < x + 18 && mouseY > y && mouseY < y + 18) { + x = slotPosition.apply(i).getLeft() + getPosX(); + y = slotPosition.apply(i).getRight() + getPosY(); + stack.translate(0, 0, 200); + GuiComponent.fill(stack, x - 1, y - 1, x + 17, y + 17, -2130706433); + stack.translate(0, 0, -200); + var componentList = new ArrayList(); + var over = slotStack.apply(i); + if (over.isEmpty()) { + componentList.add(new TranslatableComponent("gui.functionalstorage.item").withStyle(ChatFormatting.GOLD).append(new TextComponent("Empty").withStyle(ChatFormatting.WHITE))); + } else { + componentList.add(new TranslatableComponent("gui.functionalstorage.item").withStyle(ChatFormatting.GOLD).append(over.getHoverName().copy().withStyle(ChatFormatting.WHITE))); + var amount = NumberUtils.getFormatedBigNumber(over.getCount()) + "/" + NumberUtils.getFormatedBigNumber(slotMaxAmount.apply(i)); + componentList.add(new TranslatableComponent("gui.functionalstorage.amount").withStyle(ChatFormatting.GOLD).append(new TextComponent(amount).withStyle(ChatFormatting.WHITE))); + } + componentList.add(new TranslatableComponent("gui.functionalstorage.slot").withStyle(ChatFormatting.GOLD).append(new TextComponent(i + "").withStyle(ChatFormatting.WHITE))); + screen.renderTooltip(stack, componentList, Optional.empty(), mouseX - guiX, mouseY - guiY); + } + } + } + +} diff --git a/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageLangProvider.java b/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageLangProvider.java index 9a0bba9..a729caf 100644 --- a/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageLangProvider.java +++ b/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageLangProvider.java @@ -74,5 +74,8 @@ public class FunctionalStorageLangProvider extends LanguageProvider { this.add("frameddrawer.use", "How 2 Change Texture: \nInside a crafting window place the block you want use the texture of for the outside of the drawer in the first slot of the crafting window, on the second slot put the block that will be used for the texture on the inside of the framed drawer and on the third slot put a framed drawer. \n"); this.add("item.utility.slot", "Slot: "); this.add("item.utility.slot.desc", "Right click in a GUI to change slot"); + this.add("gui.functionalstorage.item", "Item: "); + this.add("gui.functionalstorage.amount", "Amount: "); + this.add("gui.functionalstorage.slot", "Slot: "); } } diff --git a/src/main/resources/assets/functionalstorage/textures/blocks/ender_front.png b/src/main/resources/assets/functionalstorage/textures/blocks/ender_front.png new file mode 100644 index 0000000000000000000000000000000000000000..4fc68cb7e42ae4be439420a2bd8a87c12dea9fab GIT binary patch literal 9354 zcmeHMcUTiy*N>ut*kBbAY%$^@D?_FxlL#mR0&CUti|!mim}-%5j{K?sZ{-#nH&LgZ?S!+H;;*Uv6@GzgcyYC*3j}Uq)AR zR?Rte!tBKAPSm4HvnTzg_3JUQZ`gdF*DpA|kN&2r)?9%q5=WQV*iMcK@($lsViy~w zYog9L(KKt;&&SA9eJTfKU$9g!-S+g*FsJq@aZ1nm_BOeji^s3GwC$SM!tvy&aQ&#J zJ{enEuPo2GrSBbX--+2=-iFj1I%d1{ramcheM)-gg9}?OD_Qqu@rlW| zJ8wrdKcMSvt7xr1D$ML}QE`0PD$c_nZ|_mQoDyfys6m@Hz8RV;IMu6a^3QI#DWdb z__nSahAiu!vY2aK&Ny*Th}zY7EndCm`jNg5lOL5hR_@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