flammpfeil / SlashBlade

1.14.4 or later project ->
https://github.com/flammpfeil/SlashBlade_2
76 stars 30 forks source link

server side crash when kill/attack muiltiple mobs in one shot #55

Closed dixyes closed 6 years ago

dixyes commented 6 years ago

the crash report

----Minecraft Crash Report ----

WARNING: coremods are present:
  Inventory Tweaks Coremod (InventoryTweaks-1.63.jar)
Contact their authors BEFORE contacting forge

// Oh - I know what I did wrong!

Time: 18-2-22 下午4:27
Description: Ticking entity

java.lang.ClassCastException: net.minecraft.item.ItemAir cannot be cast to mods.flammpfeil.slashblade.item.ItemSlashBlade
    at mods.flammpfeil.slashblade.entity.EntityRapidSlashManager.func_70071_h_(EntityRapidSlashManager.java:234)
    at net.minecraft.world.World.func_72866_a(World.java:1990)
    at net.minecraft.world.WorldServer.func_72866_a(WorldServer.java:831)
    at net.minecraft.world.World.func_72870_g(World.java:1952)
    at net.minecraft.world.World.func_72939_s(World.java:1756)
    at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:612)
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:765)
    at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:396)
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:666)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:524)
    at java.lang.Thread.run(Thread.java:748)

A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Server thread
Stacktrace:
    at mods.flammpfeil.slashblade.entity.EntityRapidSlashManager.func_70071_h_(EntityRapidSlashManager.java:234)
    at net.minecraft.world.World.func_72866_a(World.java:1990)
    at net.minecraft.world.WorldServer.func_72866_a(WorldServer.java:831)
    at net.minecraft.world.World.func_72870_g(World.java:1952)

-- Entity being ticked --
Details:
    Entity Type: flammpfeil.slashblade:rapidslashmanager (mods.flammpfeil.slashblade.entity.EntityRapidSlashManager)
    Entity ID: 26163
    Entity Name: entity.RapidSlashManager.name
    Entity's Exact location: -233.75, 67.00, 75.66
    Entity's Block location: World: (-234,67,75), Chunk: (at 6,4,11 in -15,4; contains blocks -240,0,64 to -225,255,79), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
    Entity's Momentum: 0.00, 0.00, 0.00
    Entity's Passengers: []
    Entity's Vehicle: ~~ERROR~~ NullPointerException: null
Stacktrace:
    at net.minecraft.world.World.func_72939_s(World.java:1756)
    at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:612)

-- Affected level --
Details:
    Level name: world
    All players: 1 total; [EntityPlayerMP['dixyes'/24941, l='world', x=-227.26, y=67.00, z=75.44]]
    Chunk stats: ServerChunkCache: 505 Drop: 0
    Level seed: -5482776319844758788
    Level generator: ID 00 - default, ver 1. Features enabled: true
    Level generator options: 
    Level spawn location: World: (-132,64,116), Chunk: (at 12,4,4 in -9,7; contains blocks -144,0,112 to -129,255,127), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
    Level time: 411853 game time, 44221 day time
    Level dimension: 0
    Level storage version: 0x04ABD - Anvil
    Level weather: Rain time: 4609 (now: true), thunder time: 89017 (now: false)
    Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false
Stacktrace:
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:765)
    at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:396)
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:666)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:524)
    at java.lang.Thread.run(Thread.java:748)

-- System Details --
Details:
    Minecraft Version: 1.12.2
    Operating System: Windows 10 (amd64) version 10.0
    Java Version: 1.8.0_131, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 3719810392 bytes (3547 MB) / 4260102144 bytes (4062 MB) up to 4260102144 bytes (4062 MB)
    JVM Flags: 3 total; -Xmx4g -Xms4g -Xincgc
    IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94
    FML: MCP 9.42 Powered by Forge 14.23.2.2611 11 mods loaded, 11 mods active
    States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

    | State     | ID                    | Version                  | Source                                      | Signature                                |
    |:--------- |:--------------------- |:------------------------ |:------------------------------------------- |:---------------------------------------- |
    | UCHIJAAAA | minecraft             | 1.12.2                   | minecraft.jar                               | None                                     |
    | UCHIJAAAA | mcp                   | 9.42                     | minecraft.jar                               | None                                     |
    | UCHIJAAAA | FML                   | 8.0.99.99                | forge-1.12.2-14.23.2.2611-universal.jar     | e3c3d50c7c986df74c645c0ac54639741c90a557 |
    | UCHIJAAAA | forge                 | 14.23.2.2611             | forge-1.12.2-14.23.2.2611-universal.jar     | e3c3d50c7c986df74c645c0ac54639741c90a557 |
    | UCHIJAAAA | jei                   | 4.8.5.147                | jei_1.12.2-4.8.5.147.jar                    | None                                     |
    | UCHIJAAAA | abyssalcraft          | 1.9.4.4                  | AbyssalCraft-1.12.2-1.9.4.4.jar             | 220f10d3a93b3ff5fbaa7434cc629d863d6751b9 |
    | UCHIJAAAA | flammpfeil.slashblade | mc1.12-r9                | SlashBlade-mc1.12-r9.jar                    | None                                     |
    | UCHIJAAAA | heartwork             | 2.0.0                    | Heartwork_V2.0.1_FIX1_MC1.12.2.jar          | None                                     |
    | UCHIJAAAA | inventorytweaks       | 1.63+release.109.220f184 | InventoryTweaks-1.63.jar                    | 55d2cd4f5f0961410bf7b91ef6c6bf00a766dcbe |
    | UCHIJAAAA | levelup2              | ${version}               | Level+Up!+2-1.1.15-1.12.jar                 | None                                     |
    | UCHIJAAAA | twilightforest        | 3.6.345                  | twilightforest-1.12.2-3.6.345-universal.jar | None                                     |

    Loaded coremods (and transformers): 
Inventory Tweaks Coremod (InventoryTweaks-1.63.jar)
  invtweaks.forge.asm.ContainerTransformer
    Profiler Position: N/A (disabled)
    Player Count: 1 / 20; [EntityPlayerMP['dixyes'/24941, l='world', x=-227.26, y=67.00, z=75.44]]
    Is Modded: Definitely; Server brand changed to 'fml,forge'
    Type: Dedicated Server (map_server.txt)

and

---- Minecraft Crash Report ----

WARNING: coremods are present:
  Inventory Tweaks Coremod (InventoryTweaks-1.63.jar)
Contact their authors BEFORE contacting forge

// My bad.

Time: 18-2-22 下午4:41
Description: Ticking entity

java.lang.ClassCastException: net.minecraft.item.ItemAir cannot be cast to mods.flammpfeil.slashblade.item.ItemSlashBlade
    at mods.flammpfeil.slashblade.entity.EntityHelmBrakerManager.func_70071_h_(EntityHelmBrakerManager.java:292)
    at net.minecraft.world.World.func_72866_a(World.java:1990)
    at net.minecraft.world.WorldServer.func_72866_a(WorldServer.java:831)
    at net.minecraft.world.World.func_72870_g(World.java:1952)
    at net.minecraft.world.World.func_72939_s(World.java:1756)
    at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:612)
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:765)
    at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:396)
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:666)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:524)
    at java.lang.Thread.run(Thread.java:748)

A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Server thread
Stacktrace:
    at mods.flammpfeil.slashblade.entity.EntityHelmBrakerManager.func_70071_h_(EntityHelmBrakerManager.java:292)
    at net.minecraft.world.World.func_72866_a(World.java:1990)
    at net.minecraft.world.WorldServer.func_72866_a(WorldServer.java:831)
    at net.minecraft.world.World.func_72870_g(World.java:1952)

-- Entity being ticked --
Details:
    Entity Type: flammpfeil.slashblade:helmbrakermanager (mods.flammpfeil.slashblade.entity.EntityHelmBrakerManager)
    Entity ID: 22474
    Entity Name: entity.HelmbrakerManager.name
    Entity's Exact location: -270.72, 40.00, 71.75
    Entity's Block location: World: (-271,40,71), Chunk: (at 1,2,7 in -17,4; contains blocks -272,0,64 to -257,255,79), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
    Entity's Momentum: 0.00, 0.00, 0.00
    Entity's Passengers: []
    Entity's Vehicle: ~~ERROR~~ NullPointerException: null
Stacktrace:
    at net.minecraft.world.World.func_72939_s(World.java:1756)
    at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:612)

-- Affected level --
Details:
    Level name: world
    All players: 1 total; [EntityPlayerMP['dixyes'/653, l='world', x=-270.46, y=39.68, z=71.58]]
    Chunk stats: ServerChunkCache: 543 Drop: 0
    Level seed: -5482776319844758788
    Level generator: ID 00 - default, ver 1. Features enabled: true
    Level generator options: 
    Level spawn location: World: (-132,64,116), Chunk: (at 12,4,4 in -9,7; contains blocks -144,0,112 to -129,255,127), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
    Level time: 427284 game time, 14379 day time
    Level dimension: 0
    Level storage version: 0x04ABD - Anvil
    Level weather: Rain time: 36685 (now: false), thunder time: 73586 (now: false)
    Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false
Stacktrace:
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:765)
    at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:396)
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:666)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:524)
    at java.lang.Thread.run(Thread.java:748)

-- System Details --
Details:
    Minecraft Version: 1.12.2
    Operating System: Windows 10 (amd64) version 10.0
    Java Version: 1.8.0_131, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 3770298352 bytes (3595 MB) / 4260102144 bytes (4062 MB) up to 4260102144 bytes (4062 MB)
    JVM Flags: 3 total; -Xmx4g -Xms4g -Xincgc
    IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94
    FML: MCP 9.42 Powered by Forge 14.23.2.2611 11 mods loaded, 11 mods active
    States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

    | State     | ID                    | Version                  | Source                                      | Signature                                |
    |:--------- |:--------------------- |:------------------------ |:------------------------------------------- |:---------------------------------------- |
    | UCHIJAAAA | minecraft             | 1.12.2                   | minecraft.jar                               | None                                     |
    | UCHIJAAAA | mcp                   | 9.42                     | minecraft.jar                               | None                                     |
    | UCHIJAAAA | FML                   | 8.0.99.99                | forge-1.12.2-14.23.2.2611-universal.jar     | e3c3d50c7c986df74c645c0ac54639741c90a557 |
    | UCHIJAAAA | forge                 | 14.23.2.2611             | forge-1.12.2-14.23.2.2611-universal.jar     | e3c3d50c7c986df74c645c0ac54639741c90a557 |
    | UCHIJAAAA | jei                   | 4.8.5.147                | jei_1.12.2-4.8.5.147.jar                    | None                                     |
    | UCHIJAAAA | abyssalcraft          | 1.9.4.4                  | AbyssalCraft-1.12.2-1.9.4.4.jar             | 220f10d3a93b3ff5fbaa7434cc629d863d6751b9 |
    | UCHIJAAAA | flammpfeil.slashblade | mc1.12-r9                | SlashBlade-mc1.12-r9.jar                    | None                                     |
    | UCHIJAAAA | heartwork             | 2.0.0                    | Heartwork_V2.0.1_FIX1_MC1.12.2.jar          | None                                     |
    | UCHIJAAAA | inventorytweaks       | 1.63+release.109.220f184 | InventoryTweaks-1.63.jar                    | 55d2cd4f5f0961410bf7b91ef6c6bf00a766dcbe |
    | UCHIJAAAA | levelup2              | ${version}               | Level+Up!+2-1.1.15-1.12.jar                 | None                                     |
    | UCHIJAAAA | twilightforest        | 3.6.345                  | twilightforest-1.12.2-3.6.345-universal.jar | None                                     |

    Loaded coremods (and transformers): 
Inventory Tweaks Coremod (InventoryTweaks-1.63.jar)
  invtweaks.forge.asm.ContainerTransformer
    Profiler Position: N/A (disabled)
    Player Count: 1 / 20; [EntityPlayerMP['dixyes'/653, l='world', x=-270.46, y=39.68, z=71.58]]
    Is Modded: Definitely; Server brand changed to 'fml,forge'
    Type: Dedicated Server (map_server.txt)

reason

at EntityHelmBrakerManager.java:286

if(!blade.isEmpty()){
    NBTTagCompound tag = ItemSlashBlade.getItemTagCompound(blade);
    for(Entity curEntity : list){
        //curEntity.hurtResistantTime = 0;

        if(thrower instanceof EntityPlayer){
            ItemSlashBlade itemBlade = (ItemSlashBlade)blade.getItem(); // if blade disappeared, this cast will cause uncaught exception
            itemBlade.attackTargetEntity(blade, curEntity, (EntityPlayer)thrower, true); // may break blade
        }
        else{
            DamageSource ds = new EntityDamageSource("mob", this.getThrower());
            curEntity.attackEntityFrom(ds, 10);
            if(!blade.isEmpty() && curEntity instanceof EntityLivingBase)
                ((ItemSlashBlade)blade.getItem()).hitEntity(blade,(EntityLivingBase)curEntity,(EntityLivingBase)thrower);
        }
    }
}

at EntityRapidSlashManager.java:221

if(!blade.isEmpty()){
    ItemSlashBlade itemBlade = (ItemSlashBlade)blade.getItem();
    NBTTagCompound tag = ItemSlashBlade.getItemTagCompound(blade);
    for(Entity curEntity : list){
        curEntity.hurtResistantTime = 0;

        if(!alreadyStuckEntity.contains(curEntity)){
            //UpthrustBlast
            alreadyStuckEntity.add(curEntity);
            if(getThrower() instanceof EntityLivingBase && curEntity instanceof EntityLivingBase)
                UpthrustBlast.setUpthrustBlastSword(blade, (EntityLivingBase)getThrower(), (EntityLivingBase)curEntity);
        }

        if(thrower instanceof EntityPlayer){
            itemBlade.attackTargetEntity(blade, curEntity, (EntityPlayer)thrower, true);
        }
        else{
            DamageSource ds = new EntityDamageSource("mob", this.getThrower());
            curEntity.attackEntityFrom(ds, 10);
            if(!blade.isEmpty() && curEntity instanceof EntityLivingBase)
                itemBlade.hitEntity(blade,(EntityLivingBase)curEntity,(EntityLivingBase)thrower);
        }
    }
}

solution

i pick the casting code out of loop like

if(!blade.isEmpty()){
    NBTTagCompound tag = ItemSlashBlade.getItemTagCompound(blade);
    ItemSlashBlade itemBlade = (ItemSlashBlade)blade.getItem();
    for(Entity curEntity : list){
        //curEntity.hurtResistantTime = 0;

        if(thrower instanceof EntityPlayer){
            itemBlade.attackTargetEntity(blade, curEntity, (EntityPlayer)thrower, true);
        }
        else{
            DamageSource ds = new EntityDamageSource("mob", this.getThrower());
            curEntity.attackEntityFrom(ds, 10);
            if(!blade.isEmpty() && curEntity instanceof EntityLivingBase)
                itemBlade.hitEntity(blade,(EntityLivingBase)curEntity,(EntityLivingBase)thrower);
        }
    }
}

but that's not a good way, maybe try-catch will be better.

dont know why but my gradlew build always failed with symbol not found, so i just recompile these two java into java class and replace the original file, game wont crash, but EntityRapidSlashManager class replacing failed, so i cant use rapid slash...

hope you can find better way to fix this, happy coding

dixyes commented 6 years ago

seems fixed in commit 81ef05dc64e491d1e04e657bde8a916d4891cccd