Download Spawn Egg BYID Redirect — Minecraft Mods — MetaMods

Spawn Egg BYID Redirect

Active

Downloads

0

Last update

1 year ago

Versions

1.15 — 1.21
Client and server
Fabric
Forge
Quilt
Libraries
Mobs

Spawn Egg BYID Redirect

For Players:

Some mods may require functions implemented by this mod in the background to work correctly. Simply install it alongside any mod that needs it, both on client and server.

Use Case: If a mod you have installed adds multiple spawn eggs for one mob type (for example, for different variants), and one of the spawn eggs has lost its color as a result, this mod can restore the coloring.

For Developers:

This mod replaces the BY_ID#put() call inside the SpawnEggItem constructor with BY_ID#putIfAbsent(). Although this change may seem minor, it makes a big difference when you need to have multiple spawn eggs with the same entity type (for instance, if you want spawn eggs that create variants).

Brief Tutorial on Using This Mod When Adding Something Like a Variant Spawn Egg:

  1. Create a new class extending SpawnEggItem (official Mojang mappings, extend whatever is converted to the mappings of your choice).

  2. Create a public static ArrayList of type SpawnEggItem inside the class you created as follows:

public static final ArrayList<SpawnEggItem> EGGS = new ArrayList<>();
  1. In your constructor, add the current instance to the created ArrayList as follows:
super(entityType, i, j, properties);
[...]
EGGS.add(this);
  1. Inside your ClientModInitializer, register the colors for your spawn eggs as follows:
@Override
public void onInitializeClient() {
    WolfVariantEgg.EGGS.forEach((egg) -> 
            ColorProviderRegistry.ITEM.register((stack, tintIndex) 
                    -> egg.getColor(tintIndex), egg));
}
Project members
Jackbusters

Jackbusters

Developer

Created: 12 Mar 2024

ID: 14611