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(); }
}
mod_furniture (probably not relevant):
TestRender (most likely relevant)
I mod things. Check me out on twitter or on Espernet IRC at #TheSteamTank
I mod things. Check me out on twitter or on Espernet IRC at #TheSteamTank
I mod things. Check me out on twitter or on Espernet IRC at #TheSteamTank
Fixed, thanks.
Any ideas?
I mod things. Check me out on twitter or on Espernet IRC at #TheSteamTank