• 2

    posted a message on [SOLVED]TileEntity not sent to client?
    FIXED!
    For future reference, add this code to the TileEntity:
    public Packet getDescriptionPacket()
    {
    NBTTagCompound var1 = new NBTTagCompound();
    writeToNBT(var1);
    return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, var1);
    }
    public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt) {readFromNBT(pkt.customParam1);}
    Posted in: Modification Development
  • 0

    posted a message on [SOLVED]TileEntity not sent to client?
    No, I realized it is unnecessary.
    Block:
    public boolean hasTileEntity(int metadata)
    {
    return isBlockContainer;
    }

    BlockContainer:
    protected BlockContainer(int par1, Material par2Material)
    {
    super(par1, par2Material);
    this.isBlockContainer = true;
    }
    
    protected BlockContainer(int par1, int par2, Material par3Material)
    {
    super(par1, par2, par3Material);
    this.isBlockContainer = true;
    }

    I tried your suggestion again, which can be simplified to
    if (!theWorld.isRemote) ((TileEntityBigDoorBlock)theWorld.getBlockTileEntity(x,y,z)).doStuff();
    return true

    and that didn't work at all. It sends the data to the server, but the TileEntity wasn't updated client-side.
    Posted in: Modification Development
  • 0

    posted a message on [SOLVED]TileEntity not sent to client?
    It is possible I have somehow registered the block incorrectly, because I have also had problems with making the block tick, and needed to move the code to its TileEntity.
    Posted in: Modification Development
  • 0

    posted a message on [SOLVED]TileEntity not sent to client?
    Should I exclude hasTileEntity()? I saw it's not included in other blocks, such as BlockCommandBlock.
    Posted in: Modification Development
  • 0

    posted a message on [SOLVED]TileEntity not sent to client?
    Oops, that was a typo. Anyways, it shouldn't matter how I handle onBlockActivated. The data is clearly sent to the server and saved, but not sent back to the client.
    Posted in: Modification Development
  • 0

    posted a message on [SOLVED]TileEntity not sent to client?
    Oh, OK. I thought world.isRemote() would always return true since 1.3.
    Posted in: Modification Development
  • 0

    posted a message on [SOLVED]TileEntity not sent to client?
    I don't think that's how it works. If I use Eclipse, I can enable debugging mode, in which I can modify code while Minecraft is running. The TileEntity won't 'keep' the code. I also created a new world and tested it without modifying anything, and received the same problem.
    :( I was hoping I wouldn't need to do that, because I plan on releasing this and didn't want to share the code yet. I'll post it with only the relevant parts included.
    Mod file:
    package xyz;
    import net.minecraft.src.Block;
    import net.minecraft.src.CreativeTabs;
    import net.minecraft.src.Material;
    import net.minecraft.src.ModLoader;
    import cpw.mods.fml.client.registry.RenderingRegistry;
    import cpw.mods.fml.common.Mod;
    import cpw.mods.fml.common.Mod.Init;
    import cpw.mods.fml.common.Mod.Instance;
    import cpw.mods.fml.common.Mod.PostInit;
    import cpw.mods.fml.common.Mod.PreInit;
    import cpw.mods.fml.common.SidedProxy;
    import cpw.mods.fml.common.event.FMLInitializationEvent;
    import cpw.mods.fml.common.event.FMLPostInitializationEvent;
    import cpw.mods.fml.common.event.FMLPreInitializationEvent;
    import cpw.mods.fml.common.network.NetworkMod;
    import cpw.mods.fml.common.registry.GameRegistry;
    import cpw.mods.fml.common.registry.LanguageRegistry;
    @Mod(modid="Xyz", name="Xyz", version="0.0.0")
    @NetworkMod(clientSideRequired=true, serverSideRequired=false)
    public class Xyz {
    @Instance("Xyz")
    public static Xyz instance;
    // Says where the client and server 'proxy' code is loaded.
    @SidedProxy(clientSide="Xyz.client.ClientProxy", serverSide="Xyz.CommonProxy")
    public static CommonProxy proxy;
    private static final BlockXyz blockXyz = (BlockXyz)(new BlockXyz(3100, 0, Material.piston).setHardness(-1F).setStepSound(Block.soundMetalFootstep).setCreativeTab(CreativeTabs.tabMisc).setBlockName("xyz"));
    @PreInit
    public void preInit(FMLPreInitializationEvent event) {}
    @Init
    public void load(FMLInitializationEvent event) {
    proxy.load();
    GameRegistry.registerBlock(blockXyz);
    GameRegistry.registerTileEntity(TileEntityXyz.class, "xyz");
    LanguageRegistry.addName(blockXyz, "Xyz");
    }
    @PostInit
    public void postInit(FMLPostInitializationEvent event) {}
    }

    TileEntityXyz:
    package xyz;
    import java.util.ArrayList;
    import net.minecraft.src.AxisAlignedBB;
    import net.minecraft.src.Entity;
    import net.minecraft.src.NBTTagCompound;
    import net.minecraft.src.TileEntity;
    import net.minecraft.src.World;
    public class TileEntityXyz extends TileEntity{
    public byte[] sides = new byte[6];
    public TileEntityXyz()
    {
    super();
    }
    public void readFromNBT(NBTTagCompound nbt)
    {
    super.readFromNBT(nbt);
    sides[0]=nbt.getByte("s0");
    sides[1]=nbt.getByte("s1");
    sides[2]=nbt.getByte("s2");
    sides[3]=nbt.getByte("s3");
    sides[4]=nbt.getByte("s4");
    sides[5]=nbt.getByte("s5");
    }
    public void writeToNBT(NBTTagCompound nbt)
    {
    super.writeToNBT(nbt);
    nbt.setByte("s0", sides[0]);
    nbt.setByte("s1", sides[1]);
    nbt.setByte("s2", sides[2]);
    nbt.setByte("s3", sides[3]);
    nbt.setByte("s4", sides[4]);
    nbt.setByte("s5", sides[5]);
    for (int i=0; i<6; ++i) System.out.println(sides[i]);
    }
    }

    BlockXyz:
    package xyz;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Random;
    import cpw.mods.fml.client.registry.RenderingRegistry;
    import cpw.mods.fml.common.Side;
    import cpw.mods.fml.common.asm.SideOnly;
    import net.minecraft.src.AxisAlignedBB;
    import net.minecraft.src.Block;
    import net.minecraft.src.BlockContainer;
    import net.minecraft.src.Entity;
    import net.minecraft.src.EntityPlayer;
    import net.minecraft.src.Facing;
    import net.minecraft.src.IBlockAccess;
    import net.minecraft.src.NBTTagCompound;
    import net.minecraft.src.RenderBlocks;
    import net.minecraft.src.Tessellator;
    import net.minecraft.src.TileEntity;
    import net.minecraft.src.World;
    public class BlockXyz extends BlockContainer{
    public BlockXyz(int id,int texture,net.minecraft.src.Material material)
    {
    super(id, texture, material);
    }
    public int idDropped(int par1, java.util.Random random, int zero) {return 0;}
    public boolean hasTileEntity(int i) {return true;}
    public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float i, float j, float k)
    {
    TileEntityXyz te=(TileEntityXyz)(world.getBlockTileEntity(x, y, z));
    if (te.sides[Facing.faceToSide[s]]==0) te.sides[Facing.faceToSide[s]]=2;
    else te.sides[Facing.faceToSide[s]]=0;
    world.markBlockForUpdate(x,y,z);
    return true;
    }
    @Override
    public TileEntity createNewTileEntity(World var1) {return new TileEntityXyz();}
    }

    I have excluded the CommonProxy and ClientProxy because they are bare-bones without any modifications from the tutorials other than item and texture paths. I have only included what is relevant in the above code.
    Posted in: Modification Development
  • 0

    posted a message on [SOLVED]TileEntity not sent to client?
    This is a local server. Also, I have confirmed it is a server-side error, because I made readFromNBT() print the entity data. It displayed the correct data, then I accidentally caused an error in it and the trace showed it was a server.

    Also, I have not overwritten the id, x, y, or z tags used to create and identify the TileEntity, and the TileEntity does not store items.
    Posted in: Modification Development
  • 0

    posted a message on [SOLVED]TileEntity not sent to client?
    I have a block with a TileEntity. For testing purposes, the TileEntity would set its data to predefined values when it is created. When I removed this testing code, however, I noticed the block wouldn't receive the TileEntity data from the server. I know the data is stored correctly, because the block acts like the data is there (like if the client didn't receive a block from the server; when you try to walk through it, the server would send you back). Is there any reason why this could be happening? I am using MinecraftForge for Minecraft 1.4.5.
    Posted in: Modification Development
  • 0

    posted a message on Detecting which side an entity collides with on a block
    Bump. I have also tried using sided proxies to determine if the block is on the client or server, and that didn't work.
    Posted in: Modification Development
  • 0

    posted a message on Detecting which side an entity collides with on a block
    It should but unfortunately my problem is actually more complicated than that. As I mentioned above, not all sides of the block will be solid, meaning it should be possible to be inside the block but still interact with its sides (of thickness 1/16).
    I added this code:
    @SideOnly(Side.SERVER)
    public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int par2, int par3, int par4)
    {
    double d=0.03125D; //1/32
    return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double)par2+d, (double)par3+d, (double)par4+d, (double)(par2 + 1)-d, (double)(par3 + 1)-d, (double)(par4 + 1)-d);
    }

    Using this, I can go inside the block and a collision is detected, however it is not detected if I walk into a side from the outside. If I omit the @SideOnly tag, a collision is detected from outside the block, however I cannot go inside it. I have also tried inverting d, and that doesn't work either.

    The only solution I can think of now is to make the block non-solid and cause entities to stop when they hit it, but I don't know how to do that either.

    (I didn't explain this in the top post because I had not tried adding this method yet)
    Posted in: Modification Development
  • 0

    posted a message on Detecting which side an entity collides with on a block
    Bump! Also, I should add that I am using MinecraftForge for 1.4.5.
    Posted in: Modification Development
  • 0

    posted a message on Detecting which side an entity collides with on a block
    I have a block which will behave differently when entities collide with it on different sides. The block is solid, however depending on a tile entity, it might not be solid on every side (like a cauldron). The non-solid sides are already working; all I need to do is detect what side is collided with an entity. How can I do this?
    Posted in: Modification Development
  • 0

    posted a message on TextureFX
    Hi, I'm trying to make a texture effect for a new block. The code is:
    @SideOnly(Side.CLIENT)
    public class TextureFieldFX extends FMLTextureFX
    {
    /** red RGB value for water texture */
    protected float[] red = new float[256];
    /** green RGB value for water texture */
    protected float[] green = new float[256];
    /** blue RGB value for water texture */
    protected float[] blue = new float[256];
    /** alpha RGB value for water texture */
    protected float[] alpha = new float[256];
    private int tickCounter = 0;
    public TextureFieldFX()
    {
    	 super(0);
    	 setup();
    }
    @Override
    public void setup()
    {
    	 super.setup();
    	 red = new float[tileSizeSquare];
    	 green = new float[tileSizeSquare];
    	 blue = new float[tileSizeSquare];
    	 alpha = new float[tileSizeSquare];
    	 tickCounter = 0;
    	 for (int var1=0;var1<tileSizeSquare;++var1)
    	 {
    		 imageData[var1*4]=(byte)127;
    		 imageData[var1*4+1]=(byte)127;
    		 imageData[var1*4+2]=(byte)127;
    	 }
    }
    
    public void onTick()
    {
    	 ++this.tickCounter;
    	 int var1;
    	 float var3;
    	 for (var1=0;var1<tileSizeBase;++var1)
    	 {
    		 float var4;
    		 float var5;
    		 if (var1%2==0)
    		 {
    		 var3=alpha[var1*tileSizeBase];
    		 var5=var3;
    		 for (int var2=0;var2<tileSizeBase;++var2)
    		 {
    		 var4=alpha[var1*tileSizeBase+var2];
    		 alpha[var1*tileSizeBase+var2]=var3;
    		 var3=var4;
    		 }
    		 alpha[(var1+1)*tileSizeBase-1]=var5;
    		 }
    		 else
    		 {
    		 var3=alpha[(var1+1)*tileSizeBase-1];
    		 var5=var3;
    		 for (int var2=1;var2<=tileSizeBase;++var2)
    		 {
    		 var4=alpha[(var1+1)*tileSizeBase-var2];
    		 alpha[(var1+1)*tileSizeBase-var2]=var3;
    		 var3=var4;
    		 }
    		 alpha[(var1+1)*tileSizeBase-1]=var5;
    		 }
    	 }
    	 for (var1 = 0; var1 < tileSizeSquare; ++var1)
    	 {
    		 int var4;
    		 var3 = alpha[var1];
    		 if (var3 > 1.0F) var3 = 1.0F;
    		 if (var3 < 0.0F) var3 = 0.0F;
    		 float var13 = var3 * var3;
    		 var4 = (int)(32.0F + var13 * 32.0F);
    		 if (this.anaglyphEnabled) var4 = (var4 * 30 + (int)(50.0F + var13 * 64.0F) * 59 + 2805) / 100;
    		 this.imageData[var1 * 4 + 3] = (byte)Math.min(var4*2, 255);
    	 }
    }
    public void bindImage(RenderEngine par1RenderEngine)
    {
    	 GL11.glBindTexture(GL11.GL_TEXTURE_2D, par1RenderEngine.getTexture(CommonProxy.BLOCK_PNG));
    }

    and it doesn't work. All I get it a blank block. Is there anything I'm missing? It should take the water texture and make rows alternate between moving left and moving right. This is the base texture; the block will use color multipliers.
    Posted in: Modification Development
  • To post a comment, please or register a new account.