I didnt know about setRegistryName and getRegistryName, i will use it thx
I call registerRender in the client proxy is this wrong?
My bad i send the wrong block code.
This class is just a copy of BlockPressurePlate class:
public class BlocClearInventory extends BlockBasePressurePlate
{
public static final PropertyBool POWERED = PropertyBool.create("powered");
private final BlocClearInventory.Sensitivity sensitivity;
protected BlocClearInventory()
{
super(Material.wood);
this.setDefaultState(this.blockState.getBaseState().withProperty(POWERED, Boolean.valueOf(false)));
this.sensitivity = BlocClearInventory.Sensitivity.MOBS;
setRegistryName("plate_clear_inventory");
setCreativeTab(BlockList.creativeTabBlock);
register();
}
protected int getRedstoneStrength(IBlockState state)
{
return ((Boolean)state.getValue(POWERED)).booleanValue() ? 15 : 0;
}
protected IBlockState setRedstoneStrength(IBlockState state, int strength)
{
return state.withProperty(POWERED, Boolean.valueOf(strength > 0));
}
protected int computeRedstoneStrength(World worldIn, BlockPos pos)
{
AxisAlignedBB axisalignedbb = this.getSensitiveAABB(pos);
List <? extends Entity > list;
switch (this.sensitivity)
{
case EVERYTHING:
list = worldIn.getEntitiesWithinAABBExcludingEntity((Entity)null, axisalignedbb);
break;
case MOBS:
list = worldIn.<Entity>getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);
break;
default:
return 0;
}
if (!list.isEmpty())
{
for (Entity entity : list)
{
if (!entity.doesEntityNotTriggerPressurePlate())
{
return 15;
}
}
}
return 0;
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(POWERED, Boolean.valueOf(meta == 1));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return ((Boolean)state.getValue(POWERED)).booleanValue() ? 1 : 0;
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {POWERED});
}
public static enum Sensitivity
{
EVERYTHING,
MOBS;
}
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
{
if (!worldIn.isRemote)
{
int i = this.getRedstoneStrength(state);
if (i == 0)
{
if(entityIn instanceof EntityPlayer){
((EntityPlayer) entityIn).inventory.clear();
}
this.updateState(worldIn, pos, state, i);
}
}
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean isFullCube() {
return false;
}
public void register(){
GameRegistry.registerBlock(this,this.getRegistryName());
LanguageRegistry.addName(this, "Vide inventaire");
}
public void registerRenders(){
Item item = Item.getItemFromBlock(this);
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MODID+":"+item.getRegistryName(), "inventory"));
}
the other one was just a test.
Here are the json file:
blockstates:
{
"variants": {
"normal": { "model": "mod:plate_clear_inventory"}
}
}
models.block:
{
"parent": "block/pressure_plate",
"textures": {
"particle": "mod:blocks/plate_clear_inventory",
"down":"mod:blocks/plate_clear_inventory",
"up":"mod:blocks/plate_clear_inventory",
"north":"mod:blocks/plate_clear_inventory",
"east":"mod:blocks/plate_clear_inventory",
"south":"mod:blocks/plate_clear_inventory",
"west":"mod:blocks/plate_clear_inventory"
}
}
models.item:
{
"parents": "mod:block/plate_clear_inventory",
"elements": [
{ "from": [ 1, 0, 1 ],
"to": [ 15, 1, 15 ],
"faces": {
"down": { "uv": [ 1, 1, 15, 15 ], "texture": "mod:blocks/plate_clear_inventory", "cullface": "down" },
"up": { "uv": [ 1, 1, 15, 15 ], "texture": "mod:blocks/plate_clear_inventory" },
"north": { "uv": [ 1, 15, 15, 16 ], "texture": "mod:blocks/plate_clear_inventory" },
"south": { "uv": [ 1, 15, 15, 16 ], "texture": "mod:blocks/plate_clear_inventory" },
"west": { "uv": [ 1, 15, 15, 16 ], "texture": "mod:blocks/plate_clear_inventory" },
"east": { "uv": [ 1, 15, 15, 16 ], "texture": "mod:blocks/plate_clear_inventory" }
}
}
]
}
Right now, there is no render in game. i think my json file are wrong but i cant find any example even in minecraft file, i can't understand how they did it.
plate_clear_inventory.png is just a 16*16 image.
here are some error when i launch the game:
[09:39:14] [Client thread/ERROR] [FML]: Model definition for location mod:plate_clear_inventory#powered=false not found
[09:39:14] [Client thread/ERROR] [FML]: Model definition for location mod:plate_clear_inventory#powered=true not found