Jump to content

[1.14.2] Entity Type Registry


Lycanite

Recommended Posts

I understand Forge for 1.14 is still beta but I've searched around a lot and can't find how far along it is for modded entities so figured I'd ask about this problem I'm having here, if anyone has modded entities going in 1.14.2 perhaps you can show me where I'm going wrong, etc. If it is just a Forge beta thing then that's all good, I know I can just chill for a bit until things are ready.

 

So I register my Entity Types like this: Gitlab Link

	@SubscribeEvent
	public void registerEntities(RegistryEvent.Register<EntityType<?>> event) {
		LycanitesMobs.logDebug("Creature", "Forge registering all " + this.creatures.size() + " creatures...");
		for(CreatureInfo creatureInfo : this.creatures.values()) {
			event.getRegistry().register(creatureInfo.getEntityType());
		}
	}

 

I build them like this: Gitlab Link

	public EntityType getEntityType() {
		if(this.entityType == null) {
			EntityType.Builder entityTypeBuilder = EntityType.Builder.create(EntityFactory.getInstance(), this.peaceful ? EntityClassification.CREATURE : EntityClassification.MONSTER);
			//entityTypeBuilder.setCustomClientFactory(EntityFactory.getInstance().createOnClientFunction); Client Factory never called.
			entityTypeBuilder.setTrackingRange(this.isBoss() ? 32 : 10);
			entityTypeBuilder.setUpdateInterval(3);
			entityTypeBuilder.setShouldReceiveVelocityUpdates(false);
			entityTypeBuilder.size((float)this.width, (float)this.height);
			entityTypeBuilder.disableSerialization();
			this.entityType = entityTypeBuilder.build(this.getName());
			this.entityType.setRegistryName(this.modInfo.modid, this.getName());
			EntityFactory.getInstance().addEntityType(this.entityType, this.entityClass);
		}
		return this.entityType;
	}

 

My factory's create function is this: Gitlab Link

	@Override
	public Entity create(EntityType entityType, World world) {
		LycanitesMobs.logDebug("", "Spawning entity: " + this.entityTypeConstrcutorMap.get(entityType).toString() + " Type: " + entityType.getName() + " Classification: " + entityType.getClassification()); // Name always shows pig!
		Class<? extends Entity> entityConstrcutor = this.entityTypeConstrcutorMap.get(entityType);

		try {
			Entity entity = entityConstrcutor.newInstance(entityType, world);
			world.addEntity(entity);
			return entity;
		} catch (Exception e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}

		return null;
	}

 

The problem I'm having is that on the client they always spawn as EntityPigs and immediately trigger a crash because the entity Data Manager is casting a Byte to a Bool, I'm assuming this is because on the server side the correct entity has spawned with a different set of Data manager keys:

java.lang.ClassCastException: java.lang.Byte cannot be cast to java.lang.Boolean
	at net.minecraft.entity.AgeableEntity.getGrowingAge(AgeableEntity.java:71) ~[forge-1.14.2-26.0.33_mapped_snapshot_20190618-1.14.2-recomp.jar:?] {}
	at net.minecraft.entity.passive.AnimalEntity.livingTick(AnimalEntity.java:49) ~[forge-1.14.2-26.0.33_mapped_snapshot_20190618-1.14.2-recomp.jar:?] {}
	at net.minecraft.entity.LivingEntity.tick(LivingEntity.java:2178) ~[forge-1.14.2-26.0.33_mapped_snapshot_20190618-1.14.2-recomp.jar:?] {}
	at net.minecraft.entity.MobEntity.tick(MobEntity.java:308) ~[forge-1.14.2-26.0.33_mapped_snapshot_20190618-1.14.2-recomp.jar:?] {pl:accesstransformer:B}
	at net.minecraft.client.world.ClientWorld.func_217418_a(ClientWorld.java:167) ~[forge-1.14.2-26.0.33_mapped_snapshot_20190618-1.14.2-recomp.jar:?] {pl:accesstransformer:B,pl:runtimedistcleaner:A}

 

Looking further into this, on both the client and server, when logging what's being registered, if I call getName or TranslationKey on the EntityType I always get back entity.minecraft.pig. Here's an example that is logged from here (which is called from getEntityType() posed above):

[13:14:06.710] [modloading-worker-9/DEBUG] [co.ly.LycanitesMobs/]: [LycanitesMobs] [Debug] [] Adding entity: class com.lycanitesmobs.core.entity.creature.EntityArisaur Type: TranslatableComponent{key='entity.minecraft.pig', args=[], siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}} Classification: MONSTER

Here the entity class being registered is correct and each EntityType for each entity I'm registering is definitely unique, but they call still translate as a pig.

 

I can also confirm that my Entity Factory is working correctly server side but it is never called client side, I've also tried using the Custom Client Factory, but it is never called by the client as it seems the client is always treating the EntityType as the default vanilla PIG EntityType instance.

 

Also here is an example of one of my DataManager entries:

protected static final DataParameter<Byte> TARGET = EntityDataManager.createKey(EntityCreatureBase.class, DataSerializers.BYTE);

I've made sure that I always provide the correct entity class when creating a key and I'm also assuming that this is the byte sent from the server that the client is trying to cast into a boolean as it is the first DataParameter I register for all entities in my mod.

 

The entire mod is available on Gitlab if anyone wants to look further into things.

Edited by Lycanite
Link to comment
Share on other sites

  • It's currently done via reflection because each entity is defined via a JSON file which provides the class as a string, this is just temporary though, as I later plan on changing this so that I just have one generic entity class instead that is based on the json, but it's going to take a while for me to create AI goals, control behavior, etc all from JSON definitions but it's my end goal there.
  • I've fixed the factory, when first updating from 1.12.2 I thought the factory had to spawn and forgot to remove that, so that is corrected now.
  • For the exception, this is just temporary and will go away once I finish the generic entity class in the future, for now I'm just trying to get entities showing up in the world, I can return a fallback entity instead of null, but getConstructor requires a try catch, what I'll do instead is pre load the constructor instance when the json is being parsed at startup, that should solve performance and eliminates the try catch. Either way, all entity classes involved always have that constructor available so that exception will never show up and shouldn't relate to the problem, but thanks for the feedback.
Link to comment
Share on other sites

52 minutes ago, diesieben07 said:

You never register your entities (or any other registry entries), because you register your event handlers for RegistryEvent.Register in FMLCommonSetupEvent. Registry events fire before FMLCommonSetupEvent, mostly to discourage making registry entries config dependent. You should always register all of your registry entries, regardless of configuration. Do not create registry entries dynamically.

Ah I see, I've moved my event registration into the main mod class' constructor, but the same issue is happening. Before moving them I was still getting log output from my event listeners though.

 

I've also tested with using @Mod.EventBusSubscriber directly on the class that registers entities with the same issue also.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • LINK DAFTAR : KLIK DISINI LINK DAFTAR : KLIK DISINI   Slot SHOPEEPAY adalah situs slot deposit SHOPEEPAY Ribu paling gacor di indonesia pada tahun 2023. Situs slot SHOPEEPAY kini menyediakan layanan deposit pakai aplikasi shopee yang amat gacor sampai detik ini. MAXWINBET77 Situs slot SHOPEEPAY saat ini menggunakan layanan deposit dari e-wallet shopee adalah alat pembayaran dempet digital lewat SHOPEEPAY. Slot SHOPEEPAY saat ini menjadi situs slot ternama dengan banyak nya keunggulan di dalam situs slot SHOPEEPAY ini. Slot deposit SHOPEEPAY hadir untuk menyedia kan sarana deposit paling termurah di indonesia. Deposit slot SHOPEEPAY hanya dengan modal 5000 Ribu saja kamu sudah bisa mainkan semua jenis game yang ada di dalam situs slot SHOPEEPAY Ribu seperti gates of olympus, mahjong ways 2, Legacy of Kong Maxways dan Koi Gate yang saat ini banyak sekali di cari orang karna tingkatan kemenangan nya paling besar dan mudah jackpot. TRIK DAN TRIK BERMAIN PALING JITU / SLOT DEPOSIT SHOPEEPAY Pilih Game Slot Gacor Yang Sesuai Dengan Preferensi Dan Anggaran Anda Ada banyak tipe game slot gacor yang bisa Anda pilih, mulai dari yang bertema klasik, petualangan, mitologi, sampai film. Pilihlah game slot gacor yang menarik bagi anda dan cocok dengan volatilitas dan RTP yang anda inginkan. Volatilitas yakni tingkat risiko dan varians dalam permainan, sedangkan RTP yakni prosentase pengembalian kepada pemain. Pilihlah game slot gacor dengan volatilitas dan RTP yang pantas dengan anggaran dan tujuan anda. Manajemen Bankroll Yang Baik Bankroll ialah jumlah uang yang Anda siapkan untuk bermain slot gacor. Penting bagi anda untuk mengelola bankroll anda dengan bagus supaya tidak kehabisan uang atau terjebak dalam kecanduan judi. Tentukan jumlah maksimal yang mau anda pertaruhkan per sesi, per hari, atau per minggu, dan jangan melebihi batas tersebut. Juga, tentukan jumlah kemenangan yang mau anda capai atau jumlah kerugian yang bisa anda terima, dan stop bermain dikala mencapai salah satu dari keduanya. Manfaatkan Bonus Dan Promosi Situs slot gacor Neobank menawarkan bonus dan promosi menarik kepada para pemainnya, seperti bonus new member, bonus deposit, bonus cashback, bonus referral, bonus turnover, jackpot progresif, turnamen, freebet, dan lainnya. Manfaatkan bonus dan promosi ini untuk meningkatkan modal dan peluang kemenangan anda. Tetapi, pastikan juga untuk membaca syarat dan ketentuan yang berlaku agar tidak terjebak dalam prasyarat taruhan atau batasan penarikan yang tidak menguntungkan. Pelajari Paytable Dan Fitur Game Sebelum bermain slot gacor Neobank, pastikan Anda mempelajari paytable dan fitur game. Paytable yaitu tabel yang menonjolkan skor masing masing simbol dan kombinasi kemenangan dalam game. Fitur game yaitu fitur tambahan yang bisa meningkatkan kesempatan kemenangan Anda, seperti wild, scatter, cuma cuma spins, bonus games, multiplier, dsb. Dengan mempelajari paytable dan fitur game, Anda bisa mengenal simbol mana yang semestinya Anda targetkan ketika bermain.
    • Link Daftar : KLIK DISINI  Link Login : KLIK DISINI  Link RTP   : KLIK DISINI  Link Gacor Slot Dana   : KLIK DISINI slot deposit dana 5000 ribu via dana adalah permainan slot dana gacor dengan menyediakan slot server thailand deposit dana. dan slot deposit dana adalah slot terbesar di thailand. anda cukup daftar disini dan mainkan disini slot deposit 5000 ribu via dana sudah dipastikan dengan deposit dana akan membuat akun anda menjadi akun special. situs deposit dana adalah situs yang terpercaya dan terakurat. Slot dana merupakan situs slot deposit dana yang sangat trending dan sangat dikenal luas di masyarakat. dengan adanya MAXWINBET77 anda bisa mendapatkan keuntungan besar setiap hari tanpa adanya potongan  yang pastinya menguntungkan bagi anda. situs slot dana  maxwinbet77 adalah situs slot dana terbaik 2024 dan dijamin mudah maxwin. PERMAINAN YANG ADA DI SLOT DANA MAXWINBET77: - TOGEL 4D - SLOT ONLINE - LIVE CASINO - SPORTSBOOK - ARCADE TEMBAK IKAN - SABUNG AYAM Saat Ini Slot Dana Maxwinbet77 Menyediakan Bonus Berupa : - Bonus New Member - Bonus Deposit Harian - Bonus Cashback - Bonus 2D TERBALIK - Bonus Prize 2 & Prize 3 - Bonus Refferal DAFATR DISINI
    • LINK DAFTAR : KLIK DISINI LINK DAFTAR : KLIK DISINI   Slot seabank meruapakan salah satu situs slot paling gacor deposit seabank 100% mudah maxwin, hari ini situs slot seabank meghadirkan permainan slot dengan kemudahan bergabung hanya dengan menggunakan aplikasi Seabank langsung bisa join dengan bandar slot Seabank terbaik dan terpercaya no.1 di indonesia. Slot Seabank resmi di daftar situs slot deposit pakai Seabank 5000 Gampang Maxwin dimana aplikasi Seabank tersebut telah sanggat membantu para bosku untuk bermain slot online deposit via Seabank saat ini slot Seabank ini membantu dalam mempermudah transaksi disaat bosku ingin deposit melakukan pembayaran. kini orang orang ingin bermian judi online khusus nya games slot tidak perlu khawatir lagi apabila tidak memilikui saldo di ATM, sebab dengan adanya aplikasi Seabank sudah memberikan dampak signifikan buat perjudian di indonesia. Selain slot pakai Seabank, terdapat beberapa aplikasi e-wallet yang dapat di gunakan untuk bertansaksi antara lain, slot deposit 5000 Seabank, slot dana, slot ovo, slot pulsa tanpa potongan, dan slot shopeepay mudah menang bisa bosku pakai untuk setoran Seabank resmi terbaru. intinya slot online deposit Seabank memberikan jamianan kemudahan saat main games slot gacor uang asli terbaik di indonesia bos.
    • LINK DAFTAR : KLIK DISINI LINK DAFTAR : KLIK DISINI   Slot deposit bank bsi merupakan salah satu situs slot gacor deposit bank bsi 24 jam mudah maxwin tanpa batas. hari ini slot deposit bank bsi menawarkan bonus terbesar untuk player yang sudah bergabung di situs slot bank bsi ini, dengan ada nya slot bank bsi sanget mempermudah player untuk melakukan transaksi deposit dengan bank bsi. Sebagai Situs Slot Deposit Bank Bsi meyediakan banyak permainan seperti slot online, live casino, sabung ayam, tembak ikan, sportbook semua game tersebuat sangat aman dan terpercaya. Beramin slot bank bsi sangat mudah hanya dengan niminal deposit 5000 ribu saja anda sudah bisa bermain di semua game yang sudah di sediakan oleh situs slot bank bsi. Slot bank bsi adalah saranan untuk Pemain yang mencari pengalaman bermain slot gacor sekarang dapat menemukan metode pembayaran beragam di berbagai situs slot gacor yang tersebar luas di seluruh negeri. Munculnya situs Slot Bank BSI, kini para pemain dapat menikmati kemudahan dan kenyamanan dalam melakukan transaksi pembayaran. Bahkan memungkinkan pemain untuk fokus sepenuhnya pada permainan yang mereka nikmati sepanjang waktu. Ini adalah langkah penting dalam memperluas aksesibilitas judi slot online di Indonesia dan memberikan pengalaman bermain yang lebih baik kepada para pecinta slot gacor.    
    • Sometimes love could be the worst experience. you get to love and trust your partner only to feel regret over it. i have been married for 7 years now and i found some sudden change in my partner attitude, i tried talking about it but he complains i'm nagging a lot . i tried to ignore his attitude but it became unbearable so i was advised to hire a hacker to help me gain access to his phone so i had know if he is cheating or not so i was introduced to [ Remote spy hacker @ g m ail . c o m ] and this expert helped me gain access to his phone without his notice. i got to see his messages, photos, call recordings and many more . Now i can see his cheating and that's the reason for the attitude all along.
  • Topics

×
×
  • Create New...

Important Information

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