Jump to content

[1.10.2] Glitch with custom model


JimiIT92

Recommended Posts

I've created a block using a custom model, to make it looks like is a Tombstone. But in some points the texture used is stretched and it looks awful

WYY3JTT.png

This is the class file

package com.mineworld.blocks.decorations;

import com.mineworld.core.MWBlocks;
import com.mineworld.core.MWTabs;

import net.minecraft.block.Block;
import net.minecraft.block.BlockHorizontal;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable;

public class BlockGrave extends BlockHorizontal{

public BlockGrave() {
	super(Material.ROCK, MapColor.STONE);
	this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
	this.setHardness(0.5F);
	this.setCreativeTab(MWTabs.tabDecorations);
	this.setSoundType(SoundType.STONE);
}

/**
     * Used to determine ambient occlusion and culling when rebuilding chunks for render
     */
    public boolean isOpaqueCube(IBlockState state)
    {
        return false;
    }

    public boolean isFullCube(IBlockState state)
    {
        return false;
    }

@Override
public BlockRenderLayer getBlockLayer() {
	return BlockRenderLayer.CUTOUT;
}

/**
     * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed
     * blockstate.
     */
    public IBlockState withRotation(IBlockState state, Rotation rot)
    {
        return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING)));
    }

    /**
     * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed
     * blockstate.
     */
    public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
    {
        return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING)));
    }

    /**
     * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
     * IBlockstate
     */
    public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
    {
        return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
    }

    /**
     * Convert the given metadata into a BlockState for this Block
     */
    public IBlockState getStateFromMeta(int meta)
    {
        return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta));
    }

    /**
     * Convert the BlockState into the correct metadata value
     */
    public int getMetaFromState(IBlockState state)
    {
        return ((EnumFacing)state.getValue(FACING)).getHorizontalIndex();
    }

    protected BlockStateContainer createBlockState()
    {
        return new BlockStateContainer(this, new IProperty[] {FACING});
    }
}

 

And this is the model file

{   "parent": "block/block",
    "textures": {
    "stone": "blocks/stone",
    "particle": "blocks/stone"
     },
    "elements": [
        {   "from": [ 3, 0, 3 ],
            "to": [ 13, 1, 13 ],
            "faces": {
                "down":  { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "up":    { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"}
            }
        },
	{   "from": [ 5, 1, 5],
            "to": [ 11, 2, 11 ],
            "faces": {
                "down":  { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "up":    { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"}
            }
        },
	{   "from": [ 7, 2, 7],
            "to": [ 9, 15, 9 ],
            "faces": {
                "down":  { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "up":    { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"}
            }
        },
	{   "from": [ 4, 9, 7],
            "to": [ 7, 11, 9 ],
            "faces": {
                "down":  { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "up":    { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"}
            }
        }
	,
	{   "from": [ 9, 9, 7],
            "to": [ 12, 11, 9 ],
            "faces": {
                "down":  { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "up":    { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"},
                "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#stone"}
            }
        }
    ]
}

 

How can i make the texture looks "normal" and not "stretched"?

Don't blame me if i always ask for your help. I just want to learn to be better :)

Link to comment
Share on other sites

Your UVs all state "0 -> 16" for both the U and V directions.  This means the full 16x16 texture is being used on each face.

 

If you want the texture to use as many pixels as the face is wide, then you need to match your UV values to match your from/to values.

 

Also, remove invisible faces.  The cuboid at "from": [ 5, 1, 5],"to": [ 11, 2, 11 ] will never have it's "down" face visible (it is coplanar with the top face of the previous cuboid and facing into it) so there's no reason to render it at all.

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.

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.