Jump to content

[1.9] TileEntity - Assigne new NBTCompound


Darki

Recommended Posts

Hi,

I am making a machine. With a GUI Container, the Container is working and also the TileEntity but now I see that when you place the machine twice the machines have the same TileEntity, so that in both machine are the same Inventories and Items.

Here my Codes:

TileEntity:

public class TileEntityChemicalMixer extends TileEntity{

public InventoryBasic INVENTORY;
private static int ID = 0;

public TileEntityChemicalMixer(){
	INVENTORY = new InventoryBasic("Chemical Mixer", false, 3);
}

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

	NBTTagList list = new NBTTagList();

	for(int i = 0; i < INVENTORY.getSizeInventory(); i++){
		if(INVENTORY.getStackInSlot(i) != null){
			NBTTagCompound tag = new NBTTagCompound();
			tag.setByte("Slot", (byte) i);
			INVENTORY.getStackInSlot(i).writeToNBT(tag);
			list.appendTag(tag);
		}
	}

	compound.setTag("ItemStacks-" + ID, list);
}

@Override
public void readFromNBT(NBTTagCompound compound) {
	super.readFromNBT(compound);
	NBTTagList list = compound.getTagList("ItemStacks-" + ID, 10);
	this.INVENTORY = new InventoryBasic("Chemical Mixer", false, 3);
	for(int i = 0; i < list.tagCount(); i++){
		NBTTagCompound tag = list.getCompoundTagAt(i);
		byte b = tag.getByte("Slot");
		if(b >= 0 && b < INVENTORY.getSizeInventory()){
			INVENTORY.setInventorySlotContents(b, ItemStack.loadItemStackFromNBT(tag));
		}
	}
}

}

 

Container:

public class ContainerChemicalMixer extends Container{

private TileEntityChemicalMixer tileentiy;

public ContainerChemicalMixer(IInventory inv, TileEntityChemicalMixer tileentity) {
	this.tileentiy = tileentity;
	this.addSlotToContainer(new Slot(inv, 36, 30, 17));
	this.addSlotToContainer(new Slot(inv, 37, 130, 17));
	this.addSlotToContainer(new OutputSlot(inv, 38, 80, 51));

    // Player Inventory, Slot 9-35, Slot IDs 9-35
    for (int y = 0; y < 3; ++y) {
        for (int x = 0; x < 9; ++x) {
            this.addSlotToContainer(new Slot(inv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18));
        }
    }

    // Player Inventory, Slot 0-8, Slot IDs 36-44
    for (int x = 0; x < 9; ++x) {
        this.addSlotToContainer(new Slot(inv, x, 8 + x * 18, 142));
    }
}

@Override
public boolean canInteractWith(EntityPlayer playerIn) {
	return true;
}

@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot) {
	ItemStack previous = null;
    Slot slot = (Slot) this.inventorySlots.get(fromSlot);

    if (slot != null && slot.getHasStack()) {
        ItemStack current = slot.getStack();
        previous = current.copy();

        if (fromSlot < 9) {
            // From TE Inventory to Player Inventory
            if (!this.mergeItemStack(current, 9, 37, true))
                return null;
        } else {
            // From Player Inventory to TE Inventory
            if (!this.mergeItemStack(current, 0, 9, false))
                return null;
        }

        if (current.stackSize == 0)
            slot.putStack((ItemStack) null);
        else
            slot.onSlotChanged();

        if (current.stackSize == previous.stackSize)
            return null;
        slot.onPickupFromSlot(playerIn, current);
    }
    return previous;
}

}

Link to comment
Share on other sites

Post your

Block

class.

 

Side note: I'd recommend using

IItemHandler

instead of

IInventory

and exposing it as a Capability if you want to allow automated access to the inventory by things like hoppers.

 

You can see my implementation of a vanilla-style chest using

IItemHandler

here. All referenced classes are in the linked repository.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

This is my Block Class:

public class BlockChemicalMixer extends BasicBlock{

public BlockChemicalMixer() {
	super(Material.rock, "chemicalmixer", 10F, Tool.PICKAXE, HarvestLevel.IRON);
}

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
	if(!world.isRemote){
		player.openGui(Main.INSTANCE, GuiHandler.GUI_ID, world, pos.getX(), pos.getY(), pos.getZ());
	}
	return true;
}

}

 

Nothing special. When you ask for the BasicBlock class here:

public class BasicBlock extends Block{

public BasicBlock(Material m, String name, float hardness, Tool tool, HarvestLevel level) {
	super(m);
	setUnlocalizedName(name);
	setRegistryName(name);
	setHardness(hardness);
	setCreativeTab(Main.chemTab);
	setHarvestLevel(tool.getToolClass(), level.getLevel());
}

enum HarvestLevel{

	WOOD(0),
	STONE(1),
	IRON(2),
	GOLD(0),
	DIAMOND(3);

	private int level;

	private HarvestLevel(int level) {
		this.level = level;
	}

	private int getLevel(){
		return this.level;
	}

}

enum Tool{
	PICKAXE("pickaxe"),
	AXE("axe"),
	HOE("hoe"),
	SHOVEL("shovel");

	private String toolClass;

	private Tool(String toolClass) {
		this.toolClass = toolClass;
	}

	private String getToolClass(){
		return this.toolClass;
	}

}
}

Link to comment
Share on other sites

You never instantiate your

TileEntity

anywhere. Override

Block#hasTileEntity(IBlockState)

to return

true

and

Block#createTileEntity

to create and return an instance of your

TileEntity

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Of Course I instantitate my TileEntity in the GUI Handler:

public class GuiHandler implements IGuiHandler{

public static final int GUI_ID = 0;

@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
	if (ID == GUI_ID)
        return new ContainerChemicalMixer(player.inventory, (TileEntityChemicalMixer) world.getTileEntity(new BlockPos(x, y, z)));
	else if (ID == GUI_ID + 1)
        return new ContainerGenerator(player.inventory, (TileEntityGenerator) world.getTileEntity(new BlockPos(x, y, z)));
	return null;
}

@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
	if (ID == GUI_ID)
		return new GuiChemicalMixer(new ContainerChemicalMixer(player.inventory, (TileEntityChemicalMixer) world.getTileEntity(new BlockPos(x, y, z))));
	else if (ID == GUI_ID + 1)
		return new GuiGenerator(new ContainerGenerator(player.inventory, (TileEntityGenerator) world.getTileEntity(new BlockPos(x, y, z))));
	return null;
}

}

Link to comment
Share on other sites

Of Course I instantitate my TileEntity in the GUI Handler:

public class GuiHandler implements IGuiHandler{

public static final int GUI_ID = 0;

@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
	if (ID == GUI_ID)
        return new ContainerChemicalMixer(player.inventory, (TileEntityChemicalMixer) world.getTileEntity(new BlockPos(x, y, z)));
	else if (ID == GUI_ID + 1)
        return new ContainerGenerator(player.inventory, (TileEntityGenerator) world.getTileEntity(new BlockPos(x, y, z)));
	return null;
}

@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
	if (ID == GUI_ID)
		return new GuiChemicalMixer(new ContainerChemicalMixer(player.inventory, (TileEntityChemicalMixer) world.getTileEntity(new BlockPos(x, y, z))));
	else if (ID == GUI_ID + 1)
		return new GuiGenerator(new ContainerGenerator(player.inventory, (TileEntityGenerator) world.getTileEntity(new BlockPos(x, y, z))));
	return null;
}

}

What about when it is placed?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Of Course I instantitate my TileEntity in the GUI Handler:

public class GuiHandler implements IGuiHandler{

public static final int GUI_ID = 0;

@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
	if (ID == GUI_ID)
        return new ContainerChemicalMixer(player.inventory, (TileEntityChemicalMixer) world.getTileEntity(new BlockPos(x, y, z)));
	else if (ID == GUI_ID + 1)
        return new ContainerGenerator(player.inventory, (TileEntityGenerator) world.getTileEntity(new BlockPos(x, y, z)));
	return null;
}

@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
	if (ID == GUI_ID)
		return new GuiChemicalMixer(new ContainerChemicalMixer(player.inventory, (TileEntityChemicalMixer) world.getTileEntity(new BlockPos(x, y, z))));
	else if (ID == GUI_ID + 1)
		return new GuiGenerator(new ContainerGenerator(player.inventory, (TileEntityGenerator) world.getTileEntity(new BlockPos(x, y, z))));
	return null;
}

}

 

No you don't. You instantiate the

Gui

and the

Container

using the

TileEntity

you get from the

World

(which will be

null

).

 

Side note: Store each GUI ID in its own field, don't calculate them in the method. Consider using a

switch

statement instead of an

if

-

else

chain.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Ok I try it. but i instantitate the TileEntity in the Container Class:

private TileEntityChemicalMixer tileentiy;

And then:

	public ContainerChemicalMixer(IInventory inv, TileEntityChemicalMixer tileentity) {
	this.tileentiy = tileentity;
	this.addSlotToContainer(new Slot(inv, 36, 30, 17));
	this.addSlotToContainer(new Slot(inv, 37, 130, 17));
	this.addSlotToContainer(new OutputSlot(inv, 38, 80, 51));

    // Player Inventory, Slot 9-35, Slot IDs 9-35
    for (int y = 0; y < 3; ++y) {
        for (int x = 0; x < 9; ++x) {
            this.addSlotToContainer(new Slot(inv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18));
        }
    }

    // Player Inventory, Slot 0-8, Slot IDs 36-44
    for (int x = 0; x < 9; ++x) {
        this.addSlotToContainer(new Slot(inv, x, 8 + x * 18, 142));
    }
}

Link to comment
Share on other sites

Ok I try it. but i instantitate the TileEntity in the Container Class:

private TileEntityChemicalMixer tileentiy;

And then:

	public ContainerChemicalMixer(IInventory inv, TileEntityChemicalMixer tileentity) {
	this.tileentiy = tileentity;
	this.addSlotToContainer(new Slot(inv, 36, 30, 17));
	this.addSlotToContainer(new Slot(inv, 37, 130, 17));
	this.addSlotToContainer(new OutputSlot(inv, 38, 80, 51));

    // Player Inventory, Slot 9-35, Slot IDs 9-35
    for (int y = 0; y < 3; ++y) {
        for (int x = 0; x < 9; ++x) {
            this.addSlotToContainer(new Slot(inv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18));
        }
    }

    // Player Inventory, Slot 0-8, Slot IDs 36-44
    for (int x = 0; x < 9; ++x) {
        this.addSlotToContainer(new Slot(inv, x, 8 + x * 18, 142));
    }
}

 

Again, you're not instantiating it there (and you shouldn't be), you're simply declaring a field and constructor parameter and assigning the constructor parameter to the field.

 

Instantiating means "creating an instance of", i.e. the

new

operator.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

"GUI" and "NBT" should never be used in the same sentence.

And GUIs don't contain Inventory items, they display Inventory items.

 

TL;DR: You're doing everything wrong.

 

Block -> creates TileEntity

TileEntity -> contains Items

Container -> wraps around TileEntity

GuiContainer -> displays Container

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Hm I didnt do this wrong so you said...I did it...or not? I watched a Tutorial...and this is the solution from the Tutorial

Do you have either a class that extends BlockContainer or a class that extends Block that Overrides hasTileEntity() and createTileEntity(). If not you didn't do it right. And that tutorial is wrong.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Hm I didnt do this wrong so you said...I did it...or not? I watched a Tutorial...and this is the solution from the Tutorial

 

You did something wrong, because you didn't do this:

 

Do you have either a class that extends BlockContainer or a class that extends Block that Overrides hasTileEntity() and createTileEntity(). If not you didn't do it right. And that tutorial is wrong.

 

Please do the latter, do not use BlockContainer.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Ok that wasnt in the Tutorial...now I added it:

public class BlockChemicalMixer extends BasicBlock{

public BlockChemicalMixer() {
	super(Material.rock, "chemicalmixer", 10F, Tool.PICKAXE, HarvestLevel.IRON);
	isBlockContainer = true;
}

@Override
public TileEntity createTileEntity(World world, IBlockState state) {
	return new TileEntityChemicalMixer();
}

@Override
public boolean hasTileEntity() {
	return true;
}

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
	if(!world.isRemote){
		player.openGui(Main.INSTANCE, GuiHandler.GUI_ID, world, pos.getX(), pos.getY(), pos.getZ());
	}
	return true;
}

}

 

is it right now?

Link to comment
Share on other sites

I unno. Does your code run now?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

public class ContainerChemicalMixer extends Container{

private TileEntityChemicalMixer tileentiy;

public ContainerChemicalMixer(IInventory inv, TileEntityChemicalMixer tileentity) {
	this.tileentiy = tileentity;
	this.addSlotToContainer(new Slot(inv, 36, 30, 17));
	this.addSlotToContainer(new Slot(inv, 37, 130, 17));
	this.addSlotToContainer(new OutputSlot(inv, 38, 80, 51));

    // Player Inventory, Slot 9-35, Slot IDs 9-35
    for (int y = 0; y < 3; ++y) {
        for (int x = 0; x < 9; ++x) {
            this.addSlotToContainer(new Slot(inv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18));
        }
    }

    // Player Inventory, Slot 0-8, Slot IDs 36-44
    for (int x = 0; x < 9; ++x) {
        this.addSlotToContainer(new Slot(inv, x, 8 + x * 18, 142));
    }
}

@Override
public boolean canInteractWith(EntityPlayer playerIn) {
	return true;
}

@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot) {
	ItemStack previous = null;
    Slot slot = (Slot) this.inventorySlots.get(fromSlot);

    if (slot != null && slot.getHasStack()) {
        ItemStack current = slot.getStack();
        previous = current.copy();

        if (fromSlot < 9) {
            // From TE Inventory to Player Inventory
            if (!this.mergeItemStack(current, 9, 37, true))
                return null;
        } else {
            // From Player Inventory to TE Inventory
            if (!this.mergeItemStack(current, 0, 9, false))
                return null;
        }

        if (current.stackSize == 0)
            slot.putStack((ItemStack) null);
        else
            slot.onSlotChanged();

        if (current.stackSize == previous.stackSize)
            return null;
        slot.onPickupFromSlot(playerIn, current);
    }
    return previous;
}

}

 

In your container constructor, you are linking the slots to the player's inventory (not your tile entity), which is why the same items persist over different blocks.

Link to comment
Share on other sites

In your container constructor, you are adding the inventory slots to the player's inventory (not your tile entity), which is why the same items persist over different blocks.

 

For* the player's inventory.  This class is just a representation of the inventory that already exists, you're not adding to that, you're creating the representation.

 

But yes, the problem is that the slots you want to use to represent the TileEntity's inventory you're telling the program to look at the player's inventory for the contents.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

No I changed this. In the method addSlot I changed the player inv to the tileentity inv but now there is a nullpointer exception. It seems like that the inventory is null but:

public InventoryBasic inv;
private static int ID = 0;

public TileEntityChemicalMixer(){
	inv = new InventoryBasic("Chemical Mixer", false, 3);
}

the inv gets a new Inventory?

 

Here the Error:

[12:29:36] [server thread/FATAL]: Error executing task

java.util.concurrent.ExecutionException: java.lang.NullPointerException

at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_101]

at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_101]

at net.minecraft.util.Util.runTask(Util.java:24) [util.class:?]

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:738) [MinecraftServer.class:?]

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:683) [MinecraftServer.class:?]

at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:155) [integratedServer.class:?]

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:532) [MinecraftServer.class:?]

at java.lang.Thread.run(Unknown Source) [?:1.8.0_101]

Caused by: java.lang.NullPointerException

at me.darki.chemmix.containers.ContainerChemicalMixer.<init>(ContainerChemicalMixer.java:18) ~[ContainerChemicalMixer.class:?]

at me.darki.chemmix.guis.GuiHandler.getServerGuiElement(GuiHandler.java:19) ~[GuiHandler.class:?]

at net.minecraftforge.fml.common.network.NetworkRegistry.getRemoteGuiContainer(NetworkRegistry.java:244) ~[NetworkRegistry.class:?]

at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:80) ~[FMLNetworkHandler.class:?]

at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2693) ~[EntityPlayer.class:?]

at me.darki.chemmix.blocks.BlockChemicalMixer.onBlockActivated(BlockChemicalMixer.java:36) ~[blockChemicalMixer.class:?]

at net.minecraft.server.management.PlayerInteractionManager.processRightClickBlock(PlayerInteractionManager.java:473) ~[PlayerInteractionManager.class:?]

at net.minecraft.network.NetHandlerPlayServer.processRightClickBlock(NetHandlerPlayServer.java:706) ~[NetHandlerPlayServer.class:?]

at net.minecraft.network.play.client.CPacketPlayerTryUseItem.processPacket(CPacketPlayerTryUseItem.java:68) ~[CPacketPlayerTryUseItem.class:?]

at net.minecraft.network.play.client.CPacketPlayerTryUseItem.processPacket(CPacketPlayerTryUseItem.java:13) ~[CPacketPlayerTryUseItem.class:?]

at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) ~[PacketThreadUtil$1.class:?]

at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_101]

at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_101]

at net.minecraft.util.Util.runTask(Util.java:23) ~[util.class:?]

... 5 more

 

and here the updated constructor:

public ContainerChemicalMixer(IInventory inv, TileEntityChemicalMixer tileentity) {
	this.tileentiy = tileentity;
	this.addSlotToContainer(new Slot(tileentity.inv, 0, 30, 17));
	this.addSlotToContainer(new Slot(tileentity.inv, 1, 130, 17));
	this.addSlotToContainer(new OutputSlot(tileentity.inv, 2, 80, 51));

    // Player Inventory, Slot 9-35, Slot IDs 9-35
    for (int y = 0; y < 3; ++y) {
        for (int x = 0; x < 9; ++x) {
            this.addSlotToContainer(new Slot(inv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18));
        }
    }

    // Player Inventory, Slot 0-8, Slot IDs 36-44
    for (int x = 0; x < 9; ++x) {
        this.addSlotToContainer(new Slot(inv, x, 8 + x * 18, 142));
    }
}

Link to comment
Share on other sites

Caused by: java.lang.NullPointerException

at me.darki.chemmix.containers.ContainerChemicalMixer.<init>(ContainerChemicalMixer.java:18) ~[ContainerChemicalMixer.class:?]

at me.darki.chemmix.guis.GuiHandler.getServerGuiElement(GuiHandler.java:19) ~[GuiHandler.class:?]

at net.minecraftforge.fml.common.network.NetworkRegistry.getRemoteGuiContainer(NetworkRegistry.java:244) ~[NetworkRegistry.class:?]

at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:80) ~[FMLNetworkHandler.class:?]

at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2693) ~[EntityPlayer.class:?]

at me.darki.chemmix.blocks.BlockChemicalMixer.onBlockActivated(BlockChemicalMixer.java:36) ~[blockChemicalMixer.class:?]

 

You accessed a field/method of a

null

value on line 18 of

ContainerChemicalMixer

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

The

tileentity

argument of the

ContainerChemicalMixer

constructor is

null

. This is because you override the wrong overload of

Block#hasTileEntity

. You need to override the one that takes an

IBlockState

argument instead of the one that takes no arguments.

 

Setting the

Block#isBlockContainer

field is pointless, it's never used anywhere.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Thanks man, now its working...but one little question I have anymore. Why is there a 10: NBTTagList list = compound.getTagList("ItemStacks-" + ID, 10);

in:

@Override
public void readFromNBT(NBTTagCompound compound) {
	super.readFromNBT(compound);
	NBTTagList list = compound.getTagList("ItemStacks-" + ID, 10);
	this.inv = new InventoryBasic("Chemical Mixer", false, 3);
	for(int i = 0; i < list.tagCount(); i++){
		NBTTagCompound tag = list.getCompoundTagAt(i);
		byte b = tag.getByte("Slot");
		if(b >= 0 && b < inv.getSizeInventory()){
			inv.setInventorySlotContents(b, ItemStack.loadItemStackFromNBT(tag));
		}
	}
}

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.



×
×
  • Create New...

Important Information

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