Posted April 8, 20205 yr 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 April 8, 20205 yr by the_infamous_1
April 9, 20205 yr 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.
April 9, 20205 yr Author 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 April 9, 20205 yr by the_infamous_1
April 9, 20205 yr 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.
April 9, 20205 yr Author 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 April 9, 20205 yr by the_infamous_1
April 9, 20205 yr 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.
April 9, 20205 yr Author 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
April 9, 20205 yr 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.
April 9, 20205 yr Author Gonna give it try, but quick question: 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? Edited April 9, 20205 yr by the_infamous_1
April 9, 20205 yr 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.
April 9, 20205 yr Author 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 April 9, 20205 yr by the_infamous_1
April 9, 20205 yr 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.
April 9, 20205 yr Author 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?
April 9, 20205 yr 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.
April 9, 20205 yr Author 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 April 9, 20205 yr by the_infamous_1
April 9, 20205 yr Author Okay so logging zombie.toString (event.getEntity.toString) works logging event.getWorld.toString works logging event.getWorld.getDifficultyForLocation(zombie.getPosition).toString does not work it seems Edited April 9, 20205 yr by the_infamous_1
April 9, 20205 yr Author 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 April 9, 20205 yr by the_infamous_1
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.