Jump to content

[1.14.4] Can't change Zombie Pigmen & Wither Skeleton's swords


the_infamous_1

Recommended Posts

I use LivingSpawnEvent.SpecialSpawn to make all armor-able mobs spawn with my mod's armor instead of vanilla armor, same for weapons. The code works perfectly fine for anything that is not a Zombie Pigman or a Wither Skeleton. The current issue with these two mobs is that they will correctly have the modded swords if I spawn them via spawn egg or if they enter the Overworld via portal, but they will not spawn with modded swords in the Nether. I can check via log if a mob has recently spawned naturally and was re-armed in the Nether during the re-arming event and it will say something like "Wither Skeleton at XYZ spawned with Mod Sword" and when I teleport to that mob it will have its vanilla sword and not the modded sword.

Another issue is that overworld mobs will rarely ignore the re-arming event and spawn with vanilla armor, which I don't understand.

Edited by the_infamous_1
Link to comment
Share on other sites

2 hours ago, the_infamous_1 said:

Another issue is that overworld mobs will rarely ignore the re-arming event and spawn with vanilla armor, which I don't understand.

It's hard to see what's wrong when one can't see the thing that is going wrong. Post your code.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Class where LivingSpawnEvent.SpecialSpawn is used: https://pastebin.com/08CRXyAm

Zombie Pigman Utilities: https://pastebin.com/F8HEa8qg
Wither Skeleton Utilities: https://pastebin.com/ximpsPcj

 

Note that for the pigmen and wither skeletons I don't use their armor methods, only setHeldItem and setEnchantment.

Edited by the_infamous_1
Link to comment
Share on other sites

4 minutes ago, the_infamous_1 said:

Note that for the pigmen and wither skeletons I don't use their armor methods, only the held item ones.

The equipment for entities is put on the Entity after LivingSpawnEvent.SpecialSpawn is called. Therefore it overrides yours. You should use EntityJoinWorldEvent instead.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

I figured that was the case. If I use EntityJoinWorldEvent while keeping everything the same, while it does work 100% for new worlds, I can't load old worlds (stuck at 100% loading screen) and I believe I also can't load back into the new worlds that were just created with EntityJoinWorldEvent (same stuck at 100% issue).

Edited by the_infamous_1
Link to comment
Share on other sites

1 minute ago, the_infamous_1 said:

(same stuck at 100% issue).

Set a breakpoint in your event and see what is happening.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Just now, the_infamous_1 said:

I hate to sound like a noob but how do I run with a breakpoint set (I know how to set one at least) to see what is happening? I'm in IntelliJ

This is the best I can give you for I do not use IntelliJ.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

1 minute ago, the_infamous_1 said:

Would all those for loops I have to clear a mob's equipment in the event class potentially cause runtime issues due to having to run the loop for each spawned mob?

Probably. Another problem with using EntityJoinWorldEvent is the equipment on an Entity loaded from disk will have it's equipment changed.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

So while debugging I actually ran a previously created world and actually loaded in (maybe I'm just impatient?) but yeah the for loops were executing constantly and I can see why it would slow down world loading.

When you say an Entity loaded from disk will have it's equipment changed, you mean when I go back into an old world, mobs with modded armor will go through the arming process again? If that's the case then should I just check to see if a mob is at least wearing a single Armor item that is from my mod (so, just check if the boots are modded since that seems to appear for all armored mobs). Likewise, for the Wither Skeletons and Pigmen, just check to see if their mainhand is already modded.

Edited by the_infamous_1
Link to comment
Share on other sites

10 minutes ago, the_infamous_1 said:

If that's the case then should I just check to see if a mob is at least wearing a single Armor item that is from my mod (so, just check if the boots are modded since that seems to appear for all armored mobs). Likewise, for the Wither Skeletons and Pigmen, just check to see if their mainhand is already modded.

That will work if the Entity is guaranteed to have been given your equipment. However, that is not the case. What if another mod changes the equipment or your method determines that it doesn't get an item. You should instead attach a capability to the Entity to check if you have already tried to add your equipment.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Just now, the_infamous_1 said:

I don't exactly know how to do that. Would you mind pointing me in the right direction, if not outright giving me an example?

Here is the forge documentation on Capabilities they are somewhat tricky to learn, but once you know what you need to do you'll be kicking yourself later.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

So I noticed this when debugging and attempting to load a world and failing to do so (before, when I said it was letting me load in, I didn't actually change SpecialSpawn to EntityJoinWorldEvent yet...yeah lol):

I can print to the logger zombie.toString() and get the ZombieEntity from the EntityJoinWorldEvent. I then try to print to the logger event.getWorld().getDifficultyForLocation(zombie.getPosition()).toString(), followed by a print to logger statement of ("Got past the previous line). Neither of those lines print while the world is initially trying to load. I assume that I should not be messing with getting the world or the difficulty if the actual world hasn't even been loaded?

Edited by the_infamous_1
Link to comment
Share on other sites

So, disabling anything in my event class involving local difficulty lets the world actually load, and mobs do spawn with at least their new modded weapons (including Pigmen & Wither Skeletons!).

So I guess I have to re-implement the arming system to work without difficulty as I just ripped it right out of vanilla code, vanilla code is very finnicky.

Edited by the_infamous_1
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

    • Slot deposit 3000 adalah situs slot deposit 3000 via dana yang super gacor dimana para pemain dijamin garansi wd hari ini juga hanya dengan modal receh berupa deposit sebesar 3000 baik via dana, ovo, gopay maupun linkaja untuk para pemain pengguna e-wallet di seluruh Indonesia.   DAFTAR & LOGIN AKUN PRO SLOT DEPOSIT 3000 ⭐⭐⭐ KLIK DISINI ⭐⭐⭐  
    • OLXTOTO: Menikmati Sensasi Bermain Togel dan Slot dengan Aman dan Mengasyikkan Dunia perjudian daring terus berkembang dengan cepat, dan salah satu situs yang telah menonjol dalam pasar adalah OLXTOTO. Sebagai platform resmi untuk permainan togel dan slot, OLXTOTO telah memenangkan kepercayaan banyak pemain dengan menyediakan pengalaman bermain yang aman, adil, dan mengasyikkan. DAFTAR OLXTOTO DISINI <a href="https://imgbb.com/"><img src="https://i.ibb.co/GnjSVpx/daftar1-480x480.webp" alt="daftar1-480x480" border="0" /></a> Keamanan Sebagai Prioritas Utama Salah satu aspek utama yang membuat OLXTOTO begitu menonjol adalah komitmennya terhadap keamanan pemain. Dengan menggunakan teknologi enkripsi terkini, situs ini memastikan bahwa semua informasi pribadi dan keuangan para pemain tetap aman dan terlindungi dari akses yang tidak sah. Beragam Permainan yang Menarik Di OLXTOTO, pemain dapat menemukan beragam permainan yang menarik untuk dinikmati. Mulai dari permainan klasik seperti togel hingga slot modern dengan fitur-fitur inovatif, ada sesuatu untuk setiap selera dan preferensi. Grafik yang memukau dan efek suara yang mengagumkan menambah keseruan setiap putaran. Peluang Menang yang Tinggi Salah satu hal yang paling menarik bagi para pemain adalah peluang menang yang tinggi yang ditawarkan oleh OLXTOTO. Dengan pembayaran yang adil dan peluang yang setara bagi semua pemain, setiap taruhan memberikan kesempatan nyata untuk memenangkan hadiah besar. Layanan Pelanggan yang Responsif Tim layanan pelanggan OLXTOTO siap membantu para pemain dengan setiap pertanyaan atau masalah yang mereka hadapi. Dengan layanan yang ramah dan responsif, pemain dapat yakin bahwa mereka akan mendapatkan bantuan yang mereka butuhkan dengan cepat dan efisien. Kesimpulan OLXTOTO telah membuktikan dirinya sebagai salah satu situs terbaik untuk penggemar togel dan slot online. Dengan fokus pada keamanan, beragam permainan yang menarik, peluang menang yang tinggi, dan layanan pelanggan yang luar biasa, tidak mengherankan bahwa situs ini telah menjadi pilihan utama bagi banyak pemain. Jadi, jika Anda mencari pengalaman bermain yang aman, adil, dan mengasyikkan, jangan ragu untuk bergabung dengan OLXTOTO hari ini dan rasakan sensasi kemenangan!
    • Slot deposit dana adalah situs slot deposit dana yang juga menerima dari e-wallet lain seperti deposit via dana, ovo, gopay & linkaja terlengkap saat ini, sehingga para pemain yang tidak memiliki rekening bank lokal bisa tetap bermain slot dan terbantu dengan adanya fitur tersebut.   DAFTAR & LOGIN AKUN PRO SLOT DEPOSIT DANA ⭐⭐⭐ KLIK DISINI ⭐⭐⭐  
    • Slot deposit dana adalah situs slot deposit dana minimal 5000 yang dijamin garansi super gacor dan gampang menang, dimana para pemain yang tidak memiliki rekening bank lokal tetap dalam bermain slot dengan melakukan deposit dana serta e-wallet lainnya seperti ovo, gopay maupun linkaja lengkap. Agar para pecinta slot di seluruh Indonesia tetap dapat menikmati permainan tanpa halangan apapun khususnya metode deposit, dimana ketersediaan cara deposit saat ini yang lebih beragam tentunya sangat membantu para pecinta slot.   DAFTAR & LOGIN AKUN PRO SLOT DEPOSIT DANA ⭐⭐⭐ KLIK DISINI ⭐⭐⭐  
    • Slot deposit pulsa adalah situs slot deposit pulsa tanpa potongan apapun yang dijamin garansi terpercaya, dimana kamu bisa bermain slot dengan melakukan deposit pulsa dan tanpa dikenakan potongan apapun sehingga dana yang masuk ke dalam akun akan 100% utuh. Proses penarikan dana juga dijamin gampang dan tidak sulit sehingga kamu tidak perlu khawatir akan kemenangan yang akan kamu peroleh dengan sangat mudah jika bermain disini.   DAFTAR & LOGIN AKUN PRO SLOT DEPOSIT PULSA TANPA POTONGAN ⭐⭐⭐ KLIK DISINI ⭐⭐⭐  
  • Topics

×
×
  • Create New...

Important Information

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