Jump to content

Recommended Posts

Posted

I have a JSON model that seems to produce a lot of Z-fighting (outlined in red in the image below)

Spoiler

2019-07-27_10_35_00.thumb.png.4a452927e57d94be497471a58ed83bc9.png

This is my JSON 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 ]
        }
    }
}

 

This is the 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.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;
		}
	}
	
	

}

Is there any way to fix this?

 

Posted

Well yes. You have two cubes that overlap and occupy the same space. You either need to offset your strings or sticks vertically slightly, or you need to use segmented chunks.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I tried offsetting all of the strings 1 pixel up, but the Z-fighting persists. Im not sure if I understand what you are saying

Spoiler

2019-07-27_12_47_58.thumb.png.c182c73b8183040b793cfa168fd31df3.png

 

Posted

Sorry, I was looking at the wrong place. The image getting scaled down made it hard to see the z-fighting.

 

I'm not sure. I can't see any of the cuboids overlapping. My best suggestion is to remove all the cuboids and add them back one at a time, checking at each step to see what introduces the problem.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

That's really odd. I wonder if there's a bug in the model bakery.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.