Posted February 28, 201312 yr Well, I place the first Tile Entity like this: https://dl.dropbox.com/u/36429108/bukkit/2013-02-28_20.30.07.png[/img] Looks good, ofcourse the texture is working fine there. But when I place a second Tile Entity, the texture of the first placed is being changed... https://dl.dropbox.com/u/36429108/bukkit/2013-02-28_20.30.09.png[/img] Why is that? BlockMulti: package TreviModdingCrew.PowerPlusPlus.blocks; import java.util.List; import java.util.Random; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import TreviModdingCrew.PowerPlusPlus.BaseMetaTileEntity; import TreviModdingCrew.PowerPlusPlus.PowerPlusPlus; import TreviModdingCrew.PowerPlusPlus.ProxyClient; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.src.ModLoader; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockMulti extends BlockContainer { public static TEMulti lastPlacedTileEntity; public BlockMulti(int id) { super(id, 0, Material.rock); this.setCreativeTab(PowerPlusPlus.PowerPPTab); setTextureFile(ProxyClient.TextureFile); } @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving player) { lastPlacedTileEntity = (TEMulti)world.getBlockTileEntity(x, y, z); } @Override public TileEntity createNewTileEntity(World world) { return new TEMulti(); } public boolean canHarvestBlock(EntityPlayer player, int meta) { // Item drop occurs in onBlockRemoval System.out.printf("BlockMulti.canHarvestBlock: by %s\n", player); return false; } @Override public int tickRate() { return 1; } /*@Override public void updateTick(World par1World, int x, int y, int z, Random par5Random) { TileEntity theTile = par1World.getBlockTileEntity(x, y, z); if(theTile == null) return; System.out.printf("Metadata: %d\n", theTile.blockMetadata); }*/ @Override public void onBlockHarvested(World world, int x, int y, int z, int data, EntityPlayer player) { if (!((EntityPlayerMP)player).theItemInWorldManager.isCreative()) { TileEntity te = world.getBlockTileEntity(x, y, z); NBTTagCompound tag = new NBTTagCompound("tag"); tag.setInteger("x", 0); tag.setInteger("y", 0); tag.setInteger("z", 0); ItemStack stack = new ItemStack(this, 1, te.getBlockMetadata()); dropBlockAsItem_do(world, x, y, z, stack); } } @Override public int getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { int tMeta = par1IBlockAccess.getBlockMetadata(par2, par3, par4); TileEntity theTile = par1IBlockAccess.getBlockTileEntity(par2, par3, par4); if (theTile == null) return 0; if (theTile instanceof TEMulti) { //System.out.printf("Metadata: %d\n", ((TEMulti) theTile).getTexture(par5)); return theTile.getBlockMetadata(); } return 0; } @Override //Only for the item in hand public int getBlockTextureFromSideAndMetadata(int side, int meta) { return meta; } @SideOnly(Side.CLIENT) public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) { for (int var4 = 0; var4 < 26; ++var4) { par3List.add(new ItemStack(par1, 1, var4)); } } } TEMulti: package TreviModdingCrew.PowerPlusPlus.blocks; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; import cpw.mods.fml.common.network.PacketDispatcher; import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet132TileEntityData; import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.tileentity.TileEntity; import TreviModdingCrew.PowerPlusPlus.PacketHandler; public class TEMulti extends TileEntity { public int baseBlockID; public int baseMetadata; public TEMulti() { super(); } public TEMulti(int s, int b, int d) { super(); baseBlockID = b; baseMetadata = d; } Block getBaseBlock() { return Block.blocksList[baseBlockID]; } public void readFromNBT(NBTTagCompound tc) { super.readFromNBT(tc); baseBlockID = tc.getInteger("BaseID"); baseMetadata = tc.getInteger("BaseData"); } public void writeToNBT(NBTTagCompound tc) { super.writeToNBT(tc); tc.setInteger("BaseID", baseBlockID); tc.setInteger("BaseData", baseMetadata); } @Override public Packet getDescriptionPacket() { NBTTagCompound tagCompound = new NBTTagCompound(); this.writeToNBT(tagCompound); return PacketHandler.packetFromTileEntity(this); } public void onDataPacket(INetworkManager net, Packet132TileEntityData packet) { //NBTTagCompound tag = packet.customParam1; //blockMetadata = tag.getInteger("BaseData"); this.readFromNBT(packet.customParam1); } }
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.