Jump to content

[SOLVED][1.8] Problems with custom door's blockstates .JSON


TheEnderKiller

Recommended Posts

So I'm currently making a custom door and I pretty much copied the BlockDoor.java. But the texture and model doesn't work and I'm pretty sure it's due to these errors when starting the client:

 

[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=south,half=upper,hinge=left,open=false,powered=true not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=east,half=lower,hinge=left,open=true,powered=true not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=east,half=lower,hinge=left,open=false,powered=false not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:cornplant_stage0#inventory not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=west,half=lower,hinge=left,open=true,powered=false not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:cornplant_stage2#inventory not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:cornplant_stage4#inventory not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=west,half=lower,hinge=right,open=true,powered=false not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=east,half=upper,hinge=right,open=false,powered=false not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=north,half=upper,hinge=left,open=false,powered=true not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=west,half=upper,hinge=left,open=false,powered=false not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=north,half=lower,hinge=right,open=true,powered=true not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:cornplant_stage6#inventory not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=north,half=lower,hinge=left,open=false,powered=true not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=east,half=lower,hinge=right,open=true,powered=true not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=west,half=lower,hinge=left,open=false,powered=false not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:cornplant_stage1#inventory not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=south,half=lower,hinge=right,open=true,powered=true not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:cornplant_stage3#inventory not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=east,half=upper,hinge=left,open=true,powered=true not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:cornplant_stage5#inventory not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=east,half=lower,hinge=right,open=false,powered=false not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=east,half=upper,hinge=left,open=false,powered=false not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=south,half=upper,hinge=right,open=false,powered=true not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=south,half=lower,hinge=left,open=true,powered=true not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=east,half=upper,hinge=right,open=true,powered=true not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=south,half=upper,hinge=left,open=true,powered=false not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=west,half=lower,hinge=right,open=false,powered=false not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=north,half=upper,hinge=left,open=true,powered=true not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=south,half=lower,hinge=right,open=false,powered=true not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=north,half=lower,hinge=right,open=false,powered=true not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=west,half=upper,hinge=right,open=true,powered=true not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=west,half=upper,hinge=left,open=true,powered=true not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=north,half=lower,hinge=left,open=true,powered=false not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=west,half=upper,hinge=right,open=false,powered=true not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:cornplant_stage7#inventory not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=north,half=upper,hinge=right,open=false,powered=false not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=north,half=upper,hinge=right,open=true,powered=false not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=south,half=lower,hinge=left,open=false,powered=true not found
[02:36:45] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#facing=south,half=upper,hinge=right,open=true,powered=true not found

 

 

What I think is weird with this is that I just copied a vanilla door blockstate .JSON where this stuff is defined, but they don't need the 'powered=' and the other things in there. What's wrong? This is my code for the door.

PVMBlock.java

 

package com.sirpigman.pigmanvillages.main;

import java.util.Iterator;

import net.minecraft.block.Block;
import net.minecraft.block.BlockColored;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemCloth;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;

import com.sirpigman.pigmanvillages.block.BlockCornPlant;
import com.sirpigman.pigmanvillages.block.BlockPVMDoor;
import com.sirpigman.pigmanvillages.item.ItemBaconCooked;
import com.sirpigman.pigmanvillages.item.ItemBaconGold;
import com.sirpigman.pigmanvillages.item.ItemBaconRaw;
import com.sirpigman.pigmanvillages.item.ItemBottle;
import com.sirpigman.pigmanvillages.item.ItemCornCob;
import com.sirpigman.pigmanvillages.item.ItemCornSeeds;
import com.sirpigman.pigmanvillages.item.ItemMilkBottle;
import com.sirpigman.pigmanvillages.item.ItemPVMDoor;

public class PVMBlock
{
public static Block NetherackDoor;
public static Block CornPlant;

public static void registerBlocks()
{
	NetherackDoor = new BlockPVMDoor(Material.rock);
	CornPlant = new BlockCornPlant();
	GameRegistry.registerBlock(CornPlant, "cornplant");
	GameRegistry.registerBlock(NetherackDoor, "doornetherack");
}

public static void renderBlocks()
{
	renderBlocks(NetherackDoor);
	renderBlocks(CornPlant);
}

public static void renderBlocks(Block block)
{
	Item item = Item.getItemFromBlock(block);
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation("pvm" + ":" + item.getUnlocalizedName().substring(5), "inventory"));
	ModelBakery.addVariantName(Item.getItemFromBlock(CornPlant), new String[]
			{"pvm:cornplant_stage0", "pvm:cornplant_stage1", "pvm:cornplant_stage2", "pvm:cornplant_stage3", "pvm:cornplant_stage4", "pvm:cornplant_stage5", "pvm:cornplant_stage6", "pvm:cornplant_stage7"});   
	ModelBakery.addVariantName(Item.getItemFromBlock(NetherackDoor), new String[]
			{"pvm:doornetherack_bottom", "pvm:doornetherack_bottom_rh", "pvm:doornetherack_top", "pvm:doornetherack_top_rh"});
}
}

 

BlockPVMDoor.java

 

package com.sirpigman.pigmanvillages.block;

import java.util.Random;

import com.sirpigman.pigmanvillages.main.PVMBlock;
import com.sirpigman.pigmanvillages.main.PVMItem;

import net.minecraft.block.Block;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class BlockPVMDoor extends Block
{
    public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
    public static final PropertyBool OPEN = PropertyBool.create("open");
    public static final PropertyEnum HINGE = PropertyEnum.create("hinge", BlockDoor.EnumHingePosition.class);
    public static final PropertyBool POWERED = PropertyBool.create("powered");
    public static final PropertyEnum HALF = PropertyEnum.create("half", BlockDoor.EnumDoorHalf.class);
    private final String doornetherack = "doornetherack";

    public BlockPVMDoor(Material materialIn)
    {
        super(materialIn);
	setUnlocalizedName(doornetherack);
	setHardness(1.0F);
	setStepSound(Block.soundTypeStone);
	disableStats();
        this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(OPEN, Boolean.valueOf(false)).withProperty(HINGE, BlockDoor.EnumHingePosition.LEFT).withProperty(POWERED, Boolean.valueOf(false)).withProperty(HALF, BlockDoor.EnumDoorHalf.LOWER));
    }
    
    public String getName()
{
	return doornetherack;
}

    public boolean isOpaqueCube()
    {
        return false;
    }

    public boolean isPassable(IBlockAccess worldIn, BlockPos pos)
    {
        return isOpen(combineMetadata(worldIn, pos));
    }

    public boolean isFullCube()
    {
        return false;
    }

    @SideOnly(Side.CLIENT)
    public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos)
    {
        this.setBlockBoundsBasedOnState(worldIn, pos);
        return super.getSelectedBoundingBox(worldIn, pos);
    }

    public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
    {
        this.setBlockBoundsBasedOnState(worldIn, pos);
        return super.getCollisionBoundingBox(worldIn, pos, state);
    }

    public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
    {
        this.setBoundBasedOnMeta(combineMetadata(worldIn, pos));
    }

    private void setBoundBasedOnMeta(int combinedMeta)
    {
        float f = 0.1875F;
        this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F);
        EnumFacing enumfacing = getFacing(combinedMeta);
        boolean flag = isOpen(combinedMeta);
        boolean flag1 = isHingeLeft(combinedMeta);

        if (flag)
        {
            if (enumfacing == EnumFacing.EAST)
            {
                if (!flag1)
                {
                    this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
                }
                else
                {
                    this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
                }
            }
            else if (enumfacing == EnumFacing.SOUTH)
            {
                if (!flag1)
                {
                    this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
                }
                else
                {
                    this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
                }
            }
            else if (enumfacing == EnumFacing.WEST)
            {
                if (!flag1)
                {
                    this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
                }
                else
                {
                    this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
                }
            }
            else if (enumfacing == EnumFacing.NORTH)
            {
                if (!flag1)
                {
                    this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
                }
                else
                {
                    this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
                }
            }
        }
        else if (enumfacing == EnumFacing.EAST)
        {
            this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
        }
        else if (enumfacing == EnumFacing.SOUTH)
        {
            this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
        }
        else if (enumfacing == EnumFacing.WEST)
        {
            this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
        }
        else if (enumfacing == EnumFacing.NORTH)
        {
            this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
        }
    }

    public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
    {
        
            BlockPos blockpos1 = state.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER ? pos : pos.down();
            IBlockState iblockstate1 = pos.equals(blockpos1) ? state : worldIn.getBlockState(blockpos1);

            if (iblockstate1.getBlock() != this)
            {
                return false;
            }
            else
            {
                state = iblockstate1.cycleProperty(OPEN);
                worldIn.setBlockState(blockpos1, state, 2);
                worldIn.markBlockRangeForRenderUpdate(blockpos1, pos);
                worldIn.playAuxSFXAtEntity(playerIn, ((Boolean)state.getValue(OPEN)).booleanValue() ? 1003 : 1006, pos, 0);
                return true;
            }
    }

    public void toggleDoor(World worldIn, BlockPos pos, boolean open)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (iblockstate.getBlock() == this)
        {
            BlockPos blockpos1 = iblockstate.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER ? pos : pos.down();
            IBlockState iblockstate1 = pos == blockpos1 ? iblockstate : worldIn.getBlockState(blockpos1);

            if (iblockstate1.getBlock() == this && ((Boolean)iblockstate1.getValue(OPEN)).booleanValue() != open)
            {
                worldIn.setBlockState(blockpos1, iblockstate1.withProperty(OPEN, Boolean.valueOf(open)), 2);
                worldIn.markBlockRangeForRenderUpdate(blockpos1, pos);
                worldIn.playAuxSFXAtEntity((EntityPlayer)null, open ? 1003 : 1006, pos, 0);
            }
        }
    }

    /**
     * Called when a neighboring block changes.
     */
    public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
    {
        if (state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER)
        {
            BlockPos blockpos1 = pos.down();
            IBlockState iblockstate1 = worldIn.getBlockState(blockpos1);

            if (iblockstate1.getBlock() != this)
            {
                worldIn.setBlockToAir(pos);
            }
            else if (neighborBlock != this)
            {
                this.onNeighborBlockChange(worldIn, blockpos1, iblockstate1, neighborBlock);
            }
        }
        else
        {
            boolean flag1 = false;
            BlockPos blockpos2 = pos.up();
            IBlockState iblockstate2 = worldIn.getBlockState(blockpos2);

            if (iblockstate2.getBlock() != this)
            {
                worldIn.setBlockToAir(pos);
                flag1 = true;
            }

            if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()))
            {
                worldIn.setBlockToAir(pos);
                flag1 = true;

                if (iblockstate2.getBlock() == this)
                {
                    worldIn.setBlockToAir(blockpos2);
                }
            }

            if (flag1)
            {
                if (!worldIn.isRemote)
                {
                    this.dropBlockAsItem(worldIn, pos, state, 0);
                }
            }
            else
            {
                boolean flag = worldIn.isBlockPowered(pos) || worldIn.isBlockPowered(blockpos2);

                if ((flag || neighborBlock.canProvidePower()) && neighborBlock != this && flag != ((Boolean)iblockstate2.getValue(POWERED)).booleanValue())
                {
                    worldIn.setBlockState(blockpos2, iblockstate2.withProperty(POWERED, Boolean.valueOf(flag)), 2);

                    if (flag != ((Boolean)state.getValue(OPEN)).booleanValue())
                    {
                        worldIn.setBlockState(pos, state.withProperty(OPEN, Boolean.valueOf(flag)), 2);
                        worldIn.markBlockRangeForRenderUpdate(pos, pos);
                        worldIn.playAuxSFXAtEntity((EntityPlayer)null, flag ? 1003 : 1006, pos, 0);
                    }
                }
            }
        }
    }

    /**
     * Get the Item that this Block should drop when harvested.
     *  
     * @param fortune the level of the Fortune enchantment on the player's tool
     */
    public Item getItemDropped(IBlockState state, Random rand, int fortune)
    {
        return state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER ? null : PVMItem.DoorNetherack;
    }

    /**
     * Ray traces through the blocks collision from start vector to end vector returning a ray trace hit.
     *  
     * @param start The start vector
     * @param end The end vector
     */
    public MovingObjectPosition collisionRayTrace(World worldIn, BlockPos pos, Vec3 start, Vec3 end)
    {
        this.setBlockBoundsBasedOnState(worldIn, pos);
        return super.collisionRayTrace(worldIn, pos, start, end);
    }

    public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
    {
        return pos.getY() >= worldIn.getHeight() - 1 ? false : World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && super.canPlaceBlockAt(worldIn, pos) && super.canPlaceBlockAt(worldIn, pos.up());
    }

    public int getMobilityFlag()
    {
        return 1;
    }

    public static int combineMetadata(IBlockAccess worldIn, BlockPos pos)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        int i = iblockstate.getBlock().getMetaFromState(iblockstate);
        boolean flag = isTop(i);
        IBlockState iblockstate1 = worldIn.getBlockState(pos.down());
        int j = iblockstate1.getBlock().getMetaFromState(iblockstate1);
        int k = flag ? j : i;
        IBlockState iblockstate2 = worldIn.getBlockState(pos.up());
        int l = iblockstate2.getBlock().getMetaFromState(iblockstate2);
        int i1 = flag ? i : l;
        boolean flag1 = (i1 & 1) != 0;
        boolean flag2 = (i1 & 2) != 0;
        return removeHalfBit(k) | (flag ? 8 : 0) | (flag1 ? 16 : 0) | (flag2 ? 32 : 0);
    }

    public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
    {
        BlockPos blockpos1 = pos.down();

        if (player.capabilities.isCreativeMode && state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER && worldIn.getBlockState(blockpos1).getBlock() == this)
        {
            worldIn.setBlockToAir(blockpos1);
        }
    }

    /**
     * Get the actual Block state of this Block at the given position. This applies properties not visible in the
     * metadata, such as fence connections.
     */
    public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
    {
        IBlockState iblockstate1;

        if (state.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER)
        {
            iblockstate1 = worldIn.getBlockState(pos.up());

            if (iblockstate1.getBlock() == this)
            {
                state = state.withProperty(HINGE, iblockstate1.getValue(HINGE)).withProperty(POWERED, iblockstate1.getValue(POWERED));
            }
        }
        else
        {
            iblockstate1 = worldIn.getBlockState(pos.down());

            if (iblockstate1.getBlock() == this)
            {
                state = state.withProperty(FACING, iblockstate1.getValue(FACING)).withProperty(OPEN, iblockstate1.getValue(OPEN));
            }
        }

        return state;
    }

    /**
     * Convert the given metadata into a BlockState for this Block
     */
    public IBlockState getStateFromMeta(int meta)
    {
        return (meta &  > 0 ? this.getDefaultState().withProperty(HALF, BlockDoor.EnumDoorHalf.UPPER).withProperty(HINGE, (meta & 1) > 0 ? BlockDoor.EnumHingePosition.RIGHT : BlockDoor.EnumHingePosition.LEFT).withProperty(POWERED, Boolean.valueOf((meta & 2) > 0)) : this.getDefaultState().withProperty(HALF, BlockDoor.EnumDoorHalf.LOWER).withProperty(FACING, EnumFacing.getHorizontal(meta & 3).rotateYCCW()).withProperty(OPEN, Boolean.valueOf((meta & 4) > 0));
    }

    @SideOnly(Side.CLIENT)
    public EnumWorldBlockLayer getBlockLayer()
    {
        return EnumWorldBlockLayer.CUTOUT;
    }

    /**
     * Convert the BlockState into the correct metadata value
     */
    public int getMetaFromState(IBlockState state)
    {
        byte b0 = 0;
        int i;

        if (state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER)
        {
            i = b0 | 8;

            if (state.getValue(HINGE) == BlockDoor.EnumHingePosition.RIGHT)
            {
                i |= 1;
            }

            if (((Boolean)state.getValue(POWERED)).booleanValue())
            {
                i |= 2;
            }
        }
        else
        {
            i = b0 | ((EnumFacing)state.getValue(FACING)).rotateY().getHorizontalIndex();

            if (((Boolean)state.getValue(OPEN)).booleanValue())
            {
                i |= 4;
            }
        }

        return i;
    }

    protected static int removeHalfBit(int meta)
    {
        return meta & 7;
    }

    public static boolean isOpen(IBlockAccess worldIn, BlockPos pos)
    {
        return isOpen(combineMetadata(worldIn, pos));
    }

    public static EnumFacing getFacing(IBlockAccess worldIn, BlockPos pos)
    {
        return getFacing(combineMetadata(worldIn, pos));
    }

    public static EnumFacing getFacing(int combinedMeta)
    {
        return EnumFacing.getHorizontal(combinedMeta & 3).rotateYCCW();
    }

    protected static boolean isOpen(int combinedMeta)
    {
        return (combinedMeta & 4) != 0;
    }

    protected static boolean isTop(int meta)
    {
        return (meta &  != 0;
    }

    protected static boolean isHingeLeft(int combinedMeta)
    {
        return (combinedMeta & 16) != 0;
    }

    protected BlockState createBlockState()
    {
        return new BlockState(this, new IProperty[] {HALF, FACING, OPEN, HINGE, POWERED});
    }

    public static enum EnumDoorHalf implements IStringSerializable
    {
        UPPER,
        LOWER;

        private static final String __OBFID = "CL_00002124";

        public String toString()
        {
            return this.getName();
        }

        public String getName()
        {
            return this == UPPER ? "upper" : "lower";
        }
    }

    public static enum EnumHingePosition implements IStringSerializable
    {
        LEFT,
        RIGHT;

        private static final String __OBFID = "CL_00002123";

        public String toString()
        {
            return this.getName();
        }

        public String getName()
        {
            return this == LEFT ? "left" : "right";
        }
    }
}

 

Help?

Link to comment
Share on other sites

If they don't need the powered property, then remove that property from your door. If your door needs to have that property but you do not want it listed in the JSON file, then register a custom state mapper that doesn't use it, e.g.:

ModelLoader.setCustomStateMapper(
    yourBlock, (new StateMap.Builder()).addPropertiesToIgnore(POWERED).build()
);

  • Like 1
Link to comment
Share on other sites

If they don't need the powered property, then remove that property from your door. If your door needs to have that property but you do not want it listed in the JSON file, then register a custom state mapper that doesn't use it, e.g.:

ModelLoader.setCustomStateMapper(
    yourBlock, (new StateMap.Builder()).addPropertiesToIgnore(POWERED).build()
);

I tried doing what you told me to-, but it didn't work. Here's the updated PVMBlock.java:

 

package com.sirpigman.pigmanvillages.main;

import java.util.Iterator;

import net.minecraft.block.Block;
import net.minecraft.block.BlockColored;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.statemap.StateMap;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemCloth;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;

import com.sirpigman.pigmanvillages.block.BlockCornPlant;
import com.sirpigman.pigmanvillages.block.BlockPVMDoor;
import com.sirpigman.pigmanvillages.item.ItemBaconCooked;
import com.sirpigman.pigmanvillages.item.ItemBaconGold;
import com.sirpigman.pigmanvillages.item.ItemBaconRaw;
import com.sirpigman.pigmanvillages.item.ItemBottle;
import com.sirpigman.pigmanvillages.item.ItemCornCob;
import com.sirpigman.pigmanvillages.item.ItemCornSeeds;
import com.sirpigman.pigmanvillages.item.ItemMilkBottle;
import com.sirpigman.pigmanvillages.item.ItemPVMDoor;

public class PVMBlock
{
public static Block NetherackDoor;
public static Block CornPlant;

public static void registerBlocks()
{
	NetherackDoor = new BlockPVMDoor(Material.rock);
	CornPlant = new BlockCornPlant();
	GameRegistry.registerBlock(CornPlant, "cornplant");
	GameRegistry.registerBlock(NetherackDoor, "doornetherack");
}

public static void renderBlocks()
{
	renderBlocks(NetherackDoor);
	renderBlocks(CornPlant);
	ModelBakery.addVariantName(Item.getItemFromBlock(CornPlant), new String[]
			{"pvm:cornplant_stage0", "pvm:cornplant_stage1", "pvm:cornplant_stage2", "pvm:cornplant_stage3", "pvm:cornplant_stage4", "pvm:cornplant_stage5", "pvm:cornplant_stage6", "pvm:cornplant_stage7"});   
	ModelBakery.addVariantName(Item.getItemFromBlock(NetherackDoor), new String[]
			{"pvm:doornetherack_bottom", "pvm:doornetherack_top"});
	ModelLoader.setCustomStateMapper(NetherackDoor, (new StateMap.Builder()).addPropertiesToIgnore(BlockPVMDoor.POWERED).build());
    ModelLoader.setCustomStateMapper(NetherackDoor, (new StateMap.Builder()).addPropertiesToIgnore(BlockPVMDoor.OPEN).build());
    ModelLoader.setCustomStateMapper(NetherackDoor, (new StateMap.Builder()).addPropertiesToIgnore(BlockPVMDoor.FACING).build());
    ModelLoader.setCustomStateMapper(NetherackDoor, (new StateMap.Builder()).addPropertiesToIgnore(BlockPVMDoor.HINGE).build());
    ModelLoader.setCustomStateMapper(NetherackDoor, (new StateMap.Builder()).addPropertiesToIgnore(BlockPVMDoor.HALF).build());
}

public static void renderBlocks(Block block)
{
	Item item = Item.getItemFromBlock(block);
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation("pvm" + ":" + item.getUnlocalizedName().substring(5), "inventory"));
}
}

 

Yes, I have tried to only ignore the POWERED property.

Link to comment
Share on other sites

ModelLoader.setCustomStateMapper(NetherackDoor, (new StateMap.Builder()).addPropertiesToIgnore(BlockPVMDoor.OPEN).build());
ModelLoader.setCustomStateMapper(NetherackDoor, (new StateMap.Builder()).addPropertiesToIgnore(BlockPVMDoor.FACING).build());
ModelLoader.setCustomStateMapper(NetherackDoor, (new StateMap.Builder()).addPropertiesToIgnore(BlockPVMDoor.HINGE).build());
ModelLoader.setCustomStateMapper(NetherackDoor, (new StateMap.Builder()).addPropertiesToIgnore(BlockPVMDoor.HALF).build());

Don't add a new state mapper for every property, it will replace the previous one added. You'd have to add all of your properties to 1 state mapper.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

ModelLoader.setCustomStateMapper(NetherackDoor, (new StateMap.Builder()).addPropertiesToIgnore(BlockPVMDoor.OPEN).build());
ModelLoader.setCustomStateMapper(NetherackDoor, (new StateMap.Builder()).addPropertiesToIgnore(BlockPVMDoor.FACING).build());
ModelLoader.setCustomStateMapper(NetherackDoor, (new StateMap.Builder()).addPropertiesToIgnore(BlockPVMDoor.HINGE).build());
ModelLoader.setCustomStateMapper(NetherackDoor, (new StateMap.Builder()).addPropertiesToIgnore(BlockPVMDoor.HALF).build());

Don't add a new state mapper for every property, it will replace the previous one added. You'd have to add all of your properties to 1 state mapper.

It still doesn't work.

Link to comment
Share on other sites

What doesn't work? We can't help you if we can't see your code.

 

Also, if you are just going to ignore every single property in your blockstate definition, why have them at all? Can you not just remove all of the properties from the block?

 

If you do need the states for something but want it to have one single model for every possible state, you can easily do that by returning a single ModelResourceLocation from your mapper:

new StateMapperBase() {
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
	return yourModelResourceLocationHere;
}
};

Link to comment
Share on other sites

What doesn't work? We can't help you if we can't see your code.

 

Also, if you are just going to ignore every single property in your blockstate definition, why have them at all? Can you not just remove all of the properties from the block?

 

If you do need the states for something but want it to have one single model for every possible state, you can easily do that by returning a single ModelResourceLocation from your mapper:

new StateMapperBase() {
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
	return yourModelResourceLocationHere;
}
};

What didn't change anything was adding all properties to one statemapper, I thougth it wasn't needed to post the code again when it's pretty much the same as I posted right above.

 

I ignored all properties to see if the errors would go away, that wasn't the case. Yes, I need the states because I'm making a door almost exactly the same as the vanilla ones.

 

I think doors need multiple models (for when they're open or closed for example) so I don't think that will work.

Link to comment
Share on other sites

Show your door blockstates.json file.  If you just copied the vanilla one, then you will need to add the powered states to the file like your errors were showing. Or remove the powered property from your door block like CoolAlias said.

 

Vanilla

"facing=east,half=lower,hinge=left,open=false":  { "model": "wooden_door_bottom" },

 

My custom door

"facing=east,half=lower,hinge=left,open=false,powered=true":  { "model": "telvarianexpanse:door_purpleheart_bottom" },

Link to comment
Share on other sites

Show your door blockstates.json file.  If you just copied the vanilla one, then you will need to add the powered states to the file like your errors were showing. Or remove the powered property from your door block like CoolAlias said.

 

Vanilla

"facing=east,half=lower,hinge=left,open=false":  { "model": "wooden_door_bottom" },

 

My custom door

"facing=east,half=lower,hinge=left,open=false,powered=true":  { "model": "telvarianexpanse:door_purpleheart_bottom" },

Alright, here's my blockstates.json (it's the same as the vanilla ones):

 

{
    "variants": {
        "facing=east,half=lower,hinge=left,open=false":  { "model": "doornetherack_bottom" },
        "facing=south,half=lower,hinge=left,open=false": { "model": "doornetherack_bottom", "y": 90 },
        "facing=west,half=lower,hinge=left,open=false":  { "model": "doornetherack_bottom", "y": 180 },
        "facing=north,half=lower,hinge=left,open=false": { "model": "doornetherack_bottom", "y": 270 },
        "facing=east,half=lower,hinge=right,open=false":  { "model": "doornetherack_bottom_rh" },
        "facing=south,half=lower,hinge=right,open=false": { "model": "doornetherack_bottom_rh", "y": 90 },
        "facing=west,half=lower,hinge=right,open=false":  { "model": "doornetherack_bottom_rh", "y": 180 },
        "facing=north,half=lower,hinge=right,open=false": { "model": "doornetherack_bottom_rh", "y": 270 },
        "facing=east,half=lower,hinge=left,open=true":  { "model": "doornetherack_bottom_rh", "y": 90 },
        "facing=south,half=lower,hinge=left,open=true": { "model": "doornetherack_bottom_rh", "y": 180 },
        "facing=west,half=lower,hinge=left,open=true":  { "model": "doornetherack_bottom_rh", "y": 270 },
        "facing=north,half=lower,hinge=left,open=true": { "model": "doornetherack_bottom_rh" },
        "facing=east,half=lower,hinge=right,open=true":  { "model": "doornetherack_bottom", "y": 270 },
        "facing=south,half=lower,hinge=right,open=true": { "model": "doornetherack_bottom" },
        "facing=west,half=lower,hinge=right,open=true":  { "model": "doornetherack_bottom", "y": 90 },
        "facing=north,half=lower,hinge=right,open=true": { "model": "doornetherack_bottom", "y": 180 },
        "facing=east,half=upper,hinge=left,open=false":  { "model": "doornetherack_top" },
        "facing=south,half=upper,hinge=left,open=false": { "model": "doornetherack_top", "y": 90 },
        "facing=west,half=upper,hinge=left,open=false":  { "model": "doornetherack_top", "y": 180 },
        "facing=north,half=upper,hinge=left,open=false": { "model": "doornetherack_top", "y": 270 },
        "facing=east,half=upper,hinge=right,open=false":  { "model": "doornetherack_top_rh" },
        "facing=south,half=upper,hinge=right,open=false": { "model": "doornetherack_top_rh", "y": 90 },
        "facing=west,half=upper,hinge=right,open=false":  { "model": "doornetherack_top_rh", "y": 180 },
        "facing=north,half=upper,hinge=right,open=false": { "model": "doornetherack_top_rh", "y": 270 },
        "facing=east,half=upper,hinge=left,open=true":  { "model": "doornetherack_top_rh", "y": 90 },
        "facing=south,half=upper,hinge=left,open=true": { "model": "doornetherack_top_rh", "y": 180 },
        "facing=west,half=upper,hinge=left,open=true":  { "model": "doornetherack_top_rh", "y": 270 },
        "facing=north,half=upper,hinge=left,open=true": { "model": "doornetherack_top_rh" },
        "facing=east,half=upper,hinge=right,open=true":  { "model": "doornetherack_top", "y": 270 },
        "facing=south,half=upper,hinge=right,open=true": { "model": "doornetherack_top" },
        "facing=west,half=upper,hinge=right,open=true":  { "model": "doornetherack_top", "y": 90 },
        "facing=north,half=upper,hinge=right,open=true": { "model": "doornetherack_top", "y": 180 }
    }
}

 

And I have tried to get the game to ignore the POWERED property:

PVMBlock.java

 

package com.sirpigman.pigmanvillages.main;

import java.util.Iterator;

import net.minecraft.block.Block;
import net.minecraft.block.BlockColored;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.statemap.StateMap;
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemCloth;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;

import com.sirpigman.pigmanvillages.block.BlockCornPlant;
import com.sirpigman.pigmanvillages.block.BlockPVMDoor;
import com.sirpigman.pigmanvillages.item.ItemBaconCooked;
import com.sirpigman.pigmanvillages.item.ItemBaconGold;
import com.sirpigman.pigmanvillages.item.ItemBaconRaw;
import com.sirpigman.pigmanvillages.item.ItemBottle;
import com.sirpigman.pigmanvillages.item.ItemCornCob;
import com.sirpigman.pigmanvillages.item.ItemCornSeeds;
import com.sirpigman.pigmanvillages.item.ItemMilkBottle;
import com.sirpigman.pigmanvillages.item.ItemPVMDoor;

public class PVMBlock
{
public static Block NetherackDoor;
public static Block CornPlant;

public static void registerBlocks()
{
	NetherackDoor = new BlockPVMDoor(Material.rock);
	CornPlant = new BlockCornPlant();
}

public static void renderBlocks()
{
	renderBlocks(NetherackDoor);
	renderBlocks(CornPlant);
	ModelBakery.addVariantName(Item.getItemFromBlock(CornPlant), new String[]
			{"pvm:cornplant_stage0", "pvm:cornplant_stage1", "pvm:cornplant_stage2", "pvm:cornplant_stage3", "pvm:cornplant_stage4", "pvm:cornplant_stage5", "pvm:cornplant_stage6", "pvm:cornplant_stage7"});   
	ModelBakery.addVariantName(Item.getItemFromBlock(NetherackDoor), new String[]
			{"pvm:doornetherack_bottom", "pvm:doornetherack_top"});
	ModelLoader.setCustomStateMapper(NetherackDoor, (new StateMap.Builder()).addPropertiesToIgnore(BlockPVMDoor.POWERED).build());
}

public static void gameRegistryBlocks()
{
	GameRegistry.registerBlock(CornPlant, "cornplant");
	GameRegistry.registerBlock(NetherackDoor, "doornetherack");
}

public static void renderBlocks(Block block)
{
	Item item = Item.getItemFromBlock(block);
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation("pvm" + ":" + item.getUnlocalizedName().substring(5), "inventory"));
}
}

 

 

I don't understand why I would need to add anything into the .json because the vanilla doors work fine without it?

 

(the cornplant model doesn't work either, but all my items work perfectly)

Link to comment
Share on other sites

The reason why the vanilla json works in vanilla is the POWERED property is ignored.  Just found this.  When I built my doors, there was no ModelLoader yet, so had to add the POWERED property to the json to get it to work.  Same went with my gates.

 

 

        this.registerBlockWithStateMapper(Blocks.oak_door, (new StateMap.Builder()).addPropertiesToIgnore(new IProperty[] {BlockDoor.POWERED}).build());
        this.registerBlockWithStateMapper(Blocks.spruce_door, (new StateMap.Builder()).addPropertiesToIgnore(new IProperty[] {BlockDoor.POWERED}).build());
        this.registerBlockWithStateMapper(Blocks.birch_door, (new StateMap.Builder()).addPropertiesToIgnore(new IProperty[] {BlockDoor.POWERED}).build());
        this.registerBlockWithStateMapper(Blocks.jungle_door, (new StateMap.Builder()).addPropertiesToIgnore(new IProperty[] {BlockDoor.POWERED}).build());
        this.registerBlockWithStateMapper(Blocks.acacia_door, (new StateMap.Builder()).addPropertiesToIgnore(new IProperty[] {BlockDoor.POWERED}).build());
        this.registerBlockWithStateMapper(Blocks.dark_oak_door, (new StateMap.Builder()).addPropertiesToIgnore(new IProperty[] {BlockDoor.POWERED}).build());
        this.registerBlockWithStateMapper(Blocks.iron_door, (new StateMap.Builder()).addPropertiesToIgnore(new IProperty[] {BlockDoor.POWERED}).build());
  

Link to comment
Share on other sites

The reason why the vanilla json works in vanilla is the POWERED property is ignored.  Just found this.  When I built my doors, there was no ModelLoader yet, so had to add the POWERED property to the json to get it to work.  Same went with my gates.

 

 

        this.registerBlockWithStateMapper(Blocks.oak_door, (new StateMap.Builder()).addPropertiesToIgnore(new IProperty[] {BlockDoor.POWERED}).build());
        this.registerBlockWithStateMapper(Blocks.spruce_door, (new StateMap.Builder()).addPropertiesToIgnore(new IProperty[] {BlockDoor.POWERED}).build());
        this.registerBlockWithStateMapper(Blocks.birch_door, (new StateMap.Builder()).addPropertiesToIgnore(new IProperty[] {BlockDoor.POWERED}).build());
        this.registerBlockWithStateMapper(Blocks.jungle_door, (new StateMap.Builder()).addPropertiesToIgnore(new IProperty[] {BlockDoor.POWERED}).build());
        this.registerBlockWithStateMapper(Blocks.acacia_door, (new StateMap.Builder()).addPropertiesToIgnore(new IProperty[] {BlockDoor.POWERED}).build());
        this.registerBlockWithStateMapper(Blocks.dark_oak_door, (new StateMap.Builder()).addPropertiesToIgnore(new IProperty[] {BlockDoor.POWERED}).build());
        this.registerBlockWithStateMapper(Blocks.iron_door, (new StateMap.Builder()).addPropertiesToIgnore(new IProperty[] {BlockDoor.POWERED}).build());
  

Hm, okay. So you have no idea why it isn't working for me?

Link to comment
Share on other sites

Hi

 

I would suggest; try troubleshooting a bit more without the state mapper because it seems to be causing confusion.

 

i.e. just add the extra lines to your blockstates file and get it working that way first for a couple of the states.  If the error message for that stage disappears, and the model renders properly, you'll have eliminate all the other likely causes of the problem

eg change this line

        "facing=east,half=lower,hinge=left,open=false":  { "model": "doornetherack_bottom" },

to

        "facing=east,half=lower,hinge=left,open=false,powered=false":  { "model": "doornetherack_bottom" },

        "facing=east,half=lower,hinge=left,open=false,powered=true":  { "model": "doornetherack_bottom" },

 

-TGG

Link to comment
Share on other sites

Hi

 

I would suggest; try troubleshooting a bit more without the state mapper because it seems to be causing confusion.

 

i.e. just add the extra lines to your blockstates file and get it working that way first for a couple of the states.  If the error message for that stage disappears, and the model renders properly, you'll have eliminate all the other likely causes of the problem

eg change this line

        "facing=east,half=lower,hinge=left,open=false":  { "model": "doornetherack_bottom" },

to

        "facing=east,half=lower,hinge=left,open=false,powered=false":  { "model": "doornetherack_bottom" },

        "facing=east,half=lower,hinge=left,open=false,powered=true":  { "model": "doornetherack_bottom" },

 

-TGG

Yeah, that removed the error messages, but the door still doesn't look as it should. It's still two blocks tall, pink and black checker patterned and acts like a door (you can open and close it) but it doesn't look like a door, just like before. These errors are left:

 

[01:50:01] [Client thread/ERROR] [FML]: Model definition for location pvm:cornplant#inventory not found
[01:50:01] [Client thread/ERROR] [FML]: Model definition for location pvm:doornetherack#inventory not found

 

Link to comment
Share on other sites

Hi

 

OK.  That means you've other problems as well as the state mapping- your properties are probably correct but there's something wrong with the model names, locations, model files, and/or texture files, etc :)

 

This link might help you now

http://greyminecraftcoder.blogspot.com.au/2015/03/troubleshooting-block-and-item-rendering.html

 

-TGG

Link to comment
Share on other sites

Hi

 

OK.  That means you've other problems as well as the state mapping- your properties are probably correct but there's something wrong with the model names, locations, model files, and/or texture files, etc :)

 

This link might help you now

http://greyminecraftcoder.blogspot.com.au/2015/03/troubleshooting-block-and-item-rendering.html

 

-TGG

THANK YOU!!!

Your guide made me realize that I hadn't written the mod id in the blockstate.json files when defining the models! I'm stupid...

Link to comment
Share on other sites

THANK YOU!!!

No worries :)

 

Your guide made me realize that I hadn't written the mod id in the blockstate.json files when defining the models! I'm stupid...

The 1.8 Models are just really hard to get right.  One little thing wrong and it just doesn't work, usually without any helpful symptoms.  I nearly put my first through the screen once after spending 3 hours due to an l which looked like a 1 in the font of the editor I was using.

 

-TGG

Link to comment
Share on other sites

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



×
×
  • Create New...

Important Information

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