Jump to content

Recommended Posts

Posted

Well, I place the first Tile Entity like this:

 

width=800 height=424https://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...

width=800 height=424https://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.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
    • Maybe you need to create file in assets/<modid>/items/<itemname>.json with content like this:   { "model": { "type": "minecraft:model", "model": "modname:item/itemname" } }  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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