Jump to content

Recommended Posts

Posted (edited)

RESOLVED:

 

I was so focused on looking for errors in my classes and methods that I overlooked a simple misplaced parameter that made my code use the wrong class. The issue is essentially a duplicate of  this, despite what I said in my post below. Apologies.

 

I'm making  pretty standard StairsBlock, and it's basically just a re-skin of the acacia stairs. When Minecraft loads, I get a bunch of exceptions in the debug log:

Spoiler

[12May2020 17:53:39.961] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=north,half=bottom,shape=outer_right': Unknown blockstate property: 'facing' [12May2020 17:53:39.961] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=south,half=top,shape=inner_right': Unknown blockstate property: 'facing' [12May2020 17:53:39.961] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=north,half=top,shape=inner_right': Unknown blockstate property: 'facing' [12May2020 17:53:39.962] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=south,half=top,shape=inner_left': Unknown blockstate property: 'facing' [12May2020 17:53:39.962] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=north,half=bottom,shape=outer_left': Unknown blockstate property: 'facing' [12May2020 17:53:39.962] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=east,half=top,shape=inner_right': Unknown blockstate property: 'facing' [12May2020 17:53:39.962] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=east,half=top,shape=inner_left': Unknown blockstate property: 'facing' [12May2020 17:53:39.962] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=west,half=bottom,shape=inner_right': Unknown blockstate property: 'facing' [12May2020 17:53:39.962] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=west,half=top,shape=inner_right': Unknown blockstate property: 'facing' [12May2020 17:53:39.962] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=north,half=top,shape=inner_left': Unknown blockstate property: 'facing' [12May2020 17:53:39.962] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=east,half=bottom,shape=inner_left': Unknown blockstate property: 'facing' [12May2020 17:53:39.962] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=west,half=bottom,shape=inner_left': Unknown blockstate property: 'facing' [12May2020 17:53:39.962] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=east,half=bottom,shape=outer_right': Unknown blockstate property: 'facing' [12May2020 17:53:39.962] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=north,half=top,shape=outer_left': Unknown blockstate property: 'facing' [12May2020 17:53:39.962] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=south,half=bottom,shape=straight': Unknown blockstate property: 'facing' [12May2020 17:53:39.962] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=north,half=bottom,shape=inner_right': Unknown blockstate property: 'facing' [12May2020 17:53:39.962] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=south,half=bottom,shape=inner_right': Unknown blockstate property: 'facing' [12May2020 17:53:39.962] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=east,half=top,shape=outer_left': Unknown blockstate property: 'facing' [12May2020 17:53:39.963] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=west,half=bottom,shape=straight': Unknown blockstate property: 'facing' [12May2020 17:53:39.963] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=north,half=top,shape=outer_right': Unknown blockstate property: 'facing' [12May2020 17:53:39.963] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=west,half=top,shape=inner_left': Unknown blockstate property: 'facing' [12May2020 17:53:39.963] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=west,half=top,shape=outer_right': Unknown blockstate property: 'facing' [12May2020 17:53:39.963] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=south,half=top,shape=outer_left': Unknown blockstate property: 'facing' [12May2020 17:53:39.963] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=east,half=top,shape=outer_right': Unknown blockstate property: 'facing' [12May2020 17:53:39.963] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=east,half=bottom,shape=inner_right': Unknown blockstate property: 'facing' [12May2020 17:53:39.963] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=south,half=bottom,shape=inner_left': Unknown blockstate property: 'facing' [12May2020 17:53:39.963] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=west,half=top,shape=straight': Unknown blockstate property: 'facing' [12May2020 17:53:39.963] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=west,half=top,shape=outer_left': Unknown blockstate property: 'facing' [12May2020 17:53:39.963] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=south,half=top,shape=straight': Unknown blockstate property: 'facing' [12May2020 17:53:39.963] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=east,half=top,shape=straight': Unknown blockstate property: 'facing' [12May2020 17:53:39.963] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=west,half=bottom,shape=outer_right': Unknown blockstate property: 'facing' [12May2020 17:53:39.964] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=south,half=top,shape=outer_right': Unknown blockstate property: 'facing' [12May2020 17:53:39.964] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=east,half=bottom,shape=straight': Unknown blockstate property: 'facing' [12May2020 17:53:39.964] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=west,half=bottom,shape=outer_left': Unknown blockstate property: 'facing' [12May2020 17:53:39.964] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=east,half=bottom,shape=outer_left': Unknown blockstate property: 'facing' [12May2020 17:53:39.964] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=north,half=bottom,shape=straight': Unknown blockstate property: 'facing' [12May2020 17:53:39.964] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=north,half=bottom,shape=inner_left': Unknown blockstate property: 'facing' [12May2020 17:53:39.964] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=north,half=top,shape=straight': Unknown blockstate property: 'facing' [12May2020 17:53:39.964] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=south,half=bottom,shape=outer_right': Unknown blockstate property: 'facing' [12May2020 17:53:39.964] [Server-Worker-6/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Exception loading blockstate definition: 'examplemod:blockstates/green_stone_stairs.json' in resourcepack: 'Mod Resources' for variant: 'facing=south,half=bottom,shape=outer_left': Unknown blockstate property: 'facing'

I've never had this issue before. I've checked multiple times, and my JSON is basically an exact copy of the acacia stairs JSON. The same is true of the model JSONS:
 

Spoiler

 

{
    "variants": {
        "facing=east,half=bottom,shape=straight":  { "model": "examplemod:block/green_stone_stairs" },
        "facing=west,half=bottom,shape=straight":  { "model": "examplemod:block/green_stone_stairs", "y": 180, "uvlock": true },
        "facing=south,half=bottom,shape=straight": { "model": "examplemod:block/green_stone_stairs", "y": 90, "uvlock": true },
        "facing=north,half=bottom,shape=straight": { "model": "examplemod:block/green_stone_stairs", "y": 270, "uvlock": true },
        "facing=east,half=bottom,shape=outer_right":  { "model": "examplemod:block/green_stone_stairs_outer" },
        "facing=west,half=bottom,shape=outer_right":  { "model": "examplemod:block/green_stone_stairs_outer", "y": 180, "uvlock": true },
        "facing=south,half=bottom,shape=outer_right": { "model": "examplemod:block/green_stone_stairs_outer", "y": 90, "uvlock": true },
        "facing=north,half=bottom,shape=outer_right": { "model": "examplemod:block/green_stone_stairs_outer", "y": 270, "uvlock": true },
        "facing=east,half=bottom,shape=outer_left":  { "model": "examplemod:block/green_stone_stairs_outer", "y": 270, "uvlock": true },
        "facing=west,half=bottom,shape=outer_left":  { "model": "examplemod:block/green_stone_stairs_outer", "y": 90, "uvlock": true },
        "facing=south,half=bottom,shape=outer_left": { "model": "examplemod:block/green_stone_stairs_outer" },
        "facing=north,half=bottom,shape=outer_left": { "model": "examplemod:block/green_stone_stairs_outer", "y": 180, "uvlock": true },
        "facing=east,half=bottom,shape=inner_right":  { "model": "examplemod:block/green_stone_stairs_inner" },
        "facing=west,half=bottom,shape=inner_right":  { "model": "examplemod:block/green_stone_stairs_inner", "y": 180, "uvlock": true },
        "facing=south,half=bottom,shape=inner_right": { "model": "examplemod:block/green_stone_stairs_inner", "y": 90, "uvlock": true },
        "facing=north,half=bottom,shape=inner_right": { "model": "examplemod:block/green_stone_stairs_inner", "y": 270, "uvlock": true },
        "facing=east,half=bottom,shape=inner_left":  { "model": "examplemod:block/green_stone_stairs_inner", "y": 270, "uvlock": true },
        "facing=west,half=bottom,shape=inner_left":  { "model": "examplemod:block/green_stone_stairs_inner", "y": 90, "uvlock": true },
        "facing=south,half=bottom,shape=inner_left": { "model": "examplemod:block/green_stone_stairs_inner" },
        "facing=north,half=bottom,shape=inner_left": { "model": "examplemod:block/green_stone_stairs_inner", "y": 180, "uvlock": true },
        "facing=east,half=top,shape=straight":  { "model": "examplemod:block/green_stone_stairs", "x": 180, "uvlock": true },
        "facing=west,half=top,shape=straight":  { "model": "examplemod:block/green_stone_stairs", "x": 180, "y": 180, "uvlock": true },
        "facing=south,half=top,shape=straight": { "model": "examplemod:block/green_stone_stairs", "x": 180, "y": 90, "uvlock": true },
        "facing=north,half=top,shape=straight": { "model": "examplemod:block/green_stone_stairs", "x": 180, "y": 270, "uvlock": true },
        "facing=east,half=top,shape=outer_right":  { "model": "examplemod:block/green_stone_stairs_outer", "x": 180, "y": 90, "uvlock": true },
        "facing=west,half=top,shape=outer_right":  { "model": "examplemod:block/green_stone_stairs_outer", "x": 180, "y": 270, "uvlock": true },
        "facing=south,half=top,shape=outer_right": { "model": "examplemod:block/green_stone_stairs_outer", "x": 180, "y": 180, "uvlock": true },
        "facing=north,half=top,shape=outer_right": { "model": "examplemod:block/green_stone_stairs_outer", "x": 180, "uvlock": true },
        "facing=east,half=top,shape=outer_left":  { "model": "examplemod:block/green_stone_stairs_outer", "x": 180, "uvlock": true },
        "facing=west,half=top,shape=outer_left":  { "model": "examplemod:block/green_stone_stairs_outer", "x": 180, "y": 180, "uvlock": true },
        "facing=south,half=top,shape=outer_left": { "model": "examplemod:block/green_stone_stairs_outer", "x": 180, "y": 90, "uvlock": true },
        "facing=north,half=top,shape=outer_left": { "model": "examplemod:block/green_stone_stairs_outer", "x": 180, "y": 270, "uvlock": true },
        "facing=east,half=top,shape=inner_right":  { "model": "examplemod:block/green_stone_stairs_inner", "x": 180, "y": 90, "uvlock": true },
        "facing=west,half=top,shape=inner_right":  { "model": "examplemod:block/green_stone_stairs_inner", "x": 180, "y": 270, "uvlock": true },
        "facing=south,half=top,shape=inner_right": { "model": "examplemod:block/green_stone_stairs_inner", "x": 180, "y": 180, "uvlock": true },
        "facing=north,half=top,shape=inner_right": { "model": "examplemod:block/green_stone_stairs_inner", "x": 180, "uvlock": true },
        "facing=east,half=top,shape=inner_left":  { "model": "examplemod:block/green_stone_stairs_inner", "x": 180, "uvlock": true },
        "facing=west,half=top,shape=inner_left":  { "model": "examplemod:block/green_stone_stairs_inner", "x": 180, "y": 180, "uvlock": true },
        "facing=south,half=top,shape=inner_left": { "model": "examplemod:block/green_stone_stairs_inner", "x": 180, "y": 90, "uvlock": true },
        "facing=north,half=top,shape=inner_left": { "model": "examplemod:block/green_stone_stairs_inner", "x": 180, "y": 270, "uvlock": true }
    }
}

 

 

 

 

At first glance, this seems like the same issue found here, but while I am adding the StairsBlock to my DeferredRegister in an odd way, I am initializing StairsBlock, and the method I've used to add it to my DeferredRegister has proven successful for SlabBlocks. I've listed all my code below. There's quite a bit there, so... sorry about that. Feedback is greatly appreciated.

 

Spoiler

 


package com.example.examplemod;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;

public class Registrar {

	public static final DeferredRegister<Block> BLOCKS = new DeferredRegister<>(ForgeRegistries.BLOCKS, "examplemod");
	public static final DeferredRegister<Item> ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, "examplemod");
	
	public static final RegistryObject<Item> DEF_ITEM = ITEMS.register("def_item", () -> new Item(new Item.Properties().group(ItemGroup.MISC)));
	
	
	public static ArrayList<AbstractBaseBlock> BLOCKLIST = new ArrayList<AbstractBaseBlock>(0);
	public static ArrayList<AbstractBaseBlock> AA = new ArrayList<>(0);
	
	public static ArrayList<Extension> EXTRAS = new ArrayList<>(0);
	public static ArrayList<Template> TEMPS = new ArrayList<>(0);
	
	
	public static void init()
	{
		tempInit();
		reg();
		
	}
	
	public static Template TERMINAL = new Template().addTo(TEMPS);
	public static Template BASIC_WITH_BRICKS = new Template("_slab", "_bricks", "_stairs").addTo(TEMPS);
	public static Template BASICS = new Template("_slab", "_stairs").addTo(TEMPS);
	
	
	public static  Extension SLAB = new Extension("_slab", "_slab", BaseSlab.class, TERMINAL).addTo(EXTRAS);
	public static  Extension STAIRS = new Extension("_stairs", "_stair", BaseSlab.class, TERMINAL).addTo(EXTRAS);
	public static  Extension BRICKS = new Extension("_bricks", "_brick", BaseBlock.class, BASICS).addTo(EXTRAS).setIsTerminal(false);

	public static final AbstractBaseBlock GREEN_STONE = new BaseBlock("green_stone", "green", Block.Properties.from(Blocks.STONE), BASIC_WITH_BRICKS).addTo(AA);
	
	
	
	

	
	public static void tempInit()
	{
		int k = 0;
		for(Template template : TEMPS)
		{
			k++;
			for(int i = 0; i < template.getExtensionStrings().length; i++)
			{
				if(template.getExtensionStrings() != null && template.getExtensionStrings().length > 0)
				{
					String extensionString = template.getExtensionStrings()[i];
					for(Extension extension : EXTRAS)
					{
						if(extension.getExtensionString().equals(extensionString))
						{
							Boolean alreadyListed = false;
							for(Extension listedExtension : template.getExtensionList())
							{
								if(extension.getExtensionString().equals(listedExtension.getExtensionString()))
										{
											alreadyListed = true;
										}
							}
							if(!alreadyListed) 
							{
								template.getExtensionList().add(extension); 
								ExampleMod.LOGGER.debug("tempInit: Added extension \"" + extension.getExtensionString() + "\" to TEMPS[" + String.valueOf(k-1) + "]!");
							}
						}
					}
					template.getExtensionStrings()[i] = "def_ext";
				}
			}
		}
	}
	
	
	public static void reg()
	{
		
		
		ArrayList<AbstractBaseBlock> BB = new ArrayList<>(0);
		ArrayList<AbstractBaseBlock> CC = new ArrayList<>(0);
	
		BlockState rootState;
		
		for(AbstractBaseBlock baseBlockA : AA)
		{
			ExampleMod.LOGGER.debug("Registrar.reg: Adding \"" + baseBlockA.getRegistryName() + "\" to BLOCKLIST!");
			baseBlockA.addTo(BLOCKLIST);
			rootState = baseBlockA.getState();
			//BLOCKS.register(baseBlockA.getRegistryName(), () -> baseBlockA.blockConstructor(() -> baseBlockA.getState()));
			if(!baseBlockA.isTerminal())
			{
				for(Extension extensionA : baseBlockA.getTemplate().getExtensionList())
				{
					
					try {
						extensionA.toBaseBlock(baseBlockA.getRegistryName(), baseBlockA.getBaseName(), baseBlockA.getBlockProperties()).setState(rootState).setIsTerminal(extensionA.isTerminal()).addTo(BB);
						ExampleMod.LOGGER.debug("Registrar.reg: Tossed extension, rootRegistryName\"" + baseBlockA.getRegistryName() + "\", rootBaseName\"" + baseBlockA.getBaseName() + "\" to BB from AA!");
					} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
			}
		}
		while(!BB.isEmpty() | !CC.isEmpty())
		{
			while(!BB.isEmpty())
			{
				for(int i = 0; i < BB.size(); i++)
				{
					AbstractBaseBlock baseBlockB = BB.get(i);
					ExampleMod.LOGGER.debug("Registrar.reg: Adding \"" + baseBlockB.getRegistryName() + "\" to BLOCKLIST!");
					baseBlockB.addTo(BLOCKLIST);
					rootState = baseBlockB.getState();
					//BLOCKS.register(baseBlockB.getRegistryName(), () -> baseBlockB.blockConstructor(() -> baseBlockB.getState()));
					if(!baseBlockB.isTerminal())
					{
						for(Extension extensionB : baseBlockB.getTemplate().getExtensionList())
						{
							try {
								extensionB.toBaseBlock(baseBlockB.getRegistryName(), baseBlockB.getBaseName(), baseBlockB.getBlockProperties()).setState(rootState).setIsTerminal(extensionB.isTerminal()).addTo(CC);
								ExampleMod.LOGGER.debug("Registrar.reg: Tossed extension, rootRegistryName\"" + baseBlockB.getRegistryName() + "\", rootBaseName\"" + baseBlockB.getBaseName() + "\" to CC from BB!");
							} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException e) {
								e.printStackTrace();
								break;
							}
						}
					}
					BB.remove(i);
				}
			}
			while(!CC.isEmpty())
			{
				for(int i = 0; i < CC.size(); i++)
				{
					AbstractBaseBlock baseBlockC = CC.get(i);
					ExampleMod.LOGGER.debug("Registrar.reg: Adding \"" + baseBlockC.getRegistryName() + "\" to BLOCKLIST!");
					baseBlockC.addTo(BLOCKLIST);
					rootState = baseBlockC.getState();
					//BLOCKS.register(baseBlockC.getRegistryName(), () -> baseBlockC.blockConstructor(() -> baseBlockC.getState()));
					if(!baseBlockC.isTerminal())
					{
						for(Extension extensionC : baseBlockC.getTemplate().getExtensionList())
						{
							try {
								extensionC.toBaseBlock(baseBlockC.getRegistryName(), baseBlockC.getBaseName(), baseBlockC.getBlockProperties()).setState(rootState).setIsTerminal(extensionC.isTerminal()).addTo(BB);
								ExampleMod.LOGGER.debug("Registrar.reg: Tossed extension, rootRegistryName\"" + baseBlockC.getRegistryName() + "\", rootBaseName\"" + baseBlockC.getBaseName() + "\" to BB from CC!");
							} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException e) {
								e.printStackTrace();
								break;
							}
						}
					}
					CC.remove(i);
				}
			}
		}
		for(int i = 0; i < BLOCKLIST.size(); i++)
		{
			int k = i;
			BLOCKS.register(BLOCKLIST.get(i).getRegistryName(), () -> BLOCKLIST.get(k).blockConstructor(() -> BLOCKLIST.get(k).getState()));
			ExampleMod.LOGGER.debug("Registrar.reg: Added \"" + BLOCKLIST.get(i).getRegistryName() + "\" to BLOCKS for registration!");			
		}
	}
}

 

 

 

Template class:

Spoiler

 


package com.example.examplemod;

import java.util.ArrayList;

public class Template {
private ArrayList<Extension> extensionList = new ArrayList<>(0);
private String[] extensionStrings;
	
public Template (String... extensionStrings)
{
	this.setExtensionStrings(extensionStrings);
}

public ArrayList<Extension> getExtensionList() {
	return this.extensionList;
}

public void setExtensionList(ArrayList<Extension> extensionList) {
	this.extensionList = extensionList;
}

public Template addTo(ArrayList<Template> list)
{
	list.add(this);
	return this;
}

public String[] getExtensionStrings() {
	return this.extensionStrings;
}

public void setExtensionStrings(String[] extensionStrings) {
	this.extensionStrings = extensionStrings;
}

}

 

 

 

Extension class:

Spoiler

 


package com.example.examplemod;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;

import net.minecraft.block.Block;

public class Extension {
private String extensionString;
private String extensionBaseString;

private Template template;
private Boolean usesBaseName = false;
private Boolean isTerminal = true;

private Class<? extends AbstractBaseBlock> baseBlockType;


public Extension(String extensionString, String extensionBaseString, Class<? extends AbstractBaseBlock> baseBlockType, Template template)
{
	this.setExtensionString(extensionString);
	this.setExtensionBaseString(extensionBaseString);
	this.setTemplate(template);
	this.setBaseBlockType(baseBlockType);
}

public AbstractBaseBlock toBaseBlock(String rootRegistryName, String rootBaseName, Block.Properties rootBlockProperties) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException
{
	String fullRegistryName;
	String fullBaseName;
	if(this.getUsesBaseName())
	{ 
		fullRegistryName = rootBaseName + this.getExtensionString(); 
		fullBaseName = rootBaseName + this.getExtensionBaseString();
	}
	else
	{ 
		fullRegistryName = rootRegistryName + this.getExtensionString(); 
		fullBaseName = rootRegistryName + this.getExtensionBaseString();
	}
		
	AbstractBaseBlock a = (AbstractBaseBlock) baseBlockType.getConstructors()[0].newInstance(fullRegistryName, fullBaseName, rootBlockProperties, this.template);
	a = a.setIsTerminal(this.isTerminal);
	return a;
	
}

public String getExtensionString() {
	return this.extensionString;
}

public void setExtensionString(String extensionString) {
	this.extensionString = extensionString;
}

public String getExtensionBaseString() {
	return this.extensionBaseString;
}

public void setExtensionBaseString(String extensionBaseString) {
	this.extensionBaseString = extensionBaseString;
}

public Template getTemplate() {
	return template;
}

public void setTemplate(Template template) {
	this.template = template;
}
public Extension addTo(ArrayList<Extension> list)
{
	list.add(this);
	return this;
}

public Boolean getUsesBaseName() {
	return this.usesBaseName;
}

public void useBaseName() {
	this.usesBaseName = true;
}



public Class<? extends AbstractBaseBlock> getBaseBlockType() {
	return this.baseBlockType;
}



public void setBaseBlockType(Class<? extends AbstractBaseBlock> baseBlockType) {
	this.baseBlockType = baseBlockType;
}

public Boolean isTerminal() {
	return this.isTerminal;
}

public Extension setIsTerminal(Boolean isTerminal) {
	this.isTerminal = isTerminal;
	return this;
}
}

 

 

 

AbstractBaseBlock class:

Spoiler

 


package com.example.examplemod;

import java.util.ArrayList;
import java.util.function.Supplier;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;

public abstract class AbstractBaseBlock {
private String registryName = "def_regName";
private String baseName = "def_baseName";

private Template template;
private Block.Properties blockProperties = Block.Properties.from(Blocks.AIR);

private Boolean isTerminal = false;
//private Boolean usesStateSupplier = false;
private BlockState state = Blocks.STONE.getDefaultState();


public AbstractBaseBlock(String registryName, String baseName, Block.Properties blockProperties, Template template)
{
	this.setRegistryName(registryName);
	this.setBaseName(baseName);
	this.setBlockProperties(blockProperties);
	this.setTemplate(template);
}

abstract Block blockConstructor(Supplier<BlockState> stateSupplier);


public String getRegistryName() {
	return this.registryName;
}


public void setRegistryName(String registryName) {
	this.registryName = registryName;
}


public String getBaseName() {
	return this.baseName;
}


public void setBaseName(String baseName) {
	this.baseName = baseName;
}


public Template getTemplate() {
	return this.template;
}


public void setTemplate(Template template) {
	this.template = template;
}


public Block.Properties getBlockProperties() {
	return this.blockProperties;
}


public void setBlockProperties(Block.Properties blockProperties) {
	this.blockProperties = blockProperties;
}


public Boolean isTerminal() {
	return this.isTerminal;
}


public AbstractBaseBlock setIsTerminal(Boolean isTerminal) {
	this.isTerminal = isTerminal;
	return this;
}

public AbstractBaseBlock addTo(ArrayList<AbstractBaseBlock> list)
{
	list.add(this);
	return this;
}

//public Boolean getUsesStateSupplier() {
//	return this.usesStateSupplier;
//}
//
//public void usesStateSupplier() {
//	this.usesStateSupplier = true;
//}

public BlockState getState() {
	return this.state;
}

public AbstractBaseBlock setState(BlockState state) {
	this.state = state;
	return this;
}

}

 

 

 

BaseBlock class:

Spoiler

 


package com.example.examplemod;

import java.util.function.Supplier;

import net.minecraft.block.Block;
import net.minecraft.block.Block.Properties;
import net.minecraft.block.BlockState;

public class BaseBlock extends AbstractBaseBlock{

	public BaseBlock(String registryName, String baseName, Properties blockProperties, Template template) {
		super(registryName, baseName, blockProperties, template);
	}

	@Override
	public Block blockConstructor(Supplier<BlockState> stateSupplier) {
		return new Block(this.getBlockProperties());
	}
	
	
}

 

 

 

BaseStairs class is listed below. The BaseSlab class is the same, except that blockConstructor() returns a SlabBlock, as expected.

Spoiler

 


package com.example.examplemod;

import java.util.function.Supplier;

import net.minecraft.block.Block.Properties;
import net.minecraft.block.BlockState;
import net.minecraft.block.StairsBlock;

public class BaseStairs extends AbstractBaseBlock{

	public BaseStairs(String registryName, String baseName, Properties blockProperties, Template template) {
		super(registryName, baseName, blockProperties, template);
	}

	@Override
	public StairsBlock blockConstructor(Supplier<BlockState> stateSupplier) {
		return new StairsBlock(stateSupplier, this.getBlockProperties());
	}
}

 

 

 

Here's the main class:

Spoiler

 


package com.example.examplemod;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.IForgeRegistry;

// The value here should match an entry in the META-INF/mods.toml file
@Mod("examplemod")
public class ExampleMod
{
    // Directly reference a log4j logger.
    public static final Logger LOGGER = LogManager.getLogger();

    public ExampleMod() 
    {
    	final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);

        Registrar.init();
        
        Registrar.ITEMS.register(modEventBus);
        Registrar.BLOCKS.register(modEventBus);
        
        MinecraftForge.EVENT_BUS.register(this);
  
    }

    @SubscribeEvent
    public static void onRegisterItems(final RegistryEvent.Register<Item> event) {
    	final IForgeRegistry<Item> registry = event.getRegistry();
    	
    	Registrar.BLOCKS.getEntries().stream().map(RegistryObject::get).forEach(block -> {
    		final Item.Properties properties = new Item.Properties().group(ItemGroup.MISC);
    		final BlockItem blockItem = new BlockItem(block, properties);
    		blockItem.setRegistryName(block.getRegistryName());
    		registry.register(blockItem);
    	});
    	
    	LOGGER.debug("Registered BlockItems!");
    	
    }
    
    private void setup(final FMLCommonSetupEvent event)
    {
        // some preinit code
        LOGGER.info("HELLO FROM PREINIT");
        LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
    }

    private void doClientStuff(final FMLClientSetupEvent event) {
        // do something that can only be done on the client
        LOGGER.info("Got game settings {}", event.getMinecraftSupplier().get().gameSettings);
    }

    // You can use SubscribeEvent and let the Event Bus discover methods to call
    @SubscribeEvent
    public void onServerStarting(FMLServerStartingEvent event) {
     
    }

    // You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD
    // Event bus for receiving Registry Events)
    @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
    public static class RegistryEvents {
        @SubscribeEvent
        public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) {
            // register a new block here
            LOGGER.info("HELLO from Register Block");
        }
    }
}

 

 

 

 

Edited by Dubius
Found issue
Posted

Howdy

I'd suggest you put a few breakpoints into the vanilla code as well as your Block's blockstate setup methods to see where the problem is.

You could try using manual registration instead of Deferred  in order to narrow it down eg

  @SubscribeEvent
  public static void onBlocksRegistration(final RegistryEvent.Register<Block> blockRegisterEvent) {

 

-TGG

Posted
6 hours ago, diesieben07 said:

Show your block code and how you register it.

And please format it properly (not like your JSON file).

Added additional info and re-pasted the JSON. not sure why it was jumbled like that to begin with, apologies.

Posted (edited)
On 5/14/2020 at 12:49 AM, diesieben07 said:

That is not what I meant by showing your registration code. Small snippets like that don't tell anything about what is actually going on.

Here's the class that declares my blocks and such. Other classes will be listed below. They are probably necessary to understand how this class works.

 

Spoiler

 


package com.example.examplemod;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;

public class Registrar {

	public static final DeferredRegister<Block> BLOCKS = new DeferredRegister<>(ForgeRegistries.BLOCKS, "examplemod");
	public static final DeferredRegister<Item> ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, "examplemod");
	
	public static final RegistryObject<Item> DEF_ITEM = ITEMS.register("def_item", () -> new Item(new Item.Properties().group(ItemGroup.MISC)));
	
	
	public static ArrayList<AbstractBaseBlock> BLOCKLIST = new ArrayList<AbstractBaseBlock>(0);
	public static ArrayList<AbstractBaseBlock> AA = new ArrayList<>(0);
	
	public static ArrayList<Extension> EXTRAS = new ArrayList<>(0);
	public static ArrayList<Template> TEMPS = new ArrayList<>(0);
	
	
	public static void init()
	{
		tempInit();
		reg();
		
	}
	
	public static Template TERMINAL = new Template().addTo(TEMPS);
	public static Template BASIC_WITH_BRICKS = new Template("_slab", "_bricks", "_stairs").addTo(TEMPS);
	public static Template BASICS = new Template("_slab", "_stairs").addTo(TEMPS);
	
	
	public static  Extension SLAB = new Extension("_slab", "_slab", BaseSlab.class, TERMINAL).addTo(EXTRAS);
	public static  Extension STAIRS = new Extension("_stairs", "_stair", BaseSlab.class, TERMINAL).addTo(EXTRAS);
	public static  Extension BRICKS = new Extension("_bricks", "_brick", BaseBlock.class, BASICS).addTo(EXTRAS).setIsTerminal(false);

	public static final AbstractBaseBlock GREEN_STONE = new BaseBlock("green_stone", "green", Block.Properties.from(Blocks.STONE), BASIC_WITH_BRICKS).addTo(AA);
	
	
	
	

	
	public static void tempInit()
	{
		int k = 0;
		for(Template template : TEMPS)
		{
			k++;
			for(int i = 0; i < template.getExtensionStrings().length; i++)
			{
				if(template.getExtensionStrings() != null && template.getExtensionStrings().length > 0)
				{
					String extensionString = template.getExtensionStrings()[i];
					for(Extension extension : EXTRAS)
					{
						if(extension.getExtensionString().equals(extensionString))
						{
							Boolean alreadyListed = false;
							for(Extension listedExtension : template.getExtensionList())
							{
								if(extension.getExtensionString().equals(listedExtension.getExtensionString()))
										{
											alreadyListed = true;
										}
							}
							if(!alreadyListed) 
							{
								template.getExtensionList().add(extension); 
								ExampleMod.LOGGER.debug("tempInit: Added extension \"" + extension.getExtensionString() + "\" to TEMPS[" + String.valueOf(k-1) + "]!");
							}
						}
					}
					template.getExtensionStrings()[i] = "def_ext";
				}
			}
		}
	}
	
	
	public static void reg()
	{
		
		
		ArrayList<AbstractBaseBlock> BB = new ArrayList<>(0);
		ArrayList<AbstractBaseBlock> CC = new ArrayList<>(0);
	
		BlockState rootState;
		
		for(AbstractBaseBlock baseBlockA : AA)
		{
			ExampleMod.LOGGER.debug("Registrar.reg: Adding \"" + baseBlockA.getRegistryName() + "\" to BLOCKLIST!");
			baseBlockA.addTo(BLOCKLIST);
			rootState = baseBlockA.getState();
			//BLOCKS.register(baseBlockA.getRegistryName(), () -> baseBlockA.blockConstructor(() -> baseBlockA.getState()));
			if(!baseBlockA.isTerminal())
			{
				for(Extension extensionA : baseBlockA.getTemplate().getExtensionList())
				{
					
					try {
						extensionA.toBaseBlock(baseBlockA.getRegistryName(), baseBlockA.getBaseName(), baseBlockA.getBlockProperties()).setState(rootState).setIsTerminal(extensionA.isTerminal()).addTo(BB);
						ExampleMod.LOGGER.debug("Registrar.reg: Tossed extension, rootRegistryName\"" + baseBlockA.getRegistryName() + "\", rootBaseName\"" + baseBlockA.getBaseName() + "\" to BB from AA!");
					} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
			}
		}
		while(!BB.isEmpty() | !CC.isEmpty())
		{
			while(!BB.isEmpty())
			{
				for(int i = 0; i < BB.size(); i++)
				{
					AbstractBaseBlock baseBlockB = BB.get(i);
					ExampleMod.LOGGER.debug("Registrar.reg: Adding \"" + baseBlockB.getRegistryName() + "\" to BLOCKLIST!");
					baseBlockB.addTo(BLOCKLIST);
					rootState = baseBlockB.getState();
					//BLOCKS.register(baseBlockB.getRegistryName(), () -> baseBlockB.blockConstructor(() -> baseBlockB.getState()));
					if(!baseBlockB.isTerminal())
					{
						for(Extension extensionB : baseBlockB.getTemplate().getExtensionList())
						{
							try {
								extensionB.toBaseBlock(baseBlockB.getRegistryName(), baseBlockB.getBaseName(), baseBlockB.getBlockProperties()).setState(rootState).setIsTerminal(extensionB.isTerminal()).addTo(CC);
								ExampleMod.LOGGER.debug("Registrar.reg: Tossed extension, rootRegistryName\"" + baseBlockB.getRegistryName() + "\", rootBaseName\"" + baseBlockB.getBaseName() + "\" to CC from BB!");
							} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException e) {
								e.printStackTrace();
								break;
							}
						}
					}
					BB.remove(i);
				}
			}
			while(!CC.isEmpty())
			{
				for(int i = 0; i < CC.size(); i++)
				{
					AbstractBaseBlock baseBlockC = CC.get(i);
					ExampleMod.LOGGER.debug("Registrar.reg: Adding \"" + baseBlockC.getRegistryName() + "\" to BLOCKLIST!");
					baseBlockC.addTo(BLOCKLIST);
					rootState = baseBlockC.getState();
					//BLOCKS.register(baseBlockC.getRegistryName(), () -> baseBlockC.blockConstructor(() -> baseBlockC.getState()));
					if(!baseBlockC.isTerminal())
					{
						for(Extension extensionC : baseBlockC.getTemplate().getExtensionList())
						{
							try {
								extensionC.toBaseBlock(baseBlockC.getRegistryName(), baseBlockC.getBaseName(), baseBlockC.getBlockProperties()).setState(rootState).setIsTerminal(extensionC.isTerminal()).addTo(BB);
								ExampleMod.LOGGER.debug("Registrar.reg: Tossed extension, rootRegistryName\"" + baseBlockC.getRegistryName() + "\", rootBaseName\"" + baseBlockC.getBaseName() + "\" to BB from CC!");
							} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException e) {
								e.printStackTrace();
								break;
							}
						}
					}
					CC.remove(i);
				}
			}
		}
		for(int i = 0; i < BLOCKLIST.size(); i++)
		{
			int k = i;
			BLOCKS.register(BLOCKLIST.get(i).getRegistryName(), () -> BLOCKLIST.get(k).blockConstructor(() -> BLOCKLIST.get(k).getState()));
			ExampleMod.LOGGER.debug("Registrar.reg: Added \"" + BLOCKLIST.get(i).getRegistryName() + "\" to BLOCKS for registration!");			
		}
	}
}

 

 

 

Template class:

Spoiler

 


package com.example.examplemod;

import java.util.ArrayList;

public class Template {
private ArrayList<Extension> extensionList = new ArrayList<>(0);
private String[] extensionStrings;
	
public Template (String... extensionStrings)
{
	this.setExtensionStrings(extensionStrings);
}

public ArrayList<Extension> getExtensionList() {
	return this.extensionList;
}

public void setExtensionList(ArrayList<Extension> extensionList) {
	this.extensionList = extensionList;
}

public Template addTo(ArrayList<Template> list)
{
	list.add(this);
	return this;
}

public String[] getExtensionStrings() {
	return this.extensionStrings;
}

public void setExtensionStrings(String[] extensionStrings) {
	this.extensionStrings = extensionStrings;
}

}

 

 

 

Extension class:

Spoiler

 


package com.example.examplemod;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;

import net.minecraft.block.Block;

public class Extension {
private String extensionString;
private String extensionBaseString;

private Template template;
private Boolean usesBaseName = false;
private Boolean isTerminal = true;

private Class<? extends AbstractBaseBlock> baseBlockType;


public Extension(String extensionString, String extensionBaseString, Class<? extends AbstractBaseBlock> baseBlockType, Template template)
{
	this.setExtensionString(extensionString);
	this.setExtensionBaseString(extensionBaseString);
	this.setTemplate(template);
	this.setBaseBlockType(baseBlockType);
}

public AbstractBaseBlock toBaseBlock(String rootRegistryName, String rootBaseName, Block.Properties rootBlockProperties) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException
{
	String fullRegistryName;
	String fullBaseName;
	if(this.getUsesBaseName())
	{ 
		fullRegistryName = rootBaseName + this.getExtensionString(); 
		fullBaseName = rootBaseName + this.getExtensionBaseString();
	}
	else
	{ 
		fullRegistryName = rootRegistryName + this.getExtensionString(); 
		fullBaseName = rootRegistryName + this.getExtensionBaseString();
	}
		
	AbstractBaseBlock a = (AbstractBaseBlock) baseBlockType.getConstructors()[0].newInstance(fullRegistryName, fullBaseName, rootBlockProperties, this.template);
	a = a.setIsTerminal(this.isTerminal);
	return a;
	
}

public String getExtensionString() {
	return this.extensionString;
}

public void setExtensionString(String extensionString) {
	this.extensionString = extensionString;
}

public String getExtensionBaseString() {
	return this.extensionBaseString;
}

public void setExtensionBaseString(String extensionBaseString) {
	this.extensionBaseString = extensionBaseString;
}

public Template getTemplate() {
	return template;
}

public void setTemplate(Template template) {
	this.template = template;
}
public Extension addTo(ArrayList<Extension> list)
{
	list.add(this);
	return this;
}

public Boolean getUsesBaseName() {
	return this.usesBaseName;
}

public void useBaseName() {
	this.usesBaseName = true;
}



public Class<? extends AbstractBaseBlock> getBaseBlockType() {
	return this.baseBlockType;
}



public void setBaseBlockType(Class<? extends AbstractBaseBlock> baseBlockType) {
	this.baseBlockType = baseBlockType;
}

public Boolean isTerminal() {
	return this.isTerminal;
}

public Extension setIsTerminal(Boolean isTerminal) {
	this.isTerminal = isTerminal;
	return this;
}
}

 

 

 

AbstractBaseBlock class:

Spoiler

 


package com.example.examplemod;

import java.util.ArrayList;
import java.util.function.Supplier;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;

public abstract class AbstractBaseBlock {
private String registryName = "def_regName";
private String baseName = "def_baseName";

private Template template;
private Block.Properties blockProperties = Block.Properties.from(Blocks.AIR);

private Boolean isTerminal = false;
//private Boolean usesStateSupplier = false;
private BlockState state = Blocks.STONE.getDefaultState();


public AbstractBaseBlock(String registryName, String baseName, Block.Properties blockProperties, Template template)
{
	this.setRegistryName(registryName);
	this.setBaseName(baseName);
	this.setBlockProperties(blockProperties);
	this.setTemplate(template);
}

abstract Block blockConstructor(Supplier<BlockState> stateSupplier);


public String getRegistryName() {
	return this.registryName;
}


public void setRegistryName(String registryName) {
	this.registryName = registryName;
}


public String getBaseName() {
	return this.baseName;
}


public void setBaseName(String baseName) {
	this.baseName = baseName;
}


public Template getTemplate() {
	return this.template;
}


public void setTemplate(Template template) {
	this.template = template;
}


public Block.Properties getBlockProperties() {
	return this.blockProperties;
}


public void setBlockProperties(Block.Properties blockProperties) {
	this.blockProperties = blockProperties;
}


public Boolean isTerminal() {
	return this.isTerminal;
}


public AbstractBaseBlock setIsTerminal(Boolean isTerminal) {
	this.isTerminal = isTerminal;
	return this;
}

public AbstractBaseBlock addTo(ArrayList<AbstractBaseBlock> list)
{
	list.add(this);
	return this;
}

//public Boolean getUsesStateSupplier() {
//	return this.usesStateSupplier;
//}
//
//public void usesStateSupplier() {
//	this.usesStateSupplier = true;
//}

public BlockState getState() {
	return this.state;
}

public AbstractBaseBlock setState(BlockState state) {
	this.state = state;
	return this;
}

}

 

 

 

BaseBlock class:

Spoiler

 


package com.example.examplemod;

import java.util.function.Supplier;

import net.minecraft.block.Block;
import net.minecraft.block.Block.Properties;
import net.minecraft.block.BlockState;

public class BaseBlock extends AbstractBaseBlock{

	public BaseBlock(String registryName, String baseName, Properties blockProperties, Template template) {
		super(registryName, baseName, blockProperties, template);
	}

	@Override
	public Block blockConstructor(Supplier<BlockState> stateSupplier) {
		return new Block(this.getBlockProperties());
	}
	
	
}

 

 

 

BaseStairs class is listed below. The BaseSlab class is the same, except that blockConstructor() returns a SlabBlock, as expected.

Spoiler

 


package com.example.examplemod;

import java.util.function.Supplier;

import net.minecraft.block.Block.Properties;
import net.minecraft.block.BlockState;
import net.minecraft.block.StairsBlock;

public class BaseStairs extends AbstractBaseBlock{

	public BaseStairs(String registryName, String baseName, Properties blockProperties, Template template) {
		super(registryName, baseName, blockProperties, template);
	}

	@Override
	public StairsBlock blockConstructor(Supplier<BlockState> stateSupplier) {
		return new StairsBlock(stateSupplier, this.getBlockProperties());
	}
}

 

 

 

Here's the main class:

Spoiler

 


package com.example.examplemod;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.IForgeRegistry;

// The value here should match an entry in the META-INF/mods.toml file
@Mod("examplemod")
public class ExampleMod
{
    // Directly reference a log4j logger.
    public static final Logger LOGGER = LogManager.getLogger();

    public ExampleMod() 
    {
    	final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);

        Registrar.init();
        
        Registrar.ITEMS.register(modEventBus);
        Registrar.BLOCKS.register(modEventBus);
        
        MinecraftForge.EVENT_BUS.register(this);
  
    }

    @SubscribeEvent
    public static void onRegisterItems(final RegistryEvent.Register<Item> event) {
    	final IForgeRegistry<Item> registry = event.getRegistry();
    	
    	Registrar.BLOCKS.getEntries().stream().map(RegistryObject::get).forEach(block -> {
    		final Item.Properties properties = new Item.Properties().group(ItemGroup.MISC);
    		final BlockItem blockItem = new BlockItem(block, properties);
    		blockItem.setRegistryName(block.getRegistryName());
    		registry.register(blockItem);
    	});
    	
    	LOGGER.debug("Registered BlockItems!");
    	
    }
    
    private void setup(final FMLCommonSetupEvent event)
    {
        // some preinit code
        LOGGER.info("HELLO FROM PREINIT");
        LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
    }

    private void doClientStuff(final FMLClientSetupEvent event) {
        // do something that can only be done on the client
        LOGGER.info("Got game settings {}", event.getMinecraftSupplier().get().gameSettings);
    }

    // You can use SubscribeEvent and let the Event Bus discover methods to call
    @SubscribeEvent
    public void onServerStarting(FMLServerStartingEvent event) {
     
    }

    // You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD
    // Event bus for receiving Registry Events)
    @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
    public static class RegistryEvents {
        @SubscribeEvent
        public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) {
            // register a new block here
            LOGGER.info("HELLO from Register Block");
        }
    }
}

 

 

 

 

Edited by Dubius
Clarification, spoilers for navigation
Posted
39 minutes ago, Dubius said:

public static void onRegisterItems(final RegistryEvent.Register<Item> event) { final IForgeRegistry<Item> registry = event.getRegistry(); Registrar.BLOCKS.getEntries().stream().map(RegistryObject::get).forEach(block -> {

 

39 minutes ago, Dubius said:

public static final DeferredRegister<Block> BLOCKS = new DeferredRegister<>(ForgeRegistries.BLOCKS, "examplemod");

Why are you using both a deferred register and a RegistryEvent handler? You only need one.

 

Second, BlockBase is an antipattern. Do not use it. There is already a base block class, its called Block.

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 (edited)

Thank you for pointin

17 minutes ago, Draco18s said:

 

Why are you using both a deferred register and a RegistryEvent handler? You only need one.

 

Second, BlockBase is an antipattern. Do not use it. There is already a base block class, its called Block.

Thanks for pointing that out, I'll change the names of my classes. In other news, I found the issue, and feel very stupid. Minor error. Thanks for putting up with me. I'll update the main question to reflect what I found.

 

I'll be frank, I'm not familiar enough with DeferredRegistries to really understand what the issue with having both is. I think the main thing here is that it lets me register BlockItems without having to declare them myself? Unless I can do that without the handler...

Edited by Dubius
Posted (edited)
25 minutes ago, Dubius said:

I'll be frank, I'm not familiar enough with DeferredRegistries to really understand what the issue with having both is.

DeferredRegister is a wrapper around the RegistryEvent system to allow people to create their blocks and items in a static block without breaking everything.

 

25 minutes ago, Dubius said:

I think the main thing here is that it lets me register BlockItems without having to declare them myself?

Uh, you still are. What do you think this code does?

1 hour ago, Dubius said:

Registrar.BLOCKS.getEntries().stream().map(RegistryObject::get).forEach(block -> {

    final Item.Properties properties = new Item.Properties().group(ItemGroup.MISC);

    final BlockItem blockItem = new BlockItem(block, properties);

    blockItem.setRegistryName(block.getRegistryName());

    registry.register(blockItem);

});

Sure, its a loop, and you aren't individually specifying things. Except you've done it in a way that forces all of your blocks to use the base implementation of BlockItem. Any block you want to be different you have to go fuck around with this code to make it not generate an item.

 

Technical blocks that don't have items, blocks that use a custom item, a block that you want to belong to a creative tab group other than "misc" (which, frankly, should be most of them: such as decoration, building blocks, or redstone).

Edited by Draco18s

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.