During the last few days I was working on a custom grass block in a forge 1.16.4 environment.
For now i'm aiming only to recreate a simple grass block indistinguishable in the world from the minecraft one.
I have practically copied the json file of the model from minecraft and created a simple block class with only the constructor with all the normal properties.
Here's the json:
{
"parent": "block/cube",
"textures": {
"particle": "exoticanimalmod:blocks/dirt",
"bottom": "exoticanimalmod:blocks/dirt",
"top": "exoticanimalmod:blocks/grass_block_top",
"side": "exoticanimalmod:blocks/grass_block_side",
"overlay": "exoticanimalmod:blocks/grass_block_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"}
}
}
]
}
In an event handler class i have created an IBlockColor and registered it on the custom block:
package com.EdLL.exoticanimalmod.events;
import com.EdLL.exoticanimalmod.ExoticAnimalMod;
import com.EdLL.exoticanimalmod.util.ModBlocksRegistry;
import com.EdLL.exoticanimalmod.util.ModEntityRegistry;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.world.GrassColors;
import net.minecraft.world.biome.BiomeColors;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.ColorHandlerEvent;
import net.minecraftforge.event.entity.living.LivingFallEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
@Mod.EventBusSubscriber(modid = ExoticAnimalMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class ModEventsHandler {
static final IBlockColor grassColourHandler = (state, blockAccess, pos, tintIndex) -> {
if (blockAccess != null && pos != null) {
return BiomeColors.getGrassColor(blockAccess, pos);
}
return GrassColors.get(0.5D, 1.0D);
};
@SubscribeEvent
public static void registerBlockColors(final ColorHandlerEvent.Block event){
event.getBlockColors().register(grassColourHandler, ModBlocksRegistry.EGGED_GRASS.get());
}
@SubscribeEvent
public void onEntityFall(LivingFallEvent event){
if(event.getEntityLiving().getType()== ModEntityRegistry.STAG_BEETLE_MALE.get()){
event.setCanceled(true);
}
}
}
The IBlockColor renderer does work: the overlaid texture takes the correct color of the biome grass, but the first texture (the dirt.png on the json) is turned completely black.
As you can see the overlay texture works just fine, but somehow covers the dirt texture underneath. The bottom face, that is not overlaid is working fine.
The textures i use are the ones from minecraft and i double checked that the overlay texture was a .png.
The log gives me no hint on how to fix this.. Does someone know how to help me ?