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.

[Forge 1.16.5] EntityType.Builder.create replaced with EntityType.Builder.of?

Featured Replies

Posted

Hello, I've recently started working on a new mod that involves something I've never worked on before: creating a custom mob.

I've been trying to follow tutorial videos and docs for going about it, but so far most of them seem to ask me to start by creating a basic version of the mobs class, and registering it. However, whenever I try to do so I reach a point where the current version that I'm using seems to conflict with the ones in the tutorials. The tutorials recommend I do something like this:

public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES, MOD_ID);

public static EntityType<?> SLIME_PET_ENTITY = EntityType.Builder.create(SlimePetEntity::new, EntityClassification.CREATURE).build(MOD_ID+":slime_pet").setRegistryName("slime_pet")

However, when I try to use Event.Builder.create, the function is unavailable. The only other one I could think to use is EventType.Builder.of(), but I'm having trouble understanding why this one doesn't work and just throws these errors:

Error.thumb.PNG.f26146e9f1bc5ee5c79e316aab6ebeef.PNG

Is there something I'm missing in the process? Should I be using different functions/ approaches to this registration step, or just skip it entirely? I'll post the relevant classes in a follow-up comment, but I'm currently using the latest recommended version of Forge(36.1.0) and can't seem to understand what I'm doing wrong in this early step of the process.

Any help would be greatly appreciated. Thanks in advance!

  • Author

Here are the relevant classes. First, the main SlimePetMod class:

package com.jarkon.slimepetmod;

import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ai.attributes.GlobalEntityTypeAttributes;
import net.minecraft.entity.monster.SlimeEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.SimpleFoiledItem;
import net.minecraft.item.SpawnEggItem;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.DeferredWorkQueue;
import net.minecraftforge.fml.InterModComms;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.jarkon.slimepetmod.entity.SlimePetEntity;

import java.util.stream.Collectors;

// The value here should match an entry in the META-INF/mods.toml file
@Mod("slimepetmod")
public class SlimePetMod
{
    // Directly reference a log4j logger.
    private static final Logger LOGGER = LogManager.getLogger();
	
    public static final String MOD_ID = "slimepetmod";

    
    public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES, MOD_ID);

    public static EntityType<?> SLIME_PET_ENTITY = EntityType.Builder.of(SlimePetEntity::new, EntityClassification.CREATURE).build(MOD_ID+":slime_pet").setRegistryName("slime_pet");

    public static Item slime_pet_egg;
    
	
    public SlimePetMod() {
        MinecraftForge.EVENT_BUS.register(this);
    }
    
    public static Item registerEntitySpawnEgg(EntityType<?> type, int color1, int color2, String name) {
		SpawnEggItem newEgg = new SpawnEggItem(type, color1, color2, new Item.Properties().tab(ItemGroup.TAB_MISC));
		newEgg.setRegistryName(name);
		return newEgg;

    }
    
    @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
    public static class RegistryEvents {
    	@SubscribeEvent
		public static void registerItems(final RegistryEvent.Register<Item> event) {		
    		event.getRegistry().registerAll(
					slime_pet_egg = registerEntitySpawnEgg(SLIME_PET_ENTITY, 0x008000, 0x008000, "meh")
				);			
		}
    }
}

Second, the SlimePetEntity class:

package com.jarkon.slimepetmod.entity;

import net.minecraft.entity.EntityType;
import net.minecraft.entity.monster.SlimeEntity;

import net.minecraft.world.World;

public class SlimePetEntity extends SlimeEntity{
	   
	protected SlimePetEntity(EntityType<? extends SlimePetEntity> p_i48574_1_, World p_i48574_2_) {
		super(p_i48574_1_, p_i48574_2_);
	}
}

 

  • Author

I'd also like to mention that if I use an existing mob in the EventType.Builder.of function, it works fine

(I.E. EventType.Builder.of(SlimeEntity::new, EntityClassification.CREATURE) throws no errors)

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.