• 0

    posted a message on Saving block metadata?
    Could anyone please take a look?
    Posted in: Modification Development
  • 0

    posted a message on Saving block metadata?
    I've made a chair block that is placed based on rotation and coded a funcion that should save the block metadata, but when I save and load the world, the metadata is reset (I think that is the issue, not completely sure) and all the chairs face the default direction. Here's my code:

    mod_furniture (probably not relevant):

    package net.minecraft.src;
    
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.List;
    import java.util.Map;
    import java.util.Random;
    
    public class mod_furniture extends BaseMod
    {
    public static final Block blockChair = new BlockChair(200,net.minecraft.src.TestTileEntity.class).setResistance(.5F).setBlockName("Test").setHardness(0.5f);
    public static final Item itemChair = new ItemReed(150,blockChair).setItemName("test").setCreativeTab(CreativeTabs.tabDecorations);
    public void load()
    {
    TestRender tileent1 = new TestRender();
    
    ModLoader.registerTileEntity(net.minecraft.src.TestTileEntity.class, "TestTileEntity",tileent1);
    
    ModLoader.addName(itemChair, "Test");
    
    ModLoader.addRecipe(new ItemStack(itemChair, 3), new Object[]
    {
    "#", Character.valueOf('#'),Block.dirt
    });
    
    itemChair.iconIndex = ModLoader.addOverride("/gui/items.png", "/Furniture/chairimage.png");
    
    
    }
    
    public String getVersion()
    {
    return "1.4.2";
    }
    
    }

    BlockChair (probably relevant)

    package net.minecraft.src;
    
    import java.util.Random;
    
    public class BlockChair extends BlockContainer
    {
    
            private Class TestEntityClass;
    
    
    
            protected BlockChair(int i,Class tClass)
                    {
                      super(i,Material.wood);
                      TestEntityClass = tClass;  
                    }
    
        public TileEntity getBlockEntity()
        {
                try{
                        return (TileEntity)TestEntityClass.newInstance();
                }
                catch(Exception exception){
                        throw new RuntimeException(exception);
                }
        }
    
        public int idDropped(int i, Random random, int j)
        {
            return mod_furniture.itemChair.shiftedIndex;
        }
    
        public int quanityDropped(Random random){
              return 1;
             }
    
        public int getRenderType(){
                    return -1;
        }
    
    
    
        public boolean isOpaqueCube()
        {
            return false;
        }
    
        public boolean renderAsNormalBlock()
        {
            return false;
        }
    
    
        public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
        {
         this.setBlockBounds(0.1875F, 0.0F, 0.1875F,0.8125F, 1.0F, 0.8125F);
        }
    
        public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving)
        {
    
        int p = MathHelper.floor_double((double)((par5EntityLiving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
    
        byte byte0=1;
    
        if (p == 0){byte0 = 4;}
    
        if (p == 1){byte0 = 3;}
    
        if (p == 2){byte0 = 2;}
    
        if (p == 3){byte0 = 1;}
        par1World.setBlockMetadataWithNotify(par2, par3, par4, byte0);
    
    
    
        if(!this.canBlockStay(par1World, par2, par3, par4))
          {
    
        par1World.setBlock(par2, par3, par4, 0);
        }
        }  
    
    
        /**
         * set a blocks direction
         */
    
    
    @Override
    public TileEntity createNewTileEntity(World var1) { return new TestTileEntity(); }
    
    }


    TestRender (most likely relevant)

    package net.minecraft.src;
    
    import org.lwjgl.opengl.GL11;
    
    public class TestRender extends TileEntitySpecialRenderer
    {
    
    public TestRender()
    {
    aModel = new ModelChair();
    }
    
    public void renderAModelAt(TestTileEntity tileentity1, double d, double d1, double d2, float f)
    {
    int meta=tileentity1.blockMetadata;
    GL11.glPushMatrix();
    GL11.glTranslatef((float)d + 0.5F, (float)d1 +1.5F, (float)d2 + 0.5F);
    bindTextureByName("/Furniture/chairtexture.png");
    GL11.glPushMatrix();
    //GL11.glScalef(-1, -1, 1);
    //GL11.glTranslatef(1F, 0F, 1F);
    if(meta==1)
    {
    GL11.glRotatef(180, 0.0F, 1.0F, 0.0F);
    }
    if(meta==3)
    {
    GL11.glRotatef(0, 0.0F, 1.0F, 0.0F);
    }
    if(meta==2)
    {
    GL11.glRotatef(-90, 0.0F, 1.0F, 0.0F);
    }
    if(meta==4)
    {
    GL11.glRotatef(90, 0.0F, 1.0F, 0.0F);
    }
    GL11.glScalef(1.0F, -1F, -1F);
    aModel.renderModel(0.0625F);
    GL11.glPopMatrix();
    GL11.glPopMatrix();
    }
    
    public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2,
    float f)
    {
    renderAModelAt((TestTileEntity)tileentity, d, d1, d2, f);
    }
    
    private ModelChair aModel;
    }

    TestTileEntity (this is my saving code that doesn't work, but I'd think if the other stuff was right this wouldn't be needed)

    package net.minecraft.src;
    
    public class TestTileEntity extends TileEntity{
    
    private byte byte0;
    public void writeToNBT(NBTTagCompound par1NBTTagCompound)
    {
    if (blockMetadata == 1){byte0 = 1;}
    
    if (blockMetadata == 2){byte0 = 2;}
    
    if (blockMetadata == 3){byte0 = 3;}
    
    if (blockMetadata == 4){byte0 = 4;}
    super.writeToNBT(par1NBTTagCompound);
    par1NBTTagCompound.setByte("dir", byte0);
    }
    public void readFromNBT(NBTTagCompound par1NBTTagCompound)
    {
    super.readFromNBT(par1NBTTagCompound);
    this.byte0 = par1NBTTagCompound.getByte("dir");
    if (byte0 == 1){blockMetadata = 1;}
    
    if (byte0 == 2){blockMetadata = 2;}
    
    if (byte0 == 3){blockMetadata = 3;}
    
    if (byte0== 4){blockMetadata = 4;}
    }
    }

    Posted in: Modification Development
  • 0

    posted a message on Eloraam's Mods (RedPower 2 Prerelease 6)
    Alright guys, thanks for clarification, I was hoping to make an alloy furnace/power converter for IC2 but I guess that's not happening.
    Posted in: Minecraft Mods
  • 0

    posted a message on Eloraam's Mods (RedPower 2 Prerelease 6)
    I love Redpower and I was wondering if it was alright to decompile/use Redpower to make a Redpower addon?
    (This is my new mcforum account, I lost the password for my old one, SeptimusHeap)
    Posted in: Minecraft Mods
  • To post a comment, please .