Jump to content

Entity NBT Problem?


Recommended Posts

I have here my entity, but the problem is, the server has teh falue of fallTile, but the client not, what should I add, that it will work?


package de.intektor.moreminecraft.entity;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityFallingBlock;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class EntityNotFallingBlock extends Entity{

public IBlockState fallTile;
public NBTTagCompound tileEntityData;

public EntityNotFallingBlock(World worldIn) {

public EntityNotFallingBlock(World world, double posX, double posY, double posZ, IBlockState fallingBlockState) {
	this.posX = posX;
	this.posY = posY;
	this.posZ = posZ;
	this.fallTile = fallingBlockState;
	this.setSize(0.98f, 0.98f);


protected void entityInit() {

public void onUpdate() {		

public void writeEntityToNBT(NBTTagCompound tagCompound)
        Block block = this.fallTile != null ? this.fallTile.getBlock() : Blocks.air;
        ResourceLocation resourcelocation = (ResourceLocation)Block.blockRegistry.getNameForObject(block);
        tagCompound.setString("Block", resourcelocation == null ? "" : resourcelocation.toString());
        tagCompound.setByte("Data", (byte)block.getMetaFromState(this.fallTile));

        if (this.tileEntityData != null)
            tagCompound.setTag("TileEntityData", this.tileEntityData);

    public void readEntityFromNBT(NBTTagCompound tagCompund)
        int i = tagCompund.getByte("Data") & 255;

        if (tagCompund.hasKey("Block", )
            this.fallTile = Block.getBlockFromName(tagCompund.getString("Block")).getStateFromMeta(i);
        else if (tagCompund.hasKey("TileID", 99))
            this.fallTile = Block.getBlockById(tagCompund.getInteger("TileID")).getStateFromMeta(i);
            this.fallTile = Block.getBlockById(tagCompund.getByte("Tile") & 255).getStateFromMeta(i);

        Block block = this.fallTile.getBlock();

        if (tagCompund.hasKey("TileEntityData", 10))
            this.tileEntityData = tagCompund.getCompoundTag("TileEntityData");

        if (block == null || block.getMaterial() == Material.air)
            this.fallTile = Blocks.sand.getDefaultState();

public IBlockState getBlock()
	return this.fallTile;

public World getWorldObj()
	return this.worldObj;



Creator of Extra Shoes


Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

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.

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.