Jump to content

Block Texture Isn't Appearing


Jimmeh

Recommended Posts

Hey there!

 

So I've actually made custom blocks before and I get them to work. I'm 99% sure I'm doing the exact same thing, but this time the texture isn't appearing once the block is placed (it's probably something really simple and stupid... looking forward to that "a ha!" moment .-.). The texture is appropriately applied when you're holding the ItemBlock in your hand, but it's invisible once placed.

 

Here's my BlockStorageBlock class:

public class BlockStorageBlock extends BlockContainerBase {

    public BlockStorageBlock() {
        super(Material.WOOD, BlockReferences.BlockStorageBlock);
    }

    @Override
    public boolean isOpaqueCube(IBlockState state){ //opaque = can't see through, I believe
        return false;
    } //if true, you can see through the bottom

    @Override
    public boolean isFullCube(IBlockState state){
        return true;
    } //is a normal, full sized cube?

    @Override
    public boolean isFullBlock(IBlockState state){//should fix a shadow glitch if the block is transparent or has transparent parts
        return false;
    }

    @Override
    public boolean isPassable(IBlockAccess worldIn, BlockPos pos){
        return false;
    }

    @Override
    public BlockRenderLayer getBlockLayer(){ //BlockRenderLayer.SOLID = don't want block to be transparent, but want to remove x-ray effect. Doesn't work if want transparent textures
        return BlockRenderLayer.SOLID;
    }

    @Override
    public void breakBlock(World world, BlockPos pos, IBlockState state){
        TileEntityStorageBlock te = (TileEntityStorageBlock)world.getTileEntity(pos);
        InventoryHelper.dropInventoryItems(world, pos, te);
        super.breakBlock(world, pos, state);
    }

    @Override
    public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
        if(stack.hasDisplayName()){
            ((TileEntityStorageBlock)world.getTileEntity(pos)).setCustomName(stack.getDisplayName());
        }
    }

    @Override
    public TileEntity createNewTileEntity(World world, int meta) {
        return new TileEntityStorageBlock();
    }
}

 

Here's the BlockContainerBase class that it extends:

public class BlockContainerBase extends BlockContainer {

    private BlockReferences reference;

    public BlockContainerBase(Material blockMaterialIn, BlockReferences reference) {
        super(blockMaterialIn);

        this.reference = reference;
        setUnlocalizedName(reference.getUnlocalizedName());
        setRegistryName(reference.getRegistryName());
        setCreativeTab(Test.CREATIVE_TAB);
    }

    @Override
    public TileEntity createNewTileEntity(World worldIn, int meta) {
        return null;
    }
}

 

The blockstorageblock.json blockstates file:

{
    "forge_marker": 1,
    "defaults": {
        "textures": {
            "all": "test:blocks/blockstorageblock"
        }
    },
    "variants": {
        "normal": {
            "model": "test:blockstorageblock"
        },
        "inventory": {
            "model": "test:blockstorageblock"
        }
    }
}

 

The blockstorageblock.json models/block file:

{
"textures": {
	"texture": "test:blocks/blockstorageblock"
},
"elements": [
	{
		"__comment": "Voxels-5E2F00",
		"from": [ -0.25, 15.25, -0.5 ],
		"to": [ 16.5, 16.5, 0.75 ],
		"faces": {
			"down": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"up": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"north": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"south": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"west": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"east": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" }
		}
	},
	{
		"__comment": "Voxels-5E2F00",
		"from": [ -0.25, 15.25, 0.75 ],
		"to": [ 16.5, 16, 16.25 ],
		"faces": {
			"down": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"up": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"north": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"south": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"west": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"east": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" }
		}
	},
	{
		"__comment": "Voxels-5E2F00",
		"from": [ -0.25, 16, 0.75 ],
		"to": [ 1.25, 16.5, 16.25 ],
		"faces": {
			"down": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"up": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"north": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"south": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"west": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"east": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" }
		}
	},
	{
		"__comment": "Voxels-9B4E00",
		"from": [ 0, 0, -0.25 ],
		"to": [ 16.25, 15.25, 0 ],
		"faces": {
			"down": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"up": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"north": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"south": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"west": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"east": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" }
		}
	},
	{
		"__comment": "Voxels-9B4E00",
		"from": [ 0, 0, 0 ],
		"to": [ 16.25, 0.25, 16 ],
		"faces": {
			"down": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"up": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"north": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"south": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"west": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"east": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" }
		}
	},
	{
		"__comment": "Voxels-9B4E00",
		"from": [ 0, 0.25, 0 ],
		"to": [ 0.25, 15.25, 16 ],
		"faces": {
			"down": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"up": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"north": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"south": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"west": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"east": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" }
		}
	},
	{
		"__comment": "Voxels-5E2F00",
		"from": [ 0.25, 0.25, 0 ],
		"to": [ 16, 15.25, 15.75 ],
		"faces": {
			"down": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"up": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"north": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"south": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"west": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"east": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" }
		}
	},
	{
		"__comment": "Voxels-9B4E00",
		"from": [ 0.25, 0.25, 15.75 ],
		"to": [ 16.25, 15.25, 16 ],
		"faces": {
			"down": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"up": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"north": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"south": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"west": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"east": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" }
		}
	},
	{
		"__comment": "Voxels-9B4E00",
		"from": [ 1.25, 16, 0.75 ],
		"to": [ 15, 16.25, 14.75 ],
		"faces": {
			"down": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"up": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"north": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"south": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"west": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"east": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" }
		}
	},
	{
		"__comment": "Voxels-5E2F00",
		"from": [ 1.25, 16, 14.75 ],
		"to": [ 16.5, 16.5, 16.25 ],
		"faces": {
			"down": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"up": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"north": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"south": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"west": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"east": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" }
		}
	},
	{
		"__comment": "Voxels-5E2F00",
		"from": [ 15, 16, 0.75 ],
		"to": [ 16.5, 16.25, 1 ],
		"faces": {
			"down": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"up": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"north": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"south": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"west": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"east": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" }
		}
	},
	{
		"__comment": "Voxels-9B4E00",
		"from": [ 15, 16, 1 ],
		"to": [ 15.25, 16.25, 14.75 ],
		"faces": {
			"down": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"up": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"north": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"south": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"west": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"east": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" }
		}
	},
	{
		"__comment": "Voxels-5E2F00",
		"from": [ 15.25, 16, 1 ],
		"to": [ 16.5, 16.5, 14.75 ],
		"faces": {
			"down": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"up": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"north": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"south": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"west": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"east": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" }
		}
	},
	{
		"__comment": "Voxels-5E2F00",
		"from": [ 15.25, 16.25, 0.75 ],
		"to": [ 16.5, 16.5, 1 ],
		"faces": {
			"down": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"up": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"north": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"south": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"west": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" },
			"east": { "uv": [ 8.96, 0.96, 11.04, 3.04 ], "texture": "#texture" }
		}
	},
	{
		"__comment": "Voxels-9B4E00",
		"from": [ 16, 0.25, 0 ],
		"to": [ 16.25, 15.25, 15.75 ],
		"faces": {
			"down": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"up": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"north": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"south": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"west": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" },
			"east": { "uv": [ 12.96, 0.96, 15.04, 3.04 ], "texture": "#texture" }
		}
	}
],
  "display": {
"gui": {
  "rotation":  [ 30, 225, 0 ],
  "translation":  [ -2.921, 1.6695, 0 ],
  "scale":  [ 0.7, 0.7, 0.7 ]
}
  }
}

 

Any help is greatly appreciated! I've stared at this for probably an hour straight and I can't seem to figure out what I did wrong here compared to other custom blocks I've made. Thanks! :D

 

Link to comment
Share on other sites

Don't use BlockContainer. It was never the best way to do TileEntities even in 1.7, and now that you've updated to 1.10, the createNewTileEntity method is just flat wrong (int meta? What block metadata? we operate on states now!).  Use the hasTileEntity and createNewTileEntity methods present in the Block class.

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

Don't use BlockContainer. It was never the best way to do TileEntities even in 1.7, and now that you've updated to 1.10, the createNewTileEntity method is just flat wrong (int meta? What block metadata? we operate on states now!).  Use the hasTileEntity and createNewTileEntity methods present in the Block class.

 

Oh okay. So the tutorial I was following was creating a chest-like thing, so that's why I think he used BlockContainer. So even if the thing I'm creating is going to have an inventory, stick with Block?

Link to comment
Share on other sites

By default,

BlockContainer

renders invisible. If you want it to render from a normal block model you'd need override

getRenderType

and return

EnumBlockRenderType.MODEL

. But it is probably best to do as Draco18s recommends and not use BlockContainer at all.

 

Oh okay, I appreciate the insight. I'll give this a shot!

Link to comment
Share on other sites

By default,

BlockContainer

renders invisible. If you want it to render from a normal block model you'd need override

getRenderType

and return

EnumBlockRenderType.MODEL

. But it is probably best to do as Draco18s recommends and not use BlockContainer at all.

 

Among other things.

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.