Closed 5stigma closed 11 months ago
Do you mean that you spawned a golem in jungle and then it crashed? What were the conditions?
The jungle golem can be picked up and used as a gun, it shoots cocoa bullets but when it collides with an enemy, it crashes.
What mods do you have installed except for vampire's delight and Plenty of golems?
pfff, like 600 more mods, and among them, optimization mods, It was fixed with Neruina Mod but annoying messages appear
Oh, ok, I'll look what may cause the crush, the crash report looks quite weird
Yes, It must be one of the optimization mods, thanks to one who told me which ones were possibly responsible for the crash, I was able to know that it was this mod that caused it
It looks like it tries to use vampire bite enchantment on cocoa bullet or something like that.
yes, I noticed that in the report, but I couldn't figure out why it did it, and I suspect it may happen with more similar entities.
I will try some things and combinations of mods that I think may be responsible and if I find something I will report it to you.
Yes. is VampiresDelight, I have isolated the mods and I confirm that it is between the 2 mods
@TheGridExpert you can optimize the method from https://github.com/TheGridExpert/VampiresDelight/blob/93ac0134a47f160c235a2869885b93c9930df8fe/src/main/java/net/grid/vampiresdelight/common/item/enchantment/VampireBiteEnchantment.java#L33-L43
to
@SubscribeEvent
public static void onVampireBite(LivingHurtEvent event) {
if (event.getSource().getEntity() instanceof Player player) {
ItemStack weapon = player.getMainHandItem();
int enchantmentLevel = EnchantmentHelper.getItemEnchantmentLevel(VDEnchantments.VAMPIRE_BITE.get(), weapon);
Level level = event.getEntity().getCommandSenderWorld();
if (!level.isClientSide) {
healFromDamage(player, enchantmentLevel, event.getAmount());
}
}
}
That way your code looks a little more fancy and you do not manually cast the Entity to LivingEntity.
And a piece of advice for the future.
You should only cast objects, if you either make an instanceof
check or if you are 100% sure that the cast will be successful. For your own code and APIs that might be ok, like in Vampirism we can safely cast IVampirePlayer
to VampirePlayer
without checking, but if you work with Minecraft, Forge or other APIs you should always assume that the return type of a methods or attribute only guarantees you that you will get the type it specifies. Vanilla Minecraft might give you a specific subclass of the type for all their use cases, but other mods might break it.
Thank you. I'll change it in the next update
crash-2023-12-18_03.16.47-server.txt
1.- Used jungle golem 2.- Crash