Added GUI display to drawers
This commit is contained in:
parent
a38c2a773a
commit
70abf74ce6
|
@ -30,7 +30,7 @@ a50aeb3877dd4003bb3ed359fccde1f3674bc028 assets/functionalstorage/blockstates/sp
|
||||||
fbf8ebd85350f3b4ad0bf6faf51f9ecf0677bf5b assets/functionalstorage/blockstates/warped_1.json
|
fbf8ebd85350f3b4ad0bf6faf51f9ecf0677bf5b assets/functionalstorage/blockstates/warped_1.json
|
||||||
bcd4b5e128d5175bea44ecae340aeec86cd5a123 assets/functionalstorage/blockstates/warped_2.json
|
bcd4b5e128d5175bea44ecae340aeec86cd5a123 assets/functionalstorage/blockstates/warped_2.json
|
||||||
ebc4aebffb44baa4dd507078b9fd3c74e881f4c1 assets/functionalstorage/blockstates/warped_4.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
|
68c3f6a8fe55202f83c0fcdd6c8ca10ef88019ef assets/functionalstorage/models/block/acacia_1_locked.json
|
||||||
c7d0376ba2a080ba12c344369ad11538899db176 assets/functionalstorage/models/block/acacia_2_locked.json
|
c7d0376ba2a080ba12c344369ad11538899db176 assets/functionalstorage/models/block/acacia_2_locked.json
|
||||||
79b86baeec4aa6784aa52028d2f3bc98ddab8c14 assets/functionalstorage/models/block/acacia_4_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
|
bcb281904eac23183c45786e3d703d24bba92be6 data/functionalstorage/recipes/warped_1.json
|
||||||
91e56e4558ed55571e9972bca1e8a1772655abdd data/functionalstorage/recipes/warped_2.json
|
91e56e4558ed55571e9972bca1e8a1772655abdd data/functionalstorage/recipes/warped_2.json
|
||||||
344de1ec16ecf9095fd5790c1c60a4014520829e data/functionalstorage/recipes/warped_4.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
|
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
|
38cb2a5ac786b577b097edc345083f9a1322b65e data/minecraft/tags/blocks/mineable/pickaxe.json
|
||||||
|
|
|
@ -39,6 +39,9 @@
|
||||||
"configurationtool.use": "Sneak + Right Click in the air to change modes. Right click a drawer to toggle the option.",
|
"configurationtool.use": "Sneak + Right Click in the air to change modes. Right click a drawer to toggle the option.",
|
||||||
"drawer.block.contents": "Contents: ",
|
"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",
|
"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.collector_upgrade": "Collector Upgrade",
|
||||||
"item.functionalstorage.configuration_tool": "Configuration Tool",
|
"item.functionalstorage.configuration_tool": "Configuration Tool",
|
||||||
"item.functionalstorage.copper_upgrade": "Copper Upgrade",
|
"item.functionalstorage.copper_upgrade": "Copper Upgrade",
|
||||||
|
|
|
@ -10,15 +10,6 @@
|
||||||
"functionalstorage:crimson_1",
|
"functionalstorage:crimson_1",
|
||||||
"functionalstorage:warped_1",
|
"functionalstorage:warped_1",
|
||||||
"functionalstorage:framed_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:oak_4",
|
||||||
"functionalstorage:spruce_4",
|
"functionalstorage:spruce_4",
|
||||||
"functionalstorage:birch_4",
|
"functionalstorage:birch_4",
|
||||||
|
@ -27,6 +18,15 @@
|
||||||
"functionalstorage:dark_oak_4",
|
"functionalstorage:dark_oak_4",
|
||||||
"functionalstorage:crimson_4",
|
"functionalstorage:crimson_4",
|
||||||
"functionalstorage:warped_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"
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -10,15 +10,6 @@
|
||||||
"functionalstorage:crimson_1",
|
"functionalstorage:crimson_1",
|
||||||
"functionalstorage:warped_1",
|
"functionalstorage:warped_1",
|
||||||
"functionalstorage:framed_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:oak_4",
|
||||||
"functionalstorage:spruce_4",
|
"functionalstorage:spruce_4",
|
||||||
"functionalstorage:birch_4",
|
"functionalstorage:birch_4",
|
||||||
|
@ -27,6 +18,15 @@
|
||||||
"functionalstorage:dark_oak_4",
|
"functionalstorage:dark_oak_4",
|
||||||
"functionalstorage:crimson_4",
|
"functionalstorage:crimson_4",
|
||||||
"functionalstorage:warped_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"
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -77,6 +77,7 @@ import java.awt.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
// The value here should match an entry in the META-INF/mods.toml file
|
// 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 {
|
public enum DrawerType {
|
||||||
X_1(1, 32 * 64, "1x1"),
|
X_1(1, 32 * 64, "1x1", integer -> Pair.of(16, 16)),
|
||||||
X_2(2, 16 * 64, "1x2"),
|
X_2(2, 16 * 64, "1x2", integer -> {
|
||||||
X_4(4, 8 * 64, "2x2");
|
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 slots;
|
||||||
private final int slotAmount;
|
private final int slotAmount;
|
||||||
private final String displayName;
|
private final String displayName;
|
||||||
|
private final Function<Integer, Pair<Integer, Integer>> slotPosition;
|
||||||
|
|
||||||
private DrawerType(int slots, int slotAmount, String displayName) {
|
private DrawerType(int slots, int slotAmount, String displayName, Function<Integer, Pair<Integer, Integer>> slotPosition) {
|
||||||
this.slots = slots;
|
this.slots = slots;
|
||||||
this.slotAmount = slotAmount;
|
this.slotAmount = slotAmount;
|
||||||
this.displayName = displayName;
|
this.displayName = displayName;
|
||||||
|
this.slotPosition = slotPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSlots() {
|
public int getSlots() {
|
||||||
|
@ -219,6 +230,10 @@ public class FunctionalStorage extends ModuleController {
|
||||||
public String getDisplayName() {
|
public String getDisplayName() {
|
||||||
return displayName;
|
return displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Function<Integer, Pair<Integer, Integer>> getSlotPosition() {
|
||||||
|
return slotPosition;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
|
|
@ -12,7 +12,6 @@ import com.google.common.collect.Multimap;
|
||||||
import com.google.common.collect.MultimapBuilder;
|
import com.google.common.collect.MultimapBuilder;
|
||||||
import com.hrznstudio.titanium.block.RotatableBlock;
|
import com.hrznstudio.titanium.block.RotatableBlock;
|
||||||
import com.hrznstudio.titanium.datagenerator.loot.block.BasicBlockLootTables;
|
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.recipe.generator.TitaniumShapedRecipeBuilder;
|
||||||
import com.hrznstudio.titanium.util.RayTraceUtils;
|
import com.hrznstudio.titanium.util.RayTraceUtils;
|
||||||
import com.hrznstudio.titanium.util.TileUtil;
|
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.TextComponent;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
import net.minecraft.network.chat.TranslatableComponent;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||||
import net.minecraft.world.item.BlockItem;
|
import net.minecraft.world.item.BlockItem;
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.TooltipFlag;
|
import net.minecraft.world.item.TooltipFlag;
|
||||||
import net.minecraft.world.level.BlockGetter;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
|
@ -61,10 +58,11 @@ import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
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.Consumer;
|
||||||
import java.util.function.Supplier;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class DrawerBlock extends RotatableBlock<DrawerTile> {
|
public class DrawerBlock extends RotatableBlock<DrawerTile> {
|
||||||
|
|
||||||
|
@ -144,7 +142,7 @@ public class DrawerBlock extends RotatableBlock<DrawerTile> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockEntityType.BlockEntitySupplier<DrawerTile> getTileEntityFactory() {
|
public BlockEntityType.BlockEntitySupplier<DrawerTile> getTileEntityFactory() {
|
||||||
return (blockPos, state) -> new DrawerTile(this, (BlockEntityType<DrawerTile>) 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<DrawerTile>) FunctionalStorage.DRAWER_TYPES.get(type).stream().filter(registryObjectRegistryObjectPair -> registryObjectRegistryObjectPair.getLeft().get().equals(this)).map(Pair::getRight).findFirst().get().get(), blockPos, state, type, woodType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
package com.buuz135.functionalstorage.block.tile;
|
package com.buuz135.functionalstorage.block.tile;
|
||||||
|
|
||||||
import com.buuz135.functionalstorage.FunctionalStorage;
|
import com.buuz135.functionalstorage.FunctionalStorage;
|
||||||
|
import com.buuz135.functionalstorage.client.gui.DrawerInfoGuiAddon;
|
||||||
import com.buuz135.functionalstorage.inventory.CompactingInventoryHandler;
|
import com.buuz135.functionalstorage.inventory.CompactingInventoryHandler;
|
||||||
import com.buuz135.functionalstorage.util.CompactingUtil;
|
import com.buuz135.functionalstorage.util.CompactingUtil;
|
||||||
import com.hrznstudio.titanium.annotation.Save;
|
import com.hrznstudio.titanium.annotation.Save;
|
||||||
import com.hrznstudio.titanium.block.BasicTileBlock;
|
import com.hrznstudio.titanium.block.BasicTileBlock;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.entity.player.Player;
|
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.common.util.LazyOptional;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
@ -68,11 +71,27 @@ public class CompactingDrawerTile extends ControllableDrawerTile<CompactingDrawe
|
||||||
this.hasCheckedRecipes = false;
|
this.hasCheckedRecipes = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initClient() {
|
||||||
|
super.initClient();
|
||||||
|
addGuiAddonFactory(() -> 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
|
@Override
|
||||||
public void serverTick(Level level, BlockPos pos, BlockState state, CompactingDrawerTile blockEntity) {
|
public void serverTick(Level level, BlockPos pos, BlockState state, CompactingDrawerTile blockEntity) {
|
||||||
super.serverTick(level, pos, state, blockEntity);
|
super.serverTick(level, pos, state, blockEntity);
|
||||||
if (!hasCheckedRecipes){
|
if (!hasCheckedRecipes) {
|
||||||
if (!handler.getParent().isEmpty()){
|
if (!handler.getParent().isEmpty()) {
|
||||||
CompactingUtil compactingUtil = new CompactingUtil(this.level);
|
CompactingUtil compactingUtil = new CompactingUtil(this.level);
|
||||||
compactingUtil.setup(handler.getParent());
|
compactingUtil.setup(handler.getParent());
|
||||||
handler.setup(compactingUtil);
|
handler.setup(compactingUtil);
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
package com.buuz135.functionalstorage.block.tile;
|
package com.buuz135.functionalstorage.block.tile;
|
||||||
|
|
||||||
import com.buuz135.functionalstorage.FunctionalStorage;
|
import com.buuz135.functionalstorage.FunctionalStorage;
|
||||||
|
import com.buuz135.functionalstorage.client.gui.DrawerInfoGuiAddon;
|
||||||
import com.buuz135.functionalstorage.inventory.BigInventoryHandler;
|
import com.buuz135.functionalstorage.inventory.BigInventoryHandler;
|
||||||
|
import com.buuz135.functionalstorage.util.IWoodType;
|
||||||
import com.hrznstudio.titanium.annotation.Save;
|
import com.hrznstudio.titanium.annotation.Save;
|
||||||
import com.hrznstudio.titanium.block.BasicTileBlock;
|
import com.hrznstudio.titanium.block.BasicTileBlock;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
@ -27,10 +30,12 @@ public class DrawerTile extends ControllableDrawerTile<DrawerTile> {
|
||||||
public BigInventoryHandler handler;
|
public BigInventoryHandler handler;
|
||||||
private final LazyOptional<IItemHandler> lazyStorage;
|
private final LazyOptional<IItemHandler> lazyStorage;
|
||||||
private FunctionalStorage.DrawerType type;
|
private FunctionalStorage.DrawerType type;
|
||||||
|
private IWoodType woodType;
|
||||||
|
|
||||||
public DrawerTile(BasicTileBlock<DrawerTile> base, BlockEntityType<DrawerTile> blockEntityType, BlockPos pos, BlockState state, FunctionalStorage.DrawerType type) {
|
public DrawerTile(BasicTileBlock<DrawerTile> base, BlockEntityType<DrawerTile> blockEntityType, BlockPos pos, BlockState state, FunctionalStorage.DrawerType type, IWoodType woodType) {
|
||||||
super(base, blockEntityType, pos, state);
|
super(base, blockEntityType, pos, state);
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
this.woodType = woodType;
|
||||||
this.handler = new BigInventoryHandler(type) {
|
this.handler = new BigInventoryHandler(type) {
|
||||||
@Override
|
@Override
|
||||||
public void onChange() {
|
public void onChange() {
|
||||||
|
@ -67,6 +72,18 @@ public class DrawerTile extends ControllableDrawerTile<DrawerTile> {
|
||||||
lazyStorage = LazyOptional.of(() -> this.handler);
|
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
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public <U> LazyOptional<U> getCapability(@Nonnull Capability<U> cap, @Nullable Direction side) {
|
public <U> LazyOptional<U> getCapability(@Nonnull Capability<U> cap, @Nullable Direction side) {
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
package com.buuz135.functionalstorage.block.tile;
|
package com.buuz135.functionalstorage.block.tile;
|
||||||
|
|
||||||
import com.buuz135.functionalstorage.FunctionalStorage;
|
import com.buuz135.functionalstorage.FunctionalStorage;
|
||||||
import com.buuz135.functionalstorage.block.DrawerBlock;
|
import com.buuz135.functionalstorage.client.gui.DrawerInfoGuiAddon;
|
||||||
import com.buuz135.functionalstorage.inventory.BigInventoryHandler;
|
|
||||||
import com.buuz135.functionalstorage.inventory.EnderInventoryHandler;
|
import com.buuz135.functionalstorage.inventory.EnderInventoryHandler;
|
||||||
import com.buuz135.functionalstorage.network.EnderDrawerSyncMessage;
|
import com.buuz135.functionalstorage.network.EnderDrawerSyncMessage;
|
||||||
import com.buuz135.functionalstorage.world.EnderSavedData;
|
import com.buuz135.functionalstorage.world.EnderSavedData;
|
||||||
import com.hrznstudio.titanium.annotation.Save;
|
import com.hrznstudio.titanium.annotation.Save;
|
||||||
import com.hrznstudio.titanium.block.BasicTileBlock;
|
import com.hrznstudio.titanium.block.BasicTileBlock;
|
||||||
import com.mojang.datafixers.types.Func;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
|
@ -24,7 +23,6 @@ import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.network.NetworkDirection;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
@ -50,6 +48,18 @@ public class EnderDrawerTile extends ControllableDrawerTile<EnderDrawerTile> {
|
||||||
this.lazyStorage = LazyOptional.of(() -> EnderSavedData.getInstance(this.level).getFrequency(this.frequency));
|
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
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public <U> LazyOptional<U> getCapability(@Nonnull Capability<U> cap, @Nullable Direction side) {
|
public <U> LazyOptional<U> getCapability(@Nonnull Capability<U> cap, @Nullable Direction side) {
|
||||||
|
|
|
@ -2,10 +2,10 @@ package com.buuz135.functionalstorage.block.tile;
|
||||||
|
|
||||||
import com.buuz135.functionalstorage.FunctionalStorage;
|
import com.buuz135.functionalstorage.FunctionalStorage;
|
||||||
import com.buuz135.functionalstorage.client.model.FramedDrawerModelData;
|
import com.buuz135.functionalstorage.client.model.FramedDrawerModelData;
|
||||||
|
import com.buuz135.functionalstorage.util.DrawerWoodType;
|
||||||
import com.hrznstudio.titanium.annotation.Save;
|
import com.hrznstudio.titanium.annotation.Save;
|
||||||
import com.hrznstudio.titanium.block.BasicTileBlock;
|
import com.hrznstudio.titanium.block.BasicTileBlock;
|
||||||
import net.minecraft.core.BlockPos;
|
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.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraftforge.client.model.data.IModelData;
|
import net.minecraftforge.client.model.data.IModelData;
|
||||||
|
@ -19,7 +19,7 @@ public class FramedDrawerTile extends DrawerTile{
|
||||||
private FramedDrawerModelData framedDrawerModelData;
|
private FramedDrawerModelData framedDrawerModelData;
|
||||||
|
|
||||||
public FramedDrawerTile(BasicTileBlock<DrawerTile> base, BlockEntityType<DrawerTile> blockEntityType, BlockPos pos, BlockState state, FunctionalStorage.DrawerType type) {
|
public FramedDrawerTile(BasicTileBlock<DrawerTile> base, BlockEntityType<DrawerTile> 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<>());
|
this.framedDrawerModelData = new FramedDrawerModelData(new HashMap<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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<Integer, Pair<Integer, Integer>> slotPosition;
|
||||||
|
private final Function<Integer, ItemStack> slotStack;
|
||||||
|
private final Function<Integer, Integer> slotMaxAmount;
|
||||||
|
|
||||||
|
public DrawerInfoGuiAddon(int posX, int posY, ResourceLocation gui, int slotAmount, Function<Integer, Pair<Integer, Integer>> slotPosition, Function<Integer, ItemStack> slotStack, Function<Integer, Integer> 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<Component>();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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("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", "Slot: ");
|
||||||
this.add("item.utility.slot.desc", "Right click in a GUI to change 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: ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 9.1 KiB |
Loading…
Reference in New Issue
Block a user