Jump to content

[1.19.2] about "ForgeCapabilities.ITEM_HANDLER" preload a container whit custome loot


Recommended Posts

good nights 

this one is a little hard to explains 

i finally managae to get working the briefcase i still working whit the block part but still 
briefcase01-edit.gif
back in the 1.8 the idea whit this briefcase was to give the player an initial inventory soo ineed to preload the briefcase whit items from code digginup in the code

i know minecrfas store inventories like nbt data usig a listtag named "Items" so i copy paste code from the chest container class to load things to mi briefcase but notice mi briefacase "ITEMS"  and the "ITEMS" in the GUI  dont match 
looks like to separate sets of nbt data 

both sets of "ITEMS" persist afther closing/reload the world soo is not an overwrite thing 

 

this are the methods i use read write the "ITEMS" in the item stack 

Spoiler

				
			    // ########## ########## ########## ##########
		    // @Override
		    public static NonNullList<ItemStack> read_items_from(ItemStack itemstack) {				
			        NonNullList<ItemStack> contained_items = NonNullList.withSize(9, ItemStack.EMPTY);// this.getContainerSize()				
			        if (itemstack.hasTag()) {
		            CompoundTag compoundtag = itemstack.getTag();
		            ListTag listtag = null;
		            int size = 0;				
			            if (compoundtag.contains("Items")) {
		                // ListTag listtag = new ListTag();
		                listtag = compoundtag.getList("Items", 10);
		                size = listtag.size();
		                // contained_items = NonNullList.withSize(size, ItemStack.EMPTY);				
			                for (int i = 0; i < listtag.size(); ++i) {
		                    CompoundTag itemstacktag = listtag.getCompound(i);
		                    int j = compoundtag.getByte("Slot") & 255;
		                    if (j >= 0 && j < contained_items.size()) {
		                        contained_items.set(j, ItemStack.of(itemstacktag));
		                    }
		                }
		            }
		        }
		        return contained_items;
		    }				
			    // ########## ########## ########## ##########
		    // @Override
		    public void write_items_to(ItemStack itemstack, NonNullList<ItemStack> contained_items) {				
			        CompoundTag compoundtag = null;				
			        if (itemstack.hasTag()) {
		            compoundtag = itemstack.getTag();
		        } else {
		            compoundtag = new CompoundTag();
		        }				
			        ListTag listtag = new ListTag();
		        int size = contained_items.size();				
			        for (int i = 0; i < size; ++i) {				
			            ItemStack itemslot = contained_items.get(i);
		            if (!itemslot.isEmpty()) {
		                CompoundTag itemcompound = new CompoundTag();
		                itemcompound.putByte("Slot", (byte) i);
		                itemslot.save(itemcompound);
		                listtag.add(itemcompound);
		            }
		        }
		        compoundtag.put("Items", listtag);
		        itemstack.setTag(compoundtag);
		    }				
			    // ########## ########## ########## ##########
		    // @Override
		    public void print(NonNullList<ItemStack> lista) {				
			        int count = 0;
		        for (ItemStack cosa : lista) {
		            System.out
		                    .println("[" + count + "] => " + cosa.getItem().getName(cosa).getString() + ", " + cosa.getCount());
		            count++;
		        }				
			    }
		 				
			 				
			

 

this is the code i use for the test 

Spoiler

				
			    // ########## ########## ########## ##########
		    @Override
		    public boolean onEntitySwing(ItemStack stack, LivingEntity le) {				
			        Level warudo = le.level;
		        System.out.println("onEntitySwing(" + warudo.isClientSide + ")");				
			        NonNullList<ItemStack> lista = this.read_items_from(stack);				
			        if( !warudo.isClientSide && le.isCrouching())
		        {
		             lista.set(0, new ItemStack( Items.POTATO , 3 ) );
		             lista.set(8, new ItemStack( Items.BAKED_POTATO , 3 ) );
		            this.write_items_to(stack, lista);
		        }				
			        print(lista);				
			        return true;
		    }				
			

 

###########################################################################

This getting too long 
i need to confirm if the capabilities system has its own database apart from the vainilla nbt thing 
and if its like that how doo i access tha data to put items in the briefcase ? 

 

class briefcase_item

Spoiler

				
			package mercblk.maletin;				
			import org.jetbrains.annotations.NotNull;
		import org.jetbrains.annotations.Nullable;				
			import io.netty.buffer.Unpooled;
		import mercblk.maletin.screen.menu9;
		import mercblk.util.Postate;
		import mercblk.util.Target;
		import net.minecraft.client.Minecraft;
		import net.minecraft.core.BlockPos;
		import net.minecraft.core.Direction;
		import net.minecraft.core.NonNullList;
		import net.minecraft.nbt.CompoundTag;
		import net.minecraft.nbt.ListTag;
		import net.minecraft.network.FriendlyByteBuf;
		import net.minecraft.network.chat.Component;
		import net.minecraft.server.level.ServerPlayer;
		import net.minecraft.world.Container;
		import net.minecraft.world.ContainerHelper;
		import net.minecraft.world.InteractionHand;
		import net.minecraft.world.InteractionResultHolder;
		import net.minecraft.world.MenuProvider;
		import net.minecraft.world.entity.Entity;
		import net.minecraft.world.entity.LivingEntity;
		import net.minecraft.world.entity.item.ItemEntity;
		import net.minecraft.world.entity.player.Inventory;
		import net.minecraft.world.entity.player.Player;
		import net.minecraft.world.inventory.AbstractContainerMenu;
		import net.minecraft.world.inventory.ContainerData;
		import net.minecraft.world.inventory.DispenserMenu;
		import net.minecraft.world.inventory.MenuType;
		import net.minecraft.world.item.Item;
		import net.minecraft.world.item.ItemStack;
		import net.minecraft.world.item.Items;
		import net.minecraft.world.level.Level;
		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.NetworkHooks;
		import net.minecraftforge.registries.RegistryObject;
		import net.minecraftforge.items.wrapper.InvWrapper;
		import net.minecraftforge.items.wrapper.ShulkerItemStackInvWrapper;
		import net.minecraftforge.common.capabilities.ForgeCapabilities;
		import net.minecraftforge.common.capabilities.ICapabilityProvider;				
			public class briefcase_item extends Item implements MenuProvider  { // MenuProvider implements MenuProvider, Container implements MenuProvider
		    
		    private int progress = 0;
		    private int maxProgress = 78;				
			    protected boolean remove = false;				
			    // ########## ########## ########## ##########
		    public briefcase_item(Properties propiedad) {
		        super(propiedad);
		    }				
			    // ########## ########## ########## ##########
		    public int getContainerSize() {
		        return 9;
		    }				
			    @Nullable
		    @Override
		    public ICapabilityProvider initCapabilities(ItemStack container, @Nullable CompoundTag nbt)
		    {
		        //BasketBlock basketBlock = ((BasketBlock) this.getBlock());				
			        return new item_c_provider(container);
		    }				
			    @Override
		    public @NotNull Component getDisplayName()
		    {
		        return Component.literal("Briefcase Item");
		        //return new TextComponent(((BasketBlock) this.getBlock()).basketSize.getName());
		    }    
		    
		    				
			    @Nullable
		    @Override
		    public AbstractContainerMenu createMenu(int containerId, @NotNull Inventory inventory, @NotNull Player player)
		    {
		        //return new BasketMenu(containerId, inventory, new FriendlyByteBuf(Unpooled.buffer()));
		        
		        //return new DispenserMenu( containerId, inventory );
		        return new menu9( containerId, inventory , new FriendlyByteBuf(Unpooled.buffer() ) );
		        //friendlyByteBuf -> friendlyByteBuf.writeItem(heldItem)
		        
		    }    
		    
		    @Override
		    public @NotNull InteractionResultHolder<ItemStack> use(@NotNull Level level, @NotNull Player pe, @NotNull InteractionHand interactionHand)
		    {
		        if (!level.isClientSide())
		        {
		            ItemStack heldItem = pe.getItemInHand(interactionHand);				
			            if (heldItem.getCapability(ForgeCapabilities.ITEM_HANDLER).isPresent())
		            {
		                //NetworkHooks.openGui((ServerPlayer) pe, this, friendlyByteBuf -> friendlyByteBuf.writeItem(heldItem));
		                //NetworkHooks.openGui((ServerPlayer) pe, this);
		                NetworkHooks.openScreen((ServerPlayer) pe, this);				
			                // container_ghost ghost = this.get_ghost(warudo, itemstack, pe);
		                // NetworkHooks.openScreen((ServerPlayer) pe, (this)itemstack );				
			                // pe.openMenu(ghost);
		                // NetworkHooks.openScreen((ServerPlayer) pe, ghost, pos);
		            }
		        }
		        return super.use(level, pe, interactionHand);
		    }				
			
		    // ########## ########## ########## ##########
		    // @Override
		    public static NonNullList<ItemStack> read_items_from(ItemStack itemstack) {				
			        NonNullList<ItemStack> contained_items = NonNullList.withSize(9, ItemStack.EMPTY);// this.getContainerSize()				
			        if (itemstack.hasTag()) {
		            CompoundTag compoundtag = itemstack.getTag();
		            ListTag listtag = null;
		            int size = 0;				
			            if (compoundtag.contains("Items")) {
		                // ListTag listtag = new ListTag();
		                listtag = compoundtag.getList("Items", 10);
		                size = listtag.size();
		                // contained_items = NonNullList.withSize(size, ItemStack.EMPTY);				
			                for (int i = 0; i < listtag.size(); ++i) {
		                    CompoundTag itemstacktag = listtag.getCompound(i);
		                    int j = compoundtag.getByte("Slot") & 255;
		                    if (j >= 0 && j < contained_items.size()) {
		                        contained_items.set(j, ItemStack.of(itemstacktag));
		                    }
		                }
		            }
		        }
		        return contained_items;
		    }				
			    // ########## ########## ########## ##########
		    // @Override
		    public void write_items_to(ItemStack itemstack, NonNullList<ItemStack> contained_items) {				
			        CompoundTag compoundtag = null;				
			        if (itemstack.hasTag()) {
		            compoundtag = itemstack.getTag();
		        } else {
		            compoundtag = new CompoundTag();
		        }				
			        ListTag listtag = new ListTag();
		        int size = contained_items.size();				
			        for (int i = 0; i < size; ++i) {				
			            ItemStack itemslot = contained_items.get(i);
		            if (!itemslot.isEmpty()) {
		                CompoundTag itemcompound = new CompoundTag();
		                itemcompound.putByte("Slot", (byte) i);
		                itemslot.save(itemcompound);
		                listtag.add(itemcompound);
		            }
		        }
		        compoundtag.put("Items", listtag);
		        itemstack.setTag(compoundtag);
		    }				
			    // ########## ########## ########## ##########
		    @Override
		    public boolean onEntitySwing(ItemStack stack, LivingEntity le) {				
			        Level warudo = le.level;
		        System.out.println("onEntitySwing(" + warudo.isClientSide + ")");				
			        NonNullList<ItemStack> lista = this.read_items_from(stack);				
			        if( !warudo.isClientSide && le.isCrouching())
		        {
		             lista.set(0, new ItemStack( Items.POTATO , 3 ) );
		             lista.set(8, new ItemStack( Items.BAKED_POTATO , 3 ) );
		            this.write_items_to(stack, lista);
		        }				
			        print(lista);				
			        return true;
		    }				
			    // ########## ########## ########## ##########
		    // @Override
		    public void print(NonNullList<ItemStack> lista) {				
			        int count = 0;
		        for (ItemStack cosa : lista) {
		            System.out
		                    .println("[" + count + "] => " + cosa.getItem().getName(cosa).getString() + ", " + cosa.getCount());
		            count++;
		        }				
			    }				
			
		    
		    @Override
		    public void inventoryTick(ItemStack stack, Level warudo, Entity en, int tick, boolean p_41408_) {
		        
		        Long time = warudo.getGameTime();
		        if( time % 40 == 0) {
		            //System.out.println("##inventoryTick## " + tick + warudo.isClientSide);
		            //print(this.items);            
		        }
		    }				
			    @Override
		    public void onCraftedBy(ItemStack p_41447_, Level p_41448_, Player p_41449_) {
		        System.out.println("##onCraftedBy##");
		        
		    }
		    
		    @Override
		    public boolean canFitInsideContainerItems() {
		        return false;
		     }
		    				
			    /**
		     * Called when the player Left Clicks (attacks) an entity. Processed before
		     * damage is done, if return value is true further processing is canceled and
		     * the entity is not attacked.
		     *
		     * @param stack  The Item being used
		     * @param player The player that is attacking
		     * @param entity The entity being attacked
		     * @return True to cancel the rest of the interaction.
		     */
		    @Override
		    public boolean onLeftClickEntity(ItemStack stack, Player player, Entity entity)
		    {
		        System.out.println("##onLeftClickEntity##");
		        return true;
		    }
		    
		    
		    // ########## ########## ########## ##########
		    // ########## ########## ########## ##########				
			    // ########## ########## ########## ##########
		    // ########## ########## ########## ##########
		    // ########## ########## ########## ##########
		}
		 				
			

 

class item_c_provider

Spoiler

				
			package mercblk.maletin;				
			
		import net.minecraft.core.Direction;
		import net.minecraft.nbt.CompoundTag;
		import net.minecraft.world.item.ItemStack;
		import net.minecraftforge.common.capabilities.Capability;
		import net.minecraftforge.common.capabilities.ForgeCapabilities;
		import net.minecraftforge.common.capabilities.ICapabilitySerializable;
		import net.minecraftforge.common.util.LazyOptional;
		import net.minecraftforge.items.CapabilityItemHandler;
		import net.minecraftforge.items.IItemHandler;
		import org.jetbrains.annotations.NotNull;
		import org.jetbrains.annotations.Nullable;				
			public class item_c_provider implements ICapabilitySerializable<CompoundTag>
		{
		    private final LazyOptional<IItemHandler> lazyItemHandler;				
			    public item_c_provider(ItemStack container)
		    {
		        lazyItemHandler = LazyOptional.of(() -> new item_handler(container));
		    }				
			    @NotNull
		    @Override
		    public <T> LazyOptional<T> getCapability(@NotNull Capability<T> capability, @Nullable Direction side)
		    {
		        //if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
		        
		        if (capability == ForgeCapabilities.ITEM_HANDLER )        
		        {
		            return lazyItemHandler.cast();
		        }
		        else return LazyOptional.empty();
		    }				
			    // Farm out the serialization/deserialization to the capability
		    @Override
		    public CompoundTag serializeNBT()
		    {
		        return ((item_handler) lazyItemHandler.orElseThrow(() -> new RuntimeException("Capability not found during serialization"))).serializeNBT();
		    }				
			    @Override
		    public void deserializeNBT(CompoundTag nbt)
		    {
		        ((item_handler) lazyItemHandler.orElseThrow(() -> new RuntimeException("Capability not found during deserialization"))).deserializeNBT(nbt);
		    }
		}				
			

 

class item_handler

Spoiler

				
			package mercblk.maletin;				
			
		import net.minecraft.core.NonNullList;
		import net.minecraft.nbt.CompoundTag;
		import net.minecraft.nbt.ListTag;
		import net.minecraft.world.item.ItemStack;
		import net.minecraftforge.items.ItemStackHandler;
		import org.jetbrains.annotations.NotNull;				
			public class item_handler extends ItemStackHandler
		{
		    //private final BasketBlock.BasketSize basketSize;
		    
		    ItemStack container = null;
		    				
			    public item_handler(ItemStack container)
		    {
		        super(9);
		        this.container  = container;
		    }				
			    @Override
		    public int getSlotLimit(int slot)
		    {
		        return 9;
		    }				
			    @Override
		    public boolean isItemValid(int slot, @NotNull ItemStack stack)
		    {
		        if ( stack == null ||  stack.isEmpty() ) //|| stack.getItem() instanceof BasketBlockItem
		        {
		            return false;
		        }
		        else
		        {
		            return super.isItemValid(slot, stack);
		        }
		    }
		    
		       
		    @Override
		    public void setStackInSlot(int slot, @NotNull ItemStack stack)
		    {
		        
		        System.out.println("setStackInSlot(" + slot + ")");
		        validateSlotIndex(slot);
		        this.stacks.set(slot, stack);
		        onContentsChanged(slot);
		        
		        if(this.container != null) {
		        //write_item_to_slot(this.container, slot, stack);
		        }
		    }   
		    
		    
		    // ########## ########## ########## ##########
		    // @Override
		    public static NonNullList<ItemStack> read_items_from(ItemStack itemstack) {				
			        NonNullList<ItemStack> contained_items = NonNullList.withSize(9, ItemStack.EMPTY);// this.getContainerSize()				
			        if (itemstack.hasTag()) {
		            CompoundTag compoundtag = itemstack.getTag();
		            ListTag listtag = null;
		            int size = 0;				
			            if (compoundtag.contains("Items")) {
		                // ListTag listtag = new ListTag();
		                listtag = compoundtag.getList("Items", 10);
		                size = listtag.size();
		                // contained_items = NonNullList.withSize(size, ItemStack.EMPTY);				
			                for (int i = 0; i < listtag.size(); ++i) {
		                    CompoundTag itemstacktag = listtag.getCompound(i);
		                    int j = compoundtag.getByte("Slot") & 255;
		                    if (j >= 0 && j < contained_items.size()) {
		                        contained_items.set(j, ItemStack.of(itemstacktag));
		                    }
		                }
		            }
		        }
		        return contained_items;
		    }				
			    // ########## ########## ########## ##########
		    // @Override
		    public void write_item_to_slot(ItemStack container, int slot, @NotNull ItemStack stack) {
		        //,  NonNullList<ItemStack> contained_items				
			        CompoundTag compoundtag = null;				
			        if (container.hasTag()) {
		            compoundtag = container.getTag();
		        } else {
		            compoundtag = new CompoundTag();
		        }				
			        ListTag listtag = null;
		        if (compoundtag.contains("Items")) {
		            listtag = compoundtag.getList("Items", 10);
		        }else {
		            listtag = new ListTag();
		        }
		        
		        CompoundTag itemstacktag = null;
		        
		        if(slot < listtag.size() ) {
		            itemstacktag = listtag.getCompound(slot);
		        }
		        else {
		            itemstacktag = new CompoundTag();
		        }        
		        
		        itemstacktag.putByte("Slot", (byte) slot);
		        stack.save(itemstacktag);
		        listtag.add(itemstacktag); //aqui tengi una duda, se sobreescrive o crea otra ??				
			        compoundtag.put("Items", listtag);
		        container.setTag(compoundtag);
		    }
		    
		}				
			 				
			

 

class menu9

Spoiler

				
			package mercblk.maletin.screen;				
			import org.jetbrains.annotations.NotNull;				
			import mercblk.maletin.briefcase_item;
		import mercblk.maletin.maletin_init;
		import net.minecraft.core.NonNullList;
		import net.minecraft.nbt.CompoundTag;
		import net.minecraft.nbt.ListTag;
		import net.minecraft.network.FriendlyByteBuf;
		import net.minecraft.world.InteractionHand;
		import net.minecraft.world.entity.player.Inventory;
		import net.minecraft.world.entity.player.Player;
		import net.minecraft.world.inventory.*;
		import net.minecraft.world.item.ItemStack;
		import net.minecraft.world.level.Level;
		import net.minecraft.world.level.block.entity.BlockEntity;
		import net.minecraftforge.common.capabilities.ForgeCapabilities;
		import net.minecraftforge.items.IItemHandler;
		import net.minecraftforge.items.ItemStackHandler;
		import net.minecraftforge.items.SlotItemHandler;
		import net.minecraft.world.Container;
		import net.minecraft.world.SimpleContainer;
		import net.minecraft.world.entity.player.Inventory;
		import net.minecraft.world.entity.player.Player;
		import net.minecraft.world.item.ItemStack;				
			
		public class menu9 extends AbstractContainerMenu {
		    public static mercblk.maletin.briefcase_item container_item = null;
		    private final Level level;
		    private final ContainerData data;
		    
		    public menu9(int id, Inventory inv, FriendlyByteBuf extraData) {
		        this(id, inv, new SimpleContainerData(9));
		    }				
			
		    @SuppressWarnings("removal")
		    public menu9(int id, Inventory inv, ContainerData data) {//
		        super(maletin_init.MENU9.get(), id);
		        //checkContainerSize(container_item, 9);
		        
		        this.level = inv.player.level;
		        this.data = data;				
			        addPlayerInventory(inv);
		        addPlayerHotbar(inv);				
			        Player pe = inv.player;
		        ItemStack itemstack = null; 
		        
		        InteractionHand[] manos = {InteractionHand.OFF_HAND, InteractionHand.MAIN_HAND};                
		        for( InteractionHand mano : manos) {
		            if( pe.getItemInHand(mano).getItem() instanceof briefcase_item  ) {
		                itemstack = pe.getItemInHand(mano);
		            }
		        }
		        
		        
		        itemstack.getCapability(ForgeCapabilities.ITEM_HANDLER).ifPresent(handler00 -> {
		            //this.addSlot(new SlotItemHandler(handler, 0, 12, 15));
		            //this.addSlot(new SlotItemHandler(handler, 1, 86, 15));
		            //this.addSlot(new SlotItemHandler(handler, 2, 86, 60));
		            
		            System.out.println( "\nhandler00.getSlots(" + handler00.getSlots() + ");\n" );
		            
		            for(int i = 0; i < 3; ++i) {
		                for(int j = 0; j < 3; ++j) {
		                   this.addSlot(new SlotItemHandler(handler00, j + i * 3, 62 + j * 18, 17 + i * 18));
		                }
		             }
		         
		        });
		        				
			        addDataSlots(data);
		    }				
			    public boolean isCrafting() {
		        return data.get(0) > 0;
		    }				
			    public int getScaledProgress() {
		        int progress = this.data.get(0);
		        int maxProgress = this.data.get(1);  // Max Progress
		        int progressArrowSize = 26; // This is the height in pixels of your arrow				
			        return maxProgress != 0 && progress != 0 ? progress * progressArrowSize / maxProgress : 0;
		    }				
			    // CREDIT GOES TO: diesieben07 | https://github.com/diesieben07/SevenCommons
		    // must assign a slot number to each of the slots used by the GUI.
		    // For this container, we can see both the tile inventory's slots as well as the player inventory slots and the hotbar.
		    // Each time we add a Slot to the container, it automatically increases the slotIndex, which means
		    //  0 - 8 = hotbar slots (which will map to the InventoryPlayer slot numbers 0 - 
		    //  9 - 35 = player inventory slots (which map to the InventoryPlayer slot numbers 9 - 35)
		    //  36 - 44 = TileInventory slots, which map to our TileEntity slot numbers 0 - 
		    private static final int HOTBAR_SLOT_COUNT = 9;
		    private static final int PLAYER_INVENTORY_ROW_COUNT = 3;
		    private static final int PLAYER_INVENTORY_COLUMN_COUNT = 9;
		    private static final int PLAYER_INVENTORY_SLOT_COUNT = PLAYER_INVENTORY_COLUMN_COUNT * PLAYER_INVENTORY_ROW_COUNT;
		    private static final int VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_SLOT_COUNT;
		    private static final int VANILLA_FIRST_SLOT_INDEX = 0;
		    private static final int TE_INVENTORY_FIRST_SLOT_INDEX = VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT;				
			    // THIS YOU HAVE TO DEFINE!
		    private static final int TE_INVENTORY_SLOT_COUNT = 9;  // must be the number of slots you have!				
			    @Override
		    public boolean stillValid(Player player) {
		        return true;
		    }				
			    private void addPlayerInventory(Inventory playerInventory) {
		        for (int i = 0; i < 3; ++i) {
		            for (int l = 0; l < 9; ++l) {
		                this.addSlot(new Slot(playerInventory, l + i * 9 + 9, 8 + l * 18, 86 + i * 18));
		            }
		        }
		    }				
			    private void addPlayerHotbar(Inventory playerInventory) {
		        for (int i = 0; i < 9; ++i) {
		            this.addSlot(new Slot(playerInventory, i, 8 + i * 18, 144));
		        }
		    }
		    
		//what this does 
		    @Override
		    public ItemStack quickMoveStack(Player p_38941_, int p_38942_) {
		        // TODO Auto-generated method stub
		        return null;
		    }    
		    				
			
		}
		 				
			

 

 

thanks from your time

Link to comment
Share on other sites

this picture shows the problem 
while the gui says the item has 7 redstone ingots in the capability
the print method says i have two potatoes in slots one and eight  in the itemstack nbt 

if i close minecraft and open again the world i still havethe 7 ingots in the gui and the two potatoes in the code 

 

Captura-de-pantalla-de-2023-02-02-05-43-

Link to comment
Share on other sites

That most likely means that the data on the server is not being synced to the client properly. You'll probably need to override #getShareTag to send the capability data. Additionally, you probably should make sure the stack doesn't have the items stored in two different locations.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • every time I try to load forge version 1. 12. 2 with the blockbuster mod the mclib and the metamorphs mod The game crashed and this is the crash m whilst there was a severe problem during mod loading that has caused the game to fail Error: net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Blockbuster (blockbuster)
    • Join the Ultimate EarthSMP - [RiftMC SMP] play.riftmc.net https://riftmc.net/ Join Our Discord     Are you ready to embark on a Minecraft adventure like no other? Look no further than RiftMC! With our server, you'll be transported to a world of endless possibilities, where your imagination can run wild.   Have you ever dreamed of building your own kingdom, or exploring vast landscapes with your friends? At RiftMC, you can do just that and more. With multiple gameplay options, including survival, earthsmp, and PvP gameplay, you'll never run out of things to do.   Are you looking for a challenge? Our survival mode will test your skills as you brave the dangers of the wilderness. Or, if you're feeling creative, our custom world is the perfect canvas for you to unleash your imagination and build whatever your heart desires.   Do you thrive on competition? Our PvP arenas are the perfect place for you to battle it out with other players for supremacy. Or, if you prefer a more cooperative experience, join up with other players to form communities and build sprawling cities.   But that's not all - we also have a thriving economic system, where you can buy and sell goods with other players and even start your own businesses. And with our friendly and dedicated staff, you can rest assured that you'll always have the help and support you need.   So, what are you waiting for? Are you ready to experience the adventure of a lifetime? Join the thousands of players who have already discovered the magic of RiftMC! Simply connect to play.riftmc.net and let the journey begin. Are you ready to dive in?  
    • I want a sword that will kill all hostile mobs with one hit, so is there any way to do that?
    • I have that error when i started my forge server, can anyone help me? C:\Users\orden\Desktop\Servidor MC>REM Forge requires a configured set of both JVM and program arguments. C:\Users\orden\Desktop\Servidor MC>REM Add custom JVM arguments to the user_jvm_args.txt C:\Users\orden\Desktop\Servidor MC>REM Add custom program arguments {such as nogui} to this file in the next line before the  or C:\Users\orden\Desktop\Servidor MC>REM  pass them to this script directly C:\Users\orden\Desktop\Servidor MC>java @user_jvm_args.txt @libraries/net/minecraftforge/forge/1.18.2-40.1.57/win_args.txt 2023-04-01 21:15:43,376 main WARN Advanced terminal features are not available in this environment [21:15:43] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--launchTarget, forgeserver, --fml.forgeVersion, 40.1.57, --fml.mcVersion, 1.18.2, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20220404.173914, -nogui] [21:15:43] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 9.1.3+9.1.3+main.9b69c82a starting: java version 20 by Oracle Corporation [21:15:43] [main/INFO] [op.OptiFineTransformationService/]: OptiFineTransformationService.onLoad [21:15:43] [main/INFO] [op.OptiFineTransformationService/]: OptiFine ZIP file URL: union:/C:/Users/orden/Desktop/Servidor%20MC/mods/OptiFine-1.18.2_HD_U_H7.jar%2338!/ [21:15:43] [main/INFO] [op.OptiFineTransformationService/]: OptiFine ZIP file: C:\Users\orden\Desktop\Servidor MC\mods\OptiFine-1.18.2_HD_U_H7.jar [21:15:43] [main/INFO] [op.OptiFineTransformer/]: Target.PRE_CLASS is available [21:15:43] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=union:/C:/Users/orden/Desktop/Servidor%20MC/libraries/org/spongepowered/mixin/0.8.5/mixin-0.8.5.jar%2314!/ Service=ModLauncher Env=SERVER [21:15:43] [main/INFO] [op.OptiFineTransformationService/]: OptiFineTransformationService.initialize [21:15:45] [main/INFO] [op.OptiFineTransformationService/]: OptiFineTransformationService.transformers [21:15:45] [main/INFO] [op.OptiFineTransformer/]: Targets: 350 [21:15:45] [main/INFO] [op.OptiFineTransformationService/]: additionalClassesLocator: [optifine., net.optifine.] [21:15:47] [main/INFO] [mixin/]: Compatibility level set to JAVA_17 [21:15:47] [main/INFO] [mixin/]: Successfully loaded Mixin Connector [de.maxhenkel.camera.MixinConnector] [21:15:47] [main/INFO] [mixin/]: Successfully loaded Mixin Connector [tictim.paraglider.MixinConnector] [21:15:47] [main/INFO] [cp.mo.mo.LaunchServiceHandler/MODLAUNCHER]: Launching target 'forgeserver' with arguments [-nogui] [21:15:47] [main/WARN] [mixin/]: Error loading class: net/minecraft/server/level/ChunkMap (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: @Mixin target net.minecraft.server.level.ChunkMap was not found securitycraft.mixins.json:camera.ChunkMapMixin [21:15:47] [main/WARN] [mixin/]: Error loading class: de/maxhenkel/gravestone/events/DeathEvents (java.lang.ClassNotFoundException: de.maxhenkel.gravestone.events.DeathEvents) [21:15:47] [main/WARN] [mixin/]: Error loading class: net/minecraft/world/item/ItemStack (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: @Mixin target net.minecraft.world.item.ItemStack was not found tombstone.mixins.json:ItemStackMixin [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/util/concurrent/CompletableFuture (java.lang.IllegalArgumentException: Unsupported class file major version 64) Exception in thread "main" org.spongepowered.asm.mixin.transformer.throwables.MixinTransformerError: An unexpected critical error was encountered         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:392)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClass(MixinTransformer.java:250)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.service.modlauncher.MixinTransformationHandler.processClass(MixinTransformationHandler.java:131)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.launch.MixinLaunchPluginLegacy.processClass(MixinLaunchPluginLegacy.java:131)         at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.serviceapi.ILaunchPluginService.processClassWithFlags(ILaunchPluginService.java:156)         at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.LaunchPluginHandler.offerClassNodeToPlugins(LaunchPluginHandler.java:88)         at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.ClassTransformer.transform(ClassTransformer.java:120)         at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.TransformingClassLoader.maybeTransformClassBytes(TransformingClassLoader.java:50)         at cpw.mods.securejarhandler@1.0.3/cpw.mods.cl.ModuleClassLoader.readerToClass(ModuleClassLoader.java:110)         at cpw.mods.securejarhandler@1.0.3/cpw.mods.cl.ModuleClassLoader.lambda$findClass$16(ModuleClassLoader.java:216)         at cpw.mods.securejarhandler@1.0.3/cpw.mods.cl.ModuleClassLoader.loadFromModule(ModuleClassLoader.java:226)         at cpw.mods.securejarhandler@1.0.3/cpw.mods.cl.ModuleClassLoader.findClass(ModuleClassLoader.java:216)         at cpw.mods.securejarhandler@1.0.3/cpw.mods.cl.ModuleClassLoader.loadClass(ModuleClassLoader.java:132)         at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)         at java.base/java.lang.Class.getDeclaredMethods0(Native Method)         at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3502)         at java.base/java.lang.Class.getMethodsRecursive(Class.java:3643)         at java.base/java.lang.Class.getMethod0(Class.java:3629)         at java.base/java.lang.Class.getMethod(Class.java:2319)         at MC-BOOTSTRAP/fmlloader@1.18.2-40.1.57/net.minecraftforge.fml.loading.targets.CommonServerLaunchHandler.lambda$launchService$0(CommonServerLaunchHandler.java:32)         at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37)         at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53)         at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71)         at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.Launcher.run(Launcher.java:106)         at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.Launcher.main(Launcher.java:77)         at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26)         at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23)         at cpw.mods.bootstraplauncher@1.0.0/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:149) Caused by: org.spongepowered.asm.mixin.throwables.ClassMetadataNotFoundException: java.util.concurrent.CompletableFuture         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.transformMethod(MixinPreProcessorStandard.java:754)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.transform(MixinPreProcessorStandard.java:739)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.attach(MixinPreProcessorStandard.java:310)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.createContextFor(MixinPreProcessorStandard.java:280)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinInfo.createContextFor(MixinInfo.java:1288)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.apply(MixinApplicatorStandard.java:292)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.TargetClassContext.apply(TargetClassContext.java:383)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.TargetClassContext.applyMixins(TargetClassContext.java:365)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:363)         ... 27 more C:\Users\orden\Desktop\Servidor MC>pause Presione una tecla para continuar . . .
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.