Jump to content

[1.12.2] Problem with JSON model not rendering properly in a players hand [SOLVED]


kpzip

Recommended Posts

I am having a problem with a specific item that uses a JSON model when it is rendered in your inventory where some of the faces are missing: 

Spoiler

2019-07-30_18_12_45.thumb.png.5f1c7e78afe07eaee9a2ad5ce0deaa47.png

 

This is my model:

Spoiler

{
    "textures": {
        "0": "sushimod:blocks/Bamboo_rolling_mat",
        "particle": "sushimod:blocks/bamboo_planks"
    },
    "elements": [
        {
            "name": "Stick_1",
            "from": [ -1.0, 0.0, 0.0 ], 
            "to": [ 1.0, 1.0, 16.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "east": { "texture": "#0", "uv": [ 0.0, 2.0, 8.0, 2.0 ] },
                "south": { "texture": "#0", "uv": [ 1.0, 1.0, 0.0, 0.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 2.0, 8.0, 2.0 ] },
                "up": { "texture": "#0", "uv": [ 3.0, 0.0, 4.0, 8.0 ] },
                "down": { "texture": "#0", "uv": [ 3.0, 0.0, 4.0, 8.0 ] }
            }
        },
        {
            "name": "Stick_2",
            "from": [ 3.0, 0.0, 0.0 ], 
            "to": [ 5.0, 1.0, 16.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "east": { "texture": "#0", "uv": [ 0.0, 2.0, 8.0, 2.0 ] },
                "south": { "texture": "#0", "uv": [ 1.0, 1.0, 0.0, 0.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 2.0, 8.0, 2.0 ] },
                "up": { "texture": "#0", "uv": [ 3.0, 0.0, 4.0, 8.0 ] },
                "down": { "texture": "#0", "uv": [ 3.0, 0.0, 4.0, 8.0 ] }
            }
        },
        {
            "name": "Stick_3",
            "from": [ 7.0, 0.0, 0.0 ], 
            "to": [ 9.0, 1.0, 16.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "east": { "texture": "#0", "uv": [ 0.0, 2.0, 8.0, 2.0 ] },
                "south": { "texture": "#0", "uv": [ 1.0, 1.0, 0.0, 0.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 2.0, 8.0, 2.0 ] },
                "up": { "texture": "#0", "uv": [ 3.0, 0.0, 4.0, 8.0 ] },
                "down": { "texture": "#0", "uv": [ 3.0, 0.0, 4.0, 8.0 ] }
            }
        },
        {
            "name": "Stick_4",
            "from": [ 11.0, 0.0, 0.0 ], 
            "to": [ 13.0, 1.0, 16.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "east": { "texture": "#0", "uv": [ 0.0, 2.0, 8.0, 2.0 ] },
                "south": { "texture": "#0", "uv": [ 1.0, 1.0, 0.0, 0.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 2.0, 8.0, 2.0 ] },
                "up": { "texture": "#0", "uv": [ 3.0, 0.0, 4.0, 8.0 ] },
                "down": { "texture": "#0", "uv": [ 3.0, 0.0, 4.0, 8.0 ] }
            }
        },
        {
            "name": "Stick_5",
            "from": [ 15.0, 0.0, 0.0 ], 
            "to": [ 17.0, 1.0, 16.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "east": { "texture": "#0", "uv": [ 0.0, 2.0, 8.0, 2.0 ] },
                "south": { "texture": "#0", "uv": [ 1.0, 1.0, 0.0, 0.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 2.0, 8.0, 2.0 ] },
                "up": { "texture": "#0", "uv": [ 3.0, 0.0, 4.0, 8.0 ] },
                "down": { "texture": "#0", "uv": [ 3.0, 0.0, 4.0, 8.0 ] }
            }
        },
        {
            "name": "String_1_1",
            "from": [ 1.0, 0.0, 1.0 ], 
            "to": [ 3.0, 1.0, 2.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.0, 0.0 ] },
                "south": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "down": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] }
            }
        },
        {
            "name": "String_1_2",
            "from": [ 5.0, 0.0, 1.0 ], 
            "to": [ 7.0, 1.0, 2.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.0, 0.0 ] },
                "south": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "down": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] }
            }
        },
        {
            "name": "String_1_3",
            "from": [ 9.0, 0.0, 1.0 ], 
            "to": [ 11.0, 1.0, 2.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.0, 0.0 ] },
                "south": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "down": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] }
            }
        },
        {
            "name": "String_1_4",
            "from": [ 13.0, 0.0, 1.0 ], 
            "to": [ 15.0, 1.0, 2.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.0, 0.0 ] },
                "south": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "down": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] }
            }
        },
        {
            "name": "String_2_1",
            "from": [ 1.0, 0.0, 7.0 ], 
            "to": [ 3.0, 1.0, 9.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.0, 0.0 ] },
                "south": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 2.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "down": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] }
            }
        },
        {
            "name": "String_2_2",
            "from": [ 5.0, 0.0, 7.0 ], 
            "to": [ 7.0, 1.0, 9.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.0, 0.0 ] },
                "south": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 2.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "down": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] }
            }
        },
        {
            "name": "String_2_3",
            "from": [ 9.0, 0.0, 7.0 ], 
            "to": [ 11.0, 1.0, 9.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.0, 0.0 ] },
                "south": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 2.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "down": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] }
            }
        },
        {
            "name": "String_2_4",
            "from": [ 13.0, 0.0, 7.0 ], 
            "to": [ 15.0, 1.0, 9.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.0, 0.0 ] },
                "south": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 2.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "down": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] }
            }
        },
        {
            "name": "String_3_1",
            "from": [ 1.0, 0.0, 14.0 ], 
            "to": [ 3.0, 1.0, 15.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.0, 0.0 ] },
                "south": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "down": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] }
            }
        },
        {
            "name": "String_3_2",
            "from": [ 5.0, 0.0, 14.0 ], 
            "to": [ 7.0, 1.0, 15.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.0, 0.0 ] },
                "south": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "down": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] }
            }
        },
        {
            "name": "String_3_3",
            "from": [ 9.0, 0.0, 14.0 ], 
            "to": [ 11.0, 1.0, 15.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.0, 0.0 ] },
                "south": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "down": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] }
            }
        },
        {
            "name": "String_3_4",
            "from": [ 13.0, 0.0, 14.0 ], 
            "to": [ 15.0, 1.0, 15.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.0, 0.0 ] },
                "south": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] },
                "down": { "texture": "#0", "uv": [ 8.0, 1.0, 9.0, 1.0 ] }
            }
        }
    ],
    "display": {
        "gui": {
            "rotation": [ 30, 135, 0 ],
            "translation": [ 0, 2, 0 ],
            "scale": [ 0.7, 0.7, 0.7 ]
        },
        "ground": {
            "rotation": [ 0, 0, 0 ],
            "translation": [ 0, 5, 0 ],
            "scale": [ 0.8, 0.8, 0.8 ]
        },
        "firstperson_righthand": {
            "rotation": [ 0, -225, 0 ],
            "translation": [ 0, 4, 0 ],
            "scale": [ 0.4, 0.4, 0.4 ]
        },
        "thirdperson_righthand": {
            "rotation": [ 70, 135, 0 ],
            "translation": [ 0, 5, 3 ],
            "scale": [ 0.4, 0.4, 0.4 ]
        }
    }
}

 

And this is my block class:

Spoiler

package com.kpzip.SushiMod.blocks;

import java.util.ArrayList;
import java.util.List;

import net.minecraft.block.BlockRedstoneComparator;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockFaceShape;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import com.kpzip.SushiMod.Main;
import com.kpzip.SushiMod.blocks.shapes.IHasCustomShape;
import com.kpzip.SushiMod.init.ModBlocks;
import com.kpzip.SushiMod.init.ModItems;
import com.kpzip.SushiMod.util.AxisAlignedBBReference;
import com.kpzip.SushiMod.util.handlers.EnumHandler;
import com.kpzip.SushiMod.util.handlers.EnumHandler.EnumOrthogonalRotation;

public class BlockBambooRollingMat extends BlockBase implements IHasCustomShape {
	
	public static final PropertyEnum<EnumHandler.EnumOrthogonalRotation> ROTATION = PropertyEnum.<EnumHandler.EnumOrthogonalRotation>create("rotation", EnumHandler.EnumOrthogonalRotation.class);

	public BlockBambooRollingMat(String name) {
		super(name, Material.WOOD, 0);
		this.setDefaultState(this.blockState.getBaseState().withProperty(ROTATION, EnumOrthogonalRotation.X));
		this.setCreativeTab(Main.SUSHI_BLOCKS);
		ModItems.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName()));
		this.setSoundType(SoundType.WOOD);
		setHardness(0.2F);
		setResistance(2.5F);
	
	}
	
	public BlockBambooRollingMat(String name, int unused) {
		super(name, Material.WOOD, 0);
		this.setSoundType(SoundType.WOOD);
		setHardness(0.2F);
		setResistance(2.5F);
	
	}
	
	@Override
	public boolean isOpaqueCube(IBlockState state) {
		
		return false;
		
	}
	
	@Override
	public boolean isFullCube(IBlockState state) {
		
		return false;
		
	}
	
	@Override
	public boolean isFullBlock(IBlockState state) {
		return false;
	}
	
	@Override
	public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
		if (state.getValue(ROTATION).equals(EnumOrthogonalRotation.X)) {
			return AxisAlignedBBReference.BAMBOO_ROLLING_MAT_BOUNDING_BOX;
		}
		else {
			return AxisAlignedBBReference.BAMBOO_ROLLING_MAT_BOUNDING_BOX_90;
		}
		
		
	}
	
	@Override
	public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
		
		if (!worldIn.isRemote) {
			
			ItemStack item = playerIn.getHeldItem(hand);
			boolean isCreative = playerIn.capabilities.isCreativeMode;
			
			if (item.getItem() == (Item) ModItems.NORI) {
				worldIn.setBlockState(pos, ModBlocks.BAMBOO_ROLLING_MAT_RECIPE_BASE.getDefaultState().withProperty(BlockBambooRollingMatRecipeBase.ROTATION, state.getValue(ROTATION)));
				if (!isCreative) {
					item.setCount( (item.getCount() - 1) );
				}
				
				
				
			}
			else if (item.getItem() == (Item) ModItems.STICKY_RICE) {
				worldIn.setBlockState(pos, ModBlocks.BAMBOO_ROLLING_MAT_RECIPE_BASE.getDefaultState().withProperty(BlockBambooRollingMatRecipeBase.ISCALIFORNIAROLL, true).withProperty(BlockBambooRollingMatRecipeBase.ROTATION, state.getValue(ROTATION)));
				if (!isCreative) {
					item.setCount( (item.getCount() - 1) );
				}
				
			}
			
			
		}
		return true;
		
		
	}
	
	@Override
	public EnumBlockRenderType getRenderType(IBlockState state) {
		return EnumBlockRenderType.MODEL;
	}
	
	public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
    {
        return worldIn.getBlockState(pos.down()).isTopSolid() ? super.canPlaceBlockAt(worldIn, pos) : false;
    }
	
	@Override
	protected BlockStateContainer createBlockState() {
		return new BlockStateContainer(this, new IProperty[] {ROTATION});
	}
	
	@Override
	public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
		if (placer.getHorizontalFacing() == EnumFacing.EAST || placer.getHorizontalFacing() == EnumFacing.WEST ) {
			return this.getDefaultState().withProperty(ROTATION, EnumOrthogonalRotation.Y);
		}
		return this.getDefaultState();
	}
	
	@Override
	public IBlockState getStateFromMeta(int meta) {
		if (meta == 0) {
			return this.getDefaultState().withProperty(ROTATION, EnumOrthogonalRotation.X);
		}
		else {
			return this.getDefaultState().withProperty(ROTATION, EnumOrthogonalRotation.Y);
		}
	}
	
	@Override
	public int getMetaFromState(IBlockState state) {
		if (state.getValue(ROTATION) == EnumOrthogonalRotation.X) {
			return 0;
		}
		else {
			return 1;
		}
	}
	
	@Override
	public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) {
		return BlockFaceShape.UNDEFINED;
	}
	
	

}

 

 

Edited by kpzip
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.