Jump to content

[1.12.1] Awkward to admit, I can't setup a block


PlayPrey

Recommended Posts

Greetings, 

 

I am having some issues getting as much as a basic block working,- so I just need someone to point me in the right direction. 

 

I register the block itself using the following:

 

Main Mod File:

Spoiler

@SubscribeEvent
    public static void registerBlocks(RegistryEvent.Register<Block> event) 
    {
        ModBlocks.init();
        
        for(Block block : ModBlocks.ModOres)
        {
            event.getRegistry().register(block);
        }
          
    }

ModBlocks:

Spoiler

public final class ModBlocks 
{
    public static List<Block> ModOres = new ArrayList<Block>();
    
    public static Block silverOre;
    
    public static void addBlocks()
    {
        ModOres.add(silverOre);
    }
    
    public static void init() 
    {        
        silverOre = new BasicOre("silverOre", Material.ROCK, tabExtremityOres, 4f, 0f, "pickaxe", 0);
        
        addBlocks();
    }
}

BasicOre:

Spoiler

public class BasicOre extends BlockBase
{
    public BasicOre(String name, Material mat, CreativeTabs creativeTab, float hardness, float resistance, String tool, int harvest)
    {
        super(name, mat, creativeTab, hardness, resistance, tool, harvest);
    }
}

 

ModItems:

Spoiler

public final class ModItems 
{
    public static List<Item> ModItems = new ArrayList<Item>();
    
    public static Item itemSilverOre;
    
    public static void addItems()
    {
        ModItems.add(itemSilverOre);
    }
    
    public static void init() 
    {                
        itemSilverOre = new BasicOreItem("itemSilverOre", ModBlocks.tabExtremityOres, 64);
        
        addItems();
    }
}

BasicOreItem:

Spoiler

public class BasicOreItem extends Item
{
    public BasicOreItem(String name, CreativeTabs tab)
    {
        this(name, tab, 64);
    }
    
    public BasicOreItem(String name, CreativeTabs tab, int maxSize)
    {
        setUnlocalizedName(name);
        setRegistryName(name);
        setCreativeTab(tab);
        setMaxStackSize(maxSize);
    }
}

 

 

I know this won't work as the item has no connection the the block itself ever in the code, how do I do that the proper way?

Also the item shows up just like a screenshot I used for a earlier problem. (It's for an item, but it has the exact same look but with different text) 

 

I've tried to understand the tutorials & documentation but I struggle with it so I bet the solution is the easiest thing ever. 

Thank you for reading.

 

Oh and heres the JSON file at assets/ppextreme/blockstates/silverore.json:

Spoiler

{
    "forge_marker": 1,
    "defaults": {
        "textures": {
            "all": "ppextreme:blocks/ore/silverore"
        },
        "model": "cube_all",
        "uvlock": true
    },
    "variants": {
        "normal": [{

        }]
    }
}

 

screencap.PNG

Intel(R) Core(TM) i7-8700K

32GB DDR4 2400MHz 

NVIDIA GeForce RTX 2080 8GB

Link to comment
Share on other sites

You need to use a class that extends ItemBlock for the Item form of a Block.

 

Where are you registering your item models? There should be some errors in the FML log telling you why the models aren't working, please post this using  Gist or Pastebin.

Edited by Choonster

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Look through the vanilla Minecraft classes, especially the ore blocks. I think you'll see them extending a vanilla BlockOre class, so you don't need to reinvent it.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

So I changed things up so my class extends ItemBlock, which when I think about it was a obvious fix, this required a logical parameter "Block". 

I can now place my block around using my itemBlock for it, thank you :)

 

However now I need to fixed the Model rendering for it when it's held. 

 

Main Mod File:

Spoiler

@SubscribeEvent
    public static void modelRegistryEvent(ModelRegistryEvent event)
    {
        for(Item item : ModItems.ModItems)
        {
            ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
        }

    }

ModItems:

Spoiler

public final class ModItems 
{
    public static List<Item> ModItems = new ArrayList<Item>();
    
    public static Item itemSilverOre;
    
    public static void addItems()
    {
        ModItems.add(itemSilverOre);
    }
    
    public static void init() 
    {            
        itemSilverOre = new BasicOreItem("itemSilverOre", ModBlocks.tabExtremityOres, 64, ModBlocks.silverOre); // <-- This needs to be cleaned up after changing to ItemBlock I am aware of that :)
        
        addItems();
    }
}
 

BasicOreItem:

Spoiler

public class BasicOreItem extends ItemBlock
{
    
    public BasicOreItem(String name, CreativeTabs tab, int i, Block block) 
    {
        super(block);
        this.setRegistryName("ppextreme", name);
        this.setUnlocalizedName(name);
        // TODO Auto-generated constructor stub    (Yes this needs cleaning aswell)
    }
    

}

 

SPOILER edition of the error log:

Spoiler

[22:36:51] [main/ERROR] [FML]: Exception loading model for variant ppextreme:itemsilverore#inventory for item "ppextreme:itemsilverore", normal location exception: 
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model ppextreme:item/itemsilverore with loader VanillaLoader.INSTANCE, skipping
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]
    at net.minecraftforge.client.model.ModelLoader.loadItemModels(ModelLoader.java:297) ~[ModelLoader.class:?]
    at net.minecraft.client.renderer.block.model.ModelBakery.loadVariantItemModels(ModelBakery.java:175) ~[ModelBakery.class:?]
    at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:160) ~[ModelLoader.class:?]
    at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?]
    at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:121) [SimpleReloadableResourceManager.class:?]
    at net.minecraft.client.Minecraft.init(Minecraft.java:554) [Minecraft.class:?]
    at net.minecraft.client.Minecraft.run(Minecraft.java:416) [Minecraft.class:?]
    at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_144]
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_144]
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
    at GradleStart.main(GradleStart.java:26) [start/:?]
Caused by: java.io.FileNotFoundException: ppextreme:models/item/itemsilverore.json
    at net.minecraft.client.resources.FallbackResourceManager.getResource(FallbackResourceManager.java:69) ~[FallbackResourceManager.class:?]
    at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:65) ~[SimpleReloadableResourceManager.class:?]
    at net.minecraft.client.renderer.block.model.ModelBakery.loadModel(ModelBakery.java:334) ~[ModelBakery.class:?]
    at net.minecraftforge.client.model.ModelLoader.access$1600(ModelLoader.java:126) ~[ModelLoader.class:?]
    at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:933) ~[ModelLoader$VanillaLoader.class:?]
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
    ... 20 more
[22:36:51] [main/ERROR] [FML]: Exception loading model for variant ppextreme:itemsilverore#inventory for item "ppextreme:itemsilverore", blockstate location exception: 
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model ppextreme:itemsilverore#inventory with loader VariantLoader.INSTANCE, skipping
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]
    at net.minecraftforge.client.model.ModelLoader.loadItemModels(ModelLoader.java:305) ~[ModelLoader.class:?]
    at net.minecraft.client.renderer.block.model.ModelBakery.loadVariantItemModels(ModelBakery.java:175) ~[ModelBakery.class:?]
    at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:160) ~[ModelLoader.class:?]
    at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?]
    at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:121) [SimpleReloadableResourceManager.class:?]
    at net.minecraft.client.Minecraft.init(Minecraft.java:554) [Minecraft.class:?]
    at net.minecraft.client.Minecraft.run(Minecraft.java:416) [Minecraft.class:?]
    at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_144]
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_144]
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
    at GradleStart.main(GradleStart.java:26) [start/:?]
Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException
    at net.minecraft.client.renderer.block.model.ModelBlockDefinition.getVariant(ModelBlockDefinition.java:83) ~[ModelBlockDefinition.class:?]
    at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1242) ~[ModelLoader$VariantLoader.class:?]
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
    ... 20 more

And Pastebin version: https://pastebin.com/yS1SzPL7

 

 

 

Also thank you jeffryfisher, Ill look into that as soon as I got them up and going :)

 

 

 

 

Intel(R) Core(TM) i7-8700K

32GB DDR4 2400MHz 

NVIDIA GeForce RTX 2080 8GB

Link to comment
Share on other sites

Caused by: java.io.FileNotFoundException: ppextreme:models/item/itemsilverore.json

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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.