Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.example.ecosub;
- import net.minecraftforge.items.ItemStackHandler;
- import net.minecraftforge.items.IItemHandler;
- import net.minecraft.world.level.block.entity.BlockEntity;
- import net.minecraft.world.level.Level;
- import net.minecraft.world.item.ItemStack;
- import net.minecraft.world.inventory.Slot;
- import net.minecraft.world.inventory.ContainerLevelAccess;
- import net.minecraft.world.inventory.AbstractContainerMenu;
- import net.minecraft.world.entity.player.Player;
- import net.minecraft.world.entity.player.Inventory;
- import net.minecraft.world.entity.Entity;
- import net.minecraft.network.FriendlyByteBuf;
- import net.minecraft.core.BlockPos;
- import java.util.function.Supplier;
- import java.util.Map;
- import java.util.HashMap;
- public class WalletguiMenu extends AbstractContainerMenu implements Supplier<Map<Integer, Slot>> {
- public final static HashMap<String, Object> guistate = new HashMap<>();
- public final Level world;
- public final Player entity;
- public int x, y, z;
- private ContainerLevelAccess access = ContainerLevelAccess.NULL;
- private IItemHandler internal;
- private final Map<Integer, Slot> customSlots = new HashMap<>();
- private boolean bound = false;
- private Supplier<Boolean> boundItemMatcher = null;
- private Entity boundEntity = null;
- private BlockEntity boundBlockEntity = null;
- public int balance;
- public WalletguiMenu(int id, Inventory inv, FriendlyByteBuf extraData, FriendlyByteBuf balanceData) {
- super(EcosubModMenus.WALLETGUI.get(), id);
- this.entity = inv.player;
- this.world = inv.player.level();
- this.internal = new ItemStackHandler(0);
- BlockPos pos = null;
- if (extraData != null) {
- pos = extraData.readBlockPos();
- this.x = pos.getX();
- this.y = pos.getY();
- this.z = pos.getZ();
- access = ContainerLevelAccess.create(world, pos);
- balance = balanceData.readInt();
- }
- System.out.println(1 + " " + balance);
- }
- public WalletguiMenu(int id, Inventory inv, FriendlyByteBuf extraData) {
- super(EcosubModMenus.WALLETGUI.get(), id);
- this.entity = inv.player;
- this.world = inv.player.level();
- this.internal = new ItemStackHandler(0);
- BlockPos pos = null;
- if (extraData != null) {
- pos = extraData.readBlockPos();
- this.x = pos.getX();
- this.y = pos.getY();
- this.z = pos.getZ();
- access = ContainerLevelAccess.create(world, pos);
- }
- }
- @Override
- public boolean stillValid(Player player) {
- if (this.bound) {
- if (this.boundItemMatcher != null)
- return this.boundItemMatcher.get();
- else if (this.boundBlockEntity != null)
- return AbstractContainerMenu.stillValid(this.access, player, this.boundBlockEntity.getBlockState().getBlock());
- else if (this.boundEntity != null)
- return this.boundEntity.isAlive();
- }
- return true;
- }
- @Override
- public ItemStack quickMoveStack(Player playerIn, int index) {
- return ItemStack.EMPTY;
- }
- public Map<Integer, Slot> get() {
- return customSlots;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement