Jump to content

[1.16.4] overlaying textures make the textures below black


EdLL

Recommended Posts

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.

 

2020-12-29_10_22_51.png.e4535f9910cd011c60daae6cfe3e37e0.png

 

2020-12-29_10_23_11.png.a50b3bacead6b4dea598ab3424251a09.png

 

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 ?

 

 

Edited by EdLL
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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