Jump to content

How to writeToNBT for more advanced objects?


MrDireball

Recommended Posts

So the code below will save an integer to wherever (I just know that it's important to save it or things will get screwed up), but how do I save something such as an ItemStack to in a similar manner? Please tell me that I'm not going to have to break it down into simple data types to save it...

 

Spoiler

    @Override
    public NBTTagCompound writeToNBT(NBTTagCompound compound)
    {
        super.writeToNBT(compound);
        compound.setInteger("int", int);
        return compound;
    }

 

 
 

 

Edited by MrDireball
Link to comment
Share on other sites

1 hour ago, MrDireball said:

So the code below will save an integer to wherever (I just know that it's important to save it or things will get screwed up), but how do I save something such as an ItemStack to in a similar manner? Please tell me that I'm not going to have to break it down into simple data types to save it...

 

  Reveal hidden contents


    @Override
    public NBTTagCompound writeToNBT(NBTTagCompound compound)
    {
        super.writeToNBT(compound);
        compound.setInteger("int", int);
        return compound;
    }

 

 
 

 

 

If you'd like to save an item to nbt, you'd need to call ItemStack#writeToNBT, which will write a tag to the nbt under the key "id". If you'd like to store multiple items, you need to create an NBTTagList and write all items to that.

Link to comment
Share on other sites

3 minutes ago, unassigned said:

If you'd like to save an item to nbt, you'd need to call ItemStack#writeToNBT, which will write a tag to the nbt under the key "id". If you'd like to store multiple items, you need to create an NBTTagList and write all items to that.

Could you give me a code example of that?

Link to comment
Share on other sites

                NBTTagCompound dataCompound = new NBTTagCompound();
                ItemStack newStack = new ItemStack(Items.DIAMOND);

                newStack.writeToNBT(dataCompound); //writes newStack data to dataCompound

                if(dataCompound.hasKey("id")) { ItemStack fromCompoundStack = new ItemStack(dataCompound); } //if the dataCompound has a ItemStack data, make a new stack from that data.

 

  • Like 1
Link to comment
Share on other sites

8 minutes ago, unassigned said:

                NBTTagCompound dataCompound = new NBTTagCompound();
                ItemStack newStack = new ItemStack(Items.DIAMOND);

                newStack.writeToNBT(dataCompound); //writes newStack data to dataCompound

                if(dataCompound.hasKey("id")) { ItemStack fromCompoundStack = new ItemStack(dataCompound); } //if the dataCompound has a ItemStack data, make a new stack from that data.

 

 

Link to comment
Share on other sites

What should I replace "id" with? "Minecraft:DIAMOND"?

 

Here's what I translated this into:

 

Spoiler

    @Override
    public void readFromNBT(NBTTagCompound compound)
    {
        super.readFromNBT(compound);
        if(compound.hasKey("id"))
        {
        	itemStack = new ItemStack(compound); //itemStack is a member variable of this class.
        }
    }

    @Override
    public NBTTagCompound writeToNBT(NBTTagCompound compound)
    {
        super.writeToNBT(compound);
        return itemStack.writeToNBT(compound);
    }

 

 
 
 
 

 

Edited by MrDireball
Link to comment
Share on other sites

10 minutes ago, MrDireball said:

if(compound.hasKey("id"))

You should not have this check!

Simply using writeToNBT and new ItemStack(nbt) is enough.

Note however that you should not write anything else to the compound used for the stack, so you probably want to store the stack in a sub-compound to avoid interference.

  • Like 1
Link to comment
Share on other sites

Dangit, it's not saving the item. Is there anything that you can see that's clearly wrong with this code? I doubt I'm using the super right.

 

Spoiler

    @Override
    public void readFromNBT(NBTTagCompound compound)
    {
        super.readFromNBT(compound);
        itemStack = new ItemStack(compound);
    }

    @Override
    public NBTTagCompound writeToNBT(NBTTagCompound compound)
    {
        super.writeToNBT(compound);
        return itemStack.writeToNBT(compound);
    }

 

 
 

 

Edited by MrDireball
Link to comment
Share on other sites

4 minutes ago, diesieben07 said:

Without seeing more of your code: no. We have zero context.

Please clarify also what you mean by "not saving". How exactly did you come to this conclusion, which symptoms did you observe?

I have a member variable of the type ItemStack in my DataTileEntity class, and I'd like it to still have a reference to whatever it had a reference to before I relogged. But it is null everytime I load up the world again.

 

Spoiler

import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;

public class DataTileEntity extends TileEntity {
    
    ItemStack itemStack;

    public void setItemStackment(ItemStack itemStack)
    {
        this.itemStack = itemStack;
        markDirty();
    }
    
    public ItemStack getItemStackment() {
        return itemStack;
    }

    @Override
    public void readFromNBT(NBTTagCompound compound)
    {
        super.readFromNBT(compound);
        itemStack = new ItemStack(compound);
    }

    @Override
    public NBTTagCompound writeToNBT(NBTTagCompound compound)
    {
        super.writeToNBT(compound);
        return itemStack.writeToNBT(compound);
    }
}

 

 

 

Edited by MrDireball
Link to comment
Share on other sites

Actually, I now know why.

You need to follow this advice:

22 minutes ago, diesieben07 said:

Note however that you should not write anything else to the compound used for the stack, so you probably want to store the stack in a sub-compound to avoid interference.

 

The default NBT for tile entities contains a key "id", which conflicts with the ItemStack serialization.

Link to comment
Share on other sites

1 minute ago, diesieben07 said:

Actually, I now know why.

You need to follow this advice:

 

The default NBT for tile entities contains a key "id", which conflicts with the ItemStack serialization.

I'm checking it by right-clicking a block, and it swaps the item in the player's hand with the item in the DataTileEntity, which works fine until I reload, then whatever was in it is gone.

 

So how can I get around the default setting?

Link to comment
Share on other sites

5 minutes ago, diesieben07 said:

Like I said, store the stack in a sub-compound. I.e. create a new NBTTagCompound, write the ItemStack (and only the ItemStack) to it and then add it to "your own" compound.

Pardon my bad understanding, are you saying that I should create a new instance of NBTTagCompound or a new type that derives from NBTTagCompound?

Link to comment
Share on other sites

1 hour ago, diesieben07 said:

A new instance.

I told it to read from and write to a file called "test.bat", but for some reason, it's still not working or even creating the file.

 

Spoiler

    @Override
    public void readFromNBT(NBTTagCompound compound)
    {
    	readStackFromFile("test.dat");
    }

    @Override
    public NBTTagCompound writeToNBT(NBTTagCompound compound)
    {
    	return writeStackToFile("test.dat");
    }
    
    public NBTTagCompound writeStackToFile(String fileName)
    {
        if (itemStack != null)
        {
            NBTTagCompound nbt = new NBTTagCompound();
            itemStack.writeToNBT(nbt);
            File file = new File(fileName);
            try
            {
                file.createNewFile();
                FileOutputStream fileoutputstream = new FileOutputStream(file);
                CompressedStreamTools.writeCompressed(nbt, fileoutputstream);
                fileoutputstream.close();
            }
            catch (Exception exception)
            {
                exception.printStackTrace();
            }
            return nbt;
        }
        return null;
    }
        
    public void readStackFromFile(String file)
    {
    	FileInputStream fileinputstream = null;
    	NBTTagCompound nbt = null;
		try
		{
			fileinputstream = new FileInputStream(file);
		} catch (FileNotFoundException e)
		{
			e.printStackTrace();
		}
		try
		{
			nbt = CompressedStreamTools.readCompressed(fileinputstream);
	    	itemStack = new ItemStack(nbt);
		} catch (IOException e)
		{
			e.printStackTrace();
		}
    }
}

 

 

 

Link to comment
Share on other sites

48 minutes ago, MrDireball said:

I told it to read from and write to a file called "test.bat", but for some reason, it's still not working or even creating the file.

 

  Reveal hidden contents


    @Override
    public void readFromNBT(NBTTagCompound compound)
    {
    	readStackFromFile("test.dat");
    }

    @Override
    public NBTTagCompound writeToNBT(NBTTagCompound compound)
    {
    	return writeStackToFile("test.dat");
    }
    
    public NBTTagCompound writeStackToFile(String fileName)
    {
        if (itemStack != null)
        {
            NBTTagCompound nbt = new NBTTagCompound();
            itemStack.writeToNBT(nbt);
            File file = new File(fileName);
            try
            {
                file.createNewFile();
                FileOutputStream fileoutputstream = new FileOutputStream(file);
                CompressedStreamTools.writeCompressed(nbt, fileoutputstream);
                fileoutputstream.close();
            }
            catch (Exception exception)
            {
                exception.printStackTrace();
            }
            return nbt;
        }
        return null;
    }
        
    public void readStackFromFile(String file)
    {
    	FileInputStream fileinputstream = null;
    	NBTTagCompound nbt = null;
		try
		{
			fileinputstream = new FileInputStream(file);
		} catch (FileNotFoundException e)
		{
			e.printStackTrace();
		}
		try
		{
			nbt = CompressedStreamTools.readCompressed(fileinputstream);
	    	itemStack = new ItemStack(nbt);
		} catch (IOException e)
		{
			e.printStackTrace();
		}
    }
}

 

 

 

What? Why are you creating a file? Just create a new NBTTagCompound (NBTTagCompound itemTag = new NBTTagCompound), write the data to that tag, then add that tag to your TEs compound tag (in writeToNBT) (via NBTTagCompound#setTag). Then access it when you go to read it via NBTagCompound#getCompoundTag and create a new ItemStack off this.

 

Here is an example:

    @Override
    public NBTTagCompound writeToNBT(NBTTagCompound compound) {
        super.writeToNBT(compound);
        NBTTagCompound itemData = new NBTTagCompound(); // This will store the item data seperate from the TE's data
        ItemStack stack = new ItemStack(Items.DIAMOND); // You might not need to create a new item.
        stack.writeToNBT(itemData); //writes the Item's NBT to the 'itemData'.

        compound.setTag("ItemData", itemData); //writes the itemData tag to the TEs compound. This will be attached to the TE.

        return compound;
    }

    @Override
    public void readFromNBT(NBTTagCompound compound) {
        super.readFromNBT(compound);

        NBTTagCompound itemData = compound.getCompoundTag("ItemData"); //this will get the compound
        ItemStack stack = new ItemStack(itemData); //this will read the itemData and turn it into what it was.
        //From here, the stack will be loaded back into the TE and can be accessed again.
    }

 

Edited by unassigned
fixed dumb spaces in parentheses
Link to comment
Share on other sites

29 minutes ago, unassigned said:

What? Why are you creating a file? Just create a new NBTTagCompound ( NBTTagCompound itemTag = new NBTTagCompound ), write the data to that tag, then add that tag to your TEs compound tag (in writeToNBT) (via NBTTagCompound#setTag ). Then access it when you go to read it via NBTagCompound#getTag and create a new ItemStack off this.

I'm trying to use that method of doing it, but I'm getting two errors.

 

Code:

Spoiler

    @Override
    public void readFromNBT(NBTTagCompound compound)
    {
    	super.readFromNBT(compound);
        if (compound.hasKey("item"))
        {
            itemStack.deserializeNBT((NBTTagCompound) compound.getTag("item"));
        }
    }

    @Override
    public NBTTagCompound writeToNBT(NBTTagCompound compound)
    {
        super.writeToNBT(compound);
        compound.setTag("item", itemStack.serializeNBT());
        return compound;
    }

 

 

 

First error, occurs upon placing block:

Spoiler

[19:03:26] [Server thread/FATAL] [minecraft/MinecraftServer]: Error executing task
java.util.concurrent.ExecutionException: java.lang.NullPointerException
    at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_192]
    at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_192]
    at net.minecraft.util.Util.runTask(Util.java:54) [Util.class:?]
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:798) [MinecraftServer.class:?]
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743) [MinecraftServer.class:?]
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) [IntegratedServer.class:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) [MinecraftServer.class:?]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_192]
Caused by: java.lang.NullPointerException
    at davidgingerich.davesmod.blocks.advancedblocks.datablock.DataTileEntity.writeToNBT(DataTileEntity.java:43) ~[DataTileEntity.class:?]
    at net.minecraftforge.common.util.BlockSnapshot.getTileNBT(BlockSnapshot.java:132) ~[BlockSnapshot.class:?]
    at net.minecraftforge.common.util.BlockSnapshot.<init>(BlockSnapshot.java:61) ~[BlockSnapshot.class:?]
    at net.minecraftforge.common.util.BlockSnapshot.<init>(BlockSnapshot.java:82) ~[BlockSnapshot.class:?]
    at net.minecraftforge.common.util.BlockSnapshot.getBlockSnapshot(BlockSnapshot.java:113) ~[BlockSnapshot.class:?]
    at net.minecraft.world.World.setBlockState(World.java:394) ~[World.class:?]
    at davidgingerich.davesmod.blocks.advancedblocks.datablock.DataBlock.onBlockPlacedBy(DataBlock.java:90) ~[DataBlock.class:?]
    at net.minecraft.item.ItemBlock.placeBlockAt(ItemBlock.java:205) ~[ItemBlock.class:?]
    at net.minecraft.item.ItemBlock.onItemUse(ItemBlock.java:57) ~[ItemBlock.class:?]
    at net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(ForgeHooks.java:884) ~[ForgeHooks.class:?]
    at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:200) ~[ItemStack.class:?]
    at net.minecraft.server.management.PlayerInteractionManager.processRightClickBlock(PlayerInteractionManager.java:507) ~[PlayerInteractionManager.class:?]
    at net.minecraft.network.NetHandlerPlayServer.processTryUseItemOnBlock(NetHandlerPlayServer.java:769) ~[NetHandlerPlayServer.class:?]
    at net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.processPacket(CPacketPlayerTryUseItemOnBlock.java:68) ~[CPacketPlayerTryUseItemOnBlock.class:?]
    at net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.processPacket(CPacketPlayerTryUseItemOnBlock.java:13) ~[CPacketPlayerTryUseItemOnBlock.class:?]
    at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:21) ~[PacketThreadUtil$1.class:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_192]
    at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_192]
    at net.minecraft.util.Util.runTask(Util.java:53) ~[Util.class:?]
    ... 5 more

 

Second error, occurs upon trying to save game:

 

Spoiler

[19:03:27] [Server thread/ERROR] [FML]: A TileEntity type davidgingerich.davesmod.blocks.advancedblocks.datablock.DataTileEntity has throw an exception trying to write state. It will not persist. Report this to the mod author
java.lang.NullPointerException: null
    at davidgingerich.davesmod.blocks.advancedblocks.datablock.DataTileEntity.writeToNBT(DataTileEntity.java:43) ~[DataTileEntity.class:?]
    at net.minecraft.world.chunk.storage.AnvilChunkLoader.writeChunkToNBT(AnvilChunkLoader.java:414) [AnvilChunkLoader.class:?]
    at net.minecraft.world.chunk.storage.AnvilChunkLoader.saveChunk(AnvilChunkLoader.java:185) [AnvilChunkLoader.class:?]
    at net.minecraft.world.gen.ChunkProviderServer.saveChunkData(ChunkProviderServer.java:214) [ChunkProviderServer.class:?]
    at net.minecraft.world.gen.ChunkProviderServer.saveChunks(ChunkProviderServer.java:242) [ChunkProviderServer.class:?]
    at net.minecraft.world.WorldServer.saveAllChunks(WorldServer.java:1061) [WorldServer.class:?]
    at net.minecraft.server.MinecraftServer.saveAllWorlds(MinecraftServer.java:468) [MinecraftServer.class:?]
    at net.minecraft.server.integrated.IntegratedServer.saveAllWorlds(IntegratedServer.java:274) [IntegratedServer.class:?]
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:177) [IntegratedServer.class:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) [MinecraftServer.class:?]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_192]
 

 

 

 

3
 

 

Edited by MrDireball
Link to comment
Share on other sites

32 minutes ago, unassigned said:

You can use NBTagCompound#getCompoundTag instead of NBTTagCompound#getTag

 

Aswell, are you sure that the itemStack field is not null? Are you assigning it anywhere? 

Ah, yes, I forgot to check whether it was null first. I also fixed the other error by setting itemStack to initialize to a stack of air rather than null. So although there doesn't seem to be any more errors, the problem with it not saving the value of itemStack after unloading and reloading still persists.

 

DataBlock

Spoiler

public class DataBlock extends BlockBase implements ITileEntityProvider {

    public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);

    public DataBlock() {
        super("data_block", Material.ROCK);
		setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
    }

    @SideOnly(Side.CLIENT)
    public void initModel() {
    	ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), 0, new ModelResourceLocation(getRegistryName(), "inventory"));
    }

    @Override
    public TileEntity createNewTileEntity(World worldIn, int meta) {
        return new DataTileEntity();
    }

    private DataTileEntity getTE(World world, BlockPos pos) {
        return (DataTileEntity) world.getTileEntity(pos);
    }

    @Override
    public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand,
                EnumFacing side, float hitX, float hitY, float hitZ) {
        if (!world.isRemote) {
    		DataTileEntity dataEntity = (DataTileEntity)getTE(world, pos);
    	    ItemStack itemStack = dataEntity.getItemStack();
    	    dataEntity.setItemStack(player.getHeldItemMainhand());
    	    player.setHeldItem(player.getActiveHand(), itemStack);
        }
        return true;
    }

    @Override
    public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
        world.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
    }

    @Override
    public IBlockState getStateFromMeta(int meta) {
        return getDefaultState().withProperty(FACING, EnumFacing.getFront((meta & 3) + 2));
    }

    @Override
    public int getMetaFromState(IBlockState state) {
        return state.getValue(FACING).getIndex()-2;
    }

    @Override
    protected BlockStateContainer createBlockState() {
        return new BlockStateContainer(this, FACING);
    }

 

DataTileEntity

Spoiler


public class DataTileEntity extends TileEntity {
    
    ItemStack itemStack = new ItemStack(Items.AIR);

    public void setItemStack(ItemStack itemStack)
    {
        this.itemStack = itemStack;
        markDirty();
    }
    
    public ItemStack getItemStack() {
        return itemStack;
    }

    @Override
    public void readFromNBT(NBTTagCompound compound)
    {
    	super.readFromNBT(compound);
        if (compound.hasKey("item"))
        {
            itemStack.deserializeNBT((NBTTagCompound) compound.getCompoundTag("item"));
        }
    }

    @Override
    public NBTTagCompound writeToNBT(NBTTagCompound compound)
    {
        super.writeToNBT(compound);
        if (itemStack != null)compound.setTag("item", itemStack.serializeNBT());
        return compound;
    }

 

 

 

 

 

Link to comment
Share on other sites

24 minutes ago, MrDireball said:

Ah, yes, I forgot to check whether it was null first. I also fixed the other error by setting itemStack to initialize to a stack of air rather than null. So although there doesn't seem to be any more errors, the problem with it not saving the value of itemStack after unloading and reloading still persists.

 

DataBlock

  Reveal hidden contents


public class DataBlock extends BlockBase implements ITileEntityProvider {

    public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);

    public DataBlock() {
        super("data_block", Material.ROCK);
		setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
    }

    @SideOnly(Side.CLIENT)
    public void initModel() {
    	ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), 0, new ModelResourceLocation(getRegistryName(), "inventory"));
    }

    @Override
    public TileEntity createNewTileEntity(World worldIn, int meta) {
        return new DataTileEntity();
    }

    private DataTileEntity getTE(World world, BlockPos pos) {
        return (DataTileEntity) world.getTileEntity(pos);
    }

    @Override
    public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand,
                EnumFacing side, float hitX, float hitY, float hitZ) {
        if (!world.isRemote) {
    		DataTileEntity dataEntity = (DataTileEntity)getTE(world, pos);
    	    ItemStack itemStack = dataEntity.getItemStack();
    	    dataEntity.setItemStack(player.getHeldItemMainhand());
    	    player.setHeldItem(player.getActiveHand(), itemStack);
        }
        return true;
    }

    @Override
    public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
        world.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
    }

    @Override
    public IBlockState getStateFromMeta(int meta) {
        return getDefaultState().withProperty(FACING, EnumFacing.getFront((meta & 3) + 2));
    }

    @Override
    public int getMetaFromState(IBlockState state) {
        return state.getValue(FACING).getIndex()-2;
    }

    @Override
    protected BlockStateContainer createBlockState() {
        return new BlockStateContainer(this, FACING);
    }

 

DataTileEntity

  Reveal hidden contents



public class DataTileEntity extends TileEntity {
    
    ItemStack itemStack = new ItemStack(Items.AIR);

    public void setItemStack(ItemStack itemStack)
    {
        this.itemStack = itemStack;
        markDirty();
    }
    
    public ItemStack getItemStack() {
        return itemStack;
    }

    @Override
    public void readFromNBT(NBTTagCompound compound)
    {
    	super.readFromNBT(compound);
        if (compound.hasKey("item"))
        {
            itemStack.deserializeNBT((NBTTagCompound) compound.getCompoundTag("item"));
        }
    }

    @Override
    public NBTTagCompound writeToNBT(NBTTagCompound compound)
    {
        super.writeToNBT(compound);
        if (itemStack != null)compound.setTag("item", itemStack.serializeNBT());
        return compound;
    }

 

 

 

 

 

Yeah, just remember ItemStacks should never be null. Instead, if you want an ItemStack to be empty, use ItemStack.EMPTY

 

What are you trying to achieve with this block? What it seems like you want to add the player's hand stack to its inventory. Instead of implementing your own inventory system, try exposing the IItemHandler capability. This will give your TE an inventory, and will most likely solve many of your problems. Not to mention, the capability will provide a lot better compat with other mods that access inventories. You shouldn't be creating an inventory from an ItemStack field.

 

Here is an example of what I'm saying. (You should also reference the official forge documentation)

First, create the handler itself (This will be a field will be in your TE):

    public final ItemStackHandler inv = new ItemStackHandler(1);

The constructor to ItemStackHandler is how many slots the inventory should have.

Now, you need to expose the capability for forge to access. 

    @Override
    public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
        if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY){
            return true;  //this is also where you'd check the facing, incase you only want to insert on certain sides.
        }

        return super.hasCapability(capability, facing);
    }

    @Nullable
    @Override
    public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
        if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY){ //this will check to see if the capability being 'get' is, in fact, the ItemHandler
            return (T) this.inv; //this will be the inventory field that you have attached to your TE.
        }
        return super.getCapability(capability, facing);
    }

 

To save the data of the inventory, use ItemStackHandler#serializeNBT and ItemStackHandler#deserializeNBT.

 

From the block class, you need to get the capability (using TileEntity#getCapability) and use ItemStackHandler#insertItem to put the item into the TE's inventory.

Edited by unassigned
stack correction
  • Like 1
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

    • First time seeing this error (After having played Minecraft for many, many years) and I have no clue what seems to be breaking. I've tried using the methods people have suggested to others but I always seems to have more errors.  So far the game output has been helpful in at least seeing that I have errors, and I have gone and removed multiple mods that seemed to have causes them, but yeah. I've got the log from once I start World generation here, but if you need more just tell me. https://jpst.it/3ad8S Obviously, thank you kindly for any help you may provide.
    • MultiMC version: 0.7.0-3714   Launched instance in online mode   authserver.mojang.com resolves to:     [13.35.108.35, 13.35.108.56, 13.35.108.40, 13.35.108.62]   session.minecraft.net resolves to:     [13.107.237.41, 13.107.238.41]   textures.minecraft.net resolves to:     [13.107.238.41, 13.107.237.41]   api.mojang.com resolves to:     [13.107.237.41, 13.107.238.41]   Minecraft folder is: C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/instances/1.19.2/.minecraft   Java path is: C:/Program Files/Common Files/Oracle/Java/javapath/javaw.exe   Checking Java version... Java is version 18.0.1.1, using 64-bit architecture, from Oracle Corporation.   Main Class:   io.github.zekerzhayard.forgewrapper.installer.Main   Native path:   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/instances/1.19.2/natives   Traits: traits XR:Initial traits FirstThreadOnMacOS   Libraries:   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/lwjgl/lwjgl-glfw/3.3.1/lwjgl-glfw-3.3.1.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/lwjgl/lwjgl-jemalloc/3.3.1/lwjgl-jemalloc-3.3.1.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/lwjgl/lwjgl-openal/3.3.1/lwjgl-openal-3.3.1.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/lwjgl/lwjgl-opengl/3.3.1/lwjgl-opengl-3.3.1.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/lwjgl/lwjgl-stb/3.3.1/lwjgl-stb-3.3.1.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/lwjgl/lwjgl-tinyfd/3.3.1/lwjgl-tinyfd-3.3.1.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/lwjgl/lwjgl/3.3.1/lwjgl-3.3.1.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/com/mojang/logging/1.0.0/logging-1.0.0.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/com/mojang/blocklist/1.0.10/blocklist-1.0.10.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/com/mojang/patchy/2.2.10/patchy-2.2.10.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/com/github/oshi/oshi-core/5.8.5/oshi-core-5.8.5.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/net/java/dev/jna/jna/5.10.0/jna-5.10.0.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/net/java/dev/jna/jna-platform/5.10.0/jna-platform-5.10.0.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/slf4j/slf4j-api/1.8.0-beta4/slf4j-api-1.8.0-beta4.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/apache/logging/log4j/log4j-slf4j18-impl/2.17.0/log4j-slf4j18-impl-2.17.0.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/com/ibm/icu/icu4j/70.1/icu4j-70.1.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/com/mojang/javabridge/1.2.24/javabridge-1.2.24.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/net/sf/jopt-simple/jopt-simple/5.0.4/jopt-simple-5.0.4.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/io/netty/netty-common/4.1.77.Final/netty-common-4.1.77.Final.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/io/netty/netty-buffer/4.1.77.Final/netty-buffer-4.1.77.Final.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/io/netty/netty-codec/4.1.77.Final/netty-codec-4.1.77.Final.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/io/netty/netty-handler/4.1.77.Final/netty-handler-4.1.77.Final.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/io/netty/netty-resolver/4.1.77.Final/netty-resolver-4.1.77.Final.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/io/netty/netty-transport/4.1.77.Final/netty-transport-4.1.77.Final.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/io/netty/netty-transport-native-unix-common/4.1.77.Final/netty-transport-native-unix-common-4.1.77.Final.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/io/netty/netty-transport-classes-epoll/4.1.77.Final/netty-transport-classes-epoll-4.1.77.Final.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/apache/commons/commons-lang3/3.12.0/commons-lang3-3.12.0.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/commons-io/commons-io/2.11.0/commons-io-2.11.0.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/commons-codec/commons-codec/1.15/commons-codec-1.15.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/com/mojang/brigadier/1.0.18/brigadier-1.0.18.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/com/mojang/datafixerupper/5.0.28/datafixerupper-5.0.28.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/com/google/code/gson/gson/2.8.9/gson-2.8.9.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/com/mojang/authlib/3.11.49/authlib-3.11.49.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/apache/commons/commons-compress/1.21/commons-compress-1.21.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/apache/httpcomponents/httpclient/4.5.13/httpclient-4.5.13.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/commons-logging/commons-logging/1.2/commons-logging-1.2.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/apache/httpcomponents/httpcore/4.4.14/httpcore-4.4.14.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/it/unimi/dsi/fastutil/8.5.6/fastutil-8.5.6.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/apache/logging/log4j/log4j-api/2.17.0/log4j-api-2.17.0.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/apache/logging/log4j/log4j-core/2.17.0/log4j-core-2.17.0.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/com/mojang/text2speech/1.13.9/text2speech-1.13.9.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/io/github/zekerzhayard/ForgeWrapper/mmc3/ForgeWrapper-mmc3.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/cpw/mods/securejarhandler/2.1.4/securejarhandler-2.1.4.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/ow2/asm/asm/9.3/asm-9.3.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/ow2/asm/asm-commons/9.3/asm-commons-9.3.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/ow2/asm/asm-tree/9.3/asm-tree-9.3.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/ow2/asm/asm-util/9.3/asm-util-9.3.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/ow2/asm/asm-analysis/9.3/asm-analysis-9.3.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/net/minecraftforge/accesstransformers/8.0.4/accesstransformers-8.0.4.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/antlr/antlr4-runtime/4.9.1/antlr4-runtime-4.9.1.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/net/minecraftforge/eventbus/6.0.3/eventbus-6.0.3.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/net/minecraftforge/forgespi/6.0.0/forgespi-6.0.0.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/net/minecraftforge/coremods/5.0.1/coremods-5.0.1.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/cpw/mods/modlauncher/10.0.8/modlauncher-10.0.8.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/net/minecraftforge/unsafe/0.2.0/unsafe-0.2.0.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/com/electronwill/night-config/core/3.6.4/core-3.6.4.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/com/electronwill/night-config/toml/3.6.4/toml-3.6.4.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/apache/maven/maven-artifact/3.8.5/maven-artifact-3.8.5.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/net/jodah/typetools/0.8.3/typetools-0.8.3.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/net/minecrell/terminalconsoleappender/1.2.0/terminalconsoleappender-1.2.0.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/jline/jline-reader/3.12.1/jline-reader-3.12.1.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/jline/jline-terminal/3.12.1/jline-terminal-3.12.1.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/spongepowered/mixin/0.8.5/mixin-0.8.5.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/openjdk/nashorn/nashorn-core/15.3/nashorn-core-15.3.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/net/minecraftforge/JarJarSelector/0.3.16/JarJarSelector-0.3.16.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/net/minecraftforge/JarJarMetadata/0.3.16/JarJarMetadata-0.3.16.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/cpw/mods/bootstraplauncher/1.1.2/bootstraplauncher-1.1.2.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/net/minecraftforge/JarJarFileSystems/0.3.16/JarJarFileSystems-0.3.16.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/net/minecraftforge/fmlloader/1.19.2-43.2.0/fmlloader-1.19.2-43.2.0.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/com/mojang/minecraft/1.19.2/minecraft-1.19.2-client.jar   Native libraries:   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/lwjgl/lwjgl-glfw/3.3.1/lwjgl-glfw-3.3.1-natives-windows.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/lwjgl/lwjgl-jemalloc/3.3.1/lwjgl-jemalloc-3.3.1-natives-windows.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/lwjgl/lwjgl-openal/3.3.1/lwjgl-openal-3.3.1-natives-windows.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/lwjgl/lwjgl-opengl/3.3.1/lwjgl-opengl-3.3.1-natives-windows.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/lwjgl/lwjgl-stb/3.3.1/lwjgl-stb-3.3.1-natives-windows.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/lwjgl/lwjgl-tinyfd/3.3.1/lwjgl-tinyfd-3.3.1-natives-windows.jar   C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/libraries/org/lwjgl/lwjgl/3.3.1/lwjgl-3.3.1-natives-windows.jar   Mods:   [✔️] (forge+1.19.2)+regions_unexplored+R-192.2.4.jar   [✔️] alexsmobs-1.21.1.jar   [✔️] architectury-6.4.62-forge.jar   [✔️] caelus-forge-1.19.2-3.0.0.6.jar   [✔️] cardinal-components-api-5.0.2.jar   [✔️] citadel-2.1.1-1.19.jar   [✔️] cloth-config-8.2.88-forge.jar   [✔️] configured-2.0.1-1.19.2.jar   [✔️] curios-forge-1.19.2-5.1.1.0.jar   [✔️] drinkbeer-refill-1.19.2-1.0.1.jar   [✔️] dungeons_libraries-1.19.2-3.0.7-beta.jar   [✔️] dungeons_mobs-1.19.2-4.0.4-beta.jar   [✔️] effective-1.6+1.19.2.jar   [✔️] FarmersDelight-1.19-1.2.0.jar   [✔️] geckolib-forge-1.19-3.1.39.jar   [✔️] guardvillagers-1.19.2-1.5.2.jar   [✔️] hunterillager-1.19.2-6.2.0.jar   [✔️] illagersweararmor-1.2.4.jar   [✔️] immersive_armors-1.5.4+1.19.2-forge.jar   [✔️] inmis-2.7.1-1.19.jar   [✔️] jei-1.19.2-forge-11.4.0.286.jar   [✔️] L_Enders_Cataclysm-0.52-1.19.2.jar   [✔️] mutantmore-1.19.2-early-access-1.0.7.jar   [✔️] OptiFine_1.19.2_HD_U_I1.jar   [✔️] origins-forge-1.19.2-1.5.0.6-all.jar   [✔️] pyrologerandfriends-1.6.4-1.19.2.jar   [✔️] pyrologerandfriends-1.6.5.7-1.19.2.jar   [❌] RoughlyEnoughItems-9.1.587.jar.disabled (disabled)   [✔️] TerraBlender-forge-1.19.2-2.0.1.136.jar   [✔️] TravelersBackpack-1.19.2-8.2.19.jar   [✔️] TreeChop-1.19.2-forge-0.17.3.jar   [✔️] UnityHubSetup.exe   Params:   --username  --version 1.19.2 --gameDir C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/instances/1.19.2/.minecraft --assetsDir C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/assets --assetIndex 1.19 --uuid  --accessToken  --userType  --versionType release --launchTarget forgeclient --fml.forgeVersion 43.2.0 --fml.mcVersion 1.19.2 --fml.forgeGroup net.minecraftforge --fml.mcpVersion 20220805.130853   Window size: 854 x 480   Java Arguments: [-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump, -Xms512m, -Xmx8192m, -Duser.language=en]   Minecraft process ID: 7120   Using onesix launcher.   Checking: MC_SLIM Checking: MERGED_MAPPINGS Checking: MAPPINGS Checking: MC_EXTRA Checking: MOJMAPS Checking: PATCHED Checking: MC_SRG 2023-04-02 00:31:33,330 main WARN Advanced terminal features are not available in this environment [00:31:33] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, SporadicClouds, --version, 1.19.2, --gameDir, C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/instances/1.19.2/.minecraft, --assetsDir, C:/Users/Ashes/Downloads/mmc-stable-win32/MultiMC/assets, --assetIndex, 1.19, --uuid, <PROFILE ID>, --accessToken, ????????, --userType, msa, --versionType, release, --launchTarget, forgeclient, --fml.forgeVersion, 43.2.0, --fml.mcVersion, 1.19.2, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20220805.130853, --width, 854, --height, 480] [00:31:33] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 10.0.8+10.0.8+main.0ef7e830 starting: java version 18.0.1.1 by Oracle Corporation; OS Windows 10 arch amd64 version 10.0 [00:31:34] [main/INFO] [op.OptiFineTransformationService/]: OptiFineTransformationService.onLoad [00:31:34] [main/INFO] [op.OptiFineTransformationService/]: OptiFine ZIP file URL: union:/C:/Users/Jeante%20St.Helene/Downloads/mmc-stable-win32/MultiMC/instances/1.19.2/.minecraft/mods/OptiFine_1.19.2_HD_U_I1.jar%23153!/ [00:31:34] [main/INFO] [op.OptiFineTransformationService/]: OptiFine ZIP file: C:\Users\Ashes\Downloads\mmc-stable-win32\MultiMC\instances\1.19.2\.minecraft\mods\OptiFine_1.19.2_HD_U_I1.jar [00:31:34] [main/INFO] [op.OptiFineTransformer/]: Target.PRE_CLASS is available [00:31:34] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=union:/C:/Users/Jeante%20St.Helene/Downloads/mmc-stable-win32/MultiMC/libraries/org/spongepowered/mixin/0.8.5/mixin-0.8.5.jar%23118!/ Service=ModLauncher Env=CLIENT [00:31:34] [main/INFO] [op.OptiFineTransformationService/]: OptiFineTransformationService.initialize [00:31:34] [main/WARN] [ne.mi.fm.lo.mo.ModFileParser/LOADING]: Mod file C:\Users\Ashes\Downloads\mmc-stable-win32\MultiMC\libraries\net\minecraftforge\fmlcore\1.19.2-43.2.0\fmlcore-1.19.2-43.2.0.jar is missing mods.toml file [00:31:34] [main/WARN] [ne.mi.fm.lo.mo.ModFileParser/LOADING]: Mod file C:\Users\Ashes\Downloads\mmc-stable-win32\MultiMC\libraries\net\minecraftforge\javafmllanguage\1.19.2-43.2.0\javafmllanguage-1.19.2-43.2.0.jar is missing mods.toml file [00:31:34] [main/WARN] [ne.mi.fm.lo.mo.ModFileParser/LOADING]: Mod file C:\Users\Ashes\Downloads\mmc-stable-win32\MultiMC\libraries\net\minecraftforge\lowcodelanguage\1.19.2-43.2.0\lowcodelanguage-1.19.2-43.2.0.jar is missing mods.toml file [00:31:34] [main/WARN] [ne.mi.fm.lo.mo.ModFileParser/LOADING]: Mod file C:\Users\Ashes\Downloads\mmc-stable-win32\MultiMC\libraries\net\minecraftforge\mclanguage\1.19.2-43.2.0\mclanguage-1.19.2-43.2.0.jar is missing mods.toml file [00:31:35] [main/INFO] [ne.mi.fm.lo.mo.JarInJarDependencyLocator/]: Found 3 dependencies adding them to mods collection [00:31:36] [main/INFO] [op.OptiFineTransformationService/]: OptiFineTransformationService.transformers [00:31:36] [main/INFO] [op.OptiFineTransformer/]: Targets: 386 [00:31:37] [main/INFO] [op.OptiFineTransformationService/]: additionalClassesLocator: [optifine., net.optifine.] [00:31:38] [main/INFO] [mixin/]: Compatibility level set to JAVA_17 [00:31:38] [main/INFO] [cp.mo.mo.LaunchServiceHandler/MODLAUNCHER]: Launching target 'forgeclient' with arguments [--version, 1.19.2, --gameDir, C:\Users\Ashes\Downloads\mmc-stable-win32\MultiMC\instances\1.19.2\.minecraft, --assetsDir, C:\Users\Ashes\Downloads\mmc-stable-win32\MultiMC\assets, --uuid, <PROFILE ID>, --username, SporadicClouds, --assetIndex, 1.19, --accessToken, ????????, --userType, msa, --versionType, release, --width, 854, --height, 480] Failed to start Minecraft: java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119) at java.base/java.lang.reflect.Method.invoke(Method.java:577) at io.github.zekerzhayard.forgewrapper.installer.Main.main(Main.java:57) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:577) at org.multimc.onesix.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:214) at org.multimc.onesix.OneSixLauncher.launch(OneSixLauncher.java:249) at org.multimc.EntryPoint.listen(EntryPoint.java:143) at org.multimc.EntryPoint.main(EntryPoint.java:34) Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:32) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.Launcher.run(Launcher.java:106) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.Launcher.main(Launcher.java:77) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) at cpw.mods.bootstraplauncher@1.1.2/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:141) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) ... 8 more Caused by: java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119) at java.base/java.lang.reflect.Method.invoke(Method.java:577) at MC-BOOTSTRAP/fmlloader@1.19.2-43.2.0/net.minecraftforge.fml.loading.targets.CommonClientLaunchHandler.lambda$launchService$0(CommonClientLaunchHandler.java:27) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:30) ... 16 more Caused by: 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@10.0.8/cpw.mods.modlauncher.serviceapi.ILaunchPluginService.processClassWithFlags(ILaunchPluginService.java:156) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.LaunchPluginHandler.offerClassNodeToPlugins(LaunchPluginHandler.java:88) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.ClassTransformer.transform(ClassTransformer.java:120) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.TransformingClassLoader.maybeTransformClassBytes(TransformingClassLoader.java:50) at cpw.mods.securejarhandler/cpw.mods.cl.ModuleClassLoader.readerToClass(ModuleClassLoader.java:113) at cpw.mods.securejarhandler/cpw.mods.cl.ModuleClassLoader.lambda$findClass$15(ModuleClassLoader.java:219) at cpw.mods.securejarhandler/cpw.mods.cl.ModuleClassLoader.loadFromModule(ModuleClassLoader.java:229) at cpw.mods.securejarhandler/cpw.mods.cl.ModuleClassLoader.findClass(ModuleClassLoader.java:219) at cpw.mods.securejarhandler/cpw.mods.cl.ModuleClassLoader.loadClass(ModuleClassLoader.java:135) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1013) at cpw.mods.securejarhandler/cpw.mods.cl.ModuleClassLoader.readerToClass(ModuleClassLoader.java:119) at cpw.mods.securejarhandler/cpw.mods.cl.ModuleClassLoader.lambda$findClass$15(ModuleClassLoader.java:219) at cpw.mods.securejarhandler/cpw.mods.cl.ModuleClassLoader.loadFromModule(ModuleClassLoader.java:229) at cpw.mods.securejarhandler/cpw.mods.cl.ModuleClassLoader.findClass(ModuleClassLoader.java:219) at cpw.mods.securejarhandler/cpw.mods.cl.ModuleClassLoader.loadClass(ModuleClassLoader.java:135) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at java.base/java.lang.Class.getDeclaredFields0(Native Method) at java.base/java.lang.Class.privateGetDeclaredFields(Class.java:3329) at java.base/java.lang.Class.getDeclaredFields(Class.java:2403) at TRANSFORMER/net.optifine/net.optifine.reflect.FieldLocatorTypes.<init>(FieldLocatorTypes.java:25) at TRANSFORMER/net.optifine/net.optifine.reflect.Reflector.<clinit>(Reflector.java:503) at TRANSFORMER/minecraft@1.19.2/net.minecraft.CrashReport.m_127526_(CrashReport.java:175) at TRANSFORMER/minecraft@1.19.2/net.minecraft.CrashReport.m_127529_(CrashReport.java:345) at TRANSFORMER/minecraft@1.19.2/net.minecraft.client.main.Main.m_239872_(Main.java:144) at TRANSFORMER/minecraft@1.19.2/net.minecraft.client.main.Main.main(Main.java:51) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) ... 19 more Caused by: org.spongepowered.asm.mixin.injection.throwables.InjectionError: Critical injection failure: Redirector handleIsBow(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/item/Item;)Z in dungeons_libraries.mixins.json:AbstractClientPlayerMixin failed injection check, (0/1) succeeded. Scanned 1 target(s). Using refmap dungeons_libraries.refmap.json at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.injection.struct.InjectionInfo.postInject(InjectionInfo.java:468) at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinTargetContext.applyInjections(MixinTargetContext.java:1362) at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyInjections(MixinApplicatorStandard.java:1051) at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyMixin(MixinApplicatorStandard.java:400) at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.apply(MixinApplicatorStandard.java:325) 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) ... 50 more Exiting with -1 Process exited with code -1 (0xffffffffffffffff). Please note that usually neither the exit code, nor its description are enough to diagnose issues! Always upload the entire log and not just the exit code. Clipboard copy at: 02 Apr 2023 00:49:02 -0400 Clipboard copy at: 02 Apr 2023 00:50:49 -0400  
    • When I was installing forge 1.18.2 an error automatically shows The Error Says: Failed to run processor: javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target I do not know how to fix
    • I recently got a new laptop as a gift - on my previous laptop all of my mods and everything worked completely fine and as intended but for some reason with the new one, after installing forge for 1.8 and moving both my mod and config folder over, the game crashes without even booting up. When I installed forge (1.8) I did mis click the server option instead of client but I thought it wouldn't do anything and for the most part it seems it doesn't. I did reinstall with the client option selected. The game only seems to crash when the mod folder is in the .minecraft folder, not the config. I have the windows store version of the launcher installed. if anyone has answers ill be extremely happy with any feedback. Thank you for your time.   List of Mods installed (mostly hypixel skyblock and QOL mods): Apec Block Overlay Dulkir FastChat Not Enough Updates Patcher Scrollable Tooltips Skyblock Addons Skyblock Catia Skytils SoopyV2 Timechanger Chat Triggers
    • I'm making a survival-realistic modpack on 1.18.2 and the game crashes whenever loading a new world. it never loads past 0%.  This is the crash report. If it doesn't work, I can always make another.  https://pastebin.com/Gb4Nae4V
  • Topics

×
×
  • Create New...

Important Information

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