Jump to content

[1.6.4][Solved] TileEntity not loaded correctly


SBird

Recommended Posts

Hello, i'm the new guy :>

 

In my current project I am planning to add some new mechanics, "machines" you could say and for that I am using TileEntities(Containers and Inventories to be clear), yet when my game loads it does not load the specific NBT Tags even though it saves them(At least it executes the save code), instead I get the following warning: "2013-10-16 19:44:30 [Warnung] [Minecraft-Server] Skipping TileEntity with id "(It does not even give me an ID)

I did register my TileEntity in the initialization Event of Forge:

 

	@EventHandler
public void initialize(FMLInitializationEvent event)
{
	NetworkRegistry.instance().registerGuiHandler(instance, new GuiHandler());

	GameRegistry.registerWorldGenerator(new GenerationManager());
	GameRegistry.addBiome(new BiomeGenHallow(20));

	GameRegistry.registerTileEntity(TileEntityGeneratorCreative.class, "generatorcreative");
	GameRegistry.registerTileEntity(TileEntityHellFurnace.class, "Hellfurnace");

	BloodStone = new BlockBloodStone(502, Material.rock);
	infiniteGenerator = new CreativeGenerator(500, Material.iron);
	infiniteProvider = new BlockInfiniteProvider(501, Material.iron);

	CommonProxy.proxy.registerBlock(infiniteProvider);
	CommonProxy.proxy.registerBlock(infiniteGenerator);
	CommonProxy.proxy.registerBlock(BloodStone);

	MinecraftForge.EVENT_BUS.register(this);
}

It's the HellFurnace TileEntity. Here are some other probably relevant Code segments:

 

[spoiler=TileEntityHellFurnace.java]

package eventide.tileentity;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;

public class TileEntityHellFurnace extends TileEntity implements IInventory {



public boolean isBurning;
private ItemStack[] heldItemStacks = new ItemStack[7];

public TileEntityHellFurnace()
{
	//Dummy Constructor
}

@Override
public int getSizeInventory() {
	return this.heldItemStacks.length;
}

@Override
public ItemStack getStackInSlot(int i) {
	return this.heldItemStacks[i];
}

@Override
public ItemStack decrStackSize(int i, int j) {
        if (this.heldItemStacks[i] != null)
        {
            ItemStack itemstack;

            if (this.heldItemStacks[i].stackSize <= j)
            {
                itemstack = this.heldItemStacks[i];
                this.heldItemStacks[i] = null;
                return itemstack;
            }
            else
            {
                itemstack = this.heldItemStacks[i].splitStack(j);

                if (this.heldItemStacks[i].stackSize == 0)
                {
                    this.heldItemStacks[i] = null;
                }

                return itemstack;
            }
        }
        else
        {
            return null;
        }
}

@Override
    public ItemStack getStackInSlotOnClosing(int par1)
    {
        if (this.heldItemStacks[par1] != null)
        {
            ItemStack itemstack = this.heldItemStacks[par1];
            this.heldItemStacks[par1] = null;
            return itemstack;
        }
        else
        {
            return null;
        }
    }

@Override
    public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
    {
	this.heldItemStacks[par1] = par2ItemStack;

	if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
	{
		par2ItemStack.stackSize = this.getInventoryStackLimit();
	}	
    }

@Override
    public String getInvName()
    {
        return "Hell Furnace";
    }

@Override
public boolean isInvNameLocalized() {
	return false;
}

@Override
public int getInventoryStackLimit() 
{
	return 64;
}

@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer) 
{
	return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : entityplayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
}

@Override
public void openChest() {}

@Override
public void closeChest() {}

@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
	if(i == 6)
	{
		System.out.println("Slot 6");
		return false;
	}
	System.out.println("Slot " + i);
	return true;
}

    public void readFromNBT(NBTTagCompound par1NBTTagCompound)
    {
        super.readFromNBT(par1NBTTagCompound);
        NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items");
        this.heldItemStacks = new ItemStack[this.getSizeInventory()];

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
        	System.out.println("Reading Slot " + i);
            NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i);
            byte b0 = nbttagcompound1.getByte("Slot");

            if (b0 >= 0 && b0 < this.heldItemStacks.length)
            {
                this.heldItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
            }
        }
        
    }
    public void writeToNBT(NBTTagCompound par1NBTTagCompound)
    {
    	NBTTagList nbttaglist = new NBTTagList();
        for (int i = 0; i < this.heldItemStacks.length; ++i)
        {
        	System.out.println("Attempting Write Slot " + i);
            if (this.heldItemStacks[i] != null)
            {
            	System.out.println("Writing Slot " + i);
                NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                nbttagcompound1.setByte("Slot", (byte)i);
                this.heldItemStacks[i].writeToNBT(nbttagcompound1);
                nbttaglist.appendTag(nbttagcompound1);
            }
        }
        par1NBTTagCompound.setTag("Items", nbttaglist);
    }
}

 

 

[spoiler=BlockBloodStone.java]

package eventide.block;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import eventide.Eventide;
import eventide.tileentity.TileEntityHellFurnace;

public class BlockBloodStone extends BlockContainerEventideBase{

public BlockBloodStone(int id, Material material) {
	super(id, material);
	this.setUnlocalizedName("bloodStone");
	this.setCreativeTab(CreativeTabs.tabBlock);
}

@Override
public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta)
{
	super.harvestBlock(world, player, x, y, z, meta);
	if(world.rand.nextInt(10) > 6)
	{
		world.setBlock(x, y, z, Block.lavaStill.blockID);
	}
}
@Override
    public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
    {
	System.out.println("Opening GUI");
        par5EntityPlayer.openGui(Eventide.instance, 0, par1World, par2, par3, par4);
        return true;
    }

@Override
public TileEntity createNewTileEntity(World world) {
	return new TileEntityHellFurnace();
}



}

 

 

 

I just can't seem to figure out what my error is, everything works fine except the loading routine, because the game does not seem to load the TileEntity again.

Hoping for some help out here :)

 

~SBird

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.

Announcements



×
×
  • Create New...

Important Information

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