Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

As by title, i'm trying to make a slab that looks like grass, but i have incorrect textures when placing the single slab (the double slab looks like a grass bock as i want) :/

This is the code for my Slab class

package mw.blocks.vanilla;

import java.util.List;
import java.util.Random;

import mw.core.MWMetadataBlocks;
import mw.core.MWTabs;
import mw.core.MWVanillaSlabs;
import net.minecraft.block.BlockSlab;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.IStringSerializable;
import net.minecraft.world.ColorizerGrass;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeColorHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class BlockGrassSlab extends BlockSlab
{
    public static final PropertyBool seamlessBool = PropertyBool.create("seamless");
    public static final PropertyEnum typeVar = PropertyEnum.create("variant", BlockGrassSlab.EnumType.class);

    public BlockGrassSlab()
    {
        super(Material.grass);
        IBlockState iblockstate = this.blockState.getBaseState();
        if (this.isDouble())
        {
            iblockstate = iblockstate.withProperty(seamlessBool, Boolean.valueOf(false));
        }
        else
        {
            iblockstate = iblockstate.withProperty(HALF, BlockSlab.EnumBlockHalf.BOTTOM);
        }
        this.setDefaultState(iblockstate.withProperty(typeVar, BlockGrassSlab.EnumType.NORMAL));
        this.setCreativeTab(MWTabs.tabBlock);
        this.setHardness(0.7F);
        this.setResistance(0.0F);
        this.useNeighborBrightness = !this.isDouble();
        this.setStepSound(soundTypeGrass);
    }

    @SideOnly(Side.CLIENT)
    public EnumWorldBlockLayer getBlockLayer()
    {
      return EnumWorldBlockLayer.CUTOUT_MIPPED;
    }
    
    @SideOnly(Side.CLIENT)
    public int getBlockColor()
    {
        return ColorizerGrass.getGrassColor(0.5D, 1.0D);
    }

    @SideOnly(Side.CLIENT)
    public int getRenderColor(IBlockState state)
    {
        return this.getBlockColor();
    }

    @SideOnly(Side.CLIENT)
    public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
    {
        return BiomeColorHelper.getGrassColorAtPos(worldIn, pos);
    }

    
    public Item getItemDropped(IBlockState state, Random rand, int fortune)
    {
        return Item.getItemFromBlock(MWVanillaSlabs.grass_single_slab);
    }

    @SideOnly(Side.CLIENT)
    public Item getItem(World worldIn, BlockPos pos)
    {
    	
        return Item.getItemFromBlock(MWVanillaSlabs.grass_single_slab);
    }

    public String getUnlocalizedName(int meta)
    {
        return "tile." + BlockGrassSlab.EnumType.func_176625_a(meta).func_176627_c();
    }

    public IProperty getVariantProperty()
    {
        return typeVar;
    }

    public Object getVariant(ItemStack stack)
    {
        return BlockGrassSlab.EnumType.func_176625_a(stack.getMetadata() & 7);
    }

    @SideOnly(Side.CLIENT)
    public void getSubBlocks(Item itemIn, CreativeTabs tab, List list)
    {
        if (itemIn != Item.getItemFromBlock(MWVanillaSlabs.grass_double_slab))
        {
            BlockGrassSlab.EnumType[] aenumtype = BlockGrassSlab.EnumType.values();
            int i = aenumtype.length;

            for (int j = 0; j < i; ++j)
            {
                BlockGrassSlab.EnumType enumtype = aenumtype[j];

                    list.add(new ItemStack(itemIn, 1, enumtype.func_176624_a()));
               
            }
        }
    }

    public IBlockState getStateFromMeta(int meta)
    {
        IBlockState iblockstate = this.getDefaultState().withProperty(typeVar, BlockGrassSlab.EnumType.func_176625_a(meta & 7));

        if (this.isDouble())
        {
            iblockstate = iblockstate.withProperty(seamlessBool, Boolean.valueOf((meta &  != 0));
        }
        else
        {
            iblockstate = iblockstate.withProperty(HALF, (meta &  == 0 ? BlockSlab.EnumBlockHalf.BOTTOM : BlockSlab.EnumBlockHalf.TOP);
        }

        return iblockstate;
    }

    public int getMetaFromState(IBlockState state)
    {
        byte b0 = 0;
        int i = b0 | ((BlockGrassSlab.EnumType)state.getValue(typeVar)).func_176624_a();

        if (this.isDouble())
        {
            if (((Boolean)state.getValue(seamlessBool)).booleanValue())
            {
                i |= 8;
            }
        }
        else if (state.getValue(HALF) == BlockSlab.EnumBlockHalf.TOP)
        {
            i |= 8;
        }

        return i;
    }

    protected BlockState createBlockState()
    {
        return this.isDouble() ? new BlockState(this, new IProperty[] {seamlessBool, typeVar}): new BlockState(this, new IProperty[] {HALF, typeVar});
    }

    public int damageDropped(IBlockState state)
    {
        return ((BlockGrassSlab.EnumType)state.getValue(typeVar)).func_176624_a();
    }

    public static enum EnumType implements IStringSerializable
    {
    //	VARIANT(META, "VAR NAME", "UNL.NAME");
    	NORMAL(0, "normal", "grass_single_slab");

        private static final BlockGrassSlab.EnumType[] field_176640_i = new BlockGrassSlab.EnumType[values().length];
        private final int meta;
        private final String variantName;
        private final String name;


        private EnumType(int meta, String name)
        {
            this(meta, name, name);
        }

        private EnumType(int meta, String variantName, String name)
        {
            this.meta = meta;
            this.variantName = variantName;
            this.name = name;
        }

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

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

        public static BlockGrassSlab.EnumType func_176625_a(int meta)
        {
            if (meta < 0 || meta >= field_176640_i.length)
            {
                meta = 0;
            }

            return field_176640_i[meta];
        }

        public String getName()
        {
            return this.variantName;
        }

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

        static
        {
            BlockGrassSlab.EnumType[] var0 = values();
            int var1 = var0.length;

            for (int var2 = 0; var2 < var1; ++var2)
            {
                BlockGrassSlab.EnumType var3 = var0[var2];
                field_176640_i[var3.func_176624_a()] = var3;
            }
        }
    }

@Override
public boolean isDouble() {
	return false;
}

@Override
public boolean isSideSolid(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
{
	if(side == EnumFacing.UP)
		return true;
	else
		return false;
}

}

 

And here is a screenshot of what the single slab looks like in inventory, on ground and on the upper half of a block

RkCsN8j.png

 

Basically is not painting the grass top grass texture :/

Also, there is a better way to make a slab that has no variant (just 1 type of slab, for example: only grass or only stone....)?

Thanks in advance to all who will help me :)

 

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

  • Author

i have that methods in my class but it doesn't work :(

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

Blocks are only rendered with a colour multiplier if the model defines a tint index for the face. Look at the grass.json and grass_normal.json models.

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.

  • Author

OK, so 'ive tried adding this code from the grass.json file to my both upper and half slab .json files

"elements": [
        {   "from": [ 0, 0, 0 ],
            "to": [ 16, 16, 16 ],
            "faces": {
                "down":  { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom", "cullface": "down" },
                "up":    { "uv": [ 0, 0, 16, 16 ], "texture": "#top",    "cullface": "up", "tintindex": 0 },
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "north" },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "south" },
                "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "west" },
                "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "east" }
            }
        },
        {   "from": [ 0, 0, 0 ],
            "to": [ 16, 16, 16 ],
            "faces": {
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "north" },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "south" },
                "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "west" },
                "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "east" }
            }
        }
    ]

 

So i now have this half_grass_slab.json file

{
"parent": "block/half_slab",
"textures": {
	"particle": "blocks/dirt",
        "bottom": "blocks/dirt",
        "top": "blocks/grass_top",
        "side": "blocks/grass_side",
        "overlay": "blocks/grass_side_overlay"
},
"elements": [
        {   "from": [ 0, 0, 0 ],
            "to": [ 16, 16, 16 ],
            "faces": {
                "down":  { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom", "cullface": "down" },
                "up":    { "uv": [ 0, 0, 16, 16 ], "texture": "#top",    "cullface": "up", "tintindex": 0 },
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "north" },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "south" },
                "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "west" },
                "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "east" }
            }
        },
        {   "from": [ 0, 0, 0 ],
            "to": [ 16, 16, 16 ],
            "faces": {
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "north" },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "south" },
                "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "west" },
                "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "east" }
            }
        }
    ]
}

and this upper_grass_slab.json file

{
"parent": "block/upper_slab",
"textures": {
	"particle": "blocks/dirt",
        "bottom": "blocks/dirt",
        "top": "blocks/grass_top",
        "side": "blocks/grass_side",
        "overlay": "blocks/grass_side_overlay"
},
"elements": [
        {   "from": [ 0, 0, 0 ],
            "to": [ 16, 16, 16 ],
            "faces": {
                "down":  { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom", "cullface": "down" },
                "up":    { "uv": [ 0, 0, 16, 16 ], "texture": "#top",    "cullface": "up", "tintindex": 0 },
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "north" },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "south" },
                "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "west" },
                "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "east" }
            }
        },
        {   "from": [ 0, 0, 0 ],
            "to": [ 16, 16, 16 ],
            "faces": {
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "north" },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "south" },
                "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "west" },
                "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "east" }
            }
        }
    ]
}

 

But i have errors in Eclipse, saying:

13:35:55] [Client thread/ERROR] [FML]: Exception loading model mw:block/upper_grass_slab with loader instance, skipping
com.google.gson.JsonParseException: BlockModel requires either elements or parent, found both
at net.minecraft.client.renderer.block.model.ModelBlock$Deserializer.parseModelBlock(ModelBlock.java:256) ~[ModelBlock$Deserializer.class:?]
at net.minecraft.client.renderer.block.model.ModelBlock$Deserializer.deserialize(ModelBlock.java:323) ~[ModelBlock$Deserializer.class:?]
at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:58) ~[TreeTypeAdapter.class:?]
at com.google.gson.Gson.fromJson(Gson.java:803) ~[Gson.class:?]
at com.google.gson.Gson.fromJson(Gson.java:741) ~[Gson.class:?]
at net.minecraft.client.renderer.block.model.ModelBlock.deserialize(ModelBlock.java:47) ~[ModelBlock.class:?]
at net.minecraft.client.resources.model.ModelBakery.loadModel(ModelBakery.java:269) ~[ModelBakery.class:?]
at net.minecraftforge.client.model.ModelLoader.access$900(ModelLoader.java:67) ~[ModelLoader.class:?]
at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:451) ~[ModelLoader$VanillaLoader.class:?]
at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:92) [ModelLoaderRegistry.class:?]
at net.minecraftforge.client.model.ModelLoader.loadAnyModel(ModelLoader.java:187) [ModelLoader.class:?]
at net.minecraftforge.client.model.ModelLoader.getModel(ModelLoader.java:170) [ModelLoader.class:?]
at net.minecraftforge.client.model.ModelLoader$WeightedRandomModel.<init>(ModelLoader.java:342) [ModelLoader$WeightedRandomModel.class:?]
at net.minecraftforge.client.model.ModelLoader.registerVariant(ModelLoader.java:140) [ModelLoader.class:?]
at net.minecraft.client.resources.model.ModelBakery.loadVariants(ModelBakery.java:122) [ModelBakery.class:?]
at net.minecraftforge.client.model.ModelLoader.loadBlocks(ModelLoader.java:121) [ModelLoader.class:?]
at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:91) [ModelLoader.class:?]
at net.minecraft.client.resources.model.ModelManager.onResourceManagerReload(ModelManager.java:29) [ModelManager.class:?]
at net.minecraft.client.resources.SimpleReloadableResourceManager.notifyReloadListeners(SimpleReloadableResourceManager.java:134) [simpleReloadableResourceManager.class:?]
at net.minecraft.client.resources.SimpleReloadableResourceManager.reloadResources(SimpleReloadableResourceManager.java:118) [simpleReloadableResourceManager.class:?]
at net.minecraft.client.Minecraft.refreshResources(Minecraft.java:767) [Minecraft.class:?]
at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:306) [FMLClientHandler.class:?]
at net.minecraft.client.Minecraft.startGame(Minecraft.java:521) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:356) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_51]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_51]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_51]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]
at GradleStart.main(Unknown Source) [start/:?]
[13:35:55] [Client thread/ERROR] [FML]: Exception loading model mw:block/half_grass_slab with loader instance, skipping
com.google.gson.JsonParseException: BlockModel requires either elements or parent, found both
at net.minecraft.client.renderer.block.model.ModelBlock$Deserializer.parseModelBlock(ModelBlock.java:256) ~[ModelBlock$Deserializer.class:?]
at net.minecraft.client.renderer.block.model.ModelBlock$Deserializer.deserialize(ModelBlock.java:323) ~[ModelBlock$Deserializer.class:?]
at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:58) ~[TreeTypeAdapter.class:?]
at com.google.gson.Gson.fromJson(Gson.java:803) ~[Gson.class:?]
at com.google.gson.Gson.fromJson(Gson.java:741) ~[Gson.class:?]
at net.minecraft.client.renderer.block.model.ModelBlock.deserialize(ModelBlock.java:47) ~[ModelBlock.class:?]
at net.minecraft.client.resources.model.ModelBakery.loadModel(ModelBakery.java:269) ~[ModelBakery.class:?]
at net.minecraftforge.client.model.ModelLoader.access$900(ModelLoader.java:67) ~[ModelLoader.class:?]
at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:451) ~[ModelLoader$VanillaLoader.class:?]
at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:92) [ModelLoaderRegistry.class:?]
at net.minecraftforge.client.model.ModelLoader.loadAnyModel(ModelLoader.java:187) [ModelLoader.class:?]
at net.minecraftforge.client.model.ModelLoader.getModel(ModelLoader.java:170) [ModelLoader.class:?]
at net.minecraftforge.client.model.ModelLoader$WeightedRandomModel.<init>(ModelLoader.java:342) [ModelLoader$WeightedRandomModel.class:?]
at net.minecraftforge.client.model.ModelLoader.registerVariant(ModelLoader.java:140) [ModelLoader.class:?]
at net.minecraft.client.resources.model.ModelBakery.loadVariants(ModelBakery.java:122) [ModelBakery.class:?]
at net.minecraftforge.client.model.ModelLoader.loadBlocks(ModelLoader.java:121) [ModelLoader.class:?]
at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:91) [ModelLoader.class:?]
at net.minecraft.client.resources.model.ModelManager.onResourceManagerReload(ModelManager.java:29) [ModelManager.class:?]
at net.minecraft.client.resources.SimpleReloadableResourceManager.notifyReloadListeners(SimpleReloadableResourceManager.java:134) [simpleReloadableResourceManager.class:?]
at net.minecraft.client.resources.SimpleReloadableResourceManager.reloadResources(SimpleReloadableResourceManager.java:118) [simpleReloadableResourceManager.class:?]
at net.minecraft.client.Minecraft.refreshResources(Minecraft.java:767) [Minecraft.class:?]
at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:306) [FMLClientHandler.class:?]
at net.minecraft.client.Minecraft.startGame(Minecraft.java:521) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:356) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_51]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_51]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_51]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]
at GradleStart.main(Unknown Source) [start/:?]

 

How can i solve that?

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

Like the error says, a model can only specify a parent or elements; but not both. Since you need to specify the

tintindex

in the elements, you need to define the elements yourself instead of inheriting from the default slab models.

 

You'll need to copy the grass.json model, adjust the height (the y dimension of the

from

and

to

coordinates) of each element to 8 instead of 16 and remove the

cullface

from the

up

or

down

face (like the slab models). You can then inherit from this model for each variant of grass you want to support like the default grass models.

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.

  • Author

Thanks for the answer :) Ok, i've edit the json files and now the slab looks fine on ground, but in inventory the top of the slab is still grey :/

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

  • Author

This is the half_grass_slab block model:

{
"textures": {
	"particle": "blocks/dirt",
        "bottom": "blocks/dirt",
        "top": "blocks/grass_top",
        "side": "blocks/grass_side",
        "overlay": "blocks/grass_side_overlay"
},
"elements": [
        {   "from": [ 0, 0, 0 ],
            "to": [ 16, 8, 16 ],
            "faces": {
                "down":  { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom" },
                "up":    { "uv": [ 0, 0, 16, 16 ], "texture": "#top", "tintindex": 0 },
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "north" },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "south" },
                "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "west" },
                "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "east" }
            }
        },
        {   "from": [ 0, 0, 0 ],
            "to": [ 16, 8, 16 ],
            "faces": {
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "north" },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "south" },
                "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "west" },
                "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "east" }
            }
        }
    ]
}

 

This is the upper_grass_slab block model:

{
"textures": {
	"particle": "blocks/dirt",
        "bottom": "blocks/dirt",
        "top": "blocks/grass_top",
        "side": "blocks/grass_side",
        "overlay": "blocks/grass_side_overlay"
},
"elements": [
        {   "from": [ 0, 8, 0 ],
            "to": [ 16, 16, 16 ],
            "faces": {
                "down":  { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom" },
                "up":    { "uv": [ 0, 0, 16, 16 ], "texture": "#top", "tintindex": 0 },
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "north" },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "south" },
                "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "west" },
                "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "east" }
            }
        },
        {   "from": [ 0, 8, 0 ],
            "to": [ 16, 16, 16 ],
            "faces": {
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "north" },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "south" },
                "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "west" },
                "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "east" }
            }
        }
    ]
}

 

And this is the item model file

{
"parent": "mw:block/half_grass_slab",
"display": {
	"thirdperson": {
		"rotation": [ 10, -45, 170],
		"translation": [ 0, 1.5, -2.75],
		"scale": [ 0.375, 0.375, 0.375]
	}
}
}

 

As mentioned above the slabs itself have no problems, only the rendering in inventory is wrong :/

This is how it looks right now

X0x2Qec.png

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

As mentioned above the slabs itself have no problems, only the rendering in inventory is wrong :/

 

Ah, I didn't get that from your last post.

 

If it's rendering with colour in the world but grey in your inventory, you need to create a custom

ItemBlock

class that overrides

Item#getColorFromItemStack

like

ItemColored

does. You'll want to extend

ItemSlab

(to inherit the slab placement logic) and have a constructor that takes your actual single/double slab classes for the

singleSlab

and

doubleSlab

parameters instead of

BlockSlab

(so FML can find the constructor via reflection when you register your

Block

s).

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.

  • Author

Yay! :D I added this function to my ItemGrassSlab class

@SideOnly(Side.CLIENT)
    public int getColorFromItemStack(ItemStack stack, int renderPass)
    {
        return this.single.getRenderColor(this.single.getStateFromMeta(stack.getMetadata()));
    }

and it worked :D Thanks for the answer :)

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

  • 3 months later...

Hi. I made a custom grass block model of this example. But the particles from the block also colored in the biome color. How can I fix it?

Sorry, I don't speak English very well...

The UV's in your models are off, currently they are rendering the full texture on half a block.

 

half_grass_slab block model:

{
    "textures": {
        "particle": "blocks/dirt",
        "bottom": "blocks/dirt",
        "top": "blocks/grass_top",
        "side": "blocks/grass_side",
        "overlay": "blocks/grass_side_overlay"
    },
    "elements": [
        {   "from": [ 0, 0, 0 ],
            "to": [ 16, 8, 16 ],
            "faces": {
                "down":  { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom", "cullface": "down" },
                "up":    { "uv": [ 0, 0, 16, 16 ], "texture": "#top", "tintindex": 0 },
                "north": { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "north" },
                "south": { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "south" },
                "west":  { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "west" },
                "east":  { "uv": [ 0, 8, 16, 16 ], "texture": "#side", "cullface": "east" }
            }
        },
        {   "from": [ 0, 0, 0 ],
            "to": [ 16, 8, 16 ],
            "faces": {
                "north": { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "tintindex": 0, "cullface": "north" },
                "south": { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "tintindex": 0, "cullface": "south" },
                "west":  { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "tintindex": 0, "cullface": "west" },
                "east":  { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "tintindex": 0, "cullface": "east" }
            }
        }
    ]
}

 

upper_grass_slab block model:

{
    "textures": {
        "particle": "blocks/dirt",
        "bottom": "blocks/dirt",
        "top": "blocks/grass_top",
        "side": "blocks/grass_side",
        "overlay": "blocks/grass_side_overlay"
    },
    "elements": [
        {   "from": [ 0, 8, 0 ],
            "to": [ 16, 16, 16 ],
            "faces": {
                "down":  { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom" },
                "up":    { "uv": [ 0, 0, 16, 16 ], "texture": "#top", "tintindex": 0, "cullface": "up" },
                "north": { "uv": [ 0, 0, 16,  8 ], "texture": "#side", "cullface": "north" },
                "south": { "uv": [ 0, 0, 16,  8 ], "texture": "#side", "cullface": "south" },
                "west":  { "uv": [ 0, 0, 16,  8 ], "texture": "#side", "cullface": "west" },
                "east":  { "uv": [ 0, 0, 16,  8 ], "texture": "#side", "cullface": "east" }
            }
        },
        {   "from": [ 0, 8, 0 ],
            "to": [ 16, 16, 16 ],
            "faces": {
                "north": { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "tintindex": 0, "cullface": "north" },
                "south": { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "tintindex": 0, "cullface": "south" },
                "west":  { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "tintindex": 0, "cullface": "west" },
                "east":  { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay", "tintindex": 0, "cullface": "east" }
            }
        }
    ]
}

No, I need a full grass block.

First, I created a model.

 

my_grass_model:

{
    "elements": [
        {  "from": [ 0, 0, 0 ],
            "to": [ 16, 16, 16 ],
            "faces": {
                "down":  { "uv": [ 0, 0, 16, 16 ], "texture": "#down", "cullface": "down" },
                "up":    { "uv": [ 0, 0, 16, 16 ], "texture": "#up",    "cullface": "up", "tintindex": 0 },
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#north",   "cullface": "north" },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#south",   "cullface": "south" },
                "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#west",   "cullface": "west" },
                "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#east",   "cullface": "east" }
            }
        },
        {   "from": [ 0, 0, 0 ],
            "to": [ 16, 16, 16 ],
            "faces": {
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "north" },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "south" },
                "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "west" },
                "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "east" }
            }
        }
    ]
}

 

Then, based on it created a model for my block.

 

my_grass_block

{  
    "parent": "mymod:block/my_grass_model",
    "textures": {
        "particle": "blocks/dirt",
        "down": "mymod:blocks/MyGrass_Bottom",
        "up": "blocks/grass_top",
        "north": "mymod:blocks/MyGrass",
        "east": "mymod:blocks/MyGrass",
        "south": "mymod:blocks/MyGrass",
        "west": "mymod:blocks/MyGrass",
        "overlay": "blocks/grass_side_overlay"
    }
}

 

And particles from the block have no color of the dirt. They are painted in green. How can I fix it?

 

width=800 height=601https://file-up.net/big_748f23757e8c8371e820151209082645.jpg[/img]

 

Sorry, I don't speak English very well...

@Liahim

Sorry for the confusion, I was pointing out the UV error to JimiIT92.

 

As for your particle issue, I'm not sure.

I've currently got a block with the opposite issue; item and block colored correctly but particles are grey.

Eventually I'll look into it but since I have larger parts of my mod left to upgrade its low priority.

 

I'm am using tintindex 1 for that block so my thinking is: tintindex 0 might always be used for particles so anything other then white results in colored particles, and the default grass is case exempted.

But that is based entirely on observation and has no bases in the code itself.

 

EDIT:

After posting I started wonder why I was still using tintindex 1, (it was from an older model design, and I simply didn't go through and change it)

So I change my models to use tintindex 0 and updated the colorMultiplier, and my particles are correctly colored.

 

This makes it look even more like tintindex 0 is always used on particles and grass is just hard coded.

I'd suggest using tintindex 1 in your model and changing it in your Block.colorMultiplier and Item.getColorFromItemStack.

@ShetiPhian

Sorry. How can I change the colorMultiplier method for these purposes?

I do not quite understand.

 

Now it looks like this:

    @SideOnly(Side.CLIENT)
    public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
    {
        return BiomeColorHelper.getGrassColorAtPos(worldIn, pos);
    }

 

O! I did it! Thanks for help )

    @SideOnly(Side.CLIENT)
    public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
    {
        return renderPass == 1 ? BiomeColorHelper.getGrassColorAtPos(worldIn, pos) : 16777215;
    }

Sorry, I don't speak English very well...

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.