Jump to content

Recommended Posts

Posted

My custom block model is not rendering. All it comes up as is the black and purple cube. There are two reasons that I know that it is not a problem with the model fle:

1. I created it with Mr. Crayfish's Model Creator and used an online JSON validator (it was valid).

2. It does not show up as invisible.

Code:

package com.leo.mobsuppressors.blocks;

import java.util.ArrayList;

import com.leo.mobsuppressors.EnumMobSuppressorType;
import com.leo.mobsuppressors.MobSuppressors;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class ModBlocks {
	public static Block enderSuppressor;
	public static Block creeperSuppressor;
	
	public static Block suppressionPedestal;
	
	public static void createBlocks() {
		enderSuppressor = new BlockMobSuppressor("endersuppressor", "endersuppressor", EnumMobSuppressorType.ENDER);
		creeperSuppressor = new BlockMobSuppressor("creepersuppressor", "creepersuppressor", EnumMobSuppressorType.CREEPER);
		suppressionPedestal = new BlockSuppressionPedestal("suppressionpedestal", "suppressionpedestal");
	}
	
	public static void init() {
		createBlocks();
		GameRegistry.register(enderSuppressor);
		GameRegistry.register(new ItemBlock(enderSuppressor).setRegistryName("endersuppressor"));
		
		GameRegistry.register(creeperSuppressor);
		GameRegistry.register(new ItemBlock(creeperSuppressor).setRegistryName("creepersuppressor"));
		
		GameRegistry.register(suppressionPedestal);
		GameRegistry.register(new ItemBlock(suppressionPedestal).setRegistryName("suppressionpedestal"));
	}
	
	public static void registerRenderers() {
		registerRenderer(enderSuppressor);
		registerRenderer(creeperSuppressor);
		
		registerRenderer(suppressionPedestal);
	}
	
	public static void registerRenderer(Block block) {
		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(MobSuppressors.modid + ":" + block.getUnlocalizedName().substring(5), "inventory"));
	}
}
package com.leo.mobsuppressors.blocks;

import com.leo.mobsuppressors.CreativeTab;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;

public class BlockSuppressionPedestal extends Block {
	public BlockSuppressionPedestal(String unlocalizedName, String registryName) {
		super(Material.ROCK);
		
		this.setCreativeTab(CreativeTab.mobSuppressorCreativeTab);
		
		this.setUnlocalizedName(unlocalizedName);
		this.setRegistryName(registryName);
	}
	
	public BlockSuppressionPedestal(Material materialIn) {
		super(materialIn);
	}
}
{
    "forge_marker": 1,
    "variants": {
        "normal" {
	    "model": "mob:suppressors:suppressionpedestal"
	},
	"inventory": {
            "model": "mobsuppressors:suppressionpedestal", 
	    "transform": "forge:default-block"
        }
    }
}
{
    "__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)",
    "textures": {
        "particle": "blocks/suppressionpedestal_bottom",
        "0": "blocks/suppressionpedestal_bottom"
    },
    "elements": [
        {
            "name": "Cube",
            "from": [ 0.0, 0.0, 1.0 ], 
            "to": [ 16.0, 1.0, 16.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 1.0 ] },
                "east": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 1.0 ] },
                "south": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 1.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 16.0 ] },
                "down": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }
            }
        }
    ]
}

 

Posted
  • Post the latest log output, it will contain information about the errors.
Quote

		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(MobSuppressors.modid + ":" + block.getUnlocalizedName().substring(5), "inventory"));

 

  • This approach is very outdated.
    • Instead of Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register, you should use ModelLoader.setCustomModelResourceLocation.
    • You should not use getUnlocalizedName and that messy substring business to set model locations. Instead simply use getRegistryName, which also already includes your modid.
  • Where and when do you call your ModBlocks' init() and registerRenders() methods?
1 hour ago, meee39 said:

    "textures": {
        "particle": "blocks/suppressionpedestal_bottom",
        "0": "blocks/suppressionpedestal_bottom"
    },

 

  • These textures do not contain your modid, so by default forge will be looking for them in the minecraft folder.

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.