Jump to content

Recommended Posts

Posted (edited)

Hi everyone :D I'm trying to make metadata blocks in 1.12.2 using the forge_marker blockstates system. Now, the block itself works fine, if i place them down i get different textures based on their variant. But in inventory i get the black/purple texture :/ This is my json blockstate file
 

{
    "forge_marker": 1,
    "defaults": {
        "textures": {
        },
        "model": "cube_all"
    },
    "variants": {
        "normal": [{

        }],
        "inventory": [{

        }],
         "color": {
            "white":  { "textures": { "all": "mineworld:blocks/marble_white"} },
            "black":  { "textures": { "all": "mineworld:blocks/marble_black"} },
            "red":  { "textures": { "all": "mineworld:blocks/marble_red"} },
            "brown":  { "textures": { "all": "mineworld:blocks/marble_brown"} },
            "pink":  { "textures": { "all": "mineworld:blocks/marble_pink"} },
            "yellow":  { "textures": { "all": "mineworld:blocks/marble_yellow"} },
            "green":  { "textures": { "all": "mineworld:blocks/marble_green"} }
        }
    }
}

And this is how i register them
 

ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MARBLE), 0, new ModelResourceLocation(MARBLE.getRegistryName() + "_white", "white"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MARBLE), 1, new ModelResourceLocation(MARBLE.getRegistryName() + "_black", "black"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MARBLE), 2, new ModelResourceLocation(MARBLE.getRegistryName() + "_red", "red"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MARBLE), 3, new ModelResourceLocation(MARBLE.getRegistryName() + "_brown", "brown"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MARBLE), 4, new ModelResourceLocation(MARBLE.getRegistryName() + "_pink", "pink"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MARBLE), 5, new ModelResourceLocation(MARBLE.getRegistryName() + "_yellow", "yellow"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MARBLE), 6, new ModelResourceLocation(MARBLE.getRegistryName() + "_green", "green"));

 

What am i missing here? :/ 

 

Edited by JimiIT92
Solved

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

Posted
MARBLE.getRegistryName() + "_black", "black"));

 

You're telling it to look for a different file every time. Drop that "_color" bit.

 

Also, read your logs.

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)

I removed that color part but nothing changed. My log throws this error

 

[15:40:30] [main/ERROR] [FML]: Exception loading model for variant mineworld:marble#white for item "mineworld:marble", blockstate location exception: 
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model mineworld:marble#white with loader VariantLoader.INSTANCE, skipping
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:161) ~[ModelLoaderRegistry.class:?]
	at net.minecraftforge.client.model.ModelLoader.loadItemModels(ModelLoader.java:296) ~[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:151) ~[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:559) [Minecraft.class:?]
	at net.minecraft.client.Minecraft.run(Minecraft.java:421) [Minecraft.class:?]
	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_181]
	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_181]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_181]
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
	at GradleStart.main(GradleStart.java:25) [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:1175) ~[ModelLoader$VariantLoader.class:?]
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:157) ~[ModelLoaderRegistry.class:?]
	... 20 more

 

Edited by JimiIT92
removed log syntax highlight

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

Posted

If i change to this

 

{
    "forge_marker": 1,
    "defaults": {
        "textures": {
        },
        "model": "cube_all"
    },
    "variants": {
        "normal": [{

        }],
        "inventory": [{

        }],
        "color": {
            "color=white":  { "textures": { "all": "mineworld:blocks/marble_white"} },
            "color=black":  { "textures": { "all": "mineworld:blocks/marble_black"} },
            "color=red":  { "textures": { "all": "mineworld:blocks/marble_red"} },
            "color=brown":  { "textures": { "all": "mineworld:blocks/marble_brown"} },
            "color=pink":  { "textures": { "all": "mineworld:blocks/marble_pink"} },
            "color=yellow":  { "textures": { "all": "mineworld:blocks/marble_yellow"} },
            "color=green":  { "textures": { "all": "mineworld:blocks/marble_green"} }
        }
    }
}

or to this
 

{
    "forge_marker": 1,
    "defaults": {
        "textures": {
        },
        "model": "cube_all"
    },
    "variants": {
        "normal": [{

        }],
        "inventory": [{

        }],
        "color=white":  { "textures": { "all": "mineworld:blocks/marble_white"} },
        "color=black":  { "textures": { "all": "mineworld:blocks/marble_black"} },
        "color=red":  { "textures": { "all": "mineworld:blocks/marble_red"} },
        "color=brown":  { "textures": { "all": "mineworld:blocks/marble_brown"} },
        "color=pink":  { "textures": { "all": "mineworld:blocks/marble_pink"} },
        "color=yellow":  { "textures": { "all": "mineworld:blocks/marble_yellow"} },
        "color=green":  { "textures": { "all": "mineworld:blocks/marble_green"} }
    }
}

then the placed block has no texture too :/ Also i don't understand where the difference comes from and how to tell the game to use the one without "color=" instead

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

Posted

Ok, i thought it was some error in the json file since it's the first time i use the forge blockstate format. Anyway this is the class i'm using to create the block with the variants
 

package com.mineworld.block;

import com.mineworld.block.enums.EnumMarble;
import com.mineworld.core.MWTabs;

import net.minecraft.block.BlockPlanks;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;

public class BlockMarble extends BlockMW {
	private static final PropertyEnum<EnumMarble> COLOR = PropertyEnum.<EnumMarble>create("color", EnumMarble.class);

	public BlockMarble(String name) {
		super(name, Material.ROCK, MapColor.QUARTZ, SoundType.STONE, MWTabs.BUILDING_BLOCKS);
		this.setDefaultState(this.blockState.getBaseState().withProperty(COLOR, EnumMarble.WHITE));
		setHardness(1.5F);
		setResistance(10.0F);
	}

	/**
	 * Gets the metadata of the item this Block can drop. This method is called when
	 * the block gets destroyed. It returns the metadata of the dropped item based
	 * on the old metadata of the block.
	 */
	public int damageDropped(IBlockState state) {
		return ((EnumMarble) state.getValue(COLOR)).getMetadata();
	}

	/**
	 * returns a list of blocks with the same ID, but different meta (eg: wood
	 * returns 4 blocks)
	 */
	public void getSubBlocks(CreativeTabs itemIn, NonNullList<ItemStack> items) {
		for (EnumMarble value : EnumMarble.values()) {
			items.add(new ItemStack(this, 1, value.getMetadata()));
		}
	}

	/**
	 * Get the MapColor for this Block and the given BlockState
	 */
	public MapColor getMapColor(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
		return ((EnumMarble) state.getValue(COLOR)).getMapColor();
	}

	/**
	 * Convert the BlockState into the correct metadata value
	 */
	public int getMetaFromState(IBlockState state) {
		return ((EnumMarble) state.getValue(COLOR)).getMetadata();
	}

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

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

BlockMW just sets the registry name, the unlocalized name and the creative tab

 

This is the enum i use to create the variants
 

package com.mineworld.block.enums;

import net.minecraft.block.material.MapColor;
import net.minecraft.util.IStringSerializable;

public enum EnumMarble implements IStringSerializable {
	WHITE(0, "white", MapColor.QUARTZ),
	BLACK(1, "black", MapColor.BLACK),
	RED(2, "red", MapColor.RED),
	BROWN(3, "brown", MapColor.BROWN),
	PINK(4, "pink", MapColor.PINK),
	YELLOW(5, "yellow", MapColor.YELLOW),
	GREEN(6, "green", MapColor.GREEN);

	private static final EnumMarble[] META_LOOKUP = new EnumMarble[values().length];
	private final int meta;
    private final String name;
    private final MapColor mapColor;
	
    private EnumMarble(int metaIn, String nameIn, MapColor mapColorIn)
    {
        this.meta = metaIn;
        this.name = nameIn;
        this.mapColor = mapColorIn;
    }
    
    static
    {
        for (EnumMarble value : values())
        {
            META_LOOKUP[value.getMetadata()] = value;
        }
    }
    
    public static EnumMarble byMetadata(int meta)
    {
        if (meta < 0 || meta >= META_LOOKUP.length)
        {
            meta = 0;
        }

        return META_LOOKUP[meta];
    }
    
	@Override
	public String getName() {
		return this.name;
	}

	public int getMetadata() {
		return this.meta;
	}

	public MapColor getMapColor() {
		return this.mapColor;
	}

	public String toString() {
        return this.name;
    }
}

 I looked at the vanilla code for planks but i can't find any difference that makes the variant incorrect

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

Posted

I use that base class just for blocks that don't have any particular feature (like ores, mineral blocks or colored blocks) :) Anyway i changed the registration part to "color=white" instead of just white and it worked. Except it isn't for slabs, wich i did the same thing. It says it can't found a variant for slab#color=yellow but in the model registration i specified the variant like the normal block ("color=yellow"). In this case the error could be in the json file? Here's the one i'm using

 

{
    "forge_marker": 1,
    "variants": {
        "normal": [{

        }],
        "inventory": [{

        }],
        "half": {
            "top": {
                "model": "upper_slab"
            },
            "bottom": {
                "model": "half_slab"
            }
        },
        "color": {
            "white":  { "textures": { "bottom": "mineworld:blocks/marble_white", 
                "side": "mineworld:blocks/marble_white", 
                "top": "mineworld:blocks/marble_white"

            } },
            "black":  { "textures": { "bottom": "mineworld:blocks/marble_black", 
                "side": "mineworld:blocks/marble_black", 
                "top": "mineworld:blocks/marble_black"

            } },
            "red":  { "textures": { "bottom": "mineworld:blocks/marble_red", 
                "side": "mineworld:blocks/marble_red", 
                "top": "mineworld:blocks/marble_red"

            } },
            "brown":  { "textures": { "bottom": "mineworld:blocks/marble_brown", 
                "side": "mineworld:blocks/marble_brown", 
                "top": "mineworld:blocks/marble_brown"

            } },
            "pink":  { "textures": { "bottom": "mineworld:blocks/marble_pink", 
                "side": "mineworld:blocks/marble_pink", 
                "top": "mineworld:blocks/marble_pink"

            } },
            "yellow":  { "textures": { "bottom": "mineworld:blocks/marble_yellow", 
                "side": "mineworld:blocks/marble_yellow", 
                "top": "mineworld:blocks/marble_yellow"

            } },
            "green":  { "textures": { "bottom": "mineworld:blocks/marble_green", 
                "side": "mineworld:blocks/marble_green", 
                "top": "mineworld:blocks/marble_green"

            } }
        }
    }
}

 

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

Posted

Maybe there's an issue on how i register it? I use this method to register the slab

 

public static <E extends Enum<?>> void registerMetadataBlockModel(Block block, String variantName, Class<E> variants) {
		for(int i = 0; i < variants.getEnumConstants().length; i++) {
			ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), i, new ModelResourceLocation(block.getRegistryName(),  variantName + "=" + variants.getEnumConstants()[i].name()));
		}
	}

And from the model registry event i call it like this
 

BlockUtils.registerMetadataBlockModel(MARBLE_SLAB, "color", EnumMarble.class);
BlockUtils.registerMetadataBlockModel(MARBLE_DOUBLE_SLAB, "color", EnumMarble.class);

 

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

Posted

But this method works for the normal colored blocks... By the way i changed it to get the lower case name of the enum value, but still got no inventory texture :/ 

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

Posted (edited)

The json hasn't changed, but i post it again so there's everything in one place. This is the method i use to register a block with variants. It takes the block itself, the variant name and the enum class corresponding to the variant values

 

  Reveal hidden contents

 

The enum i'm using to give the slab a variant is this

 

  Reveal hidden contents

 

and this is the slab base class 

 

  Reveal hidden contents

 

In the register block event i register the half slab and the double slab block like this

 

  Reveal hidden contents

 

As well as the item block in the register item event

 

  Reveal hidden contents

 

And finally i register the model using the ModelRegistryEvent like this

 

  Reveal hidden contents

 

The blockstates json file i use for the half slab is this

 

  Reveal hidden contents

 

While for the double slab i use this json file

 

  Reveal hidden contents

 

If i place the block on the ground it works fine, both for half slabs and double slabs, is just in inventory that i get no icon and model, just a plain black/purple texture

Edited by JimiIT92
Code lost from previous edit, fixed now

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

Posted

Update: so, after spending some time trying to figure out the arcane i did it. Reading the old messages i thought about the "variant=something" thing and i remembered that when you have multiple properties, the blockstate is something like "property1=value1,property2=value2". And so i tried using the "half=bottom,color=white" to register the white slab and it worked! I now have a proper icon displaying in the inventory :D Thanks everyone for your help :)

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

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • That is incorrect. Use the run.bat or run.sh to run the server.
    • Hello, I have been trying for days to create my server with forge-1.20.1-47.4.1-installer, which installs the server, but the forge-1.20.1-47.4.1.jar file, which is necessary to create the server, does not appear. I no longer know what to do. Help. hola buenas, llevo dias intentando poder hacer mi servidor con forge-1.20.1-47.4.1-installer el cual instalo el server, pero no aparece el archivo forge-1.20.1-47.4.1.jar , el cual es necesario para poder crear el server, ya no se que hacer ayuda.
    • Does this happen if you use the regular vanilla minecraft launcher? Also, unsure if TLauncher ever has a legit usage, as I have always seen it associated with software piracy, but if it has a legit mode, make sure it is using online mode so that it can authenticate your MS account to login. Aside from that, more information is likely needed. Post logs, as well as the paths you are placing files in (screenshots of your file explorer can be helpful as well).
    • I am using a third-party launcher that has pre-installed forge versions of Minecraft.  When I insert mods from CurseForge, I extract the files and as expected put them in the .mods folder. I am guessing that there is an error with the file transfer but I don't know for sure and sometimes I use Forge to test mods that I created before releasing previously on a different pc, so I don't know if it is the if it an extraction error but if are any tips or knowledge reply and I will read it. This is also will be kept on the forum for others that have the issues.
    • I make wires and i need connection 2 wires block. I have BooleanPropertys registered, but in mod loading it show Unknown the property in assets/wuntare/blockState. public static final BooleanProperty CONNECTED_NORTH = BooleanProperty.create("connected_north"); public static final BooleanProperty CONNECTED_SOUTH = BooleanProperty.create("connected_south"); public static final BooleanProperty CONNECTED_WEST = BooleanProperty.create("connected_west"); public static final BooleanProperty CONNECTED_EAST = BooleanProperty.create("connected_east"); public static final BooleanProperty CONNECTED_UP = BooleanProperty.create("connected_up"); public static final BooleanProperty CONNECTED_DOWN = BooleanProperty.create("connected_down"); public CopperWireWithoutInsulation0(Properties properties) { super(properties); this.registerDefaultState(this.stateDefinition.any() .setValue(CONNECTED_NORTH, false) .setValue(CONNECTED_SOUTH, false) .setValue(CONNECTED_WEST, false) .setValue(CONNECTED_EAST, false) .setValue(CONNECTED_UP, false) .setValue(CONNECTED_DOWN, false)); } @Override protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { builder.add(CONNECTED_NORTH, CONNECTED_SOUTH, CONNECTED_WEST, CONNECTED_EAST, CONNECTED_UP, CONNECTED_DOWN); } In this part blockState have problem "multipart": [ { "apply": { "model": "wuntare:block/copper_wire_without_insulation0" } }, { "when": { "connected_north": true }, "apply": { "model": "wuntare:block/copper_wire_without_insulation0_north" } },  
  • Topics

×
×
  • Create New...

Important Information

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