Make ForgeSpawnEgg assume color is opaque if alpha is set to 0.

Fixes "invisible" spawn eggs by default, but still allows modders to specify partial transparency.
This commit is contained in:
LexManos committed 2024-06-18 11:45:13 -07:00
1 parent f6a54436b9
commit 4bf0de4763
1 file changed
+9 -3
@@ -7,6 +7,7 @@ package net.minecraftforge.common;
import net.minecraft.core.Direction;
import net.minecraft.core.dispenser.DispenseItemBehavior;
import net.minecraft.util.FastColor;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MobSpawnType;
@@ -91,9 +92,14 @@ public class ForgeSpawnEggItem extends SpawnEggItem {
private static class ColorRegisterHandler {
@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void registerSpawnEggColors(RegisterColorHandlersEvent.Item event) {
MOD_EGGS.forEach(egg ->
event.register((stack, layer) -> egg.getColor(layer), egg)
);
MOD_EGGS.forEach(egg -> {
event.register((stack, layer) -> {
int color = egg.getColor(layer);
if (FastColor.ARGB32.alpha(color) == 0)
color = FastColor.ARGB32.opaque(color);
return color;
}, egg);
});
}
}
}