Kloonder Posted September 6, 2015 Posted September 6, 2015 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) { super(worldIn); } public EntityNotFallingBlock(World world, double posX, double posY, double posZ, IBlockState fallingBlockState) { super(world); this.posX = posX; this.posY = posY; this.posZ = posZ; this.fallTile = fallingBlockState; this.setSize(0.98f, 0.98f); } @Override protected void entityInit() { } @Override public void onUpdate() { super.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); } super.writeToNBT(tagCompound); } 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); } else { 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; } @SideOnly(Side.CLIENT) public World getWorldObj() { return this.worldObj; } } Quote 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
Recommended Posts
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.