Jump to content

Custom Boat (1.19)


Recommended Posts

  • 1 month later...

public class ModBoat extends Boat {

private static final EntityDataAccessor<Integer> DATA_ID_TYPE = SynchedEntityData.defineId(Boat.class, EntityDataSerializers.INT);

public ModBoat(EntityType<? extends Boat> p_38290_, Level p_38291_) { super(p_38290_, p_38291_);


public ModBoat.Type getModBoatType() { return ModBoat.Type.byId(this.entityData.get(DATA_ID_TYPE)); } public void setType(ModBoat.Type p_38333_) { this.entityData.set(DATA_ID_TYPE, p_38333_.ordinal());


public static enum Type {

CHERRY(ModBlocks.CHERRY_PLANKS.get(), "cherry"),

ALMOND(ModBlocks.ALMOND_PLANKS.get(), "almond"),

PEACH(ModBlocks.PEACH_PLANKS.get(), "peach"),

APPLE(ModBlocks.APPLE_PLANKS.get(), "apple"),

PLUM(ModBlocks.PLUM_PLANKS.get(), "plum"),

PEAR(ModBlocks.PEAR_PLANKS.get(), "pear");

private final String name;

private final Block planks;

private Type(Block p_38427_, String p_38428_) { this.name = p_38428_; this.planks = p_38427_;


public String getName() { return this.name; }

public Block getPlanks() { return this.planks; }

public String toString() { return this.name; }

public static ModBoat.Type byId(int p_38431_) { ModBoat.Type[] aboat$type = values();

if (p_38431_ < 0 || p_38431_ >= aboat$type.length) {

p_38431_ = 0;


return aboat$type[p_38431_]; } } }


Thats all I got in this class

Edited by LB2
Link to comment
Share on other sites

8 hours ago, ChampionAsh5357 said:

Ok, what are you doing with it? Where's the renderer and model? Have you registered an entity type? An entity needs those things to be able to function without crashing.

I maded the Boat and the BoatItem classes and it works, but when i spawn the boat the world crashes :(

Edited by LB2
Link to comment
Share on other sites

18 hours ago, ChampionAsh5357 said:

I will repeat the same thing again: Where's the renderer and model? Have you registered an entity type? An entity needs those things to be able to function without crashing.

I registered the Boat and Chest Boat Classes and I registered the entity type and the renderer

Also i have an error when I spawn the boat, the world just crashes.

(Caused by: java.lang.IllegalStateException: Registry is already frozen)

Edited by LB2
Link to comment
Share on other sites

On 5/16/2023 at 6:28 PM, ChampionAsh5357 said:

How are you registering the boat? Because that suggests you're trying to register the boat when it spawns, and not during the registry portion.

I just registered the entity type

Thats the class:

public class ModEntityTypes extends EntityType{

private static final Logger LOGGER = LogUtils.getLogger();

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

public static final EntityType<ModBoat> MOD_BOAT = register("mod_boat", ModEntityTypes.Builder.<ModBoat>of(ModBoat::new, MobCategory.MISC).sized(1.375F, 0.5625F).clientTrackingRange(10));

public static final EntityType<ModChestBoat> MOD_CHEST_BOAT = register("mod_chest_boat", ModEntityTypes.Builder.<ModChestBoat>of(ModChestBoat::new, MobCategory.MISC).sized(1.375F, 0.5625F).clientTrackingRange(10));

public ModEntityTypes(EntityFactory p_20574_, MobCategory p_20575_, boolean p_20576_, boolean p_20577_, boolean p_20578_, boolean p_20579_, ImmutableSet p_20580_, EntityDimensions p_20581_, int p_20582_, int p_20583_) { super(p_20574_, p_20575_, p_20576_, p_20577_, p_20578_, p_20579_, p_20580_, p_20581_, p_20582_, p_20583_);


private static <T extends Entity> EntityType<T> register(String p_20635_, ModEntityTypes.Builder<T> p_20636_) { return Registry.register(Registry.ENTITY_TYPE, p_20635_, p_20636_.build(p_20635_));


public static void register(IEventBus eventBus) { MOD_ENTITY_TYPES.register(eventBus);



Link to comment
Share on other sites


or https://forge.gemwire.uk/wiki/Registration#DeferredRegister


You can't register objects directly with the registries, except during the RegisterEvent when the registries are unfrozen.

You are trying to do it during classloading/static initialisation which occurs at an "unknown time", almost certainly when the registries are frozen.

A RegistryObject (which is the recommended mechanism) will do the registration for you at the correct time.


In future if you want help, put a minimal project on github that reproduces your problem so we can see everything you are doing.

Posting badly formatted and incomplete code in the forums will likely just mean your question gets ignored. Unless it is obvious what the problem is from what little information you post.

Edited by warjort


If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

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.

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.


  • Create New...

Important Information

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