Electrodynamics

Electrodynamics

503k Downloads

Crash when hurting fake player entity

twothe opened this issue ยท 2 comments

commented

When a player on my server hit an Ars Nouveau Decoy with a weapon the server went into a crash loop:

Caused by: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
        at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) ~[?:?]
        at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) ~[?:?]
        at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) ~[?:?]
        at java.util.Objects.checkIndex(Objects.java:359) ~[?:?]
        at java.util.ArrayList.get(ArrayList.java:427) ~[?:?]
        at electrodynamics.common.event.PlayerHandler.compareArmor(PlayerHandler.java:68) ~[Electrodynamics-1.18.2-0.6.3-10.jar%2389!/:1.18.2-0.6.3-10]
        at electrodynamics.common.event.PlayerHandler.takeDamageWithArmor(PlayerHandler.java:55) ~[Electrodynamics-1.18.2-0.6.3-10.jar%2389!/:1.18.2-0.6.3-10]
        at net.minecraftforge.eventbus.ASMEventHandler_524_PlayerHandler_takeDamageWithArmor_LivingHurtEvent.invoke(.dynamic) ~[?:?]
        at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) ~[eventbus-5.0.3.jar%232!/:?]
        at net.minecraftforge.eventbus.EventBus.post(EventBus.java:302) ~[eventbus-5.0.3.jar%232!/:?]
        at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) ~[eventbus-5.0.3.jar%232!/:?]
        at net.minecraftforge.common.ForgeHooks.onLivingHurt(ForgeHooks.java:320) ~[forge-1.18.2-40.1.54-universal.jar%23220!/:?]
        at net.minecraft.world.entity.LivingEntity.m_6475_(LivingEntity.java:1545) ~[server-1.18.2-20220404.173914-srg.jar%23215!/:?]
        at net.minecraft.world.entity.LivingEntity.m_6469_(LivingEntity.java:1049) ~[server-1.18.2-20220404.173914-srg.jar%23215!/:?]
        at net.minecraft.world.entity.Entity.m_6075_(Entity.java:450) ~[server-1.18.2-20220404.173914-srg.jar%23215!/:?]
        at net.minecraft.world.entity.LivingEntity.m_6075_(LivingEntity.java:321) ~[server-1.18.2-20220404.173914-srg.jar%23215!/:?]
        at net.minecraft.world.entity.Mob.m_6075_(Mob.java:241) ~[server-1.18.2-20220404.173914-srg.jar%23215!/:?]
        at net.minecraft.world.entity.Entity.m_8119_(Entity.java:413) ~[server-1.18.2-20220404.173914-srg.jar%23215!/:?]
        at net.minecraft.world.entity.LivingEntity.m_8119_(LivingEntity.java:2215) ~[server-1.18.2-20220404.173914-srg.jar%23215!/:?]
        at net.minecraft.world.entity.Mob.m_8119_(Mob.java:307) ~[server-1.18.2-20220404.173914-srg.jar%23215!/:?]
        at com.hollingsworth.arsnouveau.common.entity.EntityDummy.m_8119_(EntityDummy.java:80) ~[ars_nouveau-1.18.2-2.6.3.jar%2352!/:2.6.3]
        at net.minecraft.server.level.ServerLevel.m_8647_(ServerLevel.java:652) ~[server-1.18.2-20220404.173914-srg.jar%23215!/:?]
        at net.minecraft.world.level.Level.m_46653_(Level.java:486) ~[server-1.18.2-20220404.173914-srg.jar%23215!/:?]
        at net.minecraft.server.level.ServerLevel.m_184063_(ServerLevel.java:319) ~[server-1.18.2-20220404.173914-srg.jar%23215!/:?]
        at net.minecraft.world.level.entity.EntityTickList.m_156910_(EntityTickList.java:54) ~[server-1.18.2-20220404.173914-srg.jar%23215!/:?]
        at net.minecraft.server.level.ServerLevel.m_8793_(ServerLevel.java:299) ~[server-1.18.2-20220404.173914-srg.jar%23215!/:?]
        at net.minecraft.server.MinecraftServer.m_5703_(MinecraftServer.java:902) ~[server-1.18.2-20220404.173914-srg.jar%23215!/:?]
        ... 5 more
commented

return ItemStack.isSameIgnoreDurability(set1.get(0), set2[3]) && ItemStack.isSameIgnoreDurability(set1.get(1), set2[2]) && ItemStack.isSameIgnoreDurability(set1.get(2), set2[1]) && ItemStack.isSameIgnoreDurability(set1.get(3), set2[0]);

The issues seems to be that the size of the given array is not checked.

commented

Fixed it now :)